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 E8B4D95A9 for ; Thu, 7 Jan 2016 05:06:10 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP; 06 Jan 2016 20:06:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,531,1444719600"; d="scan'208";a="629267107" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jan 2016 20:06:09 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 6 Jan 2016 20:06:09 -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; Wed, 6 Jan 2016 20:06:09 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.133]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.201]) with mapi id 14.03.0248.002; Thu, 7 Jan 2016 12:05:54 +0800 From: "Pei, Yulong" To: "Tu, LijuanX A" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH] add vf port start/stop test script, plan and config file Thread-Index: AQHRSGdqmCYhxQ4V40OnYSZoPPr9tp7vbI9g Date: Thu, 7 Jan 2016 04:05:54 +0000 Message-ID: <188971FCDA171749BED5DA74ABF3E6F003520CF0@shsmsx102.ccr.corp.intel.com> References: <1452073413-7436-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1452073413-7436-1-git-send-email-lijuanx.a.tu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTJkZjRiYjctMDVkNS00MTdmLWJkMDMtMDI4OGNjNzI3YTllIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVGZoN2FPdXNDOWVCZURNSWN6U3lDUUJ4NTZxZ0NJNHdDTWJ4RFp6Y0J2UT0ifQ== 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 Cc: Lijuan Tu Subject: Re: [dts] [PATCH] add vf port start/stop test script, plan and config file 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, 07 Jan 2016 04:06:11 -0000 Please see my comment below, -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Lijuan Tu Sent: Wednesday, January 6, 2016 5:44 PM To: dts@dpdk.org Cc: Lijuan Tu Subject: [dts] [PATCH] add vf port start/stop test script, plan and config = file From: Lijuan Tu Send packets from tester ,at the same time, vf prot start/stop several time= and check if it running right. Three files added in the patch: 1, vf_port_start_stop.cfg: vm setting and qemu parameters. 2, vf_port_start_stop_test_plan.rst: test plan, describe 1 case 3, TestSuit= e_vf_port_start_stop.py: implement one case according to the tes plan Signed-off-by: Lijuan Tu --- conf/vf_port_start_stop.cfg | 107 ++++++++++++++ test_plans/vf_port_start_stop_test_plan.rst | 173 +++++++++++++++++++++++ tests/TestSuite_vf_port_start_stop.py | 212 ++++++++++++++++++++++++= ++++ 3 files changed, 492 insertions(+) create mode 100644 conf/vf_port_start_stop.cfg create mode 100644 test_pl= ans/vf_port_start_stop_test_plan.rst create mode 100644 tests/TestSuite_vf_port_start_stop.py diff --git a/conf/vf_port_start_stop.cfg b/conf/vf_port_start_stop.cfg new = file mode 100644 index 0000000..ab1c0c7 --- /dev/null +++ b/conf/vf_port_start_stop.cfg @@ -0,0 +1,107 @@ +# 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 9; disk =3D + file=3D/home/image/fedora23.img; +mem =3D + size=3D8196 +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=3D11; +daemon =3D + enable=3Dyes; diff --git a/test_plans/vf_port_start_stop_test_plan.rst b/test_plans/vf_po= rt_start_stop_test_plan.rst new file mode 100644 index 0000000..6464b55 --- /dev/null +++ b/test_plans/vf_port_start_stop_test_plan.rst @@ -0,0 +1,173 @@ +.. 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. + +Prerequisites for Topo1- PF kernel driver=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 + +Create Two VF interfaces from two kernel PF ineterfaces, and then attach t= hem to VM. Suppose PF is 0000:04:00.0 and 0000:04:00.1. Generate 2VFs using= commands below and make them in pci-stub mods. + Here Create Two VF interfaces from one kernel PF is enough. +1. Get the pci device id of DUT:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f0 drv=3Dixgbe unused=3Digb_uio + 0000:04:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection'=20 + if=3Dens261f1 drv=3Dixgbe unused=3Digb_uio + +2. Create 2 VFs from 2 PFs:: + + echo 1 > /sys/bus/pci/devices/0000\:04\:00.0/sriov_numvfs + echo 1 > /sys/bus/pci/devices/0000\:04\:00.1/sriov_numvfs + +VFs 04:10.0 & 04:10.1 have been created:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f0 drv=3Dixgbe unused=3D + 0000:04:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f1 drv=3Dixgbe unused=3D + 0000:04:10.0 '82599 Ethernet Controller Virtual Function' if=3Denp4s16= drv=3Dixgbevf unused=3D + 0000:04:10.1 '82599 Ethernet Controller Virtual Function'=20 + if=3Denp4s16f1 drv=3Dixgbevf unused=3D + +3. detach VFs from the host, bind them to pci-stub driver:: + + /sbin/modprobe pci-stub + echo "8086 10ed" > /sys/bus/pci/drivers/pci-stub/new_id + echo 0000:04:10.0 > /sys/bus/pci/devices/0000\:04\:10.0/driver/unbind + echo 0000:04:10.0 > /sys/bus/pci/drivers/pci-stub/bind + echo 0000:04:10.1 > /sys/bus/pci/devices/0000\:04\:10.1/driver/unbind + echo 0000:04:10.1 > /sys/bus/pci/drivers/pci-stub/bind + +or using the following more easy way:: + + ./dpdk_nic_bind.py -b pci-stub 04:10.0 04:10.1 + +it can be seen that VFs 04:10.0 & 04:10.1 's drv is pci-stub:: + + ./dpdk_nic_bind.py --st + 0000:04:00.0 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f0 drv=3Dixgbe unused=3Dvfio-pci + 0000:04:00.1 '82599ES 10-Gigabit SFI/SFP+ Network Connection' if=3Dens= 261f1 drv=3Dixgbe unused=3Dvfio-pci + 0000:04:10.0 '82599 Ethernet Controller Virtual Function' if=3D drv=3D= pci-stub unused=3Dixgbevf,vfio-pci + 0000:04:10.1 '82599 Ethernet Controller Virtual Function' if=3D=20 + drv=3Dpci-stub unused=3Dixgbevf,vfio-pci + +4. Do not forget bring up PFs:: + + ifconfig ens261f0 up + ifconfig ens261f1 up + +Passthrough VFs 04:10.0 & 04:10.1 to vm0, and start vm0, you can refer to = below command:: + + taskset -c 6-12 qemu-system-x86_64 \ + -enable-kvm -m 8192 -smp 6 -cpu host -name dpdk15-vm1 \ + -drive file=3D/home/image/fedora23.img \ + -netdev tap,id=3Dhostnet1,ifname=3Dtap1,script=3D/etc/qemu-ifup,vhost= =3Don \ + -device rtl8139,netdev=3Dhostnet1,id=3Dnet1,mac=3D52:54:01:6b:10:61,bu= s=3Dpci.0,addr=3D0xa \ + -device pci-assign,bus=3Dpci.0,addr=3D0x6,host=3D04:10.0 \ + -device pci-assign,bus=3Dpci.0,addr=3D0x7,host=3D04:10.1 \ + -vnc :11 -daemonize + +the /etc/qemu-ifup can be below script, need you to create first:: + + #!/bin/sh + set -x + switch=3Dbr0 + if [ -n "$1" ];then + /usr/sbin/tunctl -u `whoami` -t $1 + /sbin/ip link set $1 up + sleep 0.5s + /usr/sbin/brctl addif $switch $1 + exit 0 + else + echo "Error: no interface specified" + exit 1 + fi + +Set up bridge br0 before create /etc/qemu-ifup, for example:: + + cd /etc/sysconfig/network-scripts + vim ifcfg-enp1s0f0 + + HWADDR=3D00:1e:67:fb:0f:d4 + TYPE=3DEthernet + NAME=3Denp1s0f0 + ONBOOT=3Dyes + DEVICE=3Denp1s0f0 + NM_CONTROLLED=3Dno + BRIDGE=3Dbr0 + + vim ifcfg-br0 + TYPE=3DBridge + DEVICE=3Dbr0 + ONBOOT=3Dyes + NM_CONTROLLED=3Dno + BOOTPROTO=3Ddhcp + HOSTNAME=3D"dpdk-test58" + +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 + ./x86_64-native-linuxapp-gcc/app/testpmd -c 0x0f -n 4 -- -i + testpmd-> set fwd mac + testpmd-> start + +Test Case: port start/stop +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D +Start send packets from tester , then start/stop ports several times ,veri= fy if it running right. + +Commands could be used to start/stop ports refer to below:: + +Start port:: + + testpmd-> port start all + +Stop port:: + + testpmd-> port stop all + +Send IP+UDP packet:: + + Ether(dst=3D"0E:CB:F8:FF:4E:02",=20 + src=3D"0E:CB:F8:FF:4E:02")/IP(src=3D"127.0.0.2")/UDP()/("X"*46) + +Send IP+TCP packet:: + + Ether(dst=3D"0E:CB:F8:FF:4E:02",=20 + src=3D"0E:CB:F8:FF:4E:02")/IP(src=3D"127.0.0.2")/TCP()/("X"*46) + +Send IP+SCTP packet:: + + Ether(dst=3D"0E:CB:F8:FF:4E:02",=20 + src=3D"0E:CB:F8:FF:4E:02")/IP(src=3D"127.0.0.2")/SCTP()/("X"*46) + +Send IPv6+UDP packet:: + + Ether(dst=3D"0E:CB:F8:FF:4E:02",=20 + src=3D"0E:CB:F8:FF:4E:02")/IP(src=3D"::2")/UDP()/("X"*46) + +Send IPv6+TCP packet:: + + Ether(dst=3D"0E:CB:F8:FF:4E:02",=20 + src=3D"0E:CB:F8:FF:4E:02")/IP(src=3D"::2")/TCP()/("X"*46) + diff --git a/tests/TestSuite_vf_port_start_stop.py b/tests/TestSuite_vf_por= t_start_stop.py new file mode 100644 index 0000000..051f988 --- /dev/null +++ b/tests/TestSuite_vf_port_start_stop.py @@ -0,0 +1,212 @@ +# + +import re +import time + +import dts +from qemu_kvm import QEMUKvm +from test_case import TestCase +from pmd_output import PmdOutput +from utils import RED, GREEN +from net_device import NetDevice +from crb import Crb +from scapy.all import * +VM_CORES_MASK =3D 'all' + +class TestVfPortStartStop(TestCase): + + def set_up_all(self): + + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) > 1, "Insufficient ports") + self.vm0 =3D None + self.filename =3D "/root/vf.pcap" + + def set_up(self): + + self.setup_2pf_2vf_1vm_env_flag =3D 0 + + def pktgen_prerequisites(self): + """ + igb_uio.ko should be put in ~ before you using pktgen + """ + out =3D self.tester.send_expect("ls", "#") + self.verify("igb_uio.ko" in out, "No file igb_uio.ko") + self.tester.send_expect("modprobe uio", "#", 70) + out =3D self.tester.send_expect("lsmod | grep igb_uio", "#") + if "igb_uio" in out: + out =3D self.tester.send_expect("insmod igb_uio.ko", "#") + self.verify("could not load module" not in out, "%s" %out) + + total_huge_pages =3D self.tester.get_total_huge_pages() + if total_huge_pages =3D=3D 0: + self.tester.mount_huge_pages() + self.tester.set_huge_pages(1024) + + def send_and_verify(self, dst_mac, testpmd): + """ + Generates packets by pktgen + """ + self.pktgen_prerequisites() + # bind ports + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) + tx_pci =3D self.tester.ports_info[tx_port]['pci'] + port =3D self.tester.ports_info[tx_port]['port'] + port_driver =3D port.get_nic_driver() + self.tester.send_expect("./dpdk_nic_bind.py --bind=3Digb_uio %s"=20 + % tx_pci, "#") + + src_mac =3D self.tester.get_mac(tx_port) + + pkts =3D {'IP/UDP': Ether(dst=3D"%s" % dst_mac, src=3D"%s" % src_m= ac)/IP(src=3D"127.0.0.2")/UDP()/("X"*46), + 'IP/TCP': Ether(dst=3D"%s" % dst_mac, src=3D"%s" % src_mac= )/IP(src=3D"127.0.0.2")/TCP()/("X"*46), + 'IP/SCTP': Ether(dst=3D"%s" % dst_mac, src=3D"%s" % src_ma= c)/IP(src=3D"127.0.0.2")/SCTP()/("X"*48), + 'IPv6/UDP': Ether(dst=3D"%s" % dst_mac, src=3D"%s" % src_m= ac)/IPv6(src=3D"::2")/UDP()/("X"*46), + 'IPv6/TCP': Ether(dst=3D"%s" % dst_mac, src=3D"%s" %=20 + src_mac)/IPv6(src=3D"::2")/TCP()/("X"*46),} + + self.testpmd_reset_status(testpmd) + + for key in pkts.keys(): + self.create_pcap_file(self.filename, pkts[key])=20 It is better to write pkts.keys() to one pcap file and then using pktgen se= nd the pcap, then it avoid to start/stop pktgen in loop.=20 + self.tester.send_expect("./pktgen -c 0x1f -n 2 --proc-type au= to --socket-mem 128,128 --file-prefix pg -- -P -T -m '1.0' -s 0:%s" % self.= filename, "Pktgen >", 100) + self.tester.send_expect("start all", "Pktgen>") + time.sleep(1) + self.check_port_start_stop(testpmd) =20 + # quit pktgen + self.tester.send_expect("stop all", "Pktgen>") + self.tester.send_expect("quit", "# ") + It is better to check if it has 'RX-errors' & 'TX-errors' after frequently = port start/stop. + self.tester.send_expect("./dpdk_nic_bind.py --bind=3D%s %s"=20 + %(port_driver, tx_pci), "#") +=20 + def create_pcap_file(self, filename, pkt): + """ + Generates a valid PCAP file with the given configuration. + """ + wrpcap(filename, pkt) + + def testpmd_reset_status(self, testpmd): + """ + Reset testpmd :stop forword & stop port + """ + testpmd.execute_cmd('stop') + testpmd.execute_cmd('port stop all') + testpmd.execute_cmd('clear port stats all') + + def check_port_start_stop(self, testpmd, times=3D100): I think that 100 is not enough for stress, maybe 1000 is better. Best Regards Yulong Pei + """ + VF port start/stop several times , check if it work well. + """ + for i in range(times): + out =3D testpmd.execute_cmd('port start all') + self.verify("Checking link statuses" in out, "ERROR: port star= t all") + testpmd.execute_cmd('start') + time.sleep(.5) + testpmd.execute_cmd('stop') + out =3D testpmd.execute_cmd('port stop all') + self.verify("Checking link statuses" in out, "ERROR: port=20 + stop all") + =20 + 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_port_start_stop') + 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_start_stop_with_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') + + 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') + + time.sleep(2) + + dst_mac =3D self.vm_dut_0.get_mac_address(self.vm0_dut_ports[0]) + print "dst_mac:", dst_mac + self.send_and_verify(dst_mac, self.vm0_testpmd) + + 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.5.0