From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 28DF36CD0 for ; Fri, 14 Oct 2016 11:33:50 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 14 Oct 2016 02:33:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,344,1473145200"; d="scan'208";a="1064724653" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by orsmga002.jf.intel.com with ESMTP; 14 Oct 2016 02:33:49 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: Maxime Coquelin , Yuanhan Liu , Zhihong Wang Date: Fri, 14 Oct 2016 17:34:35 +0800 Message-Id: <1476437678-7102-5-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1476437678-7102-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1474336817-22683-1-git-send-email-zhihong.wang@intel.com> <1476437678-7102-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH v7 4/7] vhost: use last avail idx for avail ring reservation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Oct 2016 09:33:52 -0000 shadow_used_ring will be introduced later. Since then last avail idx will not be updated together with last used idx. So, here we use last_avail_idx for avail ring reservation. Signed-off-by: Yuanhan Liu Signed-off-by: Zhihong Wang --- lib/librte_vhost/virtio_net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 1a40c91..b5ba633 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -344,7 +344,7 @@ reserve_avail_buf_mergeable(struct vhost_virtqueue *vq, uint32_t size, uint32_t vec_idx = 0; uint16_t tries = 0; - cur_idx = vq->last_used_idx; + cur_idx = vq->last_avail_idx; while (1) { avail_idx = *((volatile uint16_t *)&vq->avail->idx); @@ -370,7 +370,7 @@ reserve_avail_buf_mergeable(struct vhost_virtqueue *vq, uint32_t size, return -1; } - *num_buffers = cur_idx - vq->last_used_idx; + *num_buffers = cur_idx - vq->last_avail_idx; return 0; } @@ -536,6 +536,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id, vhost_log_used_vring(dev, vq, offsetof(struct vring_used, idx), sizeof(vq->used->idx)); vq->last_used_idx += num_buffers; + vq->last_avail_idx += num_buffers; } if (likely(pkt_idx)) { -- 1.9.0