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 43A62A2EFC for ; Wed, 18 Sep 2019 08:53:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F5191BF86; Wed, 18 Sep 2019 08:53:06 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 8B6B61BF59 for ; Wed, 18 Sep 2019 08:53:04 +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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 23:53:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="187686927" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga007.fm.intel.com with ESMTP; 17 Sep 2019 23:52:59 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 23:52:55 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 23:52:54 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.92]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0439.000; Wed, 18 Sep 2019 14:52:53 +0800 From: "Tu, Lijuan" To: "Zhang, YanX A" , "dts@dpdk.org" CC: "Zhang, Yuwei1" , "Zhang, YanX A" Thread-Topic: [dts] [PATCH V1] tests/TestSuite_vf_interrupt_pmd:add a test case Thread-Index: AQHVU9rTCDnxCcXcB0+riPGKAzuMAqcxM4mA Date: Wed, 18 Sep 2019 06:52:52 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB23C09@SHSMSX101.ccr.corp.intel.com> References: <1565922991-108821-1-git-send-email-yanx.a.zhang@intel.com> In-Reply-To: <1565922991-108821-1-git-send-email-yanx.a.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-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTY4M2YyZTMtMzNiNC00NWZmLWJhN2YtNDllYzJjN2QwNTAyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMkpqTTVhUGFFQ2QzaDRPV2k1TFFVdTZGMHdGMnFyZUM4Z3I2S1wveFpMMXBNdVJ5WFgrTDJ6OEZ3TjFNNjNpRDUifQ== 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" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhang,yan > 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 cas= e >=20 > add a test case. >=20 > Signed-off-by: zhang,yan > --- > tests/TestSuite_vf_interrupt_pmd.py | 162 ++++++++++++++++++++++++---- > 1 file changed, 139 insertions(+), 23 deletions(-) >=20 > diff --git a/tests/TestSuite_vf_interrupt_pmd.py > b/tests/TestSuite_vf_interrupt_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, "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', '#') >=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/l3fw= d- > 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" % sel= f.core_user > in out1, "Wake up failed") > - self.verify( > - "lcore %s sleeps until interrupt triggers" % self.core_u= ser 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_= user > try: > self.logger.info("Launch l3fwd_sample sample:") > - self.out =3D self.dut.send_expect(cmd_vhost_net, "L3FWD_POWE= R", 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 samp= le: %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]['i= ntf'] > + # 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_pro= p_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.ou= t2, "Wake > up failed") > + self.verify( > + "lcore 2 sleeps until interrupt triggers" in self.out2, > + "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 > TestVfInterruptPmd(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.co= re_user > in self.out2, "Wake up failed") > + self.verify( > + "lcore %s sleeps until interrupt triggers" % self.core_user > + 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.co= re_user > in self.out2, "Wake up failed") > + self.verify( > + "lcore %s sleeps until interrupt triggers" % self.core_user > + 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.co= re_user > in self.out2, "Wake up failed") > + self.verify( > + "lcore %s sleeps until interrupt triggers" % self.core_user > + 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