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 E28E2A0613 for ; Tue, 24 Sep 2019 07:34:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C58772C60; Tue, 24 Sep 2019 07:34:44 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 830A02C5E for ; Tue, 24 Sep 2019 07:34:43 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 22:34:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,542,1559545200"; d="scan'208";a="182797714" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga008.jf.intel.com with ESMTP; 23 Sep 2019 22:34:42 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Sep 2019 22:34:41 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 23 Sep 2019 22:34:41 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.92]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.53]) with mapi id 14.03.0439.000; Tue, 24 Sep 2019 13:34:33 +0800 From: "Ma, LihongX" To: "Tu, Lijuan" CC: "Zhang, YanX A" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH V1] tests/vf_port_start_stop: use scapy instead pktgen send pkts Thread-Index: AQHVbcURMbP1LOQqC0qrh2CZNhv1Eac6U3BA Date: Tue, 24 Sep 2019 05:34:33 +0000 Message-ID: References: <1568745212-10618-1-git-send-email-lihongx.ma@intel.com> <2C49E4B25FAD1D419F7564D633EF72E1F481BD@SHSMSX105.ccr.corp.intel.com> In-Reply-To: <2C49E4B25FAD1D419F7564D633EF72E1F481BD@SHSMSX105.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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/vf_port_start_stop: use scapy instead pktgen send pkts 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" Hi, Lijuan You can ignore this patch, I will push version V2. -----Original Message----- From: Zhang, YanX A=20 Sent: Wednesday, September 18, 2019 10:02 AM To: Ma, LihongX ; dts@dpdk.org Cc: Ma, LihongX Subject: RE: [dts] [PATCH V1] tests/vf_port_start_stop: use scapy instead p= ktgen send pkts Tested-by: Zhang, YanX A -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong Sent: Wednesday, September 18, 2019 2:34 AM To: dts@dpdk.org Cc: Ma, LihongX Subject: [dts] [PATCH V1] tests/vf_port_start_stop: use scapy instead pktge= n send pkts Signed-off-by: lihong --- tests/TestSuite_vf_port_start_stop.py | 82 +++++++++----------------------= ---- 1 file changed, 20 insertions(+), 62 deletions(-) diff --git a/tests/TestSuite_vf_port_start_stop.py b/tests/TestSuite_vf_por= t_start_stop.py index 2ff2d1c..4f0e406 100644 --- a/tests/TestSuite_vf_port_start_stop.py +++ b/tests/TestSuite_vf_port_start_stop.py @@ -10,6 +10,7 @@ from utils import RED, GREEN from net_device import NetD= evice from crb import Crb from scapy.all import * +from scapy.layers.sctp import SCTP, SCTPChunkData VM_CORES_MASK =3D 'all' =20 class TestVfPortStartStop(TestCase): @@ -22,6 +23,8 @@ class TestVfPortStartStop(TestCase): self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") self.vm0 =3D None self.filename =3D "/tmp/vf.pcap" + self.tester_tx_port =3D self.tester.get_local_port(self.dut_ports[= 0]) + self.tester_tintf =3D=20 + self.tester.get_interface(self.tester_tx_port) =20 # set vf assign method and vf driver self.vf_driver =3D self.get_suite_cfg()['vf_driver'] @@ -37,72 +40= ,25 @@ class TestVfPortStartStop(TestCase): def set_up(self): =20 self.setup_1pf_2vf_1vm_env_flag =3D 0 - - def pktgen_prerequisites(self): - """ - igb_uio.ko should be put in ~ before you using pktgen - """ - out =3D self.tester.send_expect("ls", "#") - self.verify("igb_uio.ko" in out, "No file igb_uio.ko, please add i= t in ~") - self.tester.send_expect("modprobe uio", "#", 70) - out =3D self.tester.send_expect("lsmod | grep igb_uio", "#") - if "igb_uio" in out: - self.tester.send_expect("rmmod -f igb_uio", "#", 70) - self.tester.send_expect("insmod ~/igb_uio.ko", "#", 60) - out =3D self.tester.send_expect("lsmod | grep igb_uio", "#") - assert ("igb_uio" in out), "Failed to insmod igb_uio" - - total_huge_pages =3D self.tester.get_total_huge_pages() - if total_huge_pages =3D=3D 0: - self.tester.mount_huge_pages() - self.tester.set_huge_pages(2048) - - def pktgen_kill(self): - """ - Kill all pktgen on tester. - """ - pids =3D [] - pid_reg =3D r'p(\d+)' - out =3D self.tester.alt_session.send_expect("lsof -Fp /var/run/.pg= _config", "#", 20) - if len(out): - lines =3D out.split('\r\n') - for line in lines: - m =3D re.match(pid_reg, line) - if m: - pids.append(m.group(1)) - for pid in pids: - self.tester.alt_session.send_expect('kill -9 %s' % pid, '# ', = 20) + self.send_pks_session =3D None =20 def send_and_verify(self, dst_mac, testpmd): """ - Generates packets by pktgen + Generates packets and verify """ self.testpmd_reset_status(testpmd) =20 - self.pktgen_prerequisites() - # bind ports - self.tester_tx_port =3D self.tester.get_local_port(self.dut_ports[= 0]) - self.tester_tx_pci =3D self.tester.ports_info[self.tester_tx_port]= ['pci'] - port =3D self.tester.ports_info[self.tester_tx_port]['port'] - self.tester_port_driver =3D port.get_nic_driver() - self.tester.send_expect("./dpdk-devbind.py --force --bind=3Digb_ui= o %s" % self.tester_tx_pci, "#") - - src_mac =3D self.tester.get_mac(self.tester_tx_port)=20 + src_mac =3D self.tester.get_mac(self.tester_tx_port) if src_mac =3D=3D 'N/A': src_mac =3D "02:00:00:00:01" - - self.create_pcap_file(self.filename, dst_mac, src_mac) - - self.tester.send_expect("./pktgen -c 0x1f -n 2 --proc-type auto -= -socket-mem 128,128 --file-prefix pg -- -P -T -m '1.0' -s 0:%s" % self.file= name, "Pktgen >", 100) - time.sleep(1) - self.tester.send_expect("start all", "Pktgen>") + self.send_pkts(self.filename, dst_mac, src_mac) time.sleep(1) self.check_port_start_stop(testpmd) - # quit pktgen - self.tester.send_expect("stop all", "Pktgen>") - self.tester.send_expect("quit", "# ") + self.tester.send_expect('killall -s INT scapy', '# ') + self.tester.destroy_session(self.send_pks_session) + self.send_pks_session =3D None =20 - def create_pcap_file(self, filename, dst_mac, src_mac): + def send_pkts(self, filename, dst_mac, src_mac): """ Generates a valid PCAP file with the given configuration. """ @@ -118,6 +74,12 @@ class TestVfPortStartStop(TestCase): =20 wrpcap(filename, pkts) =20 + sendp_fmt =3D "sendp(pk, iface=3D'%s', loop=3D1)" % (self.tester_t= intf) + self.send_pks_session =3D self.tester.create_session("scapy1") + self.send_pks_session.send_expect("scapy", ">>>") + self.send_pks_session.send_expect("pk=3Drdpcap('%s')" % filename, = ">>>") + self.send_pks_session.send_command(sendp_fmt) + def testpmd_reset_status(self, testpmd): """ Reset testpmd :stop forward & stop port @@ -242,13 +204,9 @@ class= TestVfPortStartStop(TestCase): =20 def tear_down_all(self): =20 - self.pktgen_kill() - if getattr(self, 'tester_port_driver', None) and \ - getattr(self, 'tester_tx_pci', None): - self.tester.send_expect("./dpdk-devbind.py --bind=3D%s %s" \ - %(self.tester_port_driver, self.tester_tx_pci), "#") - tx_interface =3D self.tester.get_interface(self.tester_tx_port= ) - self.tester.send_expect("ifconfig %s up" % tx_interface, "#") + if self.send_pks_session: + self.tester.send_expect('killall -s INT scapy', '# ') + self.tester.destroy_session(self.send_pks_session) =20 if getattr(self, 'vm0', None): self.vm0.stop() -- 2.7.4