From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id A6C151B128 for ; Fri, 2 Nov 2018 10:08:08 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 079D53082129; Fri, 2 Nov 2018 09:08:08 +0000 (UTC) Received: from localhost (ovpn-116-180.ams2.redhat.com [10.36.116.180]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07BF05C1B2; Fri, 2 Nov 2018 09:08:06 +0000 (UTC) From: Jens Freimann To: dev@dpdk.org Cc: tiwei.bie@intel.com, maxime.coquelin@redhat.com, Gavin.Hu@arm.com Date: Fri, 2 Nov 2018 10:07:43 +0100 Message-Id: <20181102090749.17316-4-jfreimann@redhat.com> In-Reply-To: <20181102090749.17316-1-jfreimann@redhat.com> References: <20181102090749.17316-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 02 Nov 2018 09:08:08 +0000 (UTC) Subject: [dpdk-dev] [PATCH v10 3/9] 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, 02 Nov 2018 09:08:09 -0000 Add helper functions to set/clear and check descriptor flags. Signed-off-by: Jens Freimann --- drivers/net/virtio/virtqueue.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 90bff7e38..f84079ba9 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -250,6 +250,31 @@ struct virtio_tx_region { __attribute__((__aligned__(16))); }; +static inline void +_set_desc_avail(struct vring_desc_packed *desc, int wrap_counter) +{ + desc->flags |= VRING_DESC_F_AVAIL(wrap_counter) | + VRING_DESC_F_USED(!wrap_counter); +} + +static inline void +set_desc_avail(struct virtqueue *vq, struct vring_desc_packed *desc) +{ + _set_desc_avail(desc, vq->avail_wrap_counter); +} + +static inline int +desc_is_used(struct vring_desc_packed *desc, struct virtqueue *vq) +{ + uint16_t used, flags; + + flags = desc->flags; + used = !!(flags & VRING_DESC_F_USED(1)); + + return used == vq->used_wrap_counter; +} + + static inline void vring_desc_init_packed(struct virtqueue *vq, int n) { -- 2.17.1