[dpdk-dev,RFC,16/24] vhost: remember a vhost_virtqueue's queue index
Checks
Commit Message
Currently the only way of determining a struct vhost_virtqueue's index
is to search struct virtio_net->virtqueue[] for its address. Stash the
index in struct vhost_virtqueue so we won't have to search the array.
This new field will be used by virtio-vhost-user.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
drivers/librte_vhost/vhost.h | 1 +
drivers/librte_vhost/vhost.c | 2 ++
2 files changed, 3 insertions(+)
@@ -72,6 +72,7 @@ struct vhost_virtqueue {
struct vring_avail *avail;
struct vring_used *used;
uint32_t size;
+ uint32_t vring_idx;
uint16_t last_avail_idx;
uint16_t last_used_idx;
@@ -191,6 +191,8 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
memset(vq, 0, sizeof(struct vhost_virtqueue));
+ vq->vring_idx = vring_idx;
+
vq->kickfd = VIRTIO_UNINITIALIZED_EVENTFD;
vq->callfd = VIRTIO_UNINITIALIZED_EVENTFD;