[19/28] vhost: add index field in vhost virtqueues

Message ID 1560957293-17294-20-git-send-email-ndragazis@arrikto.com
State New
Delegated to: Maxime Coquelin
Headers show
Series
  • vhost: add virtio-vhost-user transport
Related show

Checks

Context Check Description
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Nikos Dragazis June 19, 2019, 3:14 p.m.
From: Stefan Hajnoczi <stefanha@redhat.com>

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>
---
 lib/librte_vhost/vhost.c | 2 ++
 lib/librte_vhost/vhost.h | 1 +
 2 files changed, 3 insertions(+)

Patch

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 91a286d..d083d7e 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -407,6 +407,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;
 
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index aba8d9b..2e7eabe 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -107,6 +107,7 @@  struct vhost_virtqueue {
 		struct vring_packed_desc_event *device_event;
 	};
 	uint32_t		size;
+	uint32_t		vring_idx;
 
 	uint16_t		last_avail_idx;
 	uint16_t		last_used_idx;