From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5333A3201 for ; Mon, 21 Oct 2019 05:24:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 97C63F3E; Mon, 21 Oct 2019 05:24:26 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 87B76A69 for ; Mon, 21 Oct 2019 05:24:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2019 20:24:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,322,1566889200"; d="scan'208";a="222330736" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 20 Oct 2019 20:24:22 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 20 Oct 2019 20:24:22 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 20 Oct 2019 20:24:21 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.96]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.33]) with mapi id 14.03.0439.000; Mon, 21 Oct 2019 11:24:20 +0800 From: "Tu, Lijuan" To: "Zeng, XiaoxiaoX" , "dts@dpdk.org" CC: "Zeng, XiaoxiaoX" Thread-Topic: [dts] [PATCH V3] tests/sriov_kvm:complete and refactor TestSuite_sriov_kvm Thread-Index: AQHVgyy0yrMOAq+y4E+ys8cQvoYuk6dkd6ow Date: Mon, 21 Oct 2019 03:24:19 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB4302C@SHSMSX101.ccr.corp.intel.com> References: <20191015194602.9570-1-xiaoxiaox.zeng@intel.com> In-Reply-To: <20191015194602.9570-1-xiaoxiaox.zeng@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjlmMTc1MWYtOWNiNS00ODFlLWFiOGQtZTcyMmZiOTgxZmM5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiXC9ORXp0eTM3ZjJlRUVwenNmcEpISkJScHFGZlhLUGZLOWtKdk52dk5cL2lsTE9sajMwenJwek5ETEtLVW93VThVIn0= 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 V3] tests/sriov_kvm:complete and refactor TestSuite_sriov_kvm 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiaoxiao Zeng > Sent: Wednesday, October 16, 2019 3:46 AM > To: dts@dpdk.org > Cc: Zeng, XiaoxiaoX > Subject: [dts] [PATCH V3] tests/sriov_kvm:complete and refactor > TestSuite_sriov_kvm >=20 > *.complete cases according to sriov_kvm_test_plan. > *.expand setup_two_vm_common_prerequisite() to suit different fwd mode. > *.use self.port_id_0 instead port_id_0 in every case. > *.change reset env method in tear_down(). > *.remove useless function and parameter >=20 > Signed-off-by: Xiaoxiao Zeng > --- > tests/TestSuite_sriov_kvm.py | 544 +++++++++++++++-------------------- > 1 file changed, 226 insertions(+), 318 deletions(-) >=20 > diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py > index 6a28129..51fdf68 100644 > --- a/tests/TestSuite_sriov_kvm.py > +++ b/tests/TestSuite_sriov_kvm.py > @@ -11,6 +11,7 @@ Test userland 10Gb PMD. > import re > import pdb > import time > +import random >=20 > from virt_common import VM > from test_case import TestCase > @@ -23,7 +24,6 @@ VM_CORES_MASK =3D 'all' >=20 >=20 > class TestSriovKvm(TestCase): > - > supported_vf_driver =3D ['pci-stub', 'vfio-pci'] >=20 > def set_up_all(self): > @@ -39,8 +39,6 @@ class TestSriovKvm(TestCase): >=20 > self.vm0 =3D None > self.vm1 =3D None > - self.vm2 =3D None > - self.vm3 =3D None >=20 > self.vf_driver =3D self.get_suite_cfg()['vf_driver'] > if self.vf_driver is None: > @@ -51,11 +49,8 @@ class TestSriovKvm(TestCase): > else: > self.vf_assign_method =3D 'vfio-pci' > self.dut.send_expect('modprobe vfio-pci', '#') > - self.setup_2vm_2pf_env_flag =3D 0 > self.setup_2vm_2vf_env_flag =3D 0 > self.setup_2vm_prerequisite_flag =3D 0 > - self.setup_4vm_4vf_env_flag =3D 0 > - self.setup_4vm_prerequisite_flag =3D 0 > self.setup_2vm_2vf_env() >=20 > def set_up(self): > @@ -114,7 +109,8 @@ class TestSriovKvm(TestCase): > try: > dut_dest_port =3D dut_ports[dest_port] > except Exception as e: > - print e > + print > + e >=20 > # using api get_local_port() to get the correct tester port. > tester_port =3D self.tester.get_local_port(dut_dest_port) > @@ -258,16 +254,15 @@ class TestSriovKvm(TestCase): > 'srcport=3D%d' % ret_ether_ip['udp']['src_port']) > if not ret_ether_ip.get('vlan'): > send_cmd =3D 'sendp([Ether(dst=3Dnutmac, src=3Dsrcmac)/'= + \ > - 'IP(dst=3Ddestip, src=3Dsrcip, len=3D%s)/' % pktlen = + \ > - 'UDP(sport=3Dsrcport, dport=3Ddestport)/' + \ > - 'Raw(load=3D"\x50"*%s)], ' % padding + \ > - 'iface=3D"%s", count=3D%d)' % (itf, count) > + 'IP(dst=3Ddestip, src=3Dsrcip, len=3D%s)/' % = pktlen + \ > + 'UDP(sport=3Dsrcport, dport=3Ddestport)/' + \ > + 'Raw(load=3D"\x50"*%s)], ' % padding + \ > + 'iface=3D"%s", count=3D%d)' % (itf, count) > else: > send_cmd =3D 'sendp([Ether(dst=3Dnutmac, > src=3Dsrcmac)/Dot1Q(vlan=3Dvlanvalue)/' + \ > 'IP(dst=3Ddestip, src=3Dsrcip, len=3D%s)/' % = pktlen + \ > 'UDP(sport=3Dsrcport, dport=3Ddestport)/' + \ > - 'Raw(load=3D"\x50"*%s)], iface=3D"%s", count= =3D%d)' % ( > - padding, itf, count) > + 'Raw(load=3D"\x50"*%s)], iface=3D"%s", > + count=3D%d)' % (padding, itf, count) > self.tester.scapy_append(send_cmd) >=20 > self.tester.scapy_execute() @@ -293,46 +288,6 @@ class > TestSriovKvm(TestCase): > "Data received by port, but should not.") > return count * loop >=20 > - def setup_2vm_2pf_env(self): > - p0 =3D self.dut_ports[0] > - p1 =3D self.dut_ports[1] > - > - self.port0 =3D self.dut.ports_info[p0]['port'] > - self.port0.unbind_driver() > - self.port0_pci =3D self.dut.ports_info[p0]['pci'] > - > - self.port1 =3D self.dut.ports_info[p1]['port'] > - self.port1.unbind_driver() > - self.port1_pci =3D self.dut.ports_info[p1]['pci'] > - > - vf0_prop =3D {'opt_host': self.port0_pci} > - vf1_prop =3D {'opt_host': self.port1_pci} > - > - # set up VM0 ENV > - self.vm0 =3D VM(self.dut, 'vm0', 'sriov_kvm') > - self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0_pro= p) > - self.vm_dut_0 =3D self.vm0.start() > - > - # set up VM1 ENV > - self.vm1 =3D VM(self.dut, 'vm1', 'sriov_kvm') > - self.vm1.set_vm_device(driver=3Dself.vf_assign_method, **vf1_pro= p) > - self.vm_dut_1 =3D self.vm1.start() > - > - self.setup_2vm_2vf_env_flag =3D 1 > - > - def destroy_2vm_2pf_env(self): > - self.vm0.stop() > - self.port0.bind_driver('igb_uio') > - self.vm0 =3D None > - > - self.vm1.stop() > - self.port1.bind_driver('igb_uio') > - self.vm1 =3D None > - > - self.dut.virt_exit() > - > - self.setup_2vm_2vf_env_flag =3D 0 > - > def setup_2vm_2vf_env(self, driver=3D'igb_uio'): > self.used_dut_port =3D self.dut_ports[0] >=20 > @@ -359,8 +314,10 @@ class TestSriovKvm(TestCase): > if driver =3D=3D 'igb_uio': > # start testpmd with 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].pci, > + 'vf1': > + self.sriov_vfs_port[1].pci} > self.host_testpmd.start_testpmd( > - "1S/2C/2T", "--rxq=3D4 --txq=3D4") > + "1S/2C/2T", "--rxq=3D4 --txq=3D4", eal_param=3Deal_p= aram) > self.host_testpmd.execute_cmd('set fwd rxonly') > self.host_testpmd.execute_cmd('start') >=20 > @@ -410,101 +367,6 @@ class TestSriovKvm(TestCase): >=20 > self.setup_2vm_2vf_env_flag =3D 0 >=20 > - def setup_4vm_4vf_env(self, driver=3D'igb_uio'): > - self.used_dut_port =3D self.dut_ports[0] > - > - self.dut.generate_sriov_vfs_by_port( > - self.used_dut_port, 4, driver=3Ddriver) > - self.sriov_vfs_port =3D self.dut.ports_info[self.used_dut_port][= 'port'] > - > - try: > - for port in self.sriov_vfs_port: > - port.bind_driver('pci-stub') > - > - time.sleep(1) > - > - vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} > - vf1_prop =3D {'opt_host': self.sriov_vfs_port[1].pci} > - vf2_prop =3D {'opt_host': self.sriov_vfs_port[2].pci} > - vf3_prop =3D {'opt_host': self.sriov_vfs_port[3].pci} > - > - for port_id in self.dut_ports: > - if port_id =3D=3D self.used_dut_port: > - continue > - port =3D self.dut.ports_info[port_id]['port'] > - port.bind_driver() > - > - if driver =3D=3D 'igb_uio': > - # start testpmd with the four VFs on the host > - self.host_testpmd =3D PmdOutput(self.dut) > - self.host_testpmd.start_testpmd( > - "1S/2C/2T") > - > - self.vm0 =3D VM(self.dut, 'vm0', 'sriov_kvm') > - self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0= _prop) > - self.vm_dut_0 =3D self.vm0.start() > - if self.vm_dut_0 is None: > - raise Exception("Set up VM0 ENV failed!") > - > - self.vm1 =3D VM(self.dut, 'vm1', 'sriov_kvm') > - self.vm1.set_vm_device(driver=3Dself.vf_assign_method, **vf1= _prop) > - self.vm_dut_1 =3D self.vm1.start() > - if self.vm_dut_1 is None: > - raise Exception("Set up VM1 ENV failed!") > - > - self.vm2 =3D VM(self.dut, 'vm2', 'sriov_kvm') > - self.vm2.set_vm_device(driver=3Dself.vf_assign_method, **vf2= _prop) > - self.vm_dut_2 =3D self.vm2.start() > - if self.vm_dut_2 is None: > - raise Exception("Set up VM2 ENV failed!") > - > - self.vm3 =3D VM(self.dut, 'vm3', 'sriov_kvm') > - self.vm3.set_vm_device(driver=3Dself.vf_assign_method, **vf3= _prop) > - self.vm_dut_3 =3D self.vm3.start() > - if self.vm_dut_3 is None: > - raise Exception("Set up VM3 ENV failed!") > - > - self.setup_4vm_4vf_env_flag =3D 1 > - except Exception as e: > - self.destroy_4vm_4vf_env() > - raise Exception(e) > - > - def destroy_4vm_4vf_env(self): > - if getattr(self, 'vm0', None): > - self.vm0.stop() > - self.vm0 =3D None > - > - if getattr(self, 'vm1', None): > - self.vm1.stop() > - self.vm1 =3D None > - > - if getattr(self, 'vm2', None): > - self.vm2.stop() > - self.vm2 =3D None > - > - if getattr(self, 'vm3', None): > - self.vm3.stop() > - self.vm3 =3D None > - > - if getattr(self, 'host_testpmd', None): > - self.host_testpmd.execute_cmd('stop') > - self.host_testpmd.execute_cmd('quit', '# ') > - self.host_testpmd =3D None > - > - self.dut.virt_exit() > - > - if getattr(self, 'used_dut_port', None) !=3D None: > - self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > - port =3D self.ports_info[self.used_dut_port]['port'] > - port.bind_driver('igb_uio') > - self.used_dut_port =3D None > - > - for port_id in self.dut_ports: > - port =3D self.dut.ports_info[port_id]['port'] > - port.bind_driver('igb_uio') > - > - self.setup_4vm_4vf_env_flag =3D 0 > - > def transform_integer(self, value): > try: > value =3D int(value) > @@ -557,7 +419,7 @@ class TestSriovKvm(TestCase): > rule_id =3D self.make_port_new_ruleid(port) >=20 > mirror_rule_cmd =3D "set port %d mirror-rule %d %s %s" % \ > - (port, rule_id, mirror_name, rule_detail) > + (port, rule_id, mirror_name, rule_detail) > out =3D self.dut.send_expect("%s" % mirror_rule_cmd, "testpmd> "= ) > self.verify('Bad arguments' not in out, "Set port %d %s failed!"= % > (port, mirror_name)) @@ -615,23 +477,27 @@ class > TestSriovKvm(TestCase): > for rule_id in self.port_mirror_ref[port][:]: > self.reset_port_mirror_rule(port, rule_id) >=20 > - def setup_two_vm_common_prerequisite(self): > - 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 rxonly') > + def setup_two_vm_common_prerequisite(self, fwd0=3D"rxonly", > fwd1=3D"mac"): > + > + if self.setup_2vm_prerequisite_flag =3D=3D 1: > + self.vm0_testpmd.execute_cmd('stop') > + self.vm1_testpmd.execute_cmd('stop') > + else: > + 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.vm1_dut_ports =3D self.vm_dut_1.get_ports('any') > + self.vm1_testpmd =3D PmdOutput(self.vm_dut_1) > + self.vm1_testpmd.start_testpmd(VM_CORES_MASK) > + self.setup_2vm_prerequisite_flag =3D 1 > + > + self.vm0_testpmd.execute_cmd('set fwd %s' % fwd0) > self.vm0_testpmd.execute_cmd('set promisc all off') > self.vm0_testpmd.execute_cmd('start') > - > - self.vm1_dut_ports =3D self.vm_dut_1.get_ports('any') > - self.vm1_testpmd =3D PmdOutput(self.vm_dut_1) > - self.vm1_testpmd.start_testpmd(VM_CORES_MASK) > - self.vm1_testpmd.execute_cmd('set fwd mac') > + self.vm1_testpmd.execute_cmd('set fwd %s' % fwd1) > self.vm1_testpmd.execute_cmd('set promisc all off') > self.vm1_testpmd.execute_cmd('start') >=20 > - self.setup_2vm_prerequisite_flag =3D 1 > - > def destroy_two_vm_common_prerequisite(self): > self.vm0_testpmd =3D None > self.vm0_dut_ports =3D None > @@ -643,21 +509,6 @@ class TestSriovKvm(TestCase): >=20 > self.setup_2vm_prerequisite_flag =3D 0 >=20 > - def stop_test_setup_two_vm_pf_env(self): > - self.setup_2vm_2pf_env() > - > - out =3D self.vm_dut_0.send_expect("ifconfig", '# ') > - print out > - out =3D self.vm_dut_0.send_expect("lspci -nn | grep -i eth", '# = ') > - print out > - > - out =3D self.vm_dut_1.send_expect("ifconfig", '# ') > - print out > - out =3D self.vm_dut_1.send_expect("lspci -nn | grep -i eth", '# = ') > - print out > - > - self.destroy_2vm_2pf_env() > - > def test_two_vms_intervm_communication(self): > if self.setup_2vm_prerequisite_flag =3D=3D 1: > self.vm0_testpmd.execute_cmd('quit', '# ') @@ -706,78 +557,1= 44 @@ > class TestSriovKvm(TestCase): > ret_stats[key] =3D end_stats[key] - start_stats[key] > return ret_stats >=20 > - def test_two_vms_pool_mirror(self): > + def test_two_vms_pool_up_mirrors(self): > + """ > + Test Case2: Mirror Traffic between 2VMs with Pool up mirroring > + """ > port_id_0 =3D 0 > packet_num =3D 10 >=20 > + # set Pool up mirror rule > rule_id =3D self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1= on') > + > + # get vm1 port stats > vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send 10 packets > self.send_packet( > self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=3Dpacket= _num) > + > + # get vm1 port stats > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # verify vm1 receive packets > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and > vm1_ret_stats['TX-packets'] =3D=3D packet_num, > + "Pool up mirror failed between VM0 and VM1!") >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and > - vm1_ret_stats['TX-packets'] =3D=3D packet_num, > - "Pool mirror failed between VM0 and VM1!") > + def test_two_vms_pool_down_mirrors(self): > + """ > + Test Case3: Mirror Traffic between 2VMs with Pool down mirroring > + """ > + port_id_0 =3D 0 > + mirror_name =3D "pool-mirror-down" > + packet_num =3D 32 > + > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", > + fwd1=3D"rxonly") >=20 > - self.reset_port_mirror_rule(port_id_0, rule_id) > + # set Pool down mirror rule > + rule_id =3D self.set_port_mirror_rule(port_id_0, mirror_name, > + '0x1 dst-pool 1 on') > + > + # get vm port stats > + vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send packets > + self.vm0_testpmd.execute_cmd('stop') > + self.vm0_testpmd.execute_cmd('start tx_first') > + > + # get vm port stats > + vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > + vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # verify vm1 receive packets > + vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, > + vm1_end_stats) > + > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX= -packets'] > and vm1_ret_stats['RX-packets'] =3D=3D packet_num, > + "Pool down mirror failed between VM0 and VM1!") >=20 > def test_two_vms_uplink_mirror(self): > + """ > + Test Case4: Mirror Traffic between 2VMs with Uplink mirroring > + """ > port_id_0 =3D 0 > packet_num =3D 10 >=20 > + # set uplink mirror rule > rule_id =3D self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 o= n') > + > + # get vm1 port stats > vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send packets > self.send_packet( > self.vm_dut_0, self.vm0_dut_ports, port_id_0, count=3Dpacket= _num) > + > + # get vm1 port stats > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # verify vm1 receive packets > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and > - vm1_ret_stats['TX-packets'] =3D=3D packet_num, > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and > + vm1_ret_stats['TX-packets'] =3D=3D packet_num, > "Uplink mirror failed between VM0 and VM1!") >=20 > - self.reset_port_mirror_rule(port_id_0, rule_id) > - > def test_two_vms_downlink_mirror(self): > - self.vm0_testpmd.execute_cmd('stop') > - self.vm1_testpmd.execute_cmd('stop') > - > + """ > + Test Case5: Mirror Traffic between 2VMs with Downlink mirroring > + """ > port_id_0 =3D 0 > + packet_num =3D 32 >=20 > + # set downlink mirror rule > rule_id =3D self.set_port_downlink_mirror(port_id_0, 'dst-pool 1= on') >=20 > - self.vm1_testpmd.execute_cmd('set fwd rxonly') > - self.vm1_testpmd.execute_cmd('start') > - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", > + fwd1=3D"rxonly") > + > + # get vms port stats > vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send packets > + self.vm0_testpmd.execute_cmd('stop') > self.vm0_testpmd.execute_cmd('start tx_first') > + > + # get vms port stats > vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # verify vm1 receive packets > vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX- > packets'], vm0_ret_stats['TX-packets']), > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D > + vm0_ret_stats['TX-packets'] and vm1_ret_stats['RX-packets'] =3D=3D > + packet_num, > "Downlink mirror failed between VM0 and VM1!") >=20 > - self.reset_port_mirror_rule(port_id_0, rule_id) > - > def test_two_vms_vlan_mirror(self): > - self.vm1_testpmd.execute_cmd('vlan set strip on 0') > + """ > + Test Case6: Mirror Traffic between 2VMs with Vlan mirroring > + """ > port_id_0 =3D 0 > - vlan_id =3D 0 > + vlan_id =3D random.randint(1, 4095) > vf_mask =3D '0x1' > packet_num =3D 10 >=20 > - self.host_testpmd.execute_cmd( > - 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mas= k)) > - rule_id =3D self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 o= n') > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", > + fwd1=3D"rxonly") > + > + # add rx vlan on VF0 > + self.host_testpmd.execute_cmd('rx_vlan add %d port %d vf %s' % > + (vlan_id, port_id_0, vf_mask)) > + > + # set vlan mirror rule > + rule_id =3D self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1 > + on' % vlan_id) >=20 > + # get vm port stats > vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send packets > ether_ip =3D {} > ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} > self.send_packet( > @@ -786,16 +703,17 @@ class TestSriovKvm(TestCase): > port_id_0, > count=3Dpacket_num, > **ether_ip) > + > + # get vm port stats > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # reset pf vlan > + self.host_testpmd.execute_cmd('rx_vlan rm %d port %d vf %s' % > + (vlan_id, port_id_0, vf_mask)) > + > + # verify vm1 receive packets > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num and > - vm1_ret_stats['TX-packets'] =3D=3D packet_num, > - "Vlan mirror failed between VM0 and VM1!") > - self.host_testpmd.execute_cmd( > - 'rx_vlan rm %d port %d vf %s' % (vlan_id, port_id_0, vf_mask= )) > - self.reset_port_mirror_rule(port_id_0, rule_id) > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num * 2, > + "Vlan mirror failed between VM0 and VM1!") >=20 > def test_two_vms_vlan_and_pool_mirror(self): > self.vm0_testpmd.execute_cmd('vlan set strip on 0') @@ -832,7 +7= 50,7 > @@ class TestSriovKvm(TestCase): > self.vm1_dut_ports, > port_id_0, > count=3D10 * > - packet_num, > + packet_num, > **ether_ip) > vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) >=20 > @@ -845,133 +763,131 @@ class TestSriovKvm(TestCase): > self.reset_port_all_mirror_rule(port_id_0) >=20 > def test_two_vms_uplink_and_downlink_mirror(self): > - self.vm0_testpmd.execute_cmd('stop') > - self.vm1_testpmd.execute_cmd('stop') > - > + """ > + Test Case7: Mirror Traffic between 2VMs with up link mirroring &= down > link mirroring > + """ > port_id_0 =3D 0 > packet_num =3D 10 >=20 > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", > + fwd1=3D"rxonly") > + > + # set mirror rule > self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') > self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') >=20 > - self.vm1_testpmd.execute_cmd('set fwd rxonly') > - self.vm1_testpmd.execute_cmd('start') > + # get vm1 port stats > vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > - vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > - self.vm0_testpmd.execute_cmd('start tx_first') > - vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > - vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > - > - vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX= -packets'], > - "Downlink mirror failed between VM0 and VM1 " + > - "when set uplink and downlink mirror!") > + # send packets > + self.send_packet(self.vm_dut_0, self.vm0_dut_ports, port_id_0, > + count=3Dpacket_num) >=20 > - self.vm0_testpmd.execute_cmd('stop') > - self.vm0_testpmd.execute_cmd('set fwd mac') > - self.vm0_testpmd.execute_cmd('start') > - > - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > - self.send_packet( > - self.vm_dut_0, > - self.vm0_dut_ports, > - port_id_0, > - count=3Dpacket_num) > + # get vm1 port stats > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # verify vm1 receive packets > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > - > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, > - "Uplink and down link mirror failed between VM0 and = VM1 " + > - "when set uplink and downlink mirror!") > - > - self.reset_port_all_mirror_rule(port_id_0) > + try: > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D packet_num * = 2, "failed") > + except: > + self.reset_port_all_mirror_rule(port_id_0) > + raise ("Set uplink and downlink mirror failed!") >=20 > def test_two_vms_vlan_and_pool_and_uplink_and_downlink(self): > - self.vm0_testpmd.execute_cmd('vlan set strip on 0') > - self.vm1_testpmd.execute_cmd('vlan set strip on 0') > - self.vm0_testpmd.execute_cmd('stop') > - self.vm1_testpmd.execute_cmd('stop') > - > + """ > + Test Case8: Mirror Traffic between 2VMs with Vlan & with up link > mirroring & down link mirroring > + """ > port_id_0 =3D 0 > - vlan_id =3D 3 > + vlan_id =3D random.randint(1, 4095) > vf_mask =3D '0x2' > packet_num =3D 1 >=20 > - self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') > - self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') > - self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" % > - (vlan_id, port_id_0, vf_mask)) > - self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % vlan_i= d) > + # set up common 2VM prerequisites > + self.setup_two_vm_common_prerequisite(fwd0=3D"mac", > + fwd1=3D"rxonly") > + > + # set mirror rule > self.set_port_pool_mirror(port_id_0, '0x1 dst-pool 1 on') > + self.set_port_downlink_mirror(port_id_0, 'dst-pool 1 on') >=20 > - self.vm1_testpmd.execute_cmd('set fwd rxonly') > - self.vm1_testpmd.execute_cmd('start') > - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > - vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > - self.vm0_testpmd.execute_cmd('start tx_first') > - vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > - vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + if self.nic.startswith('niantic'): > + self.set_port_uplink_mirror(port_id_0, 'dst-pool 1 on') >=20 > - vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > - vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > + # get vm port stats > + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0= ) > + vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0= ) >=20 > - self.verify(vm1_ret_stats['RX-packets'] =3D=3D vm0_ret_stats['TX= -packets'], > - "Downlink mirror failed between VM0 and VM1 " + > - "when set vlan, pool, uplink and downlink mirror!") > + # send packets > + self.vm0_testpmd.execute_cmd('stop') > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('start tx_first') >=20 > - self.vm0_testpmd.execute_cmd('stop') > - self.vm0_testpmd.execute_cmd('set fwd mac') > - self.vm0_testpmd.execute_cmd('start') > + # get vm port stats > + vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > + vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # verify vm1 receive packets > + vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_= end_stats) > + vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, > + vm1_end_stats) > + > + self.verify(vm1_ret_stats['RX-packets'] =3D=3D > + vm0_ret_stats['TX-packets'], "uplink &downlink mirror failed between > + VM0 and VM1") > + > + # set vlan mirror rule > + self.host_testpmd.execute_cmd("rx_vlan add %d port %d vf %s" % > (vlan_id, port_id_0, vf_mask)) > + self.set_port_vlan_mirror(port_id_0, '%d dst-pool 0 on' % > + vlan_id) > + > + # get vm port stats > vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + > + # send packets > + ether_ip =3D {} > + ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} > self.send_packet( > - self.vm_dut_0, > - self.vm0_dut_ports, > + self.vm_dut_1, > + self.vm1_dut_ports, > port_id_0, > - count=3Dpacket_num) > + count=3Dpacket_num, > + **ether_ip) > + # get vm port stats > vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # verify vm1 receive packets > vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) >=20 > - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX- > packets'], packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pa= ckets'], > packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm1_ret_stats['RX-pa= ckets'], 2 > * packet_num), > - "Uplink and downlink mirror failed between VM0 and V= M1 " + > - "when set vlan, pool, uplink and downlink mirror!") > - > - self.vm0_testpmd.execute_cmd('stop') > - self.vm0_testpmd.execute_cmd('set fwd mac') > - self.vm0_testpmd.execute_cmd('start') > + try: > + if self.nic.startswith('niantic'): > + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_nu= m and > vm1_ret_stats['RX-packets'] =3D=3D packet_num, > + "vlan mirror failed between VM0 and VM1") > + else: > + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_nu= m and > vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, > + "vlan&downlink mirror failed between VM0 and= VM1") > + except: > + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" = % > (vlan_id, port_id_0, vf_mask)) > + raise ("vlan mirror or downlink mirror failed between VM0 > + and VM1") >=20 > - ether_ip =3D {} > - ether_ip['vlan'] =3D {'vlan': '%d' % vlan_id} > - vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + # get vm port stats > vm0_start_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > + vm1_start_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) > + # send packets > self.send_packet( > - self.vm_dut_1, > - self.vm1_dut_ports, > + self.vm_dut_0, > + self.vm0_dut_ports, > port_id_0, > - count=3Dpacket_num, > - **ether_ip) > + count=3Dpacket_num) > + # get vm port stats > vm0_end_stats =3D self.vm0_testpmd.get_pmd_stats(port_id_0) > vm1_end_stats =3D self.vm1_testpmd.get_pmd_stats(port_id_0) >=20 > + # reset pf vlan > + self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" % > + (vlan_id, port_id_0, vf_mask)) > + > + # verify vm1 receive packets > vm0_ret_stats =3D self.calculate_stats(vm0_start_stats, vm0_end_= stats) > vm1_ret_stats =3D self.calculate_stats(vm1_start_stats, vm1_end_= stats) > - > - self.verify(self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['RX- > packets'], packet_num) and > - self.vm0_testpmd.check_tx_bytes(vm0_ret_stats['TX-pa= ckets'], > packet_num) and > - vm1_ret_stats['RX-packets'] =3D=3D 2 * packet_num, > - "Vlan and downlink mirror failed between VM0 and VM1= " + > - "when set vlan, pool, uplink and downlink mirror!") > - self.host_testpmd.execute_cmd("rx_vlan rm %d port %d vf %s" % > - (vlan_id, port_id_0, vf_mask)) > - self.reset_port_all_mirror_rule(port_id_0) > + self.verify(vm0_ret_stats['RX-packets'] =3D=3D packet_num and > vm0_ret_stats['TX-packets'] =3D=3D packet_num and > + vm1_ret_stats['RX-packets'] =3D=3D packet_num, "upli= nk > + mirror failed between VM0 and VM1") >=20 > def test_two_vms_add_multi_exact_mac_on_vf(self): > port_id_0 =3D 0 > @@ -1004,9 +920,9 @@ class TestSriovKvm(TestCase): > "when add multi exact MAC address on VF!") >=20 > def test_two_vms_enalbe_or_disable_one_uta_mac_on_vf(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > port_id_0 =3D 0 > @@ -1052,9 +968,9 @@ class TestSriovKvm(TestCase): > "when enable or disable one uta MAC address on VF!") >=20 > def test_two_vms_add_multi_uta_mac_on_vf(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > port_id_0 =3D 0 > @@ -1082,9 +998,9 @@ class TestSriovKvm(TestCase): > "when add multi uta MAC address on VF!") >=20 > def test_two_vms_add_or_remove_uta_mac_on_vf(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > port_id_0 =3D 0 > @@ -1119,9 +1035,9 @@ class TestSriovKvm(TestCase): > "when add or remove multi uta MAC address on= VF!") >=20 > def test_two_vms_pause_rx_queues(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > port_id_0 =3D 0 > @@ -1153,9 +1069,9 @@ class TestSriovKvm(TestCase): > "when enable or pause RX queues on VF!") >=20 > def test_two_vms_pause_tx_queuse(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > self.vm0_testpmd.execute_cmd("stop") > @@ -1190,9 +1106,9 @@ class TestSriovKvm(TestCase): > "when enable or pause TX queues on VF!") >=20 > def test_two_vms_prevent_rx_broadcast_on_vf(self): > - self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is [%s], skip this > case" %self.nic) > + self.verify(self.nic.startswith('fortville') =3D=3D False, "NIC = is > + [%s], skip this case" % self.nic) > if self.nic.startswith('fortville'): > - self.dut.logger.warning("NIC is [%s], skip this case" %self.= nic) > + self.dut.logger.warning("NIC is [%s], skip this case" % > + self.nic) > return >=20 > port_id_0 =3D 0 > @@ -1254,8 +1170,12 @@ class TestSriovKvm(TestCase): > error, "Execute command '%s' successfully, it should be = failed!" % > command) >=20 > def tear_down(self): > - self.vm0_testpmd.execute_cmd('quit', '# ') > - self.vm1_testpmd.execute_cmd('quit', '# ') > + port_id_0 =3D 0 > + self.reset_port_all_mirror_rule(port_id_0) > + self.vm0_testpmd.execute_cmd('clear port stats all') > + self.vm1_testpmd.execute_cmd('clear port stats all') > + self.vm0_testpmd.execute_cmd('stop') > + self.vm1_testpmd.execute_cmd('stop') > time.sleep(1) >=20 > def tear_down_all(self): > @@ -1263,22 +1183,10 @@ class TestSriovKvm(TestCase): > self.destroy_two_vm_common_prerequisite() > if self.setup_2vm_2vf_env_flag =3D=3D 1: > self.destroy_2vm_2vf_env() > - > - if self.setup_2vm_2pf_env_flag =3D=3D 1: > - self.destroy_2vm_2pf_env() > - > - if self.setup_4vm_prerequisite_flag =3D=3D 1: > - self.destroy_four_vm_common_prerequisite() > - if self.setup_4vm_4vf_env_flag =3D=3D 1: > - self.destroy_4vm_4vf_env() > if getattr(self, 'vm0', None): > self.vm0.stop() > if getattr(self, 'vm1', None): > self.vm1.stop() > - if getattr(self, 'vm2', None): > - self.vm2.stop() > - if getattr(self, 'vm3', None): > - self.vm3.stop() >=20 > self.dut.virt_exit() >=20 > -- > 2.17.0