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 78CC2A04A3; Thu, 11 Jun 2020 14:22:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 673862BAB; Thu, 11 Jun 2020 14:22:36 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 2313D2BAA for ; Thu, 11 Jun 2020 14:22:33 +0200 (CEST) IronPort-SDR: e10KJNn711QMMmddVjZGyq2kAFKn9r0ysh4jsGCLI8NxTrMjfCSHwH9NKWvz3BuoKe//N3lBj7 OjLx+k9rF8eg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 05:22:33 -0700 IronPort-SDR: v7aKQM4hGrGvbUOfgBNsXi496ab5HNM8MafWyFz8Y8zG3PjPp3e4wvzcYytj3FaWxTv2NrjxLU sDp862/2XTCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,499,1583222400"; d="scan'208";a="271567275" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 11 Jun 2020 05:22:32 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 11 Jun 2020 05:22:32 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.85]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0439.000; Thu, 11 Jun 2020 20:22:29 +0800 From: "Tu, Lijuan" To: "Zhang, XiX" , "dts@dpdk.org" CC: "Zhang, XiX" Thread-Topic: [dts] [PATCH V1] tests/TestSuite_shutdown_apitests:change dpdk pf create vf to kernel pf create vf Thread-Index: AQHWNAVTuoCsZgtjfE2rfAZOpt8stajTbeBA Date: Thu, 11 Jun 2020 12:22:29 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BC5BC6E@SHSMSX101.ccr.corp.intel.com> References: <1590570365-110634-1-git-send-email-xix.zhang@intel.com> In-Reply-To: <1590570365-110634-1-git-send-email-xix.zhang@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-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1] tests/TestSuite_shutdown_apitests:change dpdk pf create vf to kernel pf create 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks -----Original Message----- From: dts On Behalf Of xizhan4x Sent: 2020=1B$BG/=1B(B5=1B$B7n=1B(B27=1B$BF|=1B(B 17:06 To: dts@dpdk.org Cc: Zhang, XiX Subject: [dts] [PATCH V1] tests/TestSuite_shutdown_apitests:change dpdk pf = create vf to kernel pf create vf change dpdk pf create vf to kernel pf create vf and used ethtool Modify sp= eed Signed-off-by: xizhan4x --- tests/TestSuite_shutdown_api.py | 129 ++++++++++++++++---------------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api= .py index 3a29b9c..650ccfc 100644 --- a/tests/TestSuite_shutdown_api.py +++ b/tests/TestSuite_shutdown_api.py @@ -48,7 +48,7 @@ from exception import VerifyFailure from qemu_kvm import= QEMUKvm from settings import get_nic_name from random import randint - +from settings import DRIVERS # # # Test class. @@ -80,6 +80,18 @@ class TestShutdownApi(TestCase): self.pmdout =3D PmdOutput(self.dut) self.vm_env_done =3D False =20 + def set_up(self): + """ + Run before each test case. + """ + if self._suite_result.test_case =3D=3D "test_change_linkspeed_vf": + self.used_driver =3D self.dut.ports_info[0]["port"].get_nic_dr= iver() + driver_name =3D DRIVERS.get(self.nic) + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + self.bind_nic_driver(self.dut_ports, driver=3Ddriver_name) + self.setup_vm_env(driver_name) + def get_stats(self, portid): """ Get packets number from port statistic. @@ -188,11 +200,6 @@ class TestShutdownApi(TestCase): else: self.verify("Link detected: no" in out, "Wrong link status= ") =20 - def set_up(self): - """ - Run before each test case. - """ - pass =20 def check_linkspeed_config(self, configs): ret_val =3D False @@ -211,14 +218,12 @@ class TestShutdownApi(TestCase): return ret_val =20 def check_vf_link_status(self): - self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dchain= ed") self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology=3Dc= hained') - for i in range(10): + time.sleep(2) + for i in range(15): 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 @@ -239,7 +244,6 @@ class TestShutdownApi(TestCase): 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 @@ -247,9 += 251,6 @@ class TestShutdownApi(TestCase): if self.vm_env_done: return =20 - # 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 =20 # set vf assign method and vf driver @@ -263,12 +264,9 @@ class Te= stShutdownApi(TestCase): self.vf_assign_method =3D 'vfio-pci' self.dut.send_expect('modprobe vfio-pci', '#') =20 - self.dut.setup_modules_linux(self.target, 'igb_uio', '') - 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[ @@ -276,14 +274,11 @@= class TestShutdownApi(TestCase): 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) =20 vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} - + self.host_intf =3D self.dut.ports_info[self.used_dut_port]['intf'] + self.vf_mac =3D "00:01:23:45:67:89" + self.dut.send_expect("ip link set %s vf 0 mac %s" %=20 + (self.host_intf, self.vf_mac), "# ") # set up VM0 ENV self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'shutdown_api') self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0_prop)= @@ -294,30 +289,35 @@ class TestShutdownApi(TestCase): 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) =20 self.vm_env_done =3D True - self.dut_testpmd.quit() - self.bind_nic_driver(self.dut_ports[:1], driver=3Dself.vf_driver) + =20 def destroy_vm_env(self): + if getattr(self, 'used_dut_port', None) is not None: + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) + self.used_dut_port =3D None + + for port in self.ports: + self.dut.send_expect("ethtool -s %s autoneg on " %=20 + self.dut.ports_info[port]["intf"], "#") + + self.bind_nic_driver(self.dut_ports, driver=3Dself.used_driver or= =20 + self.drivername) + if not self.vm_env_done: return + + if getattr(self, 'self.vm0_testpmd', None): + self.vm0_testpmd.quit() + if getattr(self, 'vm0', None): - self.vm0_dut.kill_all() + if getattr(self, 'vm0_dut', 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 =20 def test_stop_restart(self): @@ -525,47 +525,53 @@ class TestShutdownApi(TestCase): self.dut.send_expect("start", "testpmd> ") self.check_forwarding() self.dut.send_expect("stop", "testpmd> ") - 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) =20 - self.verify("Supports auto-negotiation: Yes" in out, "Auto-negotia= tion not support.") - + dut_out=3Dself.dut.send_expect("ethtool %s" % self.dut.ports_info[= 0]["intf"], "# ", 100) + check_auto_negotiation=3D"Supports auto-negotiation: Yes" + self.verify(check_auto_negotiation in out and=20 + check_auto_negotiation in dut_out , "tester or dut Auto-negotiation=20 + 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) + m =3D scanner.findall(dut_out) configs =3D m[:-int(len(m) / 2)] =20 if not self.check_linkspeed_config(configs): - return; + return =20 result_linkspeed_scanner =3D r"Link\s*speed:\s([0-9]+)\s*Mbps" linkspeed_scanner =3D re.compile(result_linkspeed_scanner, re.DOTA= LL) result_linktype_scanner =3D r"Link\s*duplex:\s*(\S*)\s*-\s*duplex" linktype_scanner =3D re.compile(result_linktype_scanner, re.DOTALL= ) - + tx_rx_packets =3D 3 + self.vm0_testpmd.execute_cmd('set fwd mac', "testpmd> ", 30) + self.vm0_testpmd.execute_cmd('start') 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()), "testp= md> ") - 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. + if len(configs) !=3D 1: + self.dut.send_expect( + "ethtool -s %s autoneg off speed %s duplex %s" % = (self.dut.ports_info[port]["intf"], + = config[0], config[1].lower()), "#") + time.sleep(5) + self.tester_itf_1 =3D self.tester.get_interface(port) + pkt =3D 'Ether(dst=3D"%s", src=3D"02:00:00:00:00:01")/IP()= /UDP()/("X"*22)' % self.vf_mac + self.tester.scapy_append( + 'sendp([%s], iface=3D"%s", count=3D%d)' + % (pkt, self.tester_intf, tx_rx_packets)) + self.tester.scapy_execute() + time.sleep(2) + out =3D self.vm0_testpmd.execute_cmd('show port stats all'= ) + self.verify("RX-packets: %d" % tx_rx_packets in out and "T= X-packets: %d" % tx_rx_packets in out, + "VF Expected results: RX-packets: %d \n Actual= results:%s " % (tx_rx_packets, out)) + self.vm0_testpmd.execute_cmd('clear port stats all') + time.sleep(1) + out =3D self.vm0_testpmd.execute_cmd('show port info all') =20 linkspeed =3D linkspeed_scanner.findall(out) @@ -575,12 +581,7= @@ class TestShutdownApi(TestCase): "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() - self.destroy_vm_env() + =20 def test_enable_disablejumbo(self): """ @@ -818,8 +819,11 @@ class TestShutdownApi(TestCase): """ Run after each test case. """ + if self._suite_result.test_case =3D=3D "test_change_linkspeed_vf": + self.destroy_vm_env() self.dut.kill_all() - self.pmdout.start_testpmd("Default", "--portmask=3D%s --port-topol= ogy=3Dloop" % utils.create_mask(self.ports), socket=3Dself.ports_socket) + self.pmdout.start_testpmd("Default", "--portmask=3D%s --port-topol= ogy=3Dloop" % utils.create_mask(self.ports), + socket=3Dself.ports_socket) ports_num =3D len(self.ports) # link up test, to avoid failing further tests if link was down for i in range(ports_num): @@ -828,12 +832,11 @@ class TestShutdownApi(TestCase): # start ports, to avodi failing further tests if ports are stoped self.dut.send_expect("port start all", "testpmd> ", 100) self.dut.send_expect("quit", "# ") + =20 =20 =20 def tear_down_all(self): """ Run after each test suite. """ - if self.vm_env_done: - self.destroy_vm_env() self.dut.kill_all() -- 2.17.2