From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 3C3958D93 for ; Thu, 17 Dec 2015 04:13:12 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 16 Dec 2015 19:13:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,439,1444719600"; d="scan'208";a="709362084" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 16 Dec 2015 19:13:12 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Dec 2015 19:13:10 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 16 Dec 2015 19:13:10 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.158]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.151]) with mapi id 14.03.0248.002; Thu, 17 Dec 2015 11:13:01 +0800 From: "Xu, Qian Q" To: "Pei, Yulong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH] Add basic packet rxtx test case for sriov VF Thread-Index: AQHRN98tLMTtjMaBl0mEFvEvmnUK6J7OgKog Date: Thu, 17 Dec 2015 03:13:00 +0000 Message-ID: <82F45D86ADE5454A95A89742C8D1410E031982A7@shsmsx102.ccr.corp.intel.com> References: <1450255943-24764-1-git-send-email-yulong.pei@intel.com> In-Reply-To: <1450255943-24764-1-git-send-email-yulong.pei@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGQxOWI3MmQtMDgxNC00YjQ3LWJmYjItNjExZjM0NmFlNzc4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQUJrVVdHTUZKTGRxSExGcUtTcEkxc1Y1aWFUeWlPNlwvSytlU2JGSUhuXC84PSJ9 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: [dts] [PATCH] Add basic packet rxtx test case for sriov VF X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2015 03:13:13 -0000 Some comments about test plan below.=20 Thanks Qian -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yulong Pei Sent: Wednesday, December 16, 2015 4:52 PM To: dts@dpdk.org Subject: [dts] [PATCH] Add basic packet rxtx test case for sriov VF An basic test case for sriov VFs, based on kernel PF drivver and dpdk VF dr= iver. Signed-off-by: Yulong Pei --- conf/vf_packet_rxtx.cfg | 105 ++++++++++++++++ test_plans/vf_packet_rxtx_test_plan.rst | 100 ++++++++++++++++ tests/TestSuite_vf_packet_rxtx.py | 204 ++++++++++++++++++++++++++++= ++++ 3 files changed, 409 insertions(+) create mode 100644 conf/vf_packet_rxtx.cfg create mode 100644 test_plans/= vf_packet_rxtx_test_plan.rst create mode 100644 tests/TestSuite_vf_packet_rxtx.py diff --git a/conf/vf_packet_rxtx.cfg b/conf/vf_packet_rxtx.cfg new file mod= e 100644 index 0000000..986d289 --- /dev/null +++ b/conf/vf_packet_rxtx.cfg @@ -0,0 +1,105 @@ +# QEMU options +# name +# name: vm0 +# +# enable_kvm +# enable: [yes | no] +# +# cpu +# model: [host | core2duo | ...] +# usage: +# choose model value from the command +# qemu-system-x86_64 -cpu help +# number: '4' #number of vcpus +# cpupin: '3 4 5 6' # host cpu list +# +# mem +# size: 1024 +# +# disk +# file: /path/to/image/test.img +# +# net +# type: [nic | user | tap | bridge | ...] +# nic +# opt_vlan: 0 +# note: Default is 0. +# opt_macaddr: 00:00:00:00:01:01 +# note: if creating a nic, it`s better to specify a MAC, +# else it will get a random number. +# opt_model:["e1000" | "virtio" | "i82551" | ...] +# note: Default is e1000. +# opt_name: 'nic1' +# opt_addr: '' +# note: PCI cards only. +# opt_vectors: +# note: This option currently only affects virtio cards. +# user +# opt_vlan: 0 +# note: default is 0. +# opt_hostfwd: [tcp|udp]:[hostaddr]:hostport-[guestaddr]:gue= stport +# note: If not specified, it will be setted automaticall= y. +# tap +# opt_vlan: 0 +# note: default is 0. +# opt_br: br0 +# note: if choosing tap, need to specify bridge name, +# else it will be br0. +# opt_script: QEMU_IFUP_PATH +# note: if not specified, default is self.QEMU_IFUP_PATH= . +# opt_downscript: QEMU_IFDOWN_PATH +# note: if not specified, default is self.QEMU_IFDOWN_PA= TH. +# +# device +# driver: [pci-assign | virtio-net-pci | ...] +# pci-assign +# prop_host: 08:00.0 +# prop_addr: 00:00:00:00:01:02 +# virtio-net-pci +# prop_netdev: mynet1 +# prop_id: net1 +# prop_mac: 00:00:00:00:01:03 +# prop_bus: pci.0 +# prop_addr: 0x3 +# +# monitor +# port: 6061 =20 +# note: if adding monitor to vm, need to specicy +# this port, else it will get a free port +# on the host machine. +# +# qga +# enable: [yes | no] +# +# serial_port +# enable: [yes | no] +# +# vnc +# displayNum: 1 +# note: you can choose a number not used on the host. +# +# daemon +# enable: 'yes' +# note: +# By default VM will start with the daemonize status. +# Not support starting it on the stdin now. + +# vm configuration for pmd sriov case +[vm0] +cpu =3D + model=3Dhost,number=3D4,cpupin=3D5 6 7 8; disk =3D + file=3D/home/image/sriov-fc20-1.img; +login =3D + user=3Droot,password=3Dtester; +net =3D=20 + type=3Dnic,opt_vlan=3D0; + type=3Duser,opt_vlan=3D0; +monitor =3D=20 + port=3D; +qga =3D=20 + enable=3Dyes; +vnc =3D=20 + displayNum=3D1; +daemon =3D + enable=3Dyes; diff --git a/test_plans/vf_packet_rxtx_test_plan.rst b/test_plans/vf_packet= _rxtx_test_plan.rst new file mode 100644 index 0000000..df14ccf --- /dev/null +++ b/test_plans/vf_packet_rxtx_test_plan.rst @@ -0,0 +1,100 @@ +.. Copyright (c) <2015>, Intel Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Intel Corporation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +Test Case 1: create 2VFs from 2 kernel PFs, passthrough 2VFs to 1VM, using= dpdk vf in VM, do packet rx tx test. +=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=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 [QIAN] the title is a little long, could you change it to VF_packet_IO_kern= el_PF + +1. got the pci device id of DUT, for example, + +./dpdk_nic_bind.py --st + +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f0=20 +drv=3Di40e unused=3D +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f1=20 +drv=3Di40e unused=3D + +2. create 2 VFs from 2 PFs, + +echo 1 > /sys/bus/pci/devices/0000\:81\:00.0/sriov_numvfs +echo 1 > /sys/bus/pci/devices/0000\:81\:00.1/sriov_numvfs +./dpdk_nic_bind.py --st + +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f0=20 +drv=3Di40e unused=3D +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f1=20 +drv=3Di40e unused=3D +0000:81:02.0 'XL710/X710 Virtual Function' unused=3D +0000:81:0a.0 'XL710/X710 Virtual Function' unused=3D + +3. detach VFs from the host, bind them to pci-stub driver, + +/sbin/modprobe pci-stub + [QIAN] As to the VF device ID, better to give a way of how to know the VF d= evice ID. We need get it from "lspci -nn|grep Eth", 154C is also got from t= here.=20 +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id +echo 0000:81:02.0 > /sys/bus/pci/devices/0000:08:02.0/driver/unbind +echo 0000:81:02.0 > /sys/bus/pci/drivers/pci-stub/bind + +echo "8086 154c" > /sys/bus/pci/drivers/pci-stub/new_id +echo 0000:81:0a.0 > /sys/bus/pci/devices/0000:08:0a.0/driver/unbind +echo 0000:81:0a.0 > /sys/bus/pci/drivers/pci-stub/bind + +or using the following more easy way, + +virsh nodedev-detach pci_0000_81_02_0; virsh nodedev-detach=20 +pci_0000_81_0a_0; + +./dpdk_nic_bind.py --st + +0000:81:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f0=20 +drv=3Di40e unused=3D +0000:81:00.1 'Ethernet Controller X710 for 10GbE SFP+' if=3Dens259f1=20 +drv=3Di40e unused=3D +0000:81:02.0 'XL710/X710 Virtual Function' if=3D drv=3Dpci-stub unused=3D +0000:81:0a.0 'XL710/X710 Virtual Function' if=3D drv=3Dpci-stub unused=3D + +it can be seen that VFs 81:02.0 & 81:0a.0 's drv is pci-stub. + +4. passthrough VFs 81:02.0 & 81:0a.0 to vm0, and start vm0, + +/usr/bin/qemu-system-x86_64 -name vm0 -enable-kvm \ -cpu host -smp 4=20 +-m 2048 -drive file=3D/home/image/sriov-fc20-1.img -vnc :1 \ -device=20 +pci-assign,host=3D81:02.0,id=3Dpt_0 \ -device=20 +pci-assign,host=3D81:0a.0,id=3Dpt_1 + +5. login vm0, got VFs pci device id in vm0, assume they are 00:06.0 &=20 +00:07.0, bind them to igb_uio driver, and then start testpmd, set it in=20 +mac forward mode, + +./tools/dpdk_nic_bind.py --bind=3Digb_uio 00:06.0 00:07.0=20 +./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -w 00:06.0 -w=20 +00:07.0 -- -i --portmask=3D0x3 --txqflags=3D0 + +testpmd> set fwd mac +testpmd> start + +6. get mac address of one VF and use it as dest mac, using scapy to=20 +send 2000 ethernet frames from tester, verify the frames can be received b= y one VF and can be forward to another VF correctly. + +sendp([Ether(dst=3D"%s")/IP()/TCP()/("\x50"*1450)], iface=3D"%s", count=3D= %d) diff --git a/tests/TestSuite_vf_packet_rxtx.py b/tests/TestSuite_vf_packet_= rxtx.py new file mode 100644 index 0000000..93a8432 --- /dev/null +++ b/tests/TestSuite_vf_packet_rxtx.py @@ -0,0 +1,204 @@ +# + +import re +import time + +import dts +from qemu_kvm import QEMUKvm +from test_case import TestCase +from pmd_output import PmdOutput + +FRAME_SIZE_64 =3D 64 +VM_CORES_MASK =3D 'all' + + +class TestVfPacketRxtx(TestCase): + + def set_up_all(self): + + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + self.vm0 =3D None + + def set_up(self): + + self.setup_2pf_2vf_1vm_env_flag =3D 0 + + def get_stats(self, dut, portid, rx_tx): + + stats =3D dut.testpmd.get_pmd_stats(portid) + + if rx_tx =3D=3D "rx": + stats_result =3D [ + stats['RX-packets'], stats['RX-missed'], stats['RX-bytes']= ] + elif rx_tx =3D=3D "tx": + stats_result =3D [ + stats['TX-packets'], stats['TX-errors'], stats['TX-bytes']= ] + else: + return None + + return stats_result + + def send_packet(self, + dut, + dut_ports, + dest_port, + tester_intf=3DFalse, + frame_size=3DFRAME_SIZE_64, + count=3D1): + """ + dut: which you want to send packet to + dest_port: the port num must be the index of dut.get_ports() + count: number of packet + """ + + gp0rx_pkts, gp0rx_err, gp0rx_bytes =3D [int(_) + for _ in self.get_stats(dut,= dest_port, "rx")] + try: + dut_dest_port =3D dut_ports[dest_port] + except Exception as e: + print e + + tester_port =3D self.tester.get_local_port(self.dut_ports[0]) + + if not tester_intf: + itf =3D self.tester.get_interface(tester_port) + else: + itf =3D tester_intf + + dest_mac =3D dut.get_mac_address(dut_dest_port) + src_mac =3D dut.tester.get_mac(tester_port) + + self.tester.scapy_foreground() + send_cmd =3D 'sendp([Ether(dst=3D"%s", src=3D"%s")/IP()/TCP()/("\x= 50"*1450)], iface=3D"%s", count=3D%d)' % (dest_mac, src_mac, itf, count) + self.tester.scapy_append(send_cmd) + self.tester.scapy_execute() + + time.sleep(.5) + + p0rx_pkts, p0rx_err, p0rx_bytes =3D [int(_) + for _ in self.get_stats(dut,=20 + dest_port, "rx")] + + p0rx_pkts -=3D gp0rx_pkts + p0rx_bytes -=3D gp0rx_bytes + print("p0rx_pkts=3D%d" % p0rx_pkts) + print("p0rx_bytes=3D%d" % p0rx_bytes) + + self.verify(p0rx_pkts =3D=3D count, "Data not received by port") + + + def setup_2pf_2vf_1vm_env(self, driver=3D'default'): + + self.used_dut_port_0 =3D self.dut_ports[0] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 1, drive= r=3Ddriver) + self.sriov_vfs_port_0 =3D=20 + self.dut.ports_info[self.used_dut_port_0]['vfs_port'] + + self.used_dut_port_1 =3D self.dut_ports[1] + self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 1, drive= r=3Ddriver) + self.sriov_vfs_port_1 =3D=20 + self.dut.ports_info[self.used_dut_port_1]['vfs_port'] + + try: + + for port in self.sriov_vfs_port_0: + port.bind_driver('pci-stub') + + for port in self.sriov_vfs_port_1: + port.bind_driver('pci-stub') + + time.sleep(1) + vf0_prop =3D {'opt_host': self.sriov_vfs_port_0[0].pci} + vf1_prop =3D {'opt_host': self.sriov_vfs_port_1[0].pci} + + if driver =3D=3D 'igb_uio': + # start testpmd without the two VFs on the host + self.host_testpmd =3D PmdOutput(self.dut) + eal_param =3D '-b %(vf0)s -b %(vf1)s' % {'vf0': self.sriov= _vfs_port_0[0].pci, + 'vf1': self.sriov_v= fs_port_1[0].pci} + self.host_testpmd.start_testpmd("1S/2C/2T",=20 + eal_param=3Deal_param) + + # set up VM0 ENV + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx') + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prop) + self.vm0.set_vm_device(driver=3D'pci-assign', **vf1_prop) + self.vm_dut_0 =3D self.vm0.start() + if self.vm_dut_0 is None: + raise Exception("Set up VM0 ENV failed!") + + self.setup_2pf_2vf_1vm_env_flag =3D 1 + except Exception as e: + self.destroy_2pf_2vf_1vm_env() + raise Exception(e) + + def destroy_2pf_2vf_1vm_env(self): + if getattr(self, 'vm0', None): + #destroy testpmd in vm0 + self.vm0_testpmd.execute_cmd('stop') + self.vm0_testpmd.execute_cmd('quit', '# ') + self.vm0_testpmd =3D None + self.vm0_dut_ports =3D None + #destroy vm0 + self.vm0.stop() + self.vm0 =3D None + + if getattr(self, 'host_testpmd', None): + self.host_testpmd.execute_cmd('quit', '# ') + self.host_testpmd =3D None + + if getattr(self, 'used_dut_port_0', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) + port =3D self.dut.ports_info[self.used_dut_port_0]['port'] + port.bind_driver() + self.used_dut_port_0 =3D None + + if getattr(self, 'used_dut_port_1', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1) + port =3D self.dut.ports_info[self.used_dut_port_1]['port'] + port.bind_driver() + self.used_dut_port_1 =3D None + + for port_id in self.dut_ports: + port =3D self.dut.ports_info[port_id]['port'] + port.bind_driver() + + self.setup_2pf_2vf_1vm_env_flag =3D 0 + +######1. test case for kernel pf and dpdk vf 2pf_2vf_1vm scenario + + def test_packet_rx_tx_kernel_2pf_2vf_1vm(self): + + self.setup_2pf_2vf_1vm_env(driver=3D'') + + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + port_id_0 =3D 0 + port_id_1 =3D 1 + packet_num =3D 2000 + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd mac') + self.vm0_testpmd.execute_cmd('start') + + time.sleep(2) + + port_id_1_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_1= ) + self.send_packet( + self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=3Dpacket_n= um) + port_id_1_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_1) + self.verify( + port_id_1_end_stats['TX-packets'] - port_id_1_start_stats['TX-= packets'] =3D=3D packet_num, + "VF0 failed to forward packets to VF1") + + def tear_down(self): + + if self.setup_2pf_2vf_1vm_env_flag =3D=3D 1: + self.destroy_2pf_2vf_1vm_env() + + def tear_down_all(self): + + if getattr(self, 'vm0', None): + self.vm0.stop() + + for port_id in self.dut_ports: + self.dut.destroy_sriov_vfs_by_port(port_id) + -- 2.1.0