From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tiwei Bie Subject: Re: [PATCH v9 3/8] net/virtio: add packed virtqueue helpers Date: Thu, 25 Oct 2018 17:23:53 +0800 Message-ID: <20181025092353.GC22179@debian> References: <20181024143236.21271-1-jfreimann@redhat.com> <20181024143236.21271-4-jfreimann@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com To: Jens Freimann Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2D1C64C99 for ; Thu, 25 Oct 2018 11:25:18 +0200 (CEST) Content-Disposition: inline In-Reply-To: <20181024143236.21271-4-jfreimann@redhat.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Oct 24, 2018 at 04:32:31PM +0200, Jens Freimann wrote: > Add helper functions to set/clear and check descriptor flags. > > Signed-off-by: Jens Freimann > --- > drivers/net/virtio/virtio_ring.h | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h > index f84ab5e34..629d3477a 100644 > --- a/drivers/net/virtio/virtio_ring.h > +++ b/drivers/net/virtio/virtio_ring.h > @@ -77,6 +77,8 @@ struct vring_packed_desc_event { > > struct vring { > unsigned int num; > + unsigned int avail_wrap_counter; > + unsigned int used_wrap_counter; Above fields should be defined in struct virtqueue. > union { > struct vring_desc_packed *desc_packed; > struct vring_desc *desc; > @@ -91,6 +93,30 @@ struct vring { > }; > }; > > +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 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, struct vring *vr) > +{ > + uint16_t used, flags; > + > + flags = desc->flags; > + used = !!(flags & VRING_DESC_F_USED(1)); > + > + return used == vr->used_wrap_counter; > +} > + > /* The standard layout for the ring is a continuous chunk of memory which > * looks like this. We assume num is a power of 2. > * > -- > 2.17.1 >