summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlavio Leitner <fbl@sysclose.org>2018-01-16 02:22:16 -0200
committerIan Stokes <ian.stokes@intel.com>2018-01-17 18:12:46 +0000
commitb2e8b12f8a821905c25295e04b843c0592a44339 (patch)
tree0b3e2109deaf3d0cb517280ba6a095fa6c42b252 /lib
parentc190e2ada5de0c2e9319b8280ada88f64e064d5b (diff)
downloadopenvswitch-b2e8b12f8a821905c25295e04b843c0592a44339.tar.gz
netdev-dpdk: add vhost-user get_status.
Expose relevant vhost-user information in status. Signed-off-by: Flavio Leitner <fbl@sysclose.org> Tested-by: Kevin Traynor <ktraynor@redhat.com> Acked-by: Kevin Traynor <ktraynor@redhat.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/netdev-dpdk.c62
1 files changed, 60 insertions, 2 deletions
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index ccda3fcb3..ac2e38e7e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2616,6 +2616,64 @@ netdev_dpdk_update_flags(struct netdev *netdev,
}
static int
+netdev_dpdk_vhost_user_get_status(const struct netdev *netdev,
+ struct smap *args)
+{
+ struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+
+ ovs_mutex_lock(&dev->mutex);
+
+ bool client_mode = dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT;
+ smap_add_format(args, "mode", "%s", client_mode ? "client" : "server");
+
+ int vid = netdev_dpdk_get_vid(dev);
+ if (vid < 0) {
+ smap_add_format(args, "status", "disconnected");
+ ovs_mutex_unlock(&dev->mutex);
+ return 0;
+ } else {
+ smap_add_format(args, "status", "connected");
+ }
+
+ char socket_name[PATH_MAX];
+ if (!rte_vhost_get_ifname(vid, socket_name, PATH_MAX)) {
+ smap_add_format(args, "socket", "%s", socket_name);
+ }
+
+ uint64_t features;
+ if (!rte_vhost_get_negotiated_features(vid, &features)) {
+ smap_add_format(args, "features", "0x%016"PRIx64, features);
+ }
+
+ uint16_t mtu;
+ if (!rte_vhost_get_mtu(vid, &mtu)) {
+ smap_add_format(args, "mtu", "%d", mtu);
+ }
+
+ int numa = rte_vhost_get_numa_node(vid);
+ if (numa >= 0) {
+ smap_add_format(args, "numa", "%d", numa);
+ }
+
+ uint16_t vring_num = rte_vhost_get_vring_num(vid);
+ if (vring_num) {
+ smap_add_format(args, "num_of_vrings", "%d", vring_num);
+ }
+
+ for (int i = 0; i < vring_num; i++) {
+ struct rte_vhost_vring vring;
+ char vhost_vring[16];
+
+ rte_vhost_get_vhost_vring(vid, i, &vring);
+ snprintf(vhost_vring, 16, "vring_%d_size", i);
+ smap_add_format(args, vhost_vring, "%d", vring.size);
+ }
+
+ ovs_mutex_unlock(&dev->mutex);
+ return 0;
+}
+
+static int
netdev_dpdk_get_status(const struct netdev *netdev, struct smap *args)
{
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
@@ -3699,7 +3757,7 @@ static const struct netdev_class dpdk_vhost_class =
netdev_dpdk_vhost_get_stats,
NULL,
NULL,
- NULL,
+ netdev_dpdk_vhost_user_get_status,
netdev_dpdk_vhost_reconfigure,
netdev_dpdk_vhost_rxq_recv);
static const struct netdev_class dpdk_vhost_client_class =
@@ -3715,7 +3773,7 @@ static const struct netdev_class dpdk_vhost_client_class =
netdev_dpdk_vhost_get_stats,
NULL,
NULL,
- NULL,
+ netdev_dpdk_vhost_user_get_status,
netdev_dpdk_vhost_client_reconfigure,
netdev_dpdk_vhost_rxq_recv);