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 B7A28A00E6 for ; Wed, 7 Aug 2019 05:19:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB55634F0; Wed, 7 Aug 2019 05:19:24 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 304B22C16 for ; Wed, 7 Aug 2019 05:19:23 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Aug 2019 20:19:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,356,1559545200"; d="scan'208";a="374261362" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 06 Aug 2019 20:19:22 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 6 Aug 2019 20:19:22 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 6 Aug 2019 20:19:21 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.80]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.250]) with mapi id 14.03.0439.000; Wed, 7 Aug 2019 11:19:19 +0800 From: "Tu, Lijuan" To: "Zhao, MeijuanX" , "dts@dpdk.org" CC: "Peng, Yuan" , "Zhao, MeijuanX" Thread-Topic: [dts] [PATCH V1] tests/add new test suite softnic Thread-Index: AQHVSRCuC8eiPCR0wkC9LgzpxWC9J6bvC6aQ Date: Wed, 7 Aug 2019 03:19:19 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BAFEBB6@SHSMSX101.ccr.corp.intel.com> References: <20190802170013.13605-1-meijuanx.zhao@intel.com> In-Reply-To: <20190802170013.13605-1-meijuanx.zhao@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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDMyNzQyNWItNDg5MC00Njc2LThlOTctNGZhMDc2OTIwOWU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidlJTV21nTTlmSHZlaVVTc21ycTVmVXJqdHZrWXdWYmhGQ1BVdlFPcGtDMHBSZ1RBZG1hYThuVXNTUm9UTWNWUyJ9 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" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhaomeijuan > 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 >=20 > Signed-off-by: zhaomeijuan > --- > tests/TestSuite_softnic.py | 226 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 226 insertions(+) > create mode 100644 tests/TestSuite_softnic.py >=20 > diff --git a/tests/TestSuite_softnic.py b/tests/TestSuite_softnic.py new = file > 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 # > +modification, are permitted provided that the following conditions # > +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 # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS > FOR # > +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT # > +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, # > +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > # > +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > USE, # > +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY # > +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE > USE # > +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 > +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 tes= ting") > + global P0 > + P0 =3D ports[0] > + > + self.txItf =3D self.tester.get_interface(self.tester.get_local_p= ort(P0)) > + self.dmac =3D self.dut.get_mac_address(P0) > + self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + > + HEADER_SIZE['udp'] > + > + # 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_softnic0,firmware=3D/tmp/%s,cpu_id=3D1,conn_port=3D8086' -- -i --for= ward- > 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_= path]) > + # 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" > + % 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] > + > + self.dut.send_expect(self.cmd % (self.target, 'firmware.cli'), "= testpmd>", > 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.d= mac, > 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(tgen_input, 100, None, > self.tester.pktgen) > + _, pps =3D self.tester.pktgen.measure_throughput(stream_ids= =3Dstreams) > + 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, p= kt)) > + 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 > > + 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 profil= e AP0 ipv4 > offset 270 fwd nat %s proto %s' %s" % (pkt_location[i], t, self.root_path= + > 'nat_firmware.cli'), "#") > + self.dut.send_expect(self.cmd % (self.target, 'nat_firmw= are.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 e= xpect 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)" > + > + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % (pkt, sel= f.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 > getPackageByTcpdump.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 > getPackageByTcpdump.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