From: Stefan Hajnoczi Subject: [RFC 16/24] vhost: remember a vhost_virtqueue's queue index Date: Fri, 19 Jan 2018 13:44:36 +0000 Message-ID: <20180119134444.24927-17-stefanha@redhat.com> References: <20180119134444.24927-1-stefanha@redhat.com> Cc: maxime.coquelin@redhat.com, Yuanhan Liu , wei.w.wang@intel.com, mst@redhat.com, zhiyong.yang@intel.com, jasowang@redhat.com, Stefan Hajnoczi To: dev@dpdk.org Return-path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 329CA1B2D0 for ; Fri, 19 Jan 2018 14:47:30 +0100 (CET) In-Reply-To: <20180119134444.24927-1-stefanha@redhat.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/librte_vhost/vhost.h | 1 + drivers/librte_vhost/vhost.c | 2 ++ 2 files changed, 3 insertions(+) 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; -- 2.14.3