[dpdk-dev] [PATCH v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c

Xu, Qian Q qian.q.xu at intel.com
Fri Jan 15 09:57:22 CET 2016


Tested-by: Qian Xu <qian.q.xu at intel.com>

- 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 (rev 01)
- Target: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection (rev 01)
- Total 2 cases, 2 passed, 0 failed. 

Test Case1: test_func_vhost_user_virtio1.0-pmd with different txqflags 
======================================================================

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 vhost sample to use, need ensure that the PCI port located socket has the memory. In our case, the PCI BDF is 81:00.0, so we need assign memory for socket1.::

    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 

2. Start VM with 1 virtio, note: we need add "disable-modern=false" to enable virtio 1.0. 

    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=mem,size=2048M,mem-path=/mnt/huge,share=on -numa node,memdev=mem -mem-prealloc \
     -smp cores=2,sockets=1 -drive file=/home/img/vm1.img  \
     -chardev socket,id=char0,path=/home/qxu10/virtio-1.0/dpdk/vhost-net -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
     -device virtio-net-pci,mac=52:54:00:00:00:01,netdev=mynet1,disable-modern=false \
     -netdev tap,id=ipvm1,ifname=tap3,script=/etc/qemu-ifup -device rtl8139,netdev=ipvm1,id=net0,mac=00:00:00:00:10:01 -nographic


3. In the VM, change the config file--common_linuxapp, "CONFIG_RTE_LIBRTE_VIRTIO_DEBUG_INIT=y"; Run dpdk testpmd in VM::

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

     ./<dpdk_folder>/x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3 -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan 
    
     $ >set fwd mac
    
     $ >start tx_first

    We expect similar output as below, and see modern virtio pci detected. 
 
    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: 4194304
    PMD: virtio_read_caps(): [60] cfg type: 4, bar: 4, offset: 2000, len: 4096
    PMD: virtio_read_caps(): [50] cfg type: 3, bar: 4, offset: 1000, len: 4096
    PMD: virtio_read_caps(): [40] cfg type: 1, bar: 4, offset: 0000, len: 4096
    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 multiplier: 409                                                                                                                     6
    PMD: vtpci_init(): modern virtio pci detected.


4. Send traffic to virtio1(MAC1=52:54:00:00:00:01) with VLAN ID=1000. Check if virtio packet can be RX/TX and also check the TX packet size is same as the RX packet size.

5. Also run the dpdk testpmd in VM with txqflags=0xf01 for the virtio pmd optimization usage::

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

     ./<dpdk_folder>/x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3 -n 4 -- -i --txqflags=0x0f01 --disable-hw-vlan 
    
     $ >set fwd mac
    
     $ >start tx_first

6. Send traffic to virtio1(MAC1=52:54:00:00:00:01) and VLAN ID=1000. Check 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
===================================================================

1. Launch the Vhost sample by below commands, socket-mem is set for the vhost sample to use, need ensure that the PCI port located socket has the memory. In our case, the PCI BDF is 81:00.0, so we need assign memory for socket1.::

    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 

2. Start VM1 with 1 virtio, note: we need add "disable-modern=false" to enable virtio 1.0. 

    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=mem,size=2048M,mem-path=/mnt/huge,share=on -numa node,memdev=mem -mem-prealloc \
     -smp cores=2,sockets=1 -drive file=/home/img/vm1.img  \
     -chardev socket,id=char0,path=/home/qxu10/virtio-1.0/dpdk/vhost-net -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \
     -device virtio-net-pci,mac=52:54:00:00:00:01,netdev=mynet1,disable-modern=false \
     -netdev tap,id=ipvm1,ifname=tap3,script=/etc/qemu-ifup -device rtl8139,netdev=ipvm1,id=net0,mac=00:00:00:00:10:01 -nographic

3. Start VM2 with 1 virtio, note: 

    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=mem,size=2048M,mem-path=/mnt/huge,share=on -numa node,memdev=mem -mem-prealloc \
     -smp cores=2,sockets=1 -drive file=/home/img/vm2.img  \
     -chardev socket,id=char0,path=/home/qxu10/virtio-1.0/dpdk/vhost-net -netdev type=vhost-user,id=mynet2,chardev=char0,vhostforce \
     -device virtio-net-pci,mac=52:54:00:00:00:02,netdev=mynet2,disable-modern=true \
     -netdev tap,id=ipvm2,ifname=tap4,script=/etc/qemu-ifup -device rtl8139,netdev=ipvm2,id=net1,mac=00:00:00:00:10:02 -nographic

3. Run dpdk testpmd in VM1 and VM2::

     VM1:     

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

     ./<dpdk_folder>/x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3 -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan --eth-peer=0,52:54:00:00:00:02 
    
     $ >set fwd mac
    
     $ >start tx_first

     VM2: 

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

     ./<dpdk_folder>/x86_64-native-linuxapp-gcc/app/test-pmd/testpmd -c 0x3 -n 4 -- -i --txqflags 0x0f00 --disable-hw-vlan 
    
     $ >set fwd mac
    
     $ >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 at linux.intel.com] 
Sent: Friday, January 15, 2016 12:36 PM
To: dev at 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_pci.c

virtio_pci.c is the only file references those macros; move them there.

Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com>
---
 drivers/net/virtio/virtio_pci.c | 19 +++++++++++++++++++  drivers/net/virtio/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_pci.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
 
+
+#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 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_pci.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)  }  #endif
 
-#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



More information about the dev mailing list