From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 134331CC4B for ; Thu, 5 Apr 2018 16:42:30 +0200 (CEST) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Apr 2018 07:42:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,411,1517904000"; d="scan'208";a="39611411" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164]) by FMSMGA003.fm.intel.com with ESMTP; 05 Apr 2018 07:42:27 -0700 Date: Thu, 5 Apr 2018 22:40:29 +0800 From: Tiwei Bie To: Jens Freimann Cc: Maxime Coquelin , dev@dpdk.org, yliu@fridaylinux.org, mst@redhat.com Message-ID: <20180405144029.h7rxzkod6wgrhfm7@debian> References: <20180405101031.26468-1-jfreimann@redhat.com> <20180405101031.26468-5-jfreimann@redhat.com> <5885e525-161c-68cb-7eb6-83ddff22156a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5885e525-161c-68cb-7eb6-83ddff22156a@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v3 04/21] net/virtio: add packed virtqueue helpers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2018 14:42:31 -0000 On Thu, Apr 05, 2018 at 04:27:51PM +0200, Maxime Coquelin wrote: > On 04/05/2018 12:10 PM, Jens Freimann wrote: > > Add helper functions to set/clear and check descriptor flags. > > > > Signed-off-by: Jens Freimann > > --- > > drivers/net/virtio/virtio_ring.h | 33 +++++++++++++++++++++++++++++++++ > > drivers/net/virtio/virtqueue.c | 10 ++++++++++ > > 2 files changed, 43 insertions(+) [...] > > diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c > > index a7d0a9cbe..4f95ed5c8 100644 > > --- a/drivers/net/virtio/virtqueue.c > > +++ b/drivers/net/virtio/virtqueue.c > > @@ -58,6 +58,7 @@ virtqueue_detach_unused(struct virtqueue *vq) > > void > > virtqueue_rxvq_flush(struct virtqueue *vq) > > { > > + struct vring_desc_packed *descs = vq->vq_ring.desc_packed; > > struct virtnet_rx *rxq = &vq->rxq; > > struct virtio_hw *hw = vq->hw; > > struct vring_used_elem *uep; > > @@ -65,6 +66,15 @@ virtqueue_rxvq_flush(struct virtqueue *vq) > > uint16_t used_idx, desc_idx; > > uint16_t nb_used, i; > > + if (vtpci_packed_queue(vq->hw)) { > > + i = vq->vq_used_cons_idx & (vq->vq_nentries - 1); > > + while (desc_is_used(&descs[i])) { > > + rte_pktmbuf_free(vq->sw_ring[i]); > > + vq->vq_free_cnt++; > > + } You need to increase i here. Otherwise you are looping on the same entry. To increase i, you also need to keep track of the number of descriptors need to be skipped for each used descriptor. > > + return; > > + } > > + > > nb_used = VIRTQUEUE_NUSED(vq); > > for (i = 0; i < nb_used; i++) { > > > > With style comments taken into account: > > Reviewed-by: Maxime Coquelin >