From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id E23B45F5D for ; Wed, 21 Mar 2018 10:17:54 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 634E34026788; Wed, 21 Mar 2018 09:17:54 +0000 (UTC) Received: from localhost (dhcp-192-241.str.redhat.com [10.33.192.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9810A10B0081; Wed, 21 Mar 2018 09:17:47 +0000 (UTC) Date: Wed, 21 Mar 2018 10:17:46 +0100 From: Jens Freimann To: Tiwei Bie Cc: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mst@redhat.com Message-ID: <20180321091746.na3zdfndgdfnaxw3@dhcp-192-241.str.redhat.com> References: <20180316152120.13199-1-jfreimann@redhat.com> <20180316152120.13199-12-jfreimann@redhat.com> <20180319103956.owoyyxxo6bcdo6vd@debian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180319103956.owoyyxxo6bcdo6vd@debian> User-Agent: NeoMutt/20180223 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 21 Mar 2018 09:17:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 21 Mar 2018 09:17:54 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jfreimann@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH 11/17] vhost: add helpers for packed virtqueues 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: Wed, 21 Mar 2018 09:17:55 -0000 On Mon, Mar 19, 2018 at 06:39:56PM +0800, Tiwei Bie wrote: >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. Agree with both, thanks for the review! regards, Jens