From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id 363471CC1F for ; Thu, 5 Apr 2018 16:35:01 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD14A406FA03; Thu, 5 Apr 2018 14:35:00 +0000 (UTC) Received: from localhost (dhcp-192-241.str.redhat.com [10.33.192.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56624AB3FA; Thu, 5 Apr 2018 14:34:54 +0000 (UTC) Date: Thu, 5 Apr 2018 16:34:53 +0200 From: Jens Freimann To: Maxime Coquelin Cc: dev@dpdk.org, tiwei.bie@intel.com, yliu@fridaylinux.org, mst@redhat.com Message-ID: <20180405143453.ctaywdmzjjuqni3w@reserved-198-163.str.redhat.com> 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=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <5885e525-161c-68cb-7eb6-83ddff22156a@redhat.com> User-Agent: NeoMutt/20180223 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 05 Apr 2018 14:35:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 05 Apr 2018 14:35:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jfreimann@redhat.com' RCPT:'' 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:35:01 -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/virtio_ring.h b/drivers/net/virtio/virtio_ring.h >>index 54a11d2a9..663b4b01d 100644 >>--- a/drivers/net/virtio/virtio_ring.h >>+++ b/drivers/net/virtio/virtio_ring.h >>@@ -78,6 +78,7 @@ struct vring_packed_desc_event { >> struct vring { >> unsigned int num; >>+ unsigned int avail_wrap_counter; >> union { >> struct vring_desc_packed *desc_packed; >> struct vring_desc *desc; >>@@ -92,6 +93,38 @@ struct vring { >> }; >> }; >>+static inline void toggle_wrap_counter(struct vring *vr) >Please follow the coding style of the driver: > >static inline void >toggle_wrap_counter(struct vring *vr) > >I would also prefix the functions with vring_ to keep consistency. ok >>+{ >>+ vr->avail_wrap_counter ^= 1; >>+} >>+ >>+static inline void _set_desc_avail(struct vring_desc_packed *desc, >>+ int wrap_counter) >>+{ >>+ uint16_t flags = desc->flags; >>+ >>+ if (wrap_counter) { >>+ flags |= VRING_DESC_F_AVAIL; >>+ flags &= ~VRING_DESC_F_USED; >>+ } else { >>+ flags &= ~VRING_DESC_F_AVAIL; >>+ flags |= VRING_DESC_F_USED; >>+ } >>+ >>+ desc->flags = flags; >>+} >>+ >>+static inline void set_desc_avail(struct vring *vr, >>+ struct vring_desc_packed *desc) >>+{ >>+ _set_desc_avail(desc, vr->avail_wrap_counter); >>+} >>+ >>+static inline int desc_is_used(struct vring_desc_packed *desc) >>+{ >>+ return !(desc->flags & VRING_DESC_F_AVAIL) == !(desc->flags & VRING_DESC_F_USED); >>+} >>+ >> /* The standard layout for the ring is a continuous chunk of memory which >> * looks like this. We assume num is a power of 2. >> * >>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++; >>+ } >>+ return; >>+ } >>+ >> nb_used = VIRTQUEUE_NUSED(vq); >> for (i = 0; i < nb_used; i++) { >> > >With style comments taken into account: I'll fix it. Thanks! regards, Jens > >Reviewed-by: Maxime Coquelin >