From 4b4af666b989d18a8f823cbe827304ad8b6f1d97 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Wed, 11 May 2016 06:23:32 +0800 Subject: [PATCH] vhost: export number of queues Introduce a new API rte_vhost_get_queue_num() to export the number of queues. Signed-off-by: Yuanhan Liu Tested-by: Rich Lane Acked-by: Rich Lane --- drivers/net/vhost/rte_eth_vhost.c | 2 +- lib/librte_vhost/rte_vhost_version.map | 1 + lib/librte_vhost/rte_virtio_net.h | 11 +++++++++++ lib/librte_vhost/virtio-net.c | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index a00351b3b2..bbd76b1836 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -270,7 +270,7 @@ new_device(struct virtio_net *dev) vq->port = eth_dev->data->port_id; } - for (i = 0; i < dev->virt_qp_nb * VIRTIO_QNUM; i++) + for (i = 0; i < rte_vhost_get_queue_num(dev->vid) * VIRTIO_QNUM; i++) rte_vhost_enable_guest_notification(dev, i, 0); dev->priv = eth_dev; diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map index a323fa03b4..a65bef5455 100644 --- a/lib/librte_vhost/rte_vhost_version.map +++ b/lib/librte_vhost/rte_vhost_version.map @@ -25,5 +25,6 @@ DPDK_16.07 { global: rte_vhost_get_numa_node; + rte_vhost_get_queue_num; } DPDK_2.1; diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index b8e9b02ce3..de56b1bc7f 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -256,6 +256,17 @@ int rte_vhost_driver_session_start(void); */ int rte_vhost_get_numa_node(int vid); +/** + * Get the number of queues the device supports. + * + * @param vid + * virtio-net device ID + * + * @return + * The number of queues, 0 on failure + */ +uint32_t rte_vhost_get_queue_num(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 diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index 25b65153ff..a03ff30572 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -756,6 +756,17 @@ rte_vhost_get_numa_node(int vid) #endif } +uint32_t +rte_vhost_get_queue_num(int vid) +{ + struct virtio_net *dev = get_device(vid); + + if (dev == NULL) + return 0; + + return dev->virt_qp_nb; +} + int rte_vhost_enable_guest_notification(struct virtio_net *dev, uint16_t queue_id, int enable) { -- 2.20.1