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 97383A055E; Wed, 26 Feb 2020 02:53:53 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BD2E1BFB3; Wed, 26 Feb 2020 02:53:53 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A97021BC24 for ; Wed, 26 Feb 2020 02:53:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2020 17:53:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,486,1574150400"; d="scan'208";a="226555703" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 25 Feb 2020 17:53:50 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Feb 2020 17:53:49 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 25 Feb 2020 17:53:49 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 25 Feb 2020 17:53:49 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.196]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.222]) with mapi id 14.03.0439.000; Wed, 26 Feb 2020 09:53:47 +0800 From: "Fu, Qi" To: "Min, JiaqiX" , "dts@dpdk.org" CC: "Min, JiaqiX" Thread-Topic: [dts] [PATCH V2] tests/shutdown_api: update change linkspeed Thread-Index: AQHV68CwzrJEzHtm4E+806eJbnuXVKgst56g Date: Wed, 26 Feb 2020 01:53:47 +0000 Message-ID: <122BE83F39B639498C1565A7B0CDA2200352A569@SHSMSX103.ccr.corp.intel.com> References: <20200225093944.60115-1-jiaqix.min@intel.com> In-Reply-To: <20200225093944.60115-1-jiaqix.min@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDYwNWEwYjEtODc0MS00Y2ZjLWE4MDYtYjY1ZGQxNmM1MGYwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSU9FU2FQVU5tejhWS3E3N1JBczZhRXV5XC9JUVVhU0l1YkZMa21oQ1wvRWVSMWRiRWsrMlwveFp3TVF5bCtnY0hYRCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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/shutdown_api: update change linkspeed 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 Fu, Qi Best regards, Fu, Qi > -----Original Message----- > From: dts On Behalf Of Jiaqi Min > Sent: Tuesday, February 25, 2020 5:40 PM > To: dts@dpdk.org > Cc: Min, JiaqiX > Subject: [dts] [PATCH V2] tests/shutdown_api: update change linkspeed >=20 > update change linkspeed case > add change linkspeed vf case > add shutdown_api.cfg >=20 > Signed-off-by: Jiaqi Min > --- > conf/shutdown_api.cfg | 44 +++++++ > tests/TestSuite_shutdown_api.py | 206 ++++++++++++++++++++++++++++++-- > 2 files changed, 239 insertions(+), 11 deletions(-) create mode 100644 > conf/shutdown_api.cfg >=20 > diff --git a/conf/shutdown_api.cfg b/conf/shutdown_api.cfg new file mode > 100644 index 0000000..2787adb > --- /dev/null > +++ b/conf/shutdown_api.cfg > @@ -0,0 +1,44 @@ > +# Configuration: shutdown_api.cfg > +[vm0] > +cpu =3D > + model=3Dhost,number=3D4,cpupin=3D5 6 7 8; disk =3D > + > +file=3D/storage/vm-image/vm0.img,opt_format=3Dqcow2,opt_if=3Dvirtio,opt_= index > +=3D0,opt_media=3Ddisk; > +mem =3D > + size=3D10250; > +login =3D > + user=3Droot,password=3Dtester; > +# net option is not necessary for libvirt, comment out below 2 lines if > +using libvirt net =3D > + type=3Dnic,opt_vlan=3D0; > + type=3Duser,opt_vlan=3D0; > +qga =3D > + enable=3Dyes; > +# vnc option is not supported by libvirt yet, comment out below 2 lines > +if using libvirt vnc =3D > + displayNum=3D1; > +# daemon option is not supported by libvirt yet, comment out below 2 > +lines if using libvirt daemon =3D > + enable=3Dyes; > + > +[vm1] > +cpu =3D > + model=3Dhost,number=3D4,cpupin=3D14 15 16 17; disk =3D > + > +file=3D/storage/vm-image/vm0.img_copy.img,opt_format=3Dqcow2,opt_if=3Dvi= rtio, > +opt_index=3D0,opt_media=3Ddisk; > +mem =3D > + size=3D10250; > +login =3D > + user=3Droot,password=3Dtester; > +# net option is not necessary for libvirt, comment out below 2 lines if > +using libvirt net =3D > + type=3Dnic,opt_vlan=3D0; > + type=3Duser,opt_vlan=3D0; > +qga =3D > + enable=3Dyes; > +# vnc option is not supported by libvirt yet, comment out below 2 lines > +if using libvirt vnc =3D > + displayNum=3D2; > +# daemon option is not supported by libvirt yet, comment out below 2 > +lines if using libvirt daemon =3D > + enable=3Dyes; > diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_a= pi.py > index 03a7e86..11d451b 100644 > --- a/tests/TestSuite_shutdown_api.py > +++ b/tests/TestSuite_shutdown_api.py > @@ -44,6 +44,8 @@ from test_case import TestCase from pmd_output import > PmdOutput from settings import HEADER_SIZE, PROTOCOL_PACKET_SIZE from > exception import VerifyFailure > +from qemu_kvm import QEMUKvm > +from settings import get_nic_name >=20 > # > # > @@ -51,6 +53,7 @@ from exception import VerifyFailure # >=20 >=20 > +VM_CORES_MASK =3D 'all' > class TestShutdownApi(TestCase): >=20 > # > @@ -58,7 +61,7 @@ class TestShutdownApi(TestCase): > # > # Test cases. > # > - > + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] > def set_up_all(self): > """ > Run at the start of each test suite. > @@ -73,6 +76,7 @@ class TestShutdownApi(TestCase): > self.tester.get_interface(self.tester.get_local_port(por= t)), 5000), "# ") >=20 > self.pmdout =3D PmdOutput(self.dut) > + self.vm_env_done =3D False >=20 > def get_stats(self, portid): > """ > @@ -187,6 +191,130 @@ class TestShutdownApi(TestCase): > """ > pass >=20 > + def check_linkspeed_config(self, configs): > + ret_val =3D False > + if (configs =3D=3D None): > + self.verify(False, "Link speed config error.") > + ret_val =3D False > + elif (len(configs) < 1): > + self.verify(False, "Link speed config error.") > + ret_val =3D False > + elif len(configs) < 2: > + print("\nOnly one link speed, can't be changed.\n") > + ret_val =3D False > + else: > + ret_val =3D True > + > + return ret_val > + > + def check_vf_link_status(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port- > topology=3Dchained') > + for i in range(10): > + out =3D self.vm0_testpmd.execute_cmd('show port info 0') > + print(out) > + if 'Link status: down' in out: > + self.dut_testpmd.execute_cmd('port stop all') > + self.dut_testpmd.execute_cmd('port start all') > + time.sleep(2) > + else : > + break > + self.verify("Link status: up" in out, "VF link down!!!") > + > + def bind_nic_driver(self, ports, driver=3D""): > + if driver =3D=3D "igb_uio": > + for port in ports: > + netdev =3D self.dut.ports_info[port]['port'] > + driver =3D netdev.get_nic_driver() > + if driver !=3D 'igb_uio': > + netdev.bind_driver(driver=3D'igb_uio') > + else: > + for port in ports: > + netdev =3D self.dut.ports_info[port]['port'] > + driver_now =3D netdev.get_nic_driver() > + if driver =3D=3D "": > + driver =3D netdev.default_driver > + if driver !=3D driver_now: > + netdev.bind_driver(driver=3Ddriver) > + > + def setup_vm_env(self, driver=3D'default'): > + """ > + Create testing environment with 1VF generated from 1PF > + """ > + if self.vm_env_done: > + return > + > + # initialize vm > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") > + self.vm0 =3D None > + > + # set vf assign method and vf driver > + self.vf_driver =3D self.get_suite_cfg()['vf_driver'] > + if self.vf_driver is None: > + self.vf_driver =3D 'pci-stub' > + self.verify(self.vf_driver in self.supported_vf_driver, "Unsppor= ted vf driver") > + if self.vf_driver =3D=3D 'pci-stub': > + self.vf_assign_method =3D 'pci-assign' > + else: > + self.vf_assign_method =3D 'vfio-pci' > + self.dut.send_expect('modprobe vfio-pci', '#') > + > + self.bind_nic_driver(self.dut_ports[:1], driver=3D"igb_uio") > + self.used_dut_port =3D self.dut_ports[0] > + tester_port =3D self.tester.get_local_port(self.used_dut_port) > + self.tester_intf =3D self.tester.get_interface(tester_port) > + > + self.dut.generate_sriov_vfs_by_port( > + self.used_dut_port, 2, driver=3Ddriver) > + self.sriov_vfs_port =3D self.dut.ports_info[ > + self.used_dut_port]['vfs_port'] > + for port in self.sriov_vfs_port: > + port.bind_driver(self.vf_driver) > + time.sleep(1) > + self.dut_testpmd =3D PmdOutput(self.dut) > + self.dut_testpmd.start_testpmd( > + "Default", "--rxq=3D4 --txq=3D4 --port-topology=3Dchained") > + self.dut_testpmd.execute_cmd("start") > + time.sleep(5) > + > + vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} > + > + # set up VM0 ENV > + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'shutdown_api') > + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0_pro= p) > + try: > + self.vm0_dut =3D self.vm0.start() > + if self.vm0_dut is None: > + raise Exception("Set up VM0 ENV failed!") > + except Exception as e: > + self.destroy_vm_env() > + raise Exception(e) > + > + self.vm0_dut_ports =3D self.vm0_dut.get_ports('any') > + self.vm0_testpmd =3D PmdOutput(self.vm0_dut) > + > + self.vm_env_done =3D True > + self.dut_testpmd.quit() > + > + def destroy_vm_env(self): > + if not self.vm_env_done: > + return > + if getattr(self, 'vm0', None): > + self.vm0_dut.kill_all() > + self.vm0_testpmd =3D None > + self.vm0_dut_ports =3D None > + # destroy vm0 > + self.vm0.stop() > + self.vm0 =3D None > + > + if getattr(self, 'used_dut_port', None): > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > + port =3D self.dut.ports_info[self.used_dut_port]['port'] > + self.used_dut_port =3D None > + > + self.vm_env_done =3D False > + > def test_stop_restart(self): > """ > Stop and Restar. > @@ -306,7 +434,6 @@ class TestShutdownApi(TestCase): > self.dut.send_expect("start", "testpmd> ") > self.check_forwarding() >=20 > - > def test_change_linkspeed(self): > """ > Change Link Speed. > @@ -320,31 +447,32 @@ class TestShutdownApi(TestCase): >=20 > out =3D self.tester.send_expect( > "ethtool %s" % > self.tester.get_interface(self.tester.get_local_port(self.ports[0])), "# = ") > - if 'fortville_spirit' =3D=3D self.nic: > - result_scanner =3D r"([0-9]+)baseSR4/([A-Za-z]+)" > - else: > - result_scanner =3D r"([0-9]+)baseT/([A-Za-z]+)" > + > + self.verify("Supports auto-negotiation: Yes" in out, > + "Auto-negotiation not support.") > + > + result_scanner =3D r"([0-9]+)base\S*/([A-Za-z]+)" > scanner =3D re.compile(result_scanner, re.DOTALL) > m =3D scanner.findall(out) > configs =3D m[:-int(len(m) / 2)] > + > + if not self.check_linkspeed_config(configs): > + return; > + > for config in configs: > print(config) > if self.nic in ["ironpond"]: > if config[0] !=3D '1000' or '10000': > continue > - elif self.nic in ["fortville_eagle"]: > - if config[0] !=3D '10000': > - continue > elif self.nic in ["sagepond"]: > if config[0] !=3D '1000' and '10000': > continue > self.dut.send_expect("port stop all", "testpmd> ", 100) > for port in self.ports: > self.dut.send_expect("port config %d speed %s duplex %s"= % (port, > - = config[0], config[1].lower()), > "testpmd> ") > + config[0], config[1].lower()), "testpmd> ") > self.dut.send_expect("set fwd mac", "testpmd>") > self.dut.send_expect("port start all", "testpmd> ", 100) > - time.sleep(5) # sleep few seconds for link stable > + time.sleep(8) # sleep few seconds for link stable >=20 > for port in self.ports: > out =3D self.tester.send_expect( @@ -357,6 +485,61 @@ cl= ass > TestShutdownApi(TestCase): > self.check_forwarding() > self.dut.send_expect("stop", "testpmd> ") >=20 > + def test_change_linkspeed_vf(self): > + """ > + Change Link Speed VF . > + """ > + self.setup_vm_env() > + self.check_vf_link_status() > + out =3D self.tester.send_expect( > + "ethtool %s" % > + self.tester.get_interface(self.tester.get_local_port(self.ports[0])), > + "# ", 100) > + > + self.verify("Supports auto-negotiation: Yes" in out, > + "Auto-negotiation not support.") > + > + result_scanner =3D r"([0-9]+)base\S*/([A-Za-z]+)" > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.findall(out) > + configs =3D m[:-int(len(m) / 2)] > + > + if not self.check_linkspeed_config(configs): > + return; > + > + result_linkspeed_scanner =3D r"Link\s*speed:\s([0-9]+)\s*Mbps" > + linkspeed_scanner =3D re.compile(result_linkspeed_scanner, re.DO= TALL) > + result_linktype_scanner =3D r"Link\s*duplex:\s*(\S*)\s*-\s*duple= x" > + linktype_scanner =3D re.compile(result_linktype_scanner, > + re.DOTALL) > + > + for config in configs: > + print(config) > + if self.nic in ["ironpond"]: > + if config[0] !=3D '1000' or '10000': > + continue > + elif self.nic in ["sagepond"]: > + if config[0] !=3D '1000' and '10000': > + continue > + self.dut.send_expect("port stop all", "testpmd> ", 100) > + for port in self.ports: > + self.dut.send_expect("port config %d speed %s duplex %s"= % (port, > + config[0], config[1].lower()), "tes= tpmd> ") > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("port start all", "testpmd> ", 100) > + time.sleep(8) # sleep few seconds for link stable > + # check changing VF link speed is supported or not. > + out =3D self.vm0_testpmd.execute_cmd('show port info all') > + > + linkspeed =3D linkspeed_scanner.findall(out) > + linktype =3D linktype_scanner.findall(out) > + > + self.verify(config[0] in linkspeed, > + "Wrong VF speed reported by the self.tester.") > + self.verify(config[1].lower() =3D=3D linktype[0].lower(), > + "Wrong VF link type reported by the self.tester.= ") > + # quit vm > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + time.sleep(3) > + self.vm0_dut.kill_all() > + > def test_enable_disablejumbo(self): > """ > Enable/Disable Jumbo Frames. > @@ -582,3 +765,4 @@ class TestShutdownApi(TestCase): > Run after each test suite. > """ > self.dut.kill_all() > + self.destroy_vm_env() > -- > 2.17.1