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 9305BA04C1; Mon, 25 Nov 2019 02:15:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6EA242952; Mon, 25 Nov 2019 02:15:20 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 20289CF3 for ; Mon, 25 Nov 2019 02:15:17 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2019 17:15:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,239,1571727600"; d="scan'208";a="210944987" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga006.jf.intel.com with ESMTP; 24 Nov 2019 17:15:16 -0800 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 24 Nov 2019 17:15:14 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 24 Nov 2019 17:15:14 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.108]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.215]) with mapi id 14.03.0439.000; Mon, 25 Nov 2019 09:15:12 +0800 From: "Zhang, Yuwei1" To: "Zeng, XiaoxiaoX" , "Xie, WeiX" , "dts@dpdk.org" CC: "Xie, WeiX" Thread-Topic: [dts] [PATCH V2] tests/port_representor:new automation of port_representor Thread-Index: AQHVnbzKr10FS5lc0EO+XUR5IImjT6ebH/cw Date: Mon, 25 Nov 2019 01:15:11 +0000 Message-ID: References: <1574045622-140995-1-git-send-email-weix.xie@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 V2] tests/port_representor:new automation of port_representor 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" Acked-by: Yuwei Zhang -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Zeng, XiaoxiaoX Sent: Monday, November 18, 2019 11:03 AM To: Xie, WeiX ; dts@dpdk.org Cc: Xie, WeiX Subject: Re: [dts] [PATCH V2] tests/port_representor:new automation of port= _representor Tested-by: Zeng,XiaoxiaoX< xiaoxiaox.zeng@intel.com> -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xie Wei Sent: Monday, November 18, 2019 10:54 AM To: dts@dpdk.org Cc: Xie, WeiX Subject: [dts] [PATCH V2] tests/port_representor:new automation of port_rep= resentor new automation of port_representor Signed-off-by: Xie Wei --- tests/TestSuite_port_representor.py | 270 ++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 tests/TestSuite_port_representor.py diff --git a/tests/TestSuite_port_representor.py b/tests/TestSuite_port_rep= resentor.py new file mode 100644 index 0000000..04f7838 --- /dev/null +++ b/tests/TestSuite_port_representor.py @@ -0,0 +1,270 @@ +# BSD LICENSE +# +# Copyright(c) <2019> Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +Use two representor ports as the control plane to manage the two VFs,=20 +the control plane could change VFs behavior such as change promiscous=20 +mode, stats reset, etc. our statistical data information is independent=20 +on the control plane and data plane. +""" + +import time +import re + +from test_case import TestCase +from dut import Dut +from packet import Packet +from pmd_output import PmdOutput + + +class TestPortRepresentor(TestCase): + def set_up_all(self): + """ + Prerequisite steps for each test suite. + """ + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single", "fortville_25g= "], "NIC Unsupported: " + str(self.nic)) + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + + self.session_secondary =3D self.dut.new_session() + self.session_third =3D self.dut.new_session() + self.pmdout_pf =3D PmdOutput(self.dut) + self.pmdout_vf0 =3D PmdOutput(self.dut, self.session_secondary) + self.pmdout_vf1 =3D PmdOutput(self.dut, self.session_third) + + localPort =3D self.tester.get_local_port(self.dut_ports[0]) + self.tester_itf =3D self.tester.get_interface(localPort) + self.tester_mac =3D self.tester.get_mac(localPort) + self.pf_mac =3D self.dut.get_mac_address(0) + self.pf_pci =3D self.dut.ports_info[self.dut_ports[0]]['pci'] + + self.unicast_mac =3D "00:11:22:33:44:55" + + # This is to set up 1pf and 2vfs environment + # PF is bound to igb_uio, while VF is bound to vfio-pci. + self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 2, "igb_uio= ") + self.two_vfs_port =3D self.dut.ports_info[self.dut_ports[0]]["vfs_= port"] + self.dut.send_expect("modprobe vfio-pci", "#", 3) + try: + for port in self.two_vfs_port: + port.bind_driver(driver=3D"vfio-pci") + except Exception as e: + self.destroy_env() + raise Exception(e) + self.vfs_pci =3D + self.dut.ports_info[self.dut_ports[0]]['sriov_vfs_pci'] + + def set_up(self): + """ + Run before each test case. + """ + self.vf_flag =3D 1 + + def destroy_env(self): + """ + This is to stop testpmd and destroy 1pf and 2vfs environment. + """ + if self.vf_flag =3D=3D 1: + self.pmdout_vf1.execute_cmd("quit", "#") + time.sleep(3) + self.pmdout_vf0.execute_cmd("quit", "#") + time.sleep(3) + self.pmdout_pf.execute_cmd("quit", "#") + time.sleep(3) + else: + self.pmdout_pf.execute_cmd("quit", "#") + self.vf_flag =3D 0 + + def testpmd_pf(self): + self.pmdout_pf.start_testpmd("Default", eal_param=3D"-w=20 + %s,representor=3D0-1" % self.pf_pci, param=3D"--port-topology=3Dchained") + + def testpmd_vf0(self): + self.out_vf0 =3D self.pmdout_vf0.start_testpmd("Default", eal_para= m=3D"-w %s --file-prefix testpmd-vf0" % self.vfs_pci[0]) + self.vf0_mac =3D self.pmdout_vf0.get_port_mac(0) + + def testpmd_vf1(self): + self.out_vf1 =3D self.pmdout_vf1.start_testpmd("Default", eal_para= m=3D"-w %s --file-prefix testpmd-vf1" % self.vfs_pci[1]) + self.vf1_mac =3D self.pmdout_vf1.get_port_mac(0) + + def check_port_stats(self): + """ + show and check port stats + """ + out =3D self.pmdout_pf.execute_cmd("show port stats all", "testpmd= >") + self.logger.info(out) + result =3D re.compile('RX-packets:\s+(.*?)\s+?').findall(out, re.S= ) + return result + + def clear_port_stats(self): + """ + clear port stats in control testpmd + """ + self.pmdout_pf.execute_cmd("clear vf stats 0 0", "testpmd>", 2) + self.pmdout_pf.execute_cmd("clear vf stats 0 1", "testpmd>", 2) + self.pmdout_pf.execute_cmd("clear port stats all", "testpmd>", + 2) + + def test_port_representor_vf_stats_show_and_clear(self): + """ + use control testpmd to get and clear dataplane testpmd ports Stats + """ + self.testpmd_pf() + self.pmdout_pf.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_pf.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf0() + self.pmdout_vf0.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_vf0.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf1() + self.pmdout_vf1.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_vf1.execute_cmd("start", "testpmd>", 2) + # send 30 packets + pkt1 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.pf_mac) + pkt2 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf0_mac) + pkt3 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf1_mac) + pkts =3D [pkt1, pkt2, pkt3] + p =3D Packet() + for i in pkts: + p.append_pkt(i) + p.send_pkt(self.tester, tx_port=3Dself.tester_itf, count=3D10) + # check port stats in control testpmd + result_before =3D self.check_port_stats() + self.verify(int(result_before[1]) =3D=3D 10 and int(result_before[= 2]) =3D=3D 10, "VF Stats show error") + self.clear_port_stats() + result_after =3D self.check_port_stats() + self.verify(int(result_after[1]) =3D=3D 0 and int(result_after[2])= =20 + =3D=3D 0, "VF Stats clear error") + + def test_port_representor_vf_promiscous(self): + """ + use control testpmd to enable/disable dataplane testpmd ports prom= iscous mode + """ + self.testpmd_pf() + self.pmdout_pf.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_pf.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf0() + self.pmdout_vf0.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf1() + self.pmdout_vf1.execute_cmd("start", "testpmd>", 2) + + # set vf promisc enable and send 40 packets + self.pmdout_pf.execute_cmd("set promisc 1 on", "testpmd>") + pkt1 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.pf_mac) + pkt2 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf0_mac) + pkt3 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf1_mac) + pkt4 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.unicast_mac) + pkts =3D [pkt1, pkt2, pkt3, pkt4] + p =3D Packet() + for i in pkts: + p.append_pkt(i) + p.send_pkt(self.tester, tx_port=3Dself.tester_itf, count=3D10) + # check port stats in control testpmd + result_enable =3D self.check_port_stats() + self.verify(int(result_enable[1]) =3D=3D 20 and int(result_enable[= 2]) =3D=3D 20, "VFs receive packets error") + self.clear_port_stats() + # set vf promisc disable and send 40 packets + self.pmdout_pf.execute_cmd("set promisc 1 off", "testpmd>") + p =3D Packet() + for i in pkts: + p.append_pkt(i) + p.send_pkt(self.tester, tx_port=3Dself.tester_itf, count=3D10) + # check port stats in control testpmd + result_disable =3D self.check_port_stats() + self.verify(int(result_disable[1]) =3D=3D 10 and + int(result_disable[2]) =3D=3D 20, "VFs receive packets error") + + def test_port_representor_vf_mac_addr(self): + """ + use control testpmd to set vf mac address + """ + self.testpmd_pf() + self.pmdout_pf.execute_cmd("mac_addr set 1 aa:11:22:33:44:55", "te= stpmd>") + self.pmdout_pf.execute_cmd("mac_addr set 2 aa:22:33:44:55:66", "te= stpmd>") + self.pmdout_pf.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_pf.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf0() + self.pmdout_vf0.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_vf0.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf1() + self.pmdout_vf1.execute_cmd("set promisc 0 off", "testpmd>") + self.pmdout_vf1.execute_cmd("start", "testpmd>", 2) + # send 40 packets + pkt1 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.pf_mac) + pkt2 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf0_mac) + pkt3 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.vf1_mac) + pkt4 =3D 'Ether(src=3D"%s",dst=3D"%s")/IP()' % (self.tester_mac, s= elf.unicast_mac) + pkts =3D [pkt1, pkt2, pkt3, pkt4] + p =3D Packet() + for i in pkts: + p.append_pkt(i) + p.send_pkt(self.tester, tx_port=3Dself.tester_itf, count=3D10) + # check port stats in control testpmd + result =3D self.check_port_stats() + self.verify(int(result[1]) =3D=3D 10 and int(result[2]) =3D=3D 10,= "VFs=20 + receive packets error") + + def test_port_representor_vlan_filter(self): + """ + use control testpmd to set vlan + """ + self.testpmd_pf() + self.pmdout_pf.execute_cmd("set promisc 1 off", "testpmd>") + self.pmdout_pf.execute_cmd("vlan set filter on 1", "testpmd>") + self.pmdout_pf.execute_cmd("rx_vlan add 3 1", "testpmd>") + self.pmdout_pf.execute_cmd("set promisc 2 off", "testpmd>") + self.pmdout_pf.execute_cmd("vlan set filter on 2", "testpmd>") + self.pmdout_pf.execute_cmd("rx_vlan add 4 2", "testpmd>") + self.pmdout_pf.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf0() + self.pmdout_vf0.execute_cmd("start", "testpmd>", 2) + self.testpmd_vf1() + self.pmdout_vf1.execute_cmd("start", "testpmd>", 2) + # send 20 packets + pkt1 =3D 'Ether(src=3D"%s",dst=3D"%s")/Dot1Q(vlan=3D3)/IP()' % (se= lf.tester_mac, self.vf0_mac) + pkt2 =3D 'Ether(src=3D"%s",dst=3D"%s")/Dot1Q(vlan=3D4)/IP()' % (se= lf.tester_mac, self.vf1_mac) + pkts =3D [pkt1, pkt2] + p =3D Packet() + for i in pkts: + p.append_pkt(i) + p.send_pkt(self.tester, tx_port=3Dself.tester_itf, count=3D10) + # check port stats in control testpmd + result =3D self.check_port_stats() + self.verify(int(result[1]) =3D=3D 10 and int(result[2]) =3D=3D 10,= "VFs=20 + receive packets error") + + def tear_down(self): + """ + Run after each test case. + """ + self.destroy_env() + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() + self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0]) + self.dut.close_session(self.session_secondary) + self.dut.close_session(self.session_third) -- 2.17.2