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 948D8A2EFC for ; Wed, 18 Sep 2019 07:06:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 870021BF2F; Wed, 18 Sep 2019 07:06:41 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 16A491BF2E for ; Wed, 18 Sep 2019 07:06:39 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 22:06:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="186361481" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga008.fm.intel.com with ESMTP; 17 Sep 2019 22:06:39 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 17 Sep 2019 22:06:38 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 17 Sep 2019 22:06:38 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 17 Sep 2019 22:06:38 -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 13:06:36 +0800 From: "Tu, Lijuan" To: "Han, YingyaX" , "dts@dpdk.org" CC: "Han, YingyaX" Thread-Topic: [dts] [PATCH V1]tests/nic_single_core: replace etgen with pktgen Thread-Index: AQHVYvS2wygsZMD1qku8WFafdW09o6cw97yA Date: Wed, 18 Sep 2019 05:06:36 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB23A61@SHSMSX101.ccr.corp.intel.com> References: <20190904154457.2774-1-yingyax.han@intel.com> In-Reply-To: <20190904154457.2774-1-yingyax.han@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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDgyNDJjMTUtYmE4ZS00MjE1LWE4ZjMtOGYxNzM5MDk3NzU3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieCtnNklvaTFmTWY5Q1wvTUhOQWFNUXpOaGwzcm1naVhNVElaT1IyRVwvTkZTN2FWVnJVckhYVjk5bFNlbGp4NGRqIn0= 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/nic_single_core: replace etgen with pktgen 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 hanyingya > Sent: Wednesday, September 4, 2019 11:45 PM > To: dts@dpdk.org > Cc: Han, YingyaX > Subject: [dts] [PATCH V1]tests/nic_single_core: replace etgen with pktgen >=20 > use the new pktgen API and change the configuration for flow. > fix pep8 issue. >=20 > Signed-off-by: hanyingya > --- > tests/TestSuite_nic_single_core_perf.py | 151 +++++++++++++++--------- > 1 file changed, 92 insertions(+), 59 deletions(-) >=20 > diff --git a/tests/TestSuite_nic_single_core_perf.py > b/tests/TestSuite_nic_single_core_perf.py > index 847a94c..6a22027 100644 > --- a/tests/TestSuite_nic_single_core_perf.py > +++ b/tests/TestSuite_nic_single_core_perf.py > @@ -35,16 +35,14 @@ DPDK Test suite. > import utils > import json > import os > -import re > -import time > +import string > from test_case import TestCase > -from time import sleep > from exception import VerifyFailure > from settings import HEADER_SIZE, UPDATE_EXPECTED, load_global_setting > from pmd_output import PmdOutput from copy import deepcopy -from > prettytable import PrettyTable import rst > +from pktgen import PacketGeneratorHelper >=20 >=20 > class TestNicSingleCorePerf(TestCase): > @@ -74,6 +72,16 @@ class TestNicSingleCorePerf(TestCase): > # determine if to save test result as a separated file > self.save_result_flag =3D True >=20 > + # 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() > + > def set_up(self): > """ > Run before each test case. > @@ -112,9 +120,60 @@ class TestNicSingleCorePerf(TestCase): > 'Expected Throughput', 'Throughput Differen= ce'] > self.test_result =3D {} >=20 > - def test_nic_single_core_perf(self): > + def flows(self): > + """ > + Return a list of packets that implements the flows described in = l3fwd. > + """ > + 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_pacap_file(self, frame_size): > + """ > + Prepare traffic flow > + """ > + payload_size =3D frame_size - HEADER_SIZE['ip'] - HEADER_SIZE['e= th'] > + pcaps =3D {} > + for _port in self.dut_ports: > + index =3D self.dut_ports[_port] > + cnt =3D 0 > + for layer in self.flows()[_port * 2:(_port + 1) * 2]: > + flow =3D ['Ether(src=3D"52:00:00:00:00:00")/%s/("X"*%d)'= % (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, > string.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 range(self.nb_ports): > + if rxPort % self.nb_ports =3D=3D 0 or self.nb_ports % rxPort= =3D=3D 2: > + txIntf =3D self.tester.get_local_port(self.dut_ports[rxP= ort + 1]) > + port_id =3D self.dut_ports[rxPort + 1] > + else: > + txIntf =3D self.tester.get_local_port(self.dut_ports[rxP= ort - 1]) > + port_id =3D self.dut_ports[rxPort - 1] > + rxIntf =3D self.tester.get_local_port(self.dut_ports[rxPort]= ) > + for pcap in pcaps[port_id]: > + tgen_input.append((txIntf, rxIntf, pcap)) > + return tgen_input > + > + def test_perf_nic_single_core(self): > """ > - Run nic single core performance > + Run nic single core performance > """ > self.nb_ports =3D len(self.dut_ports) > self.verify(self.nb_ports =3D=3D 2 or self.nb_ports =3D=3D 4, @@= -126,10 +185,8 > @@ class TestNicSingleCorePerf(TestCase): > try: > for frame_size in self.test_parameters.keys(): > for nb_desc in self.test_parameters[frame_size]: > - cur_gap =3D (self.expected_throughput[frame_size][nb= _desc] - > - self.throughput[frame_size][nb_desc]) > - self.verify(cur_gap < self.gap, > - "Beyond Gap, Possible regression") > + cur_gap =3D (self.expected_throughput[frame_size][nb= _desc] - > self.throughput[frame_size][nb_desc]) > + self.verify(cur_gap < self.gap, "Beyond Gap, > + Possible regression") > except Exception as e: > self.logger.error(e) > self.handle_expected() > @@ -146,7 +203,7 @@ class TestNicSingleCorePerf(TestCase): > for frame_size in self.test_parameters.keys(): > for nb_desc in self.test_parameters[frame_size]: > self.expected_throughput[frame_size][nb_desc] =3D \ > - round(self.throughput[frame_size][nb_desc],3) > + round(self.throughput[frame_size][nb_desc], 3) >=20 > def perf_test(self, port_num): > """ > @@ -171,6 +228,8 @@ class TestNicSingleCorePerf(TestCase): >=20 > for frame_size in self.test_parameters.keys(): > self.throughput[frame_size] =3D dict() > + pcaps =3D self.create_pacap_file(frame_size) > + tgenInput =3D self.prepare_stream(pcaps) > for nb_desc in self.test_parameters[frame_size]: > self.logger.info("Test running at parameters: " + > "framesize: {}, rxd/txd: {}".format(frame_size, nb_d= esc)) @@ - > 179,10 +238,17 @@ class TestNicSingleCorePerf(TestCase): > core_config, parameter, eal_para, socket =3D self.so= cket) > self.dut.send_expect("start", "testpmd> ", 15) >=20 > - # measure throughput > - stream_ids =3D self.prepare_stream(frame_size) > - _, packets_received =3D self.tester.pktgen.measure_throu= ghput( > - stream_ids =3D stream_ids, delay =3D self.test_durat= ion) > + 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': 30} > + # _, pps =3D self.tester.traffic_generator_throughput(tg= enInput, > rate_percent=3D100, delay=3D30) > + _, packets_received =3D > self.tester.pktgen.measure_throughput(stream_ids=3Dstreams, > options=3Dtraffic_opt) > + self.verify(packets_received > 0, "No traffic > + detected") > throughput =3D packets_received / 1000000.0 > self.throughput[frame_size][nb_desc] =3D throughput >=20 > @@ -243,46 +309,6 @@ class TestNicSingleCorePerf(TestCase): > if self.save_result_flag: > self.save_result(self.test_result) >=20 > - def prepare_stream(self, frame_size): > - ''' > - create streams for ports, one port two streams, and configure th= em. > - ''' > - # traffic option > - options =3D { > - 'rate': '100%', > - } > - > - # create pcap file > - payload_size =3D frame_size - self.headers_size > - self.tester.scapy_append( > - 'wrpcap("/tmp/test0.pcap", > [Ether(src=3D"52:00:00:00:00:00")/IP(src=3D"1.2.3.4",dst=3D"1.1.1.1")/("X= "*%d)])' % > payload_size) > - self.tester.scapy_append( > - 'wrpcap("/tmp/test1.pcap", > [Ether(src=3D"52:00:00:00:00:00")/IP(src=3D"2.2.3.4",dst=3D"1.1.1.1")/("X= "*%d)])' % > payload_size) > - self.tester.scapy_execute() > - > - stream_ids =3D [] > - for i in range(self.nb_ports): > - if i % 2 =3D=3D 0: > - txport =3D self.tester.get_local_port(self.dut.get_ports= ()[i]) > - rxport =3D self.tester.get_local_port( > - self.dut.get_ports()[i + 1]) > - > - # fortville requires 2 streams for 2 queues at least, an= d > - # this's fine for other NIC too. > - for k in range(2): > - # txport -> rxport > - stream_id =3D self.tester.pktgen.add_stream( > - txport, rxport, '/tmp/test{}.pcap'.format(k)) > - self.tester.pktgen.config_stream(stream_id, options) > - stream_ids.append(stream_id) > - # rxport -> txport > - stream_id =3D self.tester.pktgen.add_stream( > - rxport, txport, '/tmp/test{}.pcap'.format(k)) > - self.tester.pktgen.config_stream(stream_id, options) > - stream_ids.append(stream_id) > - > - return stream_ids > - > def save_result(self, data): > ''' > Saves the test results as a separated file named with @@ -298,9 = +324,9 > @@ class TestNicSingleCorePerf(TestCase): > row_dict =3D dict() > row_dict['parameters'] =3D dict() > row_dict['parameters']['frame_size'] =3D dict( > - value =3D row_in['Frame Size'], unit =3D 'bytes') > + value=3Drow_in['Frame Size'], unit=3D'bytes') > row_dict['parameters']['txd/rxd'] =3D dict( > - value =3D row_in['TXD/RXD'], unit =3D 'descriptors') > + value=3Drow_in['TXD/RXD'], unit=3D'descriptors') > delta =3D (float(row_in['Throughput'].split()[0]) - > float(row_in['Expected Throughput'].split()[0])= ) > if delta >=3D -self.gap: > @@ -308,14 +334,21 @@ class TestNicSingleCorePerf(TestCase): > else: > result =3D 'FAIL' > row_dict['throughput'] =3D dict( > - delta =3D delta, unit =3D row_in['Throughput'].split= ()[1], > - result =3D result) > + delta=3Ddelta, unit=3Drow_in['Throughput'].split()[1= ], > + result=3Dresult) > json_obj['results'].append(row_dict) > with open(os.path.join(rst.path2Result, > '{0:s}_single_core_perf.json'.format( > self.nic)), 'w') as fp: > json.dump(json_obj, fp) >=20 > + 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. > -- > 2.17.1