From mboxrd@z Thu Jan 1 00:00:00 1970 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) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Oct 2018 02:25:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,423,1534834800"; d="scan'208";a="102540408" Received: from btwcube1.sh.intel.com (HELO debian) ([10.67.104.158]) by orsmga001.jf.intel.com with ESMTP; 25 Oct 2018 02:25:15 -0700 Date: Thu, 25 Oct 2018 17:23:53 +0800 From: Tiwei Bie To: Jens Freimann Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com 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 Content-Disposition: inline In-Reply-To: <20181024143236.21271-4-jfreimann@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [PATCH v9 3/8] 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, 25 Oct 2018 09:25:18 -0000 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 >