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 D3B01A2E1B for ; Wed, 4 Sep 2019 04:47:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A26391EB7F; Wed, 4 Sep 2019 04:47:42 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 06B5E1EAAA for ; Wed, 4 Sep 2019 04:47:40 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2019 19:47:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,465,1559545200"; d="scan'208";a="183760422" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 03 Sep 2019 19:47:39 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 3 Sep 2019 19:47:38 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 3 Sep 2019 19:47:38 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.113]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.86]) with mapi id 14.03.0439.000; Wed, 4 Sep 2019 10:47:36 +0800 From: "Zhang, Yuwei1" To: "Zhang, YanX A" , "dts@dpdk.org" Thread-Topic: [dts][PATCH V1] tests/TestSuite_vf_interrupt_pmd:add a test case Thread-Index: AQHVU9rK4YytpYCk4kaStquuXKtDY6b8iXOAgB5k+bA= Date: Wed, 4 Sep 2019 02:47:35 +0000 Message-ID: References: <1565922991-108821-1-git-send-email-yanx.a.zhang@intel.com> <2C49E4B25FAD1D419F7564D633EF72E1F40CE2@SHSMSX105.ccr.corp.intel.com> In-Reply-To: <2C49E4B25FAD1D419F7564D633EF72E1F40CE2@SHSMSX105.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODQyN2E4ODktMmFmYi00YjgwLWJiZDAtN2YzMTVhYjg4ZjBhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZG1Ub3NJdzQ3VDlobTdkNXQyU0lWdEZCcnZ4YUVvck9NaGw1S0dlcXlkTEVNRTg2VU1YSXdQOHhlU2txTmRucCJ9 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 V1] tests/TestSuite_vf_interrupt_pmd:add a test case 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 Regards, Yuwei -----Original Message----- From: Zhang, YanX A=20 Sent: Friday, August 16, 2019 10:38 AM To: dts@dpdk.org Cc: Zhang, Yuwei1 Subject: RE: [dts][PATCH V1] tests/TestSuite_vf_interrupt_pmd:add a test ca= se Tested-by: Zhang, YanX A -----Original Message----- From: Zhang, YanX A Sent: Friday, August 16, 2019 10:37 AM To: dts@dpdk.org Cc: Zhang, Yuwei1 ; Zhang, YanX A Subject: [dts][PATCH V1] tests/TestSuite_vf_interrupt_pmd:add a test case add a test case. Signed-off-by: zhang,yan --- tests/TestSuite_vf_interrupt_pmd.py | 162 ++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 23 deletions(-) diff --git a/tests/TestSuite_vf_interrupt_pmd.py b/tests/TestSuite_vf_inter= rupt_pmd.py index 1cf2e4e..cc15ac6 100644 --- a/tests/TestSuite_vf_interrupt_pmd.py +++ b/tests/TestSuite_vf_interrupt_pmd.py @@ -39,10 +39,12 @@ import utils import time import re =20 +from qemu_kvm import QEMUKvm from test_case import TestCase from packet import Packet =20 class TestVfInterruptPmd(TestCase): + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] =20 def set_up_all(self): """ @@ -50,7 +52,7 @@ class TestVfInterruptPmd(TestCase): """ self.dut_ports =3D self.dut.get_ports(self.nic) self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") - + self.env_done =3D False cores =3D "1S/4C/1T" self.number_of_ports =3D 1 =20 @@ -66,14 +68,23 @@ class TestVfInterruptPmd(TestCase): self.port_mask =3D utils.create_mask(ports) self.core_mask_user =3D utils.create_mask(self.core_list[0:1]) =20 + self.path =3D "./examples/l3fwd-power/build/l3fwd-power" + testport_0 =3D self.tester.get_local_port(self.dut_ports[0]) self.rx_intf_0 =3D self.tester.get_interface(testport_0) self.tester_mac =3D self.tester.get_mac(testport_0) - + self.vf0_mac =3D "00:12:34:56:78:01" self.mac_port_0 =3D self.dut.get_mac_address(self.dut_ports[0]) =20 - self.prepare_l3fwd_power() - self.dut.send_expect('modprobe vfio-pci', '#') + 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, "Unspporte= d 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', '#') =20 def set_up(self): """ @@ -81,17 +92,17 @@ class TestVfInterruptPmd(TestCase): """ self.dut.restore_interfaces() =20 - def prepare_l3fwd_power(self): + def prepare_l3fwd_power(self, use_dut): """ Change the DPDK source code and recompile """ - self.dut.send_expect( + use_dut.send_expect( "sed -i -e '/DEV_RX_OFFLOAD_CHECKSUM,/d' ./examples/l3fwd-= power/main.c", "#", 10) =20 - out =3D self.dut.send_expect("make -C examples/l3fwd-power", "#") + out =3D use_dut.send_expect("make -C examples/l3fwd-power", "#") self.verify("Error" not in out, "compilation error") =20 - def send_and_verify(self, mac, testinterface): + def send_packet(self, mac, testinterface, use_dut): """ Send a packet and verify """ @@ -99,11 +110,7 @@ class TestVfInterruptPmd(TestCase): pkt.config_layer('ether', {'dst': mac, 'src': self.tester_mac}) pkt.send_pkt(tx_port=3Dtestinterface) =20 - out1 =3D self.dut.get_session_output(timeout=3D2) - self.verify( - "lcore %s is waked up from rx interrupt on port 0" % self.= core_user in out1, "Wake up failed") - self.verify( - "lcore %s sleeps until interrupt triggers" % self.core_use= r in out1, "lcore 1 not sleeps") + self.out2 =3D use_dut.get_session_output(timeout=3D2) =20 def set_NIC_link(self): """ @@ -114,16 +121,16 @@ class TestVfInterruptPmd(TestCase): =20 self.dut.send_expect("ifconfig %s up" % self.host_intf, '#', 3) =20 - def begin_l3fwd_power(self): + def begin_l3fwd_power(self, use_dut): """ begin l3fwd-power """ cmd_vhost_net =3D "./examples/l3fwd-power/build/l3fwd-power -n %d = -c %s" % ( - self.dut.get_memory_channels(), self.core_mask_user) + \ + use_dut.get_memory_channels(), self.core_mask_user) + \ " -- -P -p 1 --config=3D'(0,0,%s)'" % self.core_us= er try: self.logger.info("Launch l3fwd_sample sample:") - self.out =3D self.dut.send_expect(cmd_vhost_net, "L3FWD_POWER"= , 60) + self.out =3D use_dut.send_expect(cmd_vhost_net, + "L3FWD_POWER", 60) if "Error" in self.out: raise Exception("Launch l3fwd-power sample failed") else: @@ -131,10 +138,99 @@ class TestVfInterruptPmd(TestCase): except Exception as e: self.logger.error("ERROR: Failed to launch l3fwd-power sample= : %s" % str(e)) =20 + def setup_vm_env(self, driver=3D'default'): + """ + Start a vm using a virtual NIC + """ + if self.env_done: + return + + self.used_dut_port_0 =3D self.dut_ports[0] + self.dut.generate_sriov_vfs_by_port( + self.used_dut_port_0, 1, driver=3Ddriver) + self.sriov_vfs_port_0 =3D self.dut.ports_info[ + self.used_dut_port_0]['vfs_port'] + + self.host_intf0 =3D self.dut.ports_info[self.used_dut_port_0]['int= f'] + # set vf mac + self.dut.send_expect("ip link set %s vf 0 mac %s" % + (self.host_intf0, self.vf0_mac), "# ") + + for port in self.sriov_vfs_port_0: + port.bind_driver(self.vf_driver) + + vf0_prop_0 =3D {'opt_host': self.sriov_vfs_port_0[0].pci} + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_interrupt_pmd') + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0_prop_= 0) + try: + self.vm0_dut =3D self.vm0.start() + if self.vm0_dut is None: + raise Exception("Set up VM ENV failed") + else: + self.verify(self.vm0_dut.ports_info[ + 0]['intf'] !=3D 'N/A', "Not interface") + except Exception as e: + self.destroy_vm_env() + self.logger.error("Failure for %s" % str(e)) + + self.env_done =3D True + + def destroy_vm_env(self): + """ + destroy vm environment + """ + if getattr(self, 'vm0', None): + self.vm0_dut.kill_all() + self.vm0_dut_ports =3D None + # destroy vm0 + self.vm0.stop() + self.vm0 =3D None + + if getattr(self, 'used_dut_port_0', None) !=3D None: + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) + self.used_dut_port_0 =3D None + + self.env_done =3D False + + def VF0_bind_vfio_pci(self): + """ + Bind VF0 to vfio-pci + """ + self.vm0_dut.send_expect("modprobe -r vfio_iommu_type1", '#', 3) + self.vm0_dut.send_expect("modprobe -r vfio", '#', 3) + self.vm0_dut.send_expect("modprobe vfio enable_unsafe_noiommu_mode= =3D1", '#', 3) + self.vm0_dut.send_expect("modprobe vfio-pci", '#', 3) + + self.vm0_dut.bind_interfaces_linux(driver=3D"vfio-pci") + + def test_nic_interrupt_VM_vfio_pci(self): + """ + Check for interrupts within the VM + """ + self.setup_vm_env() + self.prepare_l3fwd_power(self.vm0_dut) + + self.VF0_bind_vfio_pci() + + cmd =3D self.path + \ + " -l 1-3 -n %d -- -P -p 0x01 --config=3D'(0,0,2)'" % ( + self.vm0_dut.get_memory_channels()) + self.vm0_dut.send_expect(cmd, "L3FWD_POWER", 60) + time.sleep(1) + self.send_packet(self.vf0_mac, self.rx_intf_0, self.vm0_dut) + self.destroy_vm_env() + + self.verify( + "lcore 2 is waked up from rx interrupt on port 0" in self.out2= , "Wake up failed") + self.verify( + "lcore 2 sleeps until interrupt triggers" in self.out2,=20 + "lcore 2 not sleeps") + def test_nic_interrupt_VF_vfio_pci(self, driver=3D'default'): """ Check Interrupt for VF with vfio driver """ + self.prepare_l3fwd_power(self.dut) + self.set_NIC_link() =20 # generate VF and bind to vfio-pci @@ -145,31 +241,50 @@ class Tes= tVfInterruptPmd(TestCase): for port in self.sriov_vfs_port_0: port.bind_driver('vfio-pci') =20 - self.begin_l3fwd_power() + self.begin_l3fwd_power(self.dut) pattern =3D re.compile(r"(([A-Fa-f0-9]{2}:){5}[A-Fa-f0-9]{2})") self.vf_mac =3D pattern.search(self.out).group() =20 - self.send_and_verify(self.vf_mac, self.rx_intf_0) + self.send_packet(self.vf_mac, self.rx_intf_0, self.dut) + + self.verify( + "lcore %s is waked up from rx interrupt on port 0" % self.core= _user in self.out2, "Wake up failed") + self.verify( + "lcore %s sleeps until interrupt triggers" % self.core_user=20 + in self.out2, "lcore %s not sleeps" % self.core_user) =20 def test_nic_interrupt_PF_vfio_pci(self): """ Check Interrupt for PF with vfio-pci driver """ + self.prepare_l3fwd_power(self.dut) + self.dut.ports_info[0]['port'].bind_driver(driver=3D'vfio-pci') =20 - self.begin_l3fwd_power() + self.begin_l3fwd_power(self.dut) =20 - self.send_and_verify(self.mac_port_0, self.rx_intf_0) + self.send_packet(self.mac_port_0, self.rx_intf_0, self.dut) + + self.verify( + "lcore %s is waked up from rx interrupt on port 0" % self.core= _user in self.out2, "Wake up failed") + self.verify( + "lcore %s sleeps until interrupt triggers" % self.core_user=20 + in self.out2, "lcore %s not sleeps" % self.core_user) =20 def test_nic_interrupt_PF_igb_uio(self): """ Check Interrupt for PF with igb_uio driver """ + self.prepare_l3fwd_power(self.dut) + self.dut.ports_info[0]['port'].bind_driver(driver=3D'igb_uio') =20 - self.begin_l3fwd_power() + self.begin_l3fwd_power(self.dut) + + self.send_packet(self.mac_port_0, self.rx_intf_0, self.dut) =20 - self.send_and_verify(self.mac_port_0, self.rx_intf_0) + self.verify( + "lcore %s is waked up from rx interrupt on port 0" % self.core= _user in self.out2, "Wake up failed") + self.verify( + "lcore %s sleeps until interrupt triggers" % self.core_user=20 + in self.out2, "lcore %s not sleeps" % self.core_user) =20 def tear_down(self): """ @@ -181,4 +296,5 @@ class TestVfInterruptPmd(TestCase): """ Run after each test suite. """ - pass + if self.env_done: + self.destroy_vm_env() -- 2.17.2