From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 558478E6A for ; Fri, 15 Jan 2016 09:57:33 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 15 Jan 2016 00:57:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,298,1449561600"; d="scan'208";a="881890449" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 15 Jan 2016 00:57:25 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 15 Jan 2016 00:57:24 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 15 Jan 2016 00:57:23 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.172]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.209]) with mapi id 14.03.0248.002; Fri, 15 Jan 2016 16:57:23 +0800 From: "Xu, Qian Q" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [PATCH v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Thread-Index: AQHRT04akgrjCpZ/WUWSiDD7F1PR9p78QiNQ Date: Fri, 15 Jan 2016 08:57:22 +0000 Message-ID: <82F45D86ADE5454A95A89742C8D1410E031B9952@shsmsx102.ccr.corp.intel.com> References: <1452581944-24838-1-git-send-email-yuanhan.liu@linux.intel.com> <1452832571-6156-1-git-send-email-yuanhan.liu@linux.intel.com> <1452832571-6156-9-git-send-email-yuanhan.liu@linux.intel.com> In-Reply-To: <1452832571-6156-9-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGI1NjgwMzQtODZkMC00MDMzLWI1MGQtNDQxYjk2ODlkN2RmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibE0ydHNcL1l3RmtvWjR6XC9RcEs5bHp5ZytVaUZmcWhTOU9SNkgzMUNmcFZZPSJ9 x-ctpclassification: CTP_IC 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 v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2016 08:57:34 -0000 Tested-by: Qian Xu - Test Commit: ad66a85dce9a707748cb4d9592c13022ae77c067 - OS/Kernel: Fedora 21/4.1.13 - GCC: gcc (GCC) 4.9.2 20141101 (Red Hat 4.9.2-1) - CPU: Intel(R) Xeon(R) CPU E5-2695 v4 @ 2.10 - 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, 2 passed, 0 failed.=20 Test Case1: test_func_vhost_user_virtio1.0-pmd with different txqflags=20 =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=3D=3D Note: For virtio1.0 usage, we need use qemu version >2.4, such as 2.4.1 or = 2.5.0. 1. Launch the Vhost sample by below commands, socket-mem is set for the vho= st sample to use, need ensure that the PCI port located socket has the memo= ry. In our case, the PCI BDF is 81:00.0, so we need assign memory for socke= t1.:: taskset -c 18-20 ./examples/vhost/build/vhost-switch -c 0x1c0000 -n 4 -= -huge-dir /mnt/huge --socket-mem 0,2048 -- -p 1 --mergeable 0 --zero-copy 0= --vm2vm 0=20 2. Start VM with 1 virtio, note: we need add "disable-modern=3Dfalse" to en= able virtio 1.0.=20 taskset -c 22-23 \ /root/qemu-versions/qemu-2.5.0/x86_64-softmmu/qemu-system-x86_64 -name = us-vhost-vm1 \ -cpu host -enable-kvm -m 2048 -object memory-backend-file,id=3Dmem,siz= e=3D2048M,mem-path=3D/mnt/huge,share=3Don -numa node,memdev=3Dmem -mem-prea= lloc \ -smp cores=3D2,sockets=3D1 -drive file=3D/home/img/vm1.img \ -chardev socket,id=3Dchar0,path=3D/home/qxu10/virtio-1.0/dpdk/vhost-ne= t -netdev type=3Dvhost-user,id=3Dmynet1,chardev=3Dchar0,vhostforce \ -device virtio-net-pci,mac=3D52:54:00:00:00:01,netdev=3Dmynet1,disable= -modern=3Dfalse \ -netdev tap,id=3Dipvm1,ifname=3Dtap3,script=3D/etc/qemu-ifup -device r= tl8139,netdev=3Dipvm1,id=3Dnet0,mac=3D00:00:00:00:10:01 -nographic 3. In the VM, change the config file--common_linuxapp, "CONFIG_RTE_LIBRTE_V= IRTIO_DEBUG_INIT=3Dy"; Run dpdk testpmd in VM:: .//tools/dpdk_nic_bind.py --bind igb_uio 00:03.0=20 .//x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3= -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan=20 =20 $ >set fwd mac =20 $ >start tx_first We expect similar output as below, and see modern virtio pci detected.= =20 =20 PMD: virtio_read_caps(): [98] skipping non VNDR cap id: 11 PMD: virtio_read_caps(): [84] cfg type: 5, bar: 0, offset: 0000, len: 0 PMD: virtio_read_caps(): [70] cfg type: 2, bar: 4, offset: 3000, len: 4= 194304 PMD: virtio_read_caps(): [60] cfg type: 4, bar: 4, offset: 2000, len: 4= 096 PMD: virtio_read_caps(): [50] cfg type: 3, bar: 4, offset: 1000, len: 4= 096 PMD: virtio_read_caps(): [40] cfg type: 1, bar: 4, offset: 0000, len: 4= 096 PMD: virtio_read_caps(): found modern virtio pci device. PMD: virtio_read_caps(): common cfg mapped at: 0x7f2c61a83000 PMD: virtio_read_caps(): device cfg mapped at: 0x7f2c61a85000 PMD: virtio_read_caps(): isr cfg mapped at: 0x7f2c61a84000 PMD: virtio_read_caps(): notify base: 0x7f2c61a86000, notify off multip= lier: 409 = 6 PMD: vtpci_init(): modern virtio pci detected. 4. Send traffic to virtio1(MAC1=3D52:54:00:00:00:01) with VLAN ID=3D1000. C= heck if virtio packet can be RX/TX and also check the TX packet size is sam= e as the RX packet size. 5. Also run the dpdk testpmd in VM with txqflags=3D0xf01 for the virtio pmd= optimization usage:: .//tools/dpdk_nic_bind.py --bind igb_uio 00:03.0 .//x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3= -n 4 -- -i --txqflags=3D0x0f01 --disable-hw-vlan=20 =20 $ >set fwd mac =20 $ >start tx_first 6. Send traffic to virtio1(MAC1=3D52:54:00:00:00:01) and VLAN ID=3D1000. Ch= eck if virtio packet can be RX/TX and also check the TX packet size is same= as the RX packet size. Check the packet content is correct. Test Case2: test_func_vhost_user_one-vm-virtio1.0-one-vm-virtio0.95 =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 1. Launch the Vhost sample by below commands, socket-mem is set for the vho= st sample to use, need ensure that the PCI port located socket has the memo= ry. In our case, the PCI BDF is 81:00.0, so we need assign memory for socke= t1.:: taskset -c 18-20 ./examples/vhost/build/vhost-switch -c 0x1c0000 -n 4 -= -huge-dir /mnt/huge --socket-mem 0,2048 -- -p 1 --mergeable 0 --zero-copy 0= --vm2vm 1=20 2. Start VM1 with 1 virtio, note: we need add "disable-modern=3Dfalse" to e= nable virtio 1.0.=20 taskset -c 22-23 \ /root/qemu-versions/qemu-2.5.0/x86_64-softmmu/qemu-system-x86_64 -name = us-vhost-vm1 \ -cpu host -enable-kvm -m 2048 -object memory-backend-file,id=3Dmem,siz= e=3D2048M,mem-path=3D/mnt/huge,share=3Don -numa node,memdev=3Dmem -mem-prea= lloc \ -smp cores=3D2,sockets=3D1 -drive file=3D/home/img/vm1.img \ -chardev socket,id=3Dchar0,path=3D/home/qxu10/virtio-1.0/dpdk/vhost-ne= t -netdev type=3Dvhost-user,id=3Dmynet1,chardev=3Dchar0,vhostforce \ -device virtio-net-pci,mac=3D52:54:00:00:00:01,netdev=3Dmynet1,disable= -modern=3Dfalse \ -netdev tap,id=3Dipvm1,ifname=3Dtap3,script=3D/etc/qemu-ifup -device r= tl8139,netdev=3Dipvm1,id=3Dnet0,mac=3D00:00:00:00:10:01 -nographic 3. Start VM2 with 1 virtio, note:=20 taskset -c 24-25 \ /root/qemu-versions/qemu-2.5.0/x86_64-softmmu/qemu-system-x86_64 -name = us-vhost-vm1 \ -cpu host -enable-kvm -m 2048 -object memory-backend-file,id=3Dmem,siz= e=3D2048M,mem-path=3D/mnt/huge,share=3Don -numa node,memdev=3Dmem -mem-prea= lloc \ -smp cores=3D2,sockets=3D1 -drive file=3D/home/img/vm2.img \ -chardev socket,id=3Dchar0,path=3D/home/qxu10/virtio-1.0/dpdk/vhost-ne= t -netdev type=3Dvhost-user,id=3Dmynet2,chardev=3Dchar0,vhostforce \ -device virtio-net-pci,mac=3D52:54:00:00:00:02,netdev=3Dmynet2,disable= -modern=3Dtrue \ -netdev tap,id=3Dipvm2,ifname=3Dtap4,script=3D/etc/qemu-ifup -device r= tl8139,netdev=3Dipvm2,id=3Dnet1,mac=3D00:00:00:00:10:02 -nographic 3. Run dpdk testpmd in VM1 and VM2:: VM1: =20 .//tools/dpdk_nic_bind.py --bind igb_uio 00:03.0=20 .//x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3= -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan --eth-peer=3D0,52:54:00:00:= 00:02=20 =20 $ >set fwd mac =20 $ >start tx_first VM2:=20 .//tools/dpdk_nic_bind.py --bind igb_uio 00:03.0=20 .//x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3= -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan=20 =20 $ >set fwd mac =20 $ >start tx_first 4. Send 100 packets at low rate to virtio1, and the expected flow is ixia--= >NIC-->VHOST-->Virtio1-->Virtio2-->Vhost-->NIC->ixia port. Check the packet= back at ixia port is content correct, no size change and payload change. Thanks Qian -----Original Message----- From: Yuanhan Liu [mailto:yuanhan.liu@linux.intel.com]=20 Sent: Friday, January 15, 2016 12:36 PM To: dev@dpdk.org Cc: Xie, Huawei; Tetsuya Mukawa; Tan, Jianfeng; Xu, Qian Q; Yuanhan Liu Subject: [PATCH v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pc= i.c virtio_pci.c is the only file references those macros; move them there. Signed-off-by: Yuanhan Liu --- drivers/net/virtio/virtio_pci.c | 19 +++++++++++++++++++ drivers/net/virt= io/virtio_pci.h | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pc= i.c index fe8d6a2..a9f179f 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -49,6 +49,25 @@ #define PCI_CAPABILITY_LIST 0x34 #define PCI_CAP_ID_VNDR 0x09 =20 + +#define VIRTIO_PCI_REG_ADDR(hw, reg) \ + (unsigned short)((hw)->io_base + (reg)) + +#define VIRTIO_READ_REG_1(hw, reg) \ + inb((VIRTIO_PCI_REG_ADDR((hw), (reg)))) #define VIRTIO_WRITE_REG_1(hw,=20 +reg, value) \ + outb_p((unsigned char)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) + +#define VIRTIO_READ_REG_2(hw, reg) \ + inw((VIRTIO_PCI_REG_ADDR((hw), (reg)))) #define VIRTIO_WRITE_REG_2(hw,=20 +reg, value) \ + outw_p((unsigned short)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) + +#define VIRTIO_READ_REG_4(hw, reg) \ + inl((VIRTIO_PCI_REG_ADDR((hw), (reg)))) #define VIRTIO_WRITE_REG_4(hw,=20 +reg, value) \ + outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) + static void legacy_read_dev_config(struct virtio_hw *hw, uint64_t offset, void *dst, int length) diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pc= i.h index 8174245..99572a0 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -318,24 +318,6 @@ outl_p(unsigned int data, unsigned int port) } #endi= f =20 -#define VIRTIO_PCI_REG_ADDR(hw, reg) \ - (unsigned short)((hw)->io_base + (reg)) - -#define VIRTIO_READ_REG_1(hw, reg) \ - inb((VIRTIO_PCI_REG_ADDR((hw), (reg)))) -#define VIRTIO_WRITE_REG_1(hw, reg, value) \ - outb_p((unsigned char)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) - -#define VIRTIO_READ_REG_2(hw, reg) \ - inw((VIRTIO_PCI_REG_ADDR((hw), (reg)))) -#define VIRTIO_WRITE_REG_2(hw, reg, value) \ - outw_p((unsigned short)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) - -#define VIRTIO_READ_REG_4(hw, reg) \ - inl((VIRTIO_PCI_REG_ADDR((hw), (reg)))) -#define VIRTIO_WRITE_REG_4(hw, reg, value) \ - outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg)))) - static inline int vtpci_with_feature(struct virtio_hw *hw, uint64_t bit) { -- 1.9.0