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 F2D6C11C5
 for <dev@dpdk.org>; Fri,  3 Jul 2015 03:53:49 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by fmsmga103.fm.intel.com with ESMTP; 02 Jul 2015 18:53:48 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,396,1432623600"; d="scan'208";a="755204282"
Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78])
 by fmsmga002.fm.intel.com with ESMTP; 02 Jul 2015 18:53:47 -0700
Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by
 PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Fri, 3 Jul 2015 09:53:46 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by
 SHSMSX151.ccr.corp.intel.com ([169.254.3.168]) with mapi id 14.03.0224.002;
 Fri, 3 Jul 2015 09:53:45 +0800
From: "Ouyang, Changchun" <changchun.ouyang@intel.com>
To: "Xie, Huawei" <huawei.xie@intel.com>
Thread-Topic: [dpdk-dev] [PATCH] virtio: fix the vq size issue
Thread-Index: AQHQs9JlQEOaxBUIeEyxKL7zRjwCJJ3I8YBA
Date: Fri, 3 Jul 2015 01:53:44 +0000
Message-ID: <F52918179C57134FAEC9EA62FA2F962511BDEE22@shsmsx102.ccr.corp.intel.com>
References: <1435736930-26737-1-git-send-email-changchun.ouyang@intel.com>
 <C37D651A908B024F974696C65296B57B0F5504FB@SHSMSX101.ccr.corp.intel.com>
 <F52918179C57134FAEC9EA62FA2F962511BDCE1F@shsmsx102.ccr.corp.intel.com>
 <C37D651A908B024F974696C65296B57B0F552502@SHSMSX101.ccr.corp.intel.com>
 <F52918179C57134FAEC9EA62FA2F962511BDD038@shsmsx102.ccr.corp.intel.com>
 <C37D651A908B024F974696C65296B57B0F55372F@SHSMSX101.ccr.corp.intel.com>
In-Reply-To: <C37D651A908B024F974696C65296B57B0F55372F@SHSMSX101.ccr.corp.intel.com>
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] 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: Fri, 03 Jul 2015 01:53:50 -0000



> -----Original Message-----
> From: Xie, Huawei
> Sent: Thursday, July 2, 2015 5:16 PM
> To: Ouyang, Changchun
> Cc: dev@dpdk.org; Thomas Monjalon
> Subject: Re: [dpdk-dev] [PATCH] virtio: fix the vq size issue
>=20
> On 7/2/2015 10:16 AM, Ouyang, Changchun wrote:
> >
> >> -----Original Message-----
> >> From: Xie, Huawei
> >> Sent: Thursday, July 2, 2015 10:02 AM
> >> To: Ouyang, Changchun; dev@dpdk.org; Thomas Monjalon
> >> Subject: Re: [dpdk-dev] [PATCH] virtio: fix the vq size issue
> >>
> >> On 7/2/2015 8:29 AM, Ouyang, Changchun wrote:
> >>> Hi huawei,
> >>>
> >>>> -----Original Message-----
> >>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xie, Huawei
> >>>> Sent: Wednesday, July 1, 2015 11:53 PM
> >>>> To: dev@dpdk.org; Thomas Monjalon
> >>>> Subject: Re: [dpdk-dev] [PATCH] virtio: fix the vq size issue
> >>>>
> >>>> On 7/1/2015 3:49 PM, Ouyang Changchun wrote:
> >>>>> This commit breaks virtio basic packets rx functionality:
> >>>>>   d78deadae4dca240e85054bf2d604a801676becc
> >>>>>
> >>>>> The QEMU use 256 as default vring size, also use this default
> >>>>> value to calculate the virtio avail ring base address and used
> >>>>> ring base address, and vhost in the backend use the ring base
> >>>>> address to do packet
> >>>> IO.
> >>>>> Virtio spec also says the queue size in PCI configuration is
> >>>>> read-only, so virtio front end can't change it. just need use the
> >>>>> read-only value to allocate space for vring and calculate the
> >>>>> avail and used ring base address. Otherwise, the avail and used
> >>>>> ring base
> >>>> address will be different between host and guest, accordingly,
> >>>> packet IO can't work normally.
> >>>> virtio driver could still use the vq_size to initialize avail ring
> >>>> and use ring so that they still have the same base address.
> >>>> The other issue is vhost use  index & (vq->size -1) to index the rin=
g.
> >>> I am not sure what is your clear message here, Vhost has no choice
> >>> but use vq->size -1 to index the ring, It is qemu that always use
> >>> 256 as the vq size, and set the avail and used ring base address, It
> >>> also tells vhost the vq size is 256.
> >> I mean "the same base address issue" could be resolved, but we still
> >> couldn't stop vhost using idx & vq->size -1 to index the ring.
> >>
> > Then this patch will resolve this avail ring base address issue.
> I mean different ring base isn't the root cause. The commit message which
> states that this register is read only is simple and enough.=09

The direct root cause is avail ring base address issue,
Virtio front end use: vring->avail =3D vring->desc + vq_size * SIZE_OF_DESC=
_ELEMENT,
And fill the vring->avail->avail_idx, and the ring itself.
Qemu use:  vring->avail =3D vring->desc + 256 * SIZE_OF_DESC_ELEMENT,
And tell vhost this address, Vhost use this address to enqueue packets from=
 phy port  into vring.

Pls note that if vq_size is not 256, e.g. it is changed into 128, then the =
vring->avail in host and in guest
Is totally different, that is why it fail to rx any packet, because they tr=
y to use different address to get
Same content in that space.

This is why I still think it is the root cause and I need add it into the c=
ommit.

>=20
> >>>> Thomas:
> >>>> This fix works but introduces slight change with original code.
> >>>> Could we just rollback that commit?
> >>> What's your major concern for the slight change here?
> >>> just removing the unnecessary check for nb_desc itself.
> >>> So I think no issue for the slight change.
> >> No major concern. It is better if this patch just rollbacks that
> >> commit without introduce extra change if not necessary.
> >> The original code set nb_desc to vq_size, though it isn't used later.
> >>
> > I prefer to have the slight change to remove unnecessary setting.
> >
> >>> Thanks
> >>> Changchun
> >>>
> >>>
> >>>
> >>>
> >
> >