From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <qian.q.xu@intel.com>
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by dpdk.org (Postfix) with ESMTP id AB2D23787
 for <dev@dpdk.org>; Wed,  1 Jul 2015 10:55:39 +0200 (CEST)
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by orsmga101.jf.intel.com with ESMTP; 01 Jul 2015 01:55:38 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.15,384,1432623600"; d="scan'208";a="756391865"
Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91])
 by orsmga002.jf.intel.com with ESMTP; 01 Jul 2015 01:55:37 -0700
Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by
 PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS)
 id 14.3.224.2; Wed, 1 Jul 2015 16:55:37 +0800
Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.165]) by
 SHSMSX104.ccr.corp.intel.com ([169.254.5.129]) with mapi id 14.03.0224.002;
 Wed, 1 Jul 2015 16:55:35 +0800
From: "Xu, Qian Q" <qian.q.xu@intel.com>
To: "Ouyang, Changchun" <changchun.ouyang@intel.com>, "dev@dpdk.org"
 <dev@dpdk.org>
Thread-Topic: [PATCH] virtio: fix the vq size issue
Thread-Index: AQHQs9JlZdYK20EeU02SPlZqlmEUBp3GQ3iw
Date: Wed, 1 Jul 2015 08:55:33 +0000
Message-ID: <82F45D86ADE5454A95A89742C8D1410E01D775AD@shsmsx102.ccr.corp.intel.com>
References: <1435736930-26737-1-git-send-email-changchun.ouyang@intel.com>
In-Reply-To: <1435736930-26737-1-git-send-email-changchun.ouyang@intel.com>
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
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: Wed, 01 Jul 2015 08:55:40 -0000

Tested-by: Qian Xu <qian.q.xu@intel.com>
- Test Commit: c55e94f560ef5c9fcee4584952de1d0bd414aece
- OS: Fedora 21
- GCC: gcc (GCC) 4.9.2 20141101 (Red Hat 4.9.2-1)
- CPU: Intel(R) Xeon(R) CPU E5-2699 v3 @ 2.30GHz
- NIC: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (re=
v 01)
- Target: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection =
(rev 01)
- Total 2 cases(Test Case7 and 8), 2 passed, 0 failed.=20

Test Case 1:  test_perf_virtio_one_vm_dpdk_fwd_vhost-cuse_jumboframe
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

On host:

1. Start up vhost-switch, mergeable 1 means the jubmo frame feature is enab=
led. vm2vm 0 means only one vm without vm to vm communication::

    taskset -c 1-3 <dpdk_folder>/examples/vhost/build/vhost-switch -c 0xf -=
n 4 --huge-dir /mnt/huge --socket-mem 1024,1024 -- -p 1 --mergeable 1 --zer=
o-copy 0 --vm2vm 0
  =20

2. Start VM with vhost cuse as backend::

    taskset -c 4-6  /home/qxu10/qemu-2.2.0/x86_64-softmmu/qemu-system-x86_6=
4 -object memory-backend-file, id=3Dmem,size=3D2048M,mem-path=3D/mnt/huge,s=
hare=3Don -numa node,memdev=3Dmem -mem-prealloc \
    -enable-kvm -m 2048 -smp 4 -cpu host -name dpdk1-vm1 \
    -drive file=3D/home/img/dpdk1-vm1.img \
    -netdev tap,id=3Dvhost3,ifname=3Dtap_vhost3,vhost=3Don,script=3Dno \
    -device virtio-net pci,netdev=3Dvhost3,mac=3D52:54:00:00:00:01,id=3Dnet=
3,csum=3Doff,gso=3Doff,guest_csum=3Doff,guest_tso4=3Doff,guest_tso6=3Doff,g=
uest_ecn=3Doff \
    -netdev tap,id=3Dvhost4,ifname=3Dtap_vhost4,vhost=3Don,script=3Dno \
    -device virtio-net-pci,netdev=3Dvhost4,mac=3D52:54:00:00:00:02,id=3Dnet=
4,csum=3Doff,gso=3Doff,guest_csum=3Doff,guest_tso4=3Doff,guest_tso6=3Doff,g=
uest_ecn=3Doff \
    -netdev tap,id=3Dipvm1,ifname=3Dtap3,script=3D/etc/qemu-ifup -device rt=
l8139,netdev=3Dipvm1,id=3Dnet0,mac=3D00:00:00:00:00:01 \
    -localtime -nographic

On guest:

3. ensure the dpdk folder copied to the guest with the same config file and=
 build process as host. Then bind 2 virtio devices to igb_uio and start tes=
tpmd, below is the step for reference::

    ./<dpdk_folder>/tools/dpdk_nic_bind.py --bind igb_uio 00:03.0 00:04.0

    ./<dpdk_folder>/x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c f -n=
 4 -- -i --txqflags 0x0f00 --max-pkt-len 9000=20
   =20
    $ >set fwd mac
   =20
    $ >start tx_first

4. After typing start tx_first in testpmd, user can see there would be 2 vi=
rtio device with MAC and vlan id registered in vhost-user, the log would be=
 shown in host's vhost-sample output.

5. Send traffic(30second) to virtio1 and virtio2, and set the packet size f=
rom 64 to 1518 as well as the jumbo frame 3000. Check the performance in Mp=
ps. The traffic sent to virtio1 should have the DEST MAC of Virtio1's MAC, =
Vlan id of Virtio1. The traffic sent to virtio2 should have the DEST MAC of=
 Virtio2's MAC, Vlan id of Virtio2. As to the functionality criteria, The r=
eceived rate should not be zero. As to the performance criteria, need check=
 it with developer or design doc/PRD.

Test Case 7:  test_perf_virtio_one_vm_dpdk_fwd_vhost-user_jumboframe
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

This case is similar to TestCase1, just change the backend from vhost cuse =
to vhost-user, so need rebuild the dpdk in vhost-user on host, other steps =
are same as TestCase1. The command to launch vm is different, see below as =
example::=20

    <qemu-2.2.0_folder>/x86_64-softmmu/qemu-system-x86_64 -name us-vhost-vm=
1 -cpu host -enable-kvm -m 2048 -object memory-backend-file,id=3Dmem,size=
=3D2048M,mem-path=3D/mnt/huge,share=3Don -numa node,memdev=3Dmem -mem-preal=
loc -smp 2 -drive file=3D/home/img/dpdk1-vm1.img -chardev socket,id=3Dchar0=
,path=3D<dpdk/vhost-net -netdev type=3Dvhost-user,id=3Dmynet1,chardev=3Dcha=
r0,vhostforce -device virtio-net-pci,mac=3D52:54:00:00:00:01,netdev=3Dmynet=
1 -chardev socket,id=3Dchar1,path=3D/home/qxu10/dpdk/vhost-net -netdev type=
=3Dvhost-user,id=3Dmynet2,chardev=3Dchar1,vhostforce -device virtio-net-pci=
,mac=3D52:54:00:00:00:02,netdev=3Dmynet2 -netdev tap,id=3Dipvm1,ifname=3Dta=
p3,script=3D/etc/qemu-ifup -device rtl8139,netdev=3Dipvm1,id=3Dnet0,mac=3D0=
0:00:00:00:00:09 -nographic

On the guest, need add one parameter at the end of testpmd command line: --=
disable-hw-vlan-filter.

Test Case 8:  test_perf_virtio_one_vm_dpdk_fwd_vhost-user
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D

This case is similar to TestCase7, just set mergeable=3D0(disable jumbo fra=
me) when launch the vhost sample, and send the packet size from 64B to 1518=
B to check the performance and basic functions.

Thanks
Qian


-----Original Message-----
From: Ouyang, Changchun=20
Sent: Wednesday, July 01, 2015 3:49 PM
To: dev@dpdk.org
Cc: Cao, Waterman; Xu, Qian Q; Ouyang, Changchun
Subject: [PATCH] virtio: fix the vq size issue

This commit breaks virtio basic packets rx functionality:
  d78deadae4dca240e85054bf2d604a801676becc

The QEMU use 256 as default vring size, also use this default value to calc=
ulate the virtio avail ring base address and used ring base address, and vh=
ost 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 allo=
cate space for vring and calculate the avail and used ring base address. Ot=
herwise, the avail and used ring base address will be different between hos=
t and guest, accordingly, packet IO can't work normally.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 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;
 	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), fa=
ll to vq size",
+			nb_desc, vq_size);
=20
 	if (queue_type =3D=3D VTNET_RQ) {
 		snprintf(vq_name, sizeof(vq_name), "port%d_rvq%d",
--
1.8.4.2