summaryrefslogtreecommitdiff
path: root/lib/librte_vhost
diff options
context:
space:
mode:
authorYuanhan Liu <yuanhan.liu@linux.intel.com>2016-05-11 06:12:57 +0800
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-06-22 09:01:30 +0200
commit586e390013171b32c3cd3406fe0b8158816a3a1f (patch)
tree0d2ee7d7aaec1cdd11e3d4b5d39bede46005a91e /lib/librte_vhost
parentadf97191b3e1495097658feaa6e2954a4aecfed5 (diff)
downloaddpdk-586e390013171b32c3cd3406fe0b8158816a3a1f.zip
dpdk-586e390013171b32c3cd3406fe0b8158816a3a1f.tar.gz
dpdk-586e390013171b32c3cd3406fe0b8158816a3a1f.tar.xz
vhost: export numa node
Introduce a new API rte_vhost_get_numa_node() to get the numa node from which the virtio_net struct is allocated. Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Tested-by: Rich Lane <rich.lane@bigswitch.com> Acked-by: Rich Lane <rich.lane@bigswitch.com>
Diffstat (limited to 'lib/librte_vhost')
-rw-r--r--lib/librte_vhost/rte_vhost_version.map7
-rw-r--r--lib/librte_vhost/rte_virtio_net.h12
-rw-r--r--lib/librte_vhost/virtio-net.c26
3 files changed, 45 insertions, 0 deletions
diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
index 3d8709e..a323fa0 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -20,3 +20,10 @@ DPDK_2.1 {
rte_vhost_driver_unregister;
} DPDK_2.0;
+
+DPDK_16.07 {
+ global:
+
+ rte_vhost_get_numa_node;
+
+} DPDK_2.1;
diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h
index bc64e89..b8e9b02 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -245,6 +245,18 @@ int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * cons
int rte_vhost_driver_session_start(void);
/**
+ * Get the numa node from which the virtio net device's memory
+ * is allocated.
+ *
+ * @param vid
+ * virtio-net device ID
+ *
+ * @return
+ * The numa node, -1 on failure
+ */
+int rte_vhost_get_numa_node(int vid);
+
+/**
* This function adds buffers to the virtio devices RX virtqueue. Buffers can
* be received from the physical port or from another virtual device. A packet
* count is returned to indicate the number of packets that were succesfully
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index c6d3829..25b6515 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -730,6 +730,32 @@ vhost_set_backend(int vid, struct vhost_vring_file *file)
return 0;
}
+int
+rte_vhost_get_numa_node(int vid)
+{
+#ifdef RTE_LIBRTE_VHOST_NUMA
+ struct virtio_net *dev = get_device(vid);
+ int numa_node;
+ int ret;
+
+ if (dev == NULL)
+ return -1;
+
+ ret = get_mempolicy(&numa_node, NULL, 0, dev,
+ MPOL_F_NODE | MPOL_F_ADDR);
+ if (ret < 0) {
+ RTE_LOG(ERR, VHOST_CONFIG,
+ "(%d) failed to query numa node: %d\n", vid, ret);
+ return -1;
+ }
+
+ return numa_node;
+#else
+ RTE_SET_USED(vid);
+ return -1;
+#endif
+}
+
int rte_vhost_enable_guest_notification(struct virtio_net *dev,
uint16_t queue_id, int enable)
{