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 C3031A00E6 for ; Tue, 6 Aug 2019 04:52:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88D2B1B9A0; Tue, 6 Aug 2019 04:52:32 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 36CDC1B995 for ; Tue, 6 Aug 2019 04:52:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 19:52:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,352,1559545200"; d="scan'208";a="192561989" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 05 Aug 2019 19:52:29 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 5 Aug 2019 19:52:29 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 5 Aug 2019 19:52:28 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.139]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.65]) with mapi id 14.03.0439.000; Tue, 6 Aug 2019 10:52:26 +0800 From: "Peng, Yuan" To: "Zhao, MeijuanX" , "dts@dpdk.org" Thread-Topic: [dts][PATCH V1] tests/add new test suite softnic Thread-Index: AQHVSRCkm6DJh8JbEUSOHBCOWiS3UKbtccVw Date: Tue, 6 Aug 2019 02:52:26 +0000 Message-ID: <67D543A150B29E4CAAE53918F64EDAEA37740CD5@SHSMSX103.ccr.corp.intel.com> References: <20190802170013.13605-1-meijuanx.zhao@intel.com> In-Reply-To: <20190802170013.13605-1-meijuanx.zhao@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNmU5MTE3NzAtMzhkNi00ZjY0LTgyODgtODg2N2U5OTgzMTc2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTjJySnhycG5nQUFVWUgyM3lUUWpsRG5RZHBXajNxR0I2WnN6cGNJdzFLM0lCZWpWZFpXU3lzVG0yY0xiZGszdSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 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/add new test suite softnic 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: Peng, Yuan -----Original Message----- From: Zhao, MeijuanX=20 Sent: Saturday, August 3, 2019 1:00 AM To: dts@dpdk.org Cc: Peng, Yuan ; Zhao, MeijuanX Subject: [dts][PATCH V1] tests/add new test suite softnic Signed-off-by: zhaomeijuan --- tests/TestSuite_softnic.py | 226 +++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 tests/TestSuite_softnic.py diff --git a/tests/TestSuite_softnic.py b/tests/TestSuite_softnic.py new fi= le mode 100644 index 0000000..0cc3c92 --- /dev/null +++ b/tests/TestSuite_softnic.py @@ -0,0 +1,226 @@ +# BSD LICENSE +# +# Copyright(c) <2019> Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. +Test softnic API in DPDK. +""" + +import utils +import string +import re +import time +from settings import HEADER_SIZE +import os +from pktgen import PacketGeneratorHelper from test_case import TestCase=20 +from pmd_output import PmdOutput + + +class TestSoftnic(TestCase): + + def set_up_all(self): + + # Based on h/w type, choose how many ports to use + ports =3D self.dut.get_ports() + self.dut_ports =3D self.dut.get_ports(self.nic) + + # Verify that enough ports are available + self.verify(len(ports) >=3D 1, "Insufficient ports for testing") + + self.ports_socket =3D self.dut.get_numa_id(ports[0]) + # Verify that enough threads are available + cores =3D self.dut.get_core_list("1S/1C/1T") + self.verify(cores is not None, "Insufficient cores for speed testi= ng") + global P0 + P0 =3D ports[0] + + self.txItf =3D self.tester.get_interface(self.tester.get_local_por= t(P0)) + self.dmac =3D self.dut.get_mac_address(P0) + self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] +=20 + HEADER_SIZE['udp'] + =20 + # need change config files + self.root_path =3D "/tmp/" + self.firmware =3D r"dep/firmware.cli" + self.tm_firmware =3D r"dep/tm_firmware.cli" + self.nat_firmware =3D r"dep/nat_firmware.cli" + self.dut.session.copy_file_to(self.firmware, self.root_path) + self.dut.session.copy_file_to(self.tm_firmware, self.root_path) + self.dut.session.copy_file_to(self.nat_firmware, self.root_path) + self.cmd =3D "./%s/app/testpmd -c 0x7 -s 0x4 -n 4 --vdev 'net_soft= nic0,firmware=3D/tmp/%s,cpu_id=3D1,conn_port=3D8086' -- -i --forward-mode= =3Dsoftnic --portmask=3D0x2" + # get dts output path + if self.logger.log_path.startswith(os.sep): + self.output_path =3D self.logger.log_path + else: + cur_path =3D os.path.dirname( + os.path.dirname(os.path.realpath(__file__)= )) + self.output_path =3D os.sep.join([cur_path, self.logger.log_pa= th]) + # create an instance to set stream field setting + self.pktgen_helper =3D PacketGeneratorHelper() + self.dut.restore_interfaces() + self.used_dut_port =3D self.dut_ports[1] + self.host_intf =3D self.dut.ports_info[self.used_dut_port]['intf'] + out =3D self.dut.send_expect('ethtool %s' % self.host_intf, '#') + self.speed =3D re.findall('Supported link modes: (\d*)', out)[0] + self.dut.bind_interfaces_linux('igb_uio', [ports[0]]) + + def set_up(self): + """ + Run before each test case. + """ + def change_config_file(self, file_name): + self.dut.send_expect("sed -i -e '4c link LINK0 dev %s' %s" % (self= .dut.ports_info[0]['pci'], self.root_path+file_name), "#") + self.dut.send_expect("sed -i -e 's/thread [0-9]/thread 2/g' %s"=20 + % self.root_path+file_name, "#") + + def test_perf_softnic_performance(self): + self.frame_size =3D [64, 128, 256, 512, 1024, 1280, 1518] + self.change_config_file('firmware.cli') + # 10G nic pps(M) + expect_pps =3D [14, 8, 4, 2, 1, 0.9, 0.8] + =20 + self.dut.send_expect(self.cmd % (self.target, 'firmware.cli'), "te= stpmd>", timeout=3D300) + self.dut.send_expect("set fwd macswap", "testpmd>") + self.dut.send_expect("start", "testpmd>") + rx_port =3D self.tester.get_local_port(0) + tx_port =3D self.tester.get_local_port(0) + n =3D 0 + for frame in self.frame_size: + payload_size =3D frame - self.headers_size + tgen_input =3D [] + pcap =3D os.sep.join([self.output_path, "test.pcap"]) + pkt =3D "Ether(dst=3D'%s')/IP()/UDP()/Raw('x'*%d)" % (self.dma= c, payload_size) + self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, pkt)) + tgen_input.append((tx_port, rx_port, pcap)) + self.tester.scapy_execute() + # clear streams before add new streams + self.tester.pktgen.clear_streams() + # run packet generator + streams =3D self.pktgen_helper.prepare_stream_from_tginput(tge= n_input, 100, None, self.tester.pktgen) + _, pps =3D self.tester.pktgen.measure_throughput(stream_ids=3D= streams) + pps =3D pps / 1000000.0 + self.verify(pps > 0, 'No traffic detected') + self.verify(pps > expect_pps[n], 'No traffic detected') + n =3D n + 1 + + def test_perf_shaping_for_pipe(self): + self.change_config_file('tm_firmware.cli') + self.dut.send_expect(self.cmd % (self.target, 'tm_firmware.cli'), = "testpmd> ", timeout=3D800) + self.dut.send_expect("set fwd macswap", "testpmd>") + self.dut.send_expect("start", "testpmd>") + rx_port =3D self.tester.get_local_port(0) + pkts =3D ["Ether(dst=3D'%s')/IP(dst=3D'100.0.0.0')/UDP()/Raw('x'*(= 64 - %s))", "Ether(dst=3D'%s')/IP(dst=3D'100.0.15.255')/UDP()/Raw('x'*(64 -= %s))", "Ether(dst=3D'%s')/IP(dst=3D'100.0.4.0')/UDP()/Raw('x'*(64 - %s))"] + except_bps_range =3D [1700000, 2000000] + + for i in range(3): + tgen_input =3D [] + pcap =3D os.sep.join([self.output_path, "test.pcap"]) + pkt =3D pkts[i] % (self.dmac, self.headers_size) + self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, pkt= )) + tgen_input.append((rx_port, rx_port, pcap)) + if i =3D=3D 2: + vm_config =3D self.set_fields_ip() + else: + vm_config =3D self.set_fields() + self.tester.scapy_execute() + # clear streams before add new streams + self.tester.pktgen.clear_streams() + # run packet generator + streams =3D self.pktgen_helper.prepare_stream_from_tginput= (tgen_input, 100, vm_config, self.tester.pktgen) + bps, pps =3D self.tester.pktgen.measure_throughput(stream_= ids=3Dstreams) + if i =3D=3D 2: + self.verify(except_bps_range[1]*16 > bps > except_bps_= range[0]*16, 'No traffic detected') + else: + self.verify(except_bps_range[1] > bps >=20 + except_bps_range[0], 'No traffic detected') + + def test_nat(self): + self.change_config_file('nat_firmware.cli') + expect_ips =3D ['192.168.0.1.5000', '192.168.0.2.5001'] + ips =3D ['100.0.0.1', '100.0.0.2'] + pkt_location =3D ['src', 'dst'] + pkt_type =3D ['tcp', 'udp'] + for t in pkt_type: + for i in range(2): + self.dut.send_expect("sed -i -e '12c table action profile = AP0 ipv4 offset 270 fwd nat %s proto %s' %s" % (pkt_location[i], t, self.ro= ot_path + 'nat_firmware.cli'), "#") + self.dut.send_expect(self.cmd % (self.target, 'nat_firmwar= e.cli'), "testpmd>", timeout=3D60) + self.dut.send_expect("start", "testpmd>") + # src ip tcp + for j in range(2): + out =3D self.scapy_send_packet(pkt_location[i], ips[j]= , t) + self.verify(expect_ips[j] in out, 'fail to receive exp= ect packet') + self.dut.send_expect("quit", "# ") + time.sleep(1) + + def scapy_send_packet(self, pkt_location, ip, pkt_type): + self.tester.scapy_foreground() + pkt =3D "Ether(dst=3D'%s')/IP(dst=3D'%s')/" % (self.dmac, ip) + if pkt_type =3D=3D 'tcp': + pkt =3D pkt + "TCP()/Raw('x'*20)" + else: + pkt =3D pkt + "UDP()/Raw('x'*20)" + =20 + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (pkt, self.= txItf)) + self.start_tcpdump(self.txItf) + self.tester.scapy_execute() + out =3D self.get_tcpdump_package() + return out + + def get_tcpdump_package(self): + time.sleep(4) + self.tester.send_expect("killall tcpdump", "#") + out =3D self.tester.send_expect("tcpdump -A -nn -e -vv -r getPacka= geByTcpdump.cap |grep '192.168'", "#") + return out + + def start_tcpdump(self, rxItf): + self.tester.send_expect("rm -rf getPackageByTcpdump.cap", "#") + self.tester.send_expect("tcpdump -A -nn -e -vv -w getPackageByTcpd= ump.cap -i %s 2> /dev/null& " % self.txItf, "#") + time.sleep(4) + + def set_fields(self): + fields_config =3D { + 'ip': {'dst': {'range': 1, 'action': 'inc'}, }, } + return fields_config + + def set_fields_ip(self): + fields_config =3D { + 'ip': {'dst': {'range': 16, 'action': 'inc'}, }, } + return fields_config + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.send_expect('quit', '# ') + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.17.1