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 5E5A9A0524; Mon, 24 Feb 2020 06:06:39 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2186C1BE85; Mon, 24 Feb 2020 06:06:39 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7D4EA2C39 for ; Mon, 24 Feb 2020 06:06:36 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2020 21:06:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,478,1574150400"; d="scan'208";a="270739389" Received: from intel.sh.intel.com ([10.239.255.136]) by fmsmga002.fm.intel.com with ESMTP; 23 Feb 2020 21:06:33 -0800 From: Jiaqi Min To: dts@dpdk.org Cc: Jiaqi Min Date: Mon, 24 Feb 2020 05:02:04 +0000 Message-Id: <20200224050204.54467-1-jiaqix.min@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dts] [PATCH V1] tests/shutdown_api: modify 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" fix test change linkspeed add test change linkspeed vf add testcase vf to test plan add shutdown_api.cfg 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 diff --git a/conf/shutdown_api.cfg b/conf/shutdown_api.cfg new file mode 100644 index 0000000..fe762f8 --- /dev/null +++ b/conf/shutdown_api.cfg @@ -0,0 +1,44 @@ +# Configuration sample: sriov_kvm.cfg +[vm0] +cpu = + model=host,number=4,cpupin=5 6 7 8; +disk = + file=/storage/vm-image/vm0.img,opt_format=qcow2,opt_if=virtio,opt_index=0,opt_media=disk; +mem = + size=10250; +login = + user=root,password=tester; +# net option is not necessary for libvirt, comment out below 2 lines if using libvirt +net = + type=nic,opt_vlan=0; + type=user,opt_vlan=0; +qga = + enable=yes; +# vnc option is not supported by libvirt yet, comment out below 2 lines if using libvirt +vnc = + displayNum=1; +# daemon option is not supported by libvirt yet, comment out below 2 lines if using libvirt +daemon = + enable=yes; + +[vm1] +cpu = + model=host,number=4,cpupin=14 15 16 17; +disk = + file=/storage/vm-image/vm0.img_copy.img,opt_format=qcow2,opt_if=virtio,opt_index=0,opt_media=disk; +mem = + size=10250; +login = + user=root,password=tester; +# net option is not necessary for libvirt, comment out below 2 lines if using libvirt +net = + type=nic,opt_vlan=0; + type=user,opt_vlan=0; +qga = + enable=yes; +# vnc option is not supported by libvirt yet, comment out below 2 lines if using libvirt +vnc = + displayNum=2; +# daemon option is not supported by libvirt yet, comment out below 2 lines if using libvirt +daemon = + enable=yes; diff --git a/tests/TestSuite_shutdown_api.py b/tests/TestSuite_shutdown_api.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 # # @@ -51,6 +53,7 @@ from exception import VerifyFailure # +VM_CORES_MASK = 'all' class TestShutdownApi(TestCase): # @@ -58,7 +61,7 @@ class TestShutdownApi(TestCase): # # Test cases. # - + supported_vf_driver = ['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(port)), 5000), "# ") self.pmdout = PmdOutput(self.dut) + self.vm_env_done = False def get_stats(self, portid): """ @@ -187,6 +191,130 @@ class TestShutdownApi(TestCase): """ pass + def check_linkspeed_config(self, configs): + ret_val = False + if (configs == None): + self.verify(False, "Link speed config error.") + ret_val = False + elif (len(configs) < 1): + self.verify(False, "Link speed config error.") + ret_val = False + elif len(configs) < 2: + print("\nOnly one link speed, can't be changed.\n") + ret_val = False + else: + ret_val = True + + return ret_val + + def check_vf_link_status(self): + self.dut_testpmd.start_testpmd("Default", "--port-topology=chained") + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology=chained') + for i in range(10): + out = 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=""): + if driver == "igb_uio": + for port in ports: + netdev = self.dut.ports_info[port]['port'] + driver = netdev.get_nic_driver() + if driver != 'igb_uio': + netdev.bind_driver(driver='igb_uio') + else: + for port in ports: + netdev = self.dut.ports_info[port]['port'] + driver_now = netdev.get_nic_driver() + if driver == "": + driver = netdev.default_driver + if driver != driver_now: + netdev.bind_driver(driver=driver) + + def setup_vm_env(self, driver='default'): + """ + Create testing environment with 1VF generated from 1PF + """ + if self.vm_env_done: + return + + # initialize vm + self.dut_ports = self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >= 1, "Insufficient ports") + self.vm0 = None + + # set vf assign method and vf driver + self.vf_driver = self.get_suite_cfg()['vf_driver'] + if self.vf_driver is None: + self.vf_driver = 'pci-stub' + self.verify(self.vf_driver in self.supported_vf_driver, "Unspported vf driver") + if self.vf_driver == 'pci-stub': + self.vf_assign_method = 'pci-assign' + else: + self.vf_assign_method = 'vfio-pci' + self.dut.send_expect('modprobe vfio-pci', '#') + + self.bind_nic_driver(self.dut_ports[:1], driver="igb_uio") + self.used_dut_port = self.dut_ports[0] + tester_port = self.tester.get_local_port(self.used_dut_port) + self.tester_intf = self.tester.get_interface(tester_port) + + self.dut.generate_sriov_vfs_by_port( + self.used_dut_port, 2, driver=driver) + self.sriov_vfs_port = 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 = PmdOutput(self.dut) + self.dut_testpmd.start_testpmd( + "Default", "--rxq=4 --txq=4 --port-topology=chained") + self.dut_testpmd.execute_cmd("start") + time.sleep(5) + + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci} + + # set up VM0 ENV + self.vm0 = QEMUKvm(self.dut, 'vm0', 'shutdown_api') + self.vm0.set_vm_device(driver=self.vf_assign_method, **vf0_prop) + try: + self.vm0_dut = 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 = self.vm0_dut.get_ports('any') + self.vm0_testpmd = PmdOutput(self.vm0_dut) + + self.vm_env_done = 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 = None + self.vm0_dut_ports = None + # destroy vm0 + self.vm0.stop() + self.vm0 = None + + if getattr(self, 'used_dut_port', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) + port = self.dut.ports_info[self.used_dut_port]['port'] + self.used_dut_port = None + + self.vm_env_done = 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() - def test_change_linkspeed(self): """ Change Link Speed. @@ -320,31 +447,32 @@ class TestShutdownApi(TestCase): out = self.tester.send_expect( "ethtool %s" % self.tester.get_interface(self.tester.get_local_port(self.ports[0])), "# ") - if 'fortville_spirit' == self.nic: - result_scanner = r"([0-9]+)baseSR4/([A-Za-z]+)" - else: - result_scanner = r"([0-9]+)baseT/([A-Za-z]+)" + + self.verify("Supports auto-negotiation: Yes" in out, "Auto-negotiation not support.") + + result_scanner = r"([0-9]+)base\S*/([A-Za-z]+)" scanner = re.compile(result_scanner, re.DOTALL) m = scanner.findall(out) configs = 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] != '1000' or '10000': continue - elif self.nic in ["fortville_eagle"]: - if config[0] != '10000': - continue elif self.nic in ["sagepond"]: if config[0] != '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 for port in self.ports: out = self.tester.send_expect( @@ -357,6 +485,61 @@ class TestShutdownApi(TestCase): 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 = 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 = r"([0-9]+)base\S*/([A-Za-z]+)" + scanner = re.compile(result_scanner, re.DOTALL) + m = scanner.findall(out) + configs = m[:-int(len(m) / 2)] + + if not self.check_linkspeed_config(configs): + return; + + result_linkspeed_scanner = r"Link\s*speed:\s([0-9]+)\s*Mbps" + linkspeed_scanner = re.compile(result_linkspeed_scanner, re.DOTALL) + result_linktype_scanner = r"Link\s*duplex:\s*(\S*)\s*-\s*duplex" + linktype_scanner = re.compile(result_linktype_scanner, re.DOTALL) + + for config in configs: + print(config) + if self.nic in ["ironpond"]: + if config[0] != '1000' or '10000': + continue + elif self.nic in ["sagepond"]: + if config[0] != '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> ") + 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 = self.vm0_testpmd.execute_cmd('show port info all') + + linkspeed = linkspeed_scanner.findall(out) + linktype = linktype_scanner.findall(out) + + self.verify(config[0] in linkspeed, + "Wrong VF speed reported by the self.tester.") + self.verify(config[1].lower() == 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