From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tiwei Bie Subject: Re: [PATCH 11/17] vhost: add helpers for packed virtqueues Date: Mon, 19 Mar 2018 18:39:56 +0800 Message-ID: <20180319103956.owoyyxxo6bcdo6vd@debian> References: <20180316152120.13199-1-jfreimann@redhat.com> <20180316152120.13199-12-jfreimann@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mst@redhat.com To: Jens Freimann Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A2A07101B for ; Mon, 19 Mar 2018 11:41:58 +0100 (CET) Content-Disposition: inline In-Reply-To: <20180316152120.13199-12-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 Fri, Mar 16, 2018 at 04:21:14PM +0100, Jens Freimann wrote: > Add some helper functions to set/check descriptor flags > and toggle the used wrap counter. > > Signed-off-by: Jens Freimann [...] > > +static inline void > +toggle_wrap_counter(struct vhost_virtqueue *vq) > +{ > + vq->used_wrap_counter ^= 1; > +} > + > +static inline int > +desc_is_avail(struct vhost_virtqueue *vq, struct vring_desc_packed *desc) > +{ > + if (unlikely(!vq)) > + return -1; Maybe it's better to let the caller make sure the vq won't be NULL. > + > + if (vq->used_wrap_counter == 1) > + if ((desc->flags & DESC_AVAIL) && !(desc->flags & DESC_USED)) > + return 1; > + if (vq->used_wrap_counter == 0) Maybe it's better to use '} else {' here. Thanks > + if (!(desc->flags & DESC_AVAIL) && (desc->flags & DESC_USED)) > + return 1; > + return 0; > +}