Skip to content

Commit

Permalink
netdev-dpdk: add vhost-user get_status.
Browse files Browse the repository at this point in the history
Expose relevant vhost-user information in status.

Signed-off-by: Flavio Leitner <[email protected]>
Tested-by: Kevin Traynor <[email protected]>
Acked-by: Kevin Traynor <[email protected]>
Signed-off-by: Ian Stokes <[email protected]>
  • Loading branch information
fleitner authored and istokes committed Jan 17, 2018
1 parent c190e2a commit b2e8b12
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Post-v2.8.0
* Configuring a controller, or unconfiguring all controllers, now deletes
all groups and meters (as well as all flows).
- New --enable-sparse configure option enables "sparse" checking by default.
- Added additional information to vhost-user status.

v2.8.0 - 31 Aug 2017
--------------------
Expand Down
62 changes: 60 additions & 2 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,64 @@ netdev_dpdk_update_flags(struct netdev *netdev,
return error;
}

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)
{
Expand Down Expand Up @@ -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 =
Expand All @@ -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);

Expand Down

0 comments on commit b2e8b12

Please sign in to comment.