From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <changchun.ouyang@intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id 42032377A
 for <dev@dpdk.org>; Thu, 16 Apr 2015 05:39:34 +0200 (CEST)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga103.fm.intel.com with ESMTP; 15 Apr 2015 20:39:33 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.11,585,1422950400"; d="scan'208";a="680914388"
Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91])
 by orsmga001.jf.intel.com with ESMTP; 15 Apr 2015 20:39:32 -0700
Received: from kmsmsx154.gar.corp.intel.com (172.21.73.14) by
 PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Thu, 16 Apr 2015 11:39:31 +0800
Received: from shsmsx103.ccr.corp.intel.com (10.239.110.14) by
 KMSMSX154.gar.corp.intel.com (172.21.73.14) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Thu, 16 Apr 2015 11:39:30 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by
 SHSMSX103.ccr.corp.intel.com ([169.254.4.80]) with mapi id 14.03.0224.002;
 Thu, 16 Apr 2015 11:39:23 +0800
From: "Ouyang, Changchun" <changchun.ouyang@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>, "dev@dpdk.org"
 <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH 4/5] virtio: fix ring size negotiation
Thread-Index: AQHQd4/pjBhKAfLLNECfkY4JaPAKEJ1O/H+g
Date: Thu, 16 Apr 2015 03:39:24 +0000
Message-ID: <F52918179C57134FAEC9EA62FA2F962511AC1EAE@shsmsx102.ccr.corp.intel.com>
References: <1429111219-8789-1-git-send-email-stephen@networkplumber.org>
 <1429111219-8789-5-git-send-email-stephen@networkplumber.org>
In-Reply-To: <1429111219-8789-5-git-send-email-stephen@networkplumber.org>
Accept-Language: zh-CN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH 4/5] virtio: fix ring size negotiation
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://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: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 16 Apr 2015 03:39:34 -0000



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen
> Hemminger
> Sent: Wednesday, April 15, 2015 11:20 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH 4/5] virtio: fix ring size negotiation
>=20
> This fixes another of the issues with running virtio on non-KVM
> envirionments. For example, Google Compute Engine reports a ring size of
> 16K.
>=20
> If guest virtio requests more slots than available then the queue should =
just

I suspect 'more' here should be 'less'?

> be initialized to the smaller value.
>=20
> Conversely, if the number of descriptors requested exceeds the virtio hos=
t
> queue size, then just silently use the smaller host size.
>=20
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/librte_pmd_virtio/virtio_ethdev.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>=20
> diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c
> b/lib/librte_pmd_virtio/virtio_ethdev.c
> index 3cb9c6a..db0232e 100644
> --- a/lib/librte_pmd_virtio/virtio_ethdev.c
> +++ b/lib/librte_pmd_virtio/virtio_ethdev.c
> @@ -267,13 +267,21 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> *dev,
>  	if (vq_size =3D=3D 0) {
>  		PMD_INIT_LOG(ERR, "%s: virtqueue does not exist",
> __func__);
>  		return -EINVAL;
> -	} else if (!rte_is_power_of_2(vq_size)) {
> +	}
> +
> +	if (!rte_is_power_of_2(vq_size)) {
>  		PMD_INIT_LOG(ERR, "%s: virtqueue size is not powerof 2",
> __func__);
>  		return -EINVAL;
> -	} else if (nb_desc !=3D vq_size) {
> -		PMD_INIT_LOG(ERR, "Warning: nb_desc(%d) is not equal to
> vq size (%d), fall to vq size",
> -			nb_desc, vq_size);
> -		nb_desc =3D vq_size;
> +	}
> +
> +	if (nb_desc < vq_size) {
> +		if (!rte_is_power_of_2(nb_desc)) {
> +			PMD_INIT_LOG(ERR,
> +				     "nb_desc(%u) size is not powerof 2",
> +				     nb_desc);
> +			return -EINVAL;
> +		}
> +		vq_size =3D nb_desc;

Don't we need a warning when nb_desc > vq_size?

>  	}
>=20
>  	if (queue_type =3D=3D VTNET_RQ) {
> --
> 2.1.4