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 691E65A0C
 for <dev@dpdk.org>; Tue, 21 Jul 2015 07:06:08 +0200 (CEST)
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga103.fm.intel.com with ESMTP; 20 Jul 2015 22:06:07 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,513,1432623600"; d="scan'208";a="768095563"
Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82])
 by orsmga002.jf.intel.com with ESMTP; 20 Jul 2015 22:06:06 -0700
Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by
 PGSMSX103.gar.corp.intel.com (10.221.44.82) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Tue, 21 Jul 2015 13:06:05 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by
 SHSMSX103.ccr.corp.intel.com ([169.254.4.46]) with mapi id 14.03.0224.002;
 Tue, 21 Jul 2015 13:06:03 +0800
From: "Ouyang, Changchun" <changchun.ouyang@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Thread-Topic: [PATCH v2 1/2] virtio: fix queue size and number of descriptors
Thread-Index: AQHQwxujRXtWyx73F0mgqHbCMM9uUZ3lXqow
Date: Tue, 21 Jul 2015 05:06:03 +0000
Message-ID: <F52918179C57134FAEC9EA62FA2F962511C0EBE4@shsmsx102.ccr.corp.intel.com>
References: <1437417646-11221-1-git-send-email-stephen@networkplumber.org>
 <1437417646-11221-2-git-send-email-stephen@networkplumber.org>
In-Reply-To: <1437417646-11221-2-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
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 1/2] virtio: fix queue size and number of
	descriptors
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: Tue, 21 Jul 2015 05:06:09 -0000



> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Tuesday, July 21, 2015 2:41 AM
> To: Ouyang, Changchun
> Cc: dev@dpdk.org; Stephen Hemminger
> Subject: [PATCH v2 1/2] virtio: fix queue size and number of descriptors
>=20
> The virtual queue ring size and the number of slots actually usable are
> separate parameters. In the most common environment (QEMU) the virtual
> queue ring size is 256, but some environments the ring maybe much larger.
>=20
> The ring size comes from the host and the driver must use the actual size
> passed.
>=20
> The number of descriptors can be either zero to use the whole available r=
ing,
> or some value smaller. This is used to limit the number of mbufs allocate=
d for
> the receive ring. If more descriptors are requested than available the si=
ze is
> silently truncated.
>=20
> Note: the ring size (from host) must be a power of two, but the number of
> descriptors used can be any size from 1 to the size of the virtual ring.
>=20
> Reported-by: Ouyang Changchun <changchun.ouyang@intel.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Basically ok for this change, so
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>

> ---
>  drivers/net/virtio/virtio_ethdev.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
>=20
> diff --git a/drivers/net/virtio/virtio_ethdev.c
> b/drivers/net/virtio/virtio_ethdev.c
> index 9ca9bb2..d460d89 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -276,8 +276,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
>  	 */
>  	vq_size =3D VIRTIO_READ_REG_2(hw, VIRTIO_PCI_QUEUE_NUM);
>  	PMD_INIT_LOG(DEBUG, "vq_size: %d nb_desc:%d", vq_size,
> nb_desc);
> -	if (nb_desc =3D=3D 0)
> -		nb_desc =3D vq_size;
>  	if (vq_size =3D=3D 0) {
>  		PMD_INIT_LOG(ERR, "%s: virtqueue does not exist",
> __func__);
>  		return -EINVAL;
> @@ -288,16 +286,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> *dev,
>  		return -EINVAL;
>  	}
>=20
> -	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;
> -	}
> -
>  	if (queue_type =3D=3D VTNET_RQ) {
>  		snprintf(vq_name, sizeof(vq_name), "port%d_rvq%d",
>  			dev->data->port_id, queue_idx);
> @@ -325,7 +313,10 @@ int virtio_dev_queue_setup(struct rte_eth_dev
> *dev,
>  	vq->queue_id =3D queue_idx;
>  	vq->vq_queue_index =3D vtpci_queue_idx;
>  	vq->vq_nentries =3D vq_size;
> -	vq->vq_free_cnt =3D vq_size;
> +
> +	if (nb_desc =3D=3D 0 || nb_desc > vq_size)
> +		nb_desc =3D vq_size;
> +	vq->vq_free_cnt =3D nb_desc;
>=20
>  	/*
>  	 * Reserve a memzone for vring elements
> --
> 2.1.4