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 <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
This commit is contained in:
Yuanhan Liu 2016-05-11 06:23:32 +08:00
parent 586e390013
commit 4b4af666b9
4 changed files with 24 additions and 1 deletions

View File

@ -270,7 +270,7 @@ new_device(struct virtio_net *dev)
vq->port = eth_dev->data->port_id; 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); rte_vhost_enable_guest_notification(dev, i, 0);
dev->priv = eth_dev; dev->priv = eth_dev;

View File

@ -25,5 +25,6 @@ DPDK_16.07 {
global: global:
rte_vhost_get_numa_node; rte_vhost_get_numa_node;
rte_vhost_get_queue_num;
} DPDK_2.1; } DPDK_2.1;

View File

@ -256,6 +256,17 @@ int rte_vhost_driver_session_start(void);
*/ */
int rte_vhost_get_numa_node(int vid); 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 * 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 * be received from the physical port or from another virtual device. A packet

View File

@ -756,6 +756,17 @@ rte_vhost_get_numa_node(int vid)
#endif #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, int rte_vhost_enable_guest_notification(struct virtio_net *dev,
uint16_t queue_id, int enable) uint16_t queue_id, int enable)
{ {