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 F022D5F1A for ; Thu, 25 Oct 2018 16:40:53 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58C9F3082B4C; Thu, 25 Oct 2018 14:40:53 +0000 (UTC) Received: from localhost (ovpn-116-124.ams2.redhat.com [10.36.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E61A50088; Thu, 25 Oct 2018 14:40:48 +0000 (UTC) Date: Thu, 25 Oct 2018 16:40:46 +0200 From: Jens Freimann To: Tiwei Bie Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com Message-ID: <20181025144046.dbuzlijxnqzw3r3o@jenstp.localdomain> References: <20181024143236.21271-1-jfreimann@redhat.com> <20181024143236.21271-4-jfreimann@redhat.com> <20181025092353.GC22179@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20181025092353.GC22179@debian> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 25 Oct 2018 14:40:53 +0000 (UTC) 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 14:40:54 -0000 On Thu, Oct 25, 2018 at 05:23:53PM +0800, Tiwei Bie wrote: >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. ok regards, Jens > >> 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 >>