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 50B05A2EFC for ; Wed, 18 Sep 2019 07:37:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 468681BF8C; Wed, 18 Sep 2019 07:37:13 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 706B31BF8B for ; Wed, 18 Sep 2019 07:37:11 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 22:37:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="216824266" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 17 Sep 2019 22:37:10 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 22:37:10 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 22:37:09 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.140]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.23]) with mapi id 14.03.0439.000; Wed, 18 Sep 2019 13:37:08 +0800 From: "Peng, Yuan" To: "Han, YingyaX" , "dts@dpdk.org" Thread-Topic: [dts][PATCH V1]tests: add performance_thread test suite Thread-Index: AQHVY7LSBhrLNXtnokCJqkMeEN1M56cw/s0Q Date: Wed, 18 Sep 2019 05:37:08 +0000 Message-ID: <67D543A150B29E4CAAE53918F64EDAEA37760529@SHSMSX103.ccr.corp.intel.com> References: <20190905142601.25547-1-yingyax.han@intel.com> In-Reply-To: <20190905142601.25547-1-yingyax.han@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: add performance_thread test suite 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: Han, YingyaX=20 Sent: Thursday, September 5, 2019 10:26 PM To: dts@dpdk.org; Peng, Yuan Cc: Han, YingyaX Subject: [dts][PATCH V1]tests: add performance_thread test suite Signed-off-by: hanyingya --- conf/performance_thread.cfg | 4 + tests/TestSuite_performance_thread.py | 255 ++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 conf/performance_thread.cfg create mode 100644 tests/T= estSuite_performance_thread.py diff --git a/conf/performance_thread.cfg b/conf/performance_thread.cfg new = file mode 100644 index 0000000..2bc76ea --- /dev/null +++ b/conf/performance_thread.cfg @@ -0,0 +1,4 @@ +[suite] +# specify cores to test based on dut cpu specification. +frame_size=3D[64, 128, 256, 512, 1024, 2000] cores=3D[2, 4, 8, 16] diff --git a/tests/TestSuite_performance_thread.py b/tests/TestSuite_perfor= mance_thread.py new file mode 100644 index 0000000..4d4cfe0 --- /dev/null +++ b/tests/TestSuite_performance_thread.py @@ -0,0 +1,255 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 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. +Performance-Thread test script. +""" +import os +import string +import utils +from test_case import TestCase +from settings import HEADER_SIZE +from pktgen import PacketGeneratorHelper + + +class TestPerformanceThread(TestCase): + + def set_up_all(self): + """ + Run at the start of each test suite. + """ + self.tester.extend_external_packet_generator(TestPerformanceThread= , self) + self.dut_ports =3D self.dut.get_ports(self.nic) + global valports + valports =3D [_ for _ in self.dut_ports if=20 + self.tester.get_local_port(_) !=3D -1] + + # Verify that enough ports are available + self.verify(len(valports) >=3D 2, "Insufficent Ports") + + self.port_mask =3D utils.create_mask(valports) + self.socket =3D self.dut.get_numa_id(self.dut_ports[0]) + + self.frame_sizes =3D self.get_suite_cfg()["frame_size"] + self.nb_cores =3D self.get_suite_cfg()["cores"] + self.headers_size =3D HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEA= DER_SIZE['tcp'] + self.path =3D "examples/performance-thread/l3fwd-thread/build/l3fw= d-thread" + + # compile performance_thread app + out =3D self.dut.build_dpdk_apps("./examples/performance-thread/l3= fwd-thread") + self.verify("Error" not in out, "compilation error 1") + self.verify("No such file" not in out, "compilation error 2") + + # results table header + self.test_results =3D {'header': [], 'data': []} + + # 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() + + def set_up(self): + """ + Run before each test case. + """ + pass + + def flows(self): + """ + Return a list of packets that implements the flows described. + """ + return [ + 'IP(src=3D"1.2.3.4",dst=3D"192.18.1.0")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.1.1")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.0.0")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.0.1")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.3.0")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.3.1")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.2.0")', + 'IP(src=3D"1.2.3.4",dst=3D"192.18.2.1")'] + + def create_cores(self, cores): + + core_config =3D "1S/{}C/1T".format(cores) + core_list =3D self.dut.get_core_list(core_config, socket=3Dself.so= cket) + core_mask =3D utils.create_mask(core_list) + return core_list, core_mask + + def config_rx_tx(self, cores, core_list): + + # config --tx and --tx params for performace thread app + if cores =3D=3D 2: + rx =3D "({},{},{},{})".format(valports[0], 0, core_list[0], 0)= + "," + "({},{},{},{})".format(valports[1], 0, + = core_list[0], 0) + tx =3D "({},{})".format(core_list[1], 0) + elif cores =3D=3D 4: + rx =3D "({},{},{},{})".format(valports[0], 0, core_list[0], 0)= + "," + "({},{},{},{})".format(valports[1], 0, + = core_list[1], 1) + tx =3D "({},{})".format(core_list[2], 0) + "," + "({},{})".for= mat(core_list[3], 1) + elif cores =3D=3D 8: + rx =3D "({},{},{},{})".format(valports[0], 0, core_list[0], 0)= + "," + \ + "({},{},{},{})".format(valports[0], 1, core_list[1], 1) += "," + \ + "({},{},{},{})".format(valports[1], 0, core_list[2], 2) += "," + \ + "({},{},{},{})".format(valports[1], 1, core_list[3], 3) + tx =3D "({},{})".format(core_list[4], 0) + "," + "({},{})".for= mat(core_list[5], 1) + "," + \ + "({},{})".format(core_list[6], 2) + "," + "({},{})".forma= t(core_list[7], 3) + elif cores =3D=3D 16: + rx =3D "({},{},{},{})".format(valports[0], 0, core_list[0], 0)= + "," + \ + "({},{},{},{})".format(valports[0], 1, core_list[1], 1) += "," + \ + "({},{},{},{})".format(valports[0], 2, core_list[2], 2) += "," + \ + "({},{},{},{})".format(valports[0], 3, core_list[3], 3) += "," + \ + "({},{},{},{})".format(valports[1], 0, core_list[4], 4) += "," + \ + "({},{},{},{})".format(valports[1], 1, core_list[5], 5) += "," + \ + "({},{},{},{})".format(valports[1], 2, core_list[6], 6) += "," + \ + "({},{},{},{})".format(valports[1], 3, core_list[7], 7) + tx =3D "({},{})".format(core_list[8], 0) + "," + "({},{})".for= mat(core_list[9], 1) + "," + \ + "({},{})".format(core_list[10], 2) + "," + "({},{})".form= at(core_list[11], 3) + "," + \ + "({},{})".format(core_list[12], 4) + "," + "({},{})".form= at(core_list[13], 5) + "," + \ + "({},{})".format(core_list[14], 6) + "," +=20 + "({},{})".format(core_list[15], 7) + + lcore_config =3D "(%s-%s)@%s" % (core_list[0], core_list[-1], core= _list[0]) + return lcore_config, rx, tx + + def create_pacap_file(self, frame_size): + """ + Prepare traffic flow + """ + dmac =3D [self.dut.get_mac_address(self.dut_ports[i]) for i in val= ports] + smac =3D ["02:00:00:00:00:0%d" % i for i in valports] + payload_size =3D frame_size - HEADER_SIZE['ip'] - HEADER_SIZE['eth= '] + pcaps =3D {} + for _port in valports: + index =3D valports[_port] + cnt =3D 0 + for layer in self.flows()[_port * 2:(_port + 1) * 2]: + flow =3D ['Ether(dst=3D"%s", src=3D"%s")/%s/("X"*%d)' % (d= mac[index], smac[index], layer, payload_size)] + pcap =3D os.sep.join([self.output_path, "dst{0}_{1}.pcap".= format(index, cnt)]) + self.tester.scapy_append('wrpcap("%s", [%s])' % (pcap, str= ing.join(flow, ','))) + self.tester.scapy_execute() + if index not in pcaps: + pcaps[index] =3D [] + pcaps[index].append(pcap) + cnt +=3D 1 + return pcaps + + def prepare_stream(self, pcaps): + """ + create streams for ports,one port one stream + """ + tgen_input =3D [] + for rxPort in valports: + if rxPort % len(valports) =3D=3D 0 or len(valports) % rxPort = =3D=3D 2: + txIntf =3D self.tester.get_local_port(valports[rxPort + 1]= ) + port_id =3D valports[rxPort + 1] + else: + txIntf =3D self.tester.get_local_port(valports[rxPort - 1]= ) + port_id =3D valports[rxPort - 1] + rxIntf =3D self.tester.get_local_port(valports[rxPort]) + for pcap in pcaps[port_id]: + tgen_input.append((txIntf, rxIntf, pcap)) + return tgen_input + + def perf_test(self, params): + + # create result table + header_row =3D ["Frame size", "S/C/T", "Throughput(Mpps)", "Line R= ate(%)"] + self.test_results["header"] =3D header_row + self.result_table_create(header_row) + self.test_results["data"] =3D [] + + for cores in self.nb_cores: + core_list, core_mask =3D self.create_cores(cores) + lcore_config, rx, tx =3D self.config_rx_tx(cores, core_list) + if self.running_case is "test_perf_n_lcore_per_pcore": + cmdline =3D "{} -n 4 --lcores=3D'{}' {} --rx=3D'{}' --tx= =3D'{}'".format(self.path, lcore_config, params, rx, tx) + else: + cmdline =3D "{} -c {} {} --rx=3D'{}' --tx=3D'{}'".format(s= elf.path, core_mask, params, rx, tx) + self.dut.send_expect(cmdline, "L3FWD:", 120) + + for frame_size in self.frame_sizes: + pcaps =3D self.create_pacap_file(frame_size) + # send the traffic and Measure test + tgenInput =3D self.prepare_stream(pcaps) + + vm_config =3D self.set_fields() + # clear streams before add new streams + self.tester.pktgen.clear_streams() + # run packet generator + streams =3D self.pktgen_helper.prepare_stream_from_tginput= (tgenInput, 100, vm_config, self.tester.pktgen) + # set traffic option + traffic_opt =3D {'delay': 15} + _, pps =3D self.tester.pktgen.measure_throughput(stream_id= s=3Dstreams, options=3Dtraffic_opt) + self.verify(pps > 0, "No traffic detected") + pps /=3D 1000000.0 + linerate =3D self.wirespeed(self.nic, frame_size, len(valp= orts)) + percentage =3D pps * 100 / linerate + data_row =3D [frame_size, "1S/{}C/1T".format(cores), str(p= ps), str(percentage)] + self.result_table_add(data_row) + self.test_results["data"].append(data_row) + # stop application + self.dut.send_expect("^C", "# ", 15) + self.result_table_print() + + def test_perf_one_lcore_per_pcore(self): + params =3D "-n 4 -- -P -p {} --enable-jumbo --max-pkt-len=3D2500 -= -no-lthread" .format(self.port_mask) + self.perf_test(params) + + def test_perf_n_lthreads_per_pcore(self): + params =3D "-n 4 -- -P -p {} --enable-jumbo --max-pkt-len=3D2500" = .format(self.port_mask) + self.perf_test(params) + + def test_perf_n_lcore_per_pcore(self): + params =3D "-- -P -p {} --enable-jumbo --max-pkt-len 2500 --no-lth= read" .format(self.port_mask) + self.perf_test(params) + + def set_fields(self): + """ + set ip protocol field behavior + """ + fields_config =3D {'ip': {'src': {'action': 'random'}, }, } + return fields_config + + def tear_down(self): + """ + Run after each test case. + """ + self.dut.kill_all() + + def tear_down_all(self): + """ + Run after each test suite. + """ + pass -- 2.17.1