[dpdk-dev,RFC,16/24] vhost: remember a vhost_virtqueue's queue index

Message ID 20180119134444.24927-17-stefanha@redhat.com (mailing list archive)
State RFC, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Stefan Hajnoczi Jan. 19, 2018, 1:44 p.m. UTC
  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(+)
  

Patch

diff --git a/drivers/librte_vhost/vhost.h b/drivers/librte_vhost/vhost.h
index a50b802e7..08ad874ef 100644
--- a/drivers/librte_vhost/vhost.h
+++ b/drivers/librte_vhost/vhost.h
@@ -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;
diff --git a/drivers/librte_vhost/vhost.c b/drivers/librte_vhost/vhost.c
index 0d95a4b3a..886444683 100644
--- a/drivers/librte_vhost/vhost.c
+++ b/drivers/librte_vhost/vhost.c
@@ -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;