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 5311D726F for ; Fri, 16 Mar 2018 16:21:41 +0100 (CET) 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 B1EDC406E8D1; Fri, 16 Mar 2018 15:21:40 +0000 (UTC) Received: from localhost (dhcp-192-241.str.redhat.com [10.33.192.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F26E3AFD74; Fri, 16 Mar 2018 15:21:33 +0000 (UTC) From: Jens Freimann To: dev@dpdk.org Cc: tiwei.bie@intel.com, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mst@redhat.com Date: Fri, 16 Mar 2018 16:21:07 +0100 Message-Id: <20180316152120.13199-5-jfreimann@redhat.com> In-Reply-To: <20180316152120.13199-1-jfreimann@redhat.com> References: <20180316152120.13199-1-jfreimann@redhat.com> 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.7]); Fri, 16 Mar 2018 15:21:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Fri, 16 Mar 2018 15:21:40 +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: [dpdk-dev] [PATCH 04/17] 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: Fri, 16 Mar 2018 15:21:41 -0000 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 | 3 +++ 2 files changed, 36 insertions(+) diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h index 6eb0077..2de2ede 100644 --- a/drivers/net/virtio/virtio_ring.h +++ b/drivers/net/virtio/virtio_ring.h @@ -74,12 +74,45 @@ struct vring_desc_packed { struct vring { unsigned int num; + unsigned int avail_wrap_counter; struct vring_desc *desc; struct vring_avail *avail; struct vring_used *used; struct vring_desc_packed *desc_packed; }; +static inline void toggle_wrap_counter(struct vring *vr) +{ + 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 |= DESC_AVAIL; + flags &= ~DESC_USED; + } else { + flags &= ~DESC_AVAIL; + flags |= DESC_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 & DESC_AVAIL) == !(desc->flags & DESC_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 a7d0a9c..6806056 100644 --- a/drivers/net/virtio/virtqueue.c +++ b/drivers/net/virtio/virtqueue.c @@ -65,6 +65,9 @@ struct rte_mbuf * uint16_t used_idx, desc_idx; uint16_t nb_used, i; + if (vtpci_packed_queue(vq->hw)) + return; + nb_used = VIRTQUEUE_NUSED(vq); for (i = 0; i < nb_used; i++) { -- 1.8.3.1