From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <tiwei.bie@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id A2A07101B
 for <dev@dpdk.org>; Mon, 19 Mar 2018 11:41:58 +0100 (CET)
X-Amp-Result: UNKNOWN
X-Amp-Original-Verdict: FILE UNKNOWN
X-Amp-File-Uploaded: False
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 19 Mar 2018 03:41:32 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.48,330,1517904000"; d="scan'208";a="36202459"
Received: from debian.sh.intel.com (HELO debian) ([10.67.104.164])
 by orsmga003.jf.intel.com with ESMTP; 19 Mar 2018 03:41:31 -0700
Date: Mon, 19 Mar 2018 18:39:56 +0800
From: Tiwei Bie <tiwei.bie@intel.com>
To: Jens Freimann <jfreimann@redhat.com>
Cc: dev@dpdk.org, yliu@fridaylinux.org, maxime.coquelin@redhat.com,
 mst@redhat.com
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
Content-Disposition: inline
In-Reply-To: <20180316152120.13199-12-jfreimann@redhat.com>
User-Agent: NeoMutt/20170113 (1.7.2)
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 <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 19 Mar 2018 10:41:59 -0000

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 <jfreimann@redhat.com>
[...]
>  
> +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;
> +}