From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <qian.q.xu@intel.com>
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by dpdk.org (Postfix) with ESMTP id B1218C3BE
 for <dev@dpdk.org>; Mon, 20 Jul 2015 05:40:43 +0200 (CEST)
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by fmsmga103.fm.intel.com with ESMTP; 19 Jul 2015 20:40:42 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,506,1432623600"; d="scan'208";a="609161769"
Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98])
 by orsmga003.jf.intel.com with ESMTP; 19 Jul 2015 20:40:40 -0700
Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by
 PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Mon, 20 Jul 2015 11:40:39 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by
 SHSMSX101.ccr.corp.intel.com ([169.254.1.246]) with mapi id 14.03.0224.002;
 Mon, 20 Jul 2015 11:40:38 +0800
From: "Xu, Qian Q" <qian.q.xu@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>, "Ouyang, Changchun"
 <changchun.ouyang@intel.com>, 'Thomas Monjalon' <thomas.monjalon@6wind.com>
Thread-Topic: [dpdk-dev] [PATCH] virtio: fix the vq size issue
Thread-Index: AQHQs9JlZdYK20EeU02SPlZqlmEUBp3fbVEAgARkC0A=
Date: Mon, 20 Jul 2015 03:40:37 +0000
Message-ID: <82F45D86ADE5454A95A89742C8D1410E01D7DBAF@shsmsx102.ccr.corp.intel.com>
References: <1435736930-26737-1-git-send-email-changchun.ouyang@intel.com>
 <20150717092756.16d7265e@urahara>
In-Reply-To: <20150717092756.16d7265e@urahara>
Accept-Language: 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] virtio: fix the vq size issue
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: Mon, 20 Jul 2015 03:40:44 -0000

Hi, Thomas and all
I saw in the latest rc1 package, the patch is not merged, and it's a critic=
al issue from validation view. I'm responsible for testing the dpdk vhost/v=
irtio features, and I found using the latest code, dpdk-vhost/dpdk-virtio c=
an't RX/TX package, then my 50% tests are failed while in DPDK2.0 they can =
pass. As you know, it's the basic functions for dpdk virtio to RX/TX, if it=
's not fixed, I think we can't release the R2.1 package. Please help merge =
the patch, thx.=20



Thanks
Qian


-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
Sent: Saturday, July 18, 2015 12:28 AM
To: Ouyang, Changchun
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] virtio: fix the vq size issue

On Wed,  1 Jul 2015 15:48:50 +0800
Ouyang Changchun <changchun.ouyang@intel.com> wrote:

> This commit breaks virtio basic packets rx functionality:
>   d78deadae4dca240e85054bf2d604a801676becc
>=20
> The QEMU use 256 as default vring size, also use this default value to=20
> calculate the virtio avail ring base address and used ring base=20
> address, and vhost in the backend use the ring base address to do packet =
IO.
>=20
> Virtio spec also says the queue size in PCI configuration is=20
> read-only, so virtio front end can't change it. just need use the=20
> read-only value to allocate space for vring and calculate the avail=20
> and used ring base address. Otherwise, the avail and used ring base addre=
ss will be different between host and guest, accordingly, packet IO can't w=
ork normally.
>=20
> Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
>=20
> diff --git a/drivers/net/virtio/virtio_ethdev.c=20
> b/drivers/net/virtio/virtio_ethdev.c
> index fe5f9a1..d84de13 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -263,8 +263,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;

command queue is setup with nb_desc =3D 0

>  	if (vq_size =3D=3D 0) {
>  		PMD_INIT_LOG(ERR, "%s: virtqueue does not exist", __func__);
>  		return -EINVAL;
> @@ -275,15 +273,9 @@ 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 (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);

Nack. This breaks onn Google Compute Engine the vring size is 16K.

An application that wants to work on both QEMU and GCE will want to pass a =
reasonable size and have the negotiation resolve to best value.

For example, vRouter passes 512 as Rx ring size.
On QEMU this gets rounded down to 256 and on GCE only 512 elements are used=
.

This is what the Linux kernel virtio does.