From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 74C05A046B for ; Wed, 26 Jun 2019 10:28:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68A7B44BE; Wed, 26 Jun 2019 10:28:01 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 2930A25D9 for ; Wed, 26 Jun 2019 10:27:59 +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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 01:27:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,419,1557212400"; d="scan'208";a="360671459" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 26 Jun 2019 01:27:58 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 26 Jun 2019 01:27:58 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 26 Jun 2019 01:27:57 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.87]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.225]) with mapi id 14.03.0439.000; Wed, 26 Jun 2019 16:27:55 +0800 From: "Tu, Lijuan" To: "Han, YingyaX" , "dts@dpdk.org" CC: "Han, YingyaX" Thread-Topic: [dts] [PATCH V1]tests/l3fwd: l3fwd script refactoring Thread-Index: AQHVJzVFizbovIhIBE++0EjX+IfS06ato33A Date: Wed, 26 Jun 2019 08:27:54 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BAC52B4@SHSMSX101.ccr.corp.intel.com> References: <20190620145621.43712-1-yingyax.han@intel.com> In-Reply-To: <20190620145621.43712-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.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWVhNDAwY2YtNjJkYy00ODFjLWIyNGItOGIxMjE2OTIxMjYxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiV1FxWGRPWXBsNHBzRE5tV3dSYUF1OVpSSjNBYll1QlpTc0QwMXFZTUswVHNPNFFobmhcL2NsOHVValFqN3hxVm8ifQ== 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/l3fwd: l3fwd script refactoring 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" Could you please rework your patch, maybe the code baseline changed. Applying: tests/l3fwd: l3fwd script refactoring error: patch failed: tests/TestSuite_l3fwd.py:1 error: tests/TestSuite_l3fwd.py: patch does not apply Patch failed at 0001 tests/l3fwd: l3fwd script refactoring > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of hanyingya > Sent: Thursday, June 20, 2019 10:56 PM > To: dts@dpdk.org > Cc: Han, YingyaX > Subject: [dts] [PATCH V1]tests/l3fwd: l3fwd script refactoring >=20 > Signed-off-by: hanyingya > --- > tests/TestSuite_l3fwd.py | 535 +++++++++++++++++++++------------------ > 1 file changed, 284 insertions(+), 251 deletions(-) >=20 > diff --git a/tests/TestSuite_l3fwd.py b/tests/TestSuite_l3fwd.py index > 78eaee7..8e4e23e 100644 > --- a/tests/TestSuite_l3fwd.py > +++ b/tests/TestSuite_l3fwd.py > @@ -1,6 +1,6 @@ > # BSD LICENSE > # > -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > +# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. > # All rights reserved. > # > # Redistribution and use in source and binary forms, with or without @@ = - > 36,42 +36,32 @@ Layer-3 forwarding test script. >=20 > import utils > import string > +import time > import re > +import os > from test_case import TestCase > from exception import VerifyFailure > from settings import HEADER_SIZE > from etgen import IxiaPacketGenerator >=20 > -class TestL3fwd(TestCase,IxiaPacketGenerator): >=20 > - path =3D "./examples/l3fwd/build/" > +class TestL3fwd(TestCase, IxiaPacketGenerator): >=20 > - test_cases_2_ports =3D [(1,"1S/1C/1T","%s -c %s -n %d -- -P -p %s -= -config > '(P0,0,C{1.1.0}), (P1,0,C{1.1.0})'"), > - #"1S/1C/2T": "%s -c %s -n %d -- -p %s --confi= g '(P0,0,C{1.1.0}), > (P1,0,C{1.1.1})'", > - (1,"1S/2C/1T","%s -c %s -n %d -- -P -p %s --c= onfig > '(P0,0,C{1.1.0}), (P1,0,C{1.2.0})'"), > - (1,"1S/4C/1T", "%s -c %s -n %d -- -p %s --con= fig > '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}),(P0,1,C{1.3.0}), (P1,1,C{1.4.0})'"), > - #"2S/2C/1T": "%s -c %s -n %d -- -p %s --confi= g '(P0,0,C{0.1.0}), > (P1,0,C{0.2.0}),(P0,1,C{1.3.0}), (P1,1,C{1.4.0})'", > - ] > - > - test_cases_4_ports =3D [(1, "1S/1C/1T", > - "%s -c %s -n %d -- -P -p %s --config > '(P0,0,C{1.1.0}),(P1,0,C{1.1.0}),(P2,0,C{1.1.0}),(P3,0,C{1.1.0})'"), > - #(1, "1S/2C/2T", > - # "%s -c %s -n %d -- -p %s --config > '(P0,0,C{1.1.0}),(P1,0,C{1.1.1}),(P2,0,C{1.2.0}),(P3,0,C{1.2.1})'"), > - (1, "1S/4C/1T", > - "%s -c %s -n %d -- -P -p %s --config > '(P0,0,C{1.1.0}),(P1,0,C{1.2.0}),(P2,0,C{1.3.0}),(P3,0,C{1.4.0})'"), > - #(2, "1S/8C/1T", > - #"%s -c %s -n %d -- -p %s --config > '(P0,0,C{1.1.0}),(P0,1,C{1.2.0}),(P1,0,C{1.3.0}),(P1,1,C{1.4.0}),(P2,0,C{= 1.5.0}),(P2,1 > ,C{1.6.0}),(P3,0,C{1.7.0}),(P3,1,C{1.8.0})'"), > - #(2, "2S/2C/1T", > - # "%s -c %s -n %d -- -p %s --config > '(P0,0,C{1.1.0}),(P1,0,C{1.2.0}),(P2,0,C{0.3.0}),(P3,0,C{0.4.0})'"), > - ] > - > - queues_4_ports =3D [] > - > - for case in test_cases_4_ports: > - if case[0] * 4 not in queues_4_ports: > - queues_4_ports.append(case[0] * 4) > - > - host_table =3D [ > + path =3D "./examples/l3fwd/build/" > + cmdline_2_ports =3D { > + "1S/1C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.1.0})'", > + "1S/1C/2T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.1.1})'", > + "1S/2C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.2.0})'", > + "1S/4C/1T": "%s -c %s -n %d -- -p %s -P --config > + '(P0,0,C{1.1.0}), (P1,0,C{1.2.0}), (P0,1,C{1.3.0}), (P1,1,C{1.4.0})'"} > + > + cmdline_4_ports =3D { > + "1S/1C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.1.0}), (P2,0,C{1.1.0}), (P3,0,C{1.1.0})'", > + "1S/2C/2T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.1.1}), (P2,0,C{1.2.0}), (P3,0,C{1.2.1})'", > + "1S/4C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.2.0}), (P2,1,C{1.3.0}), (P3,1,C{1.4.0})'", > + "1S/8C/1T": "%s -c %s -n %d -- -p %s -P --config '(P0,0,C{1.1.0}= ), > (P1,0,C{1.2.0}), (P2,0,C{1.3.0}), (P3,0,C{1,4,0}),\ > + (P0,1,C{1.5.0}), (P1,1,C{1.6.0}), (P2,1,C{1.7.0}), > + (P3,1,C{1,8,0})'"} > + > + ipv4_em_table =3D [ > "{{IPv4(10,100,0,1), IPv4(1,2,3,4), 1, 10, IPPROTO_UDP}, P0}", > "{{IPv4(10,101,0,1), IPv4(1,2,3,4), 1, 10, IPPROTO_UDP}, P0}", > "{{IPv4(11,100,0,1), IPv4(1,2,3,4), 1, 11, IPPROTO_UDP}, P1}", @= @ -82,7 > +72,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator): > "{{IPv4(13,101,0,1), IPv4(1,2,3,4), 1, 13, IPPROTO_UDP}, P3}", > ] >=20 > - lpm_table =3D [ > + ipv4_lpm_table =3D [ > "{IPv4(10,100,0,0), 24, P0}", > "{IPv4(10,101,0,0), 24, P0}", > "{IPv4(11,100,0,0), 24, P1}", > @@ -93,125 +83,130 @@ class TestL3fwd(TestCase,IxiaPacketGenerator): > "{IPv4(13,101,0,0), 24, P3}", > ] >=20 > - frame_sizes =3D [64, 72, 128, 256, 512, 1024, 1518, 2048] # 65, 128 > - > - methods =3D ['lpm']#, 'exact'] > - > - # > - # > - # Utility methods and other non-test code. > - # > - # Insert or move non-test functions here. > - def portRepl(self, match): > - """ > - Function to replace P([0123]) pattern in tables > - """ > - > - portid =3D match.group(1) > - self.verify(int(portid) in range(4), "invalid port id") > - if int(portid) >=3D len(valports): > - return '0' > - else: > - return '%s' % valports[int(portid)] > + ipv6_em_table =3D [ > + "{{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, = 0x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x02, > 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 10, IPPROTO_UDP}, P0}", > + "{{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, = 0x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x02, > 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 10, IPPROTO_UDP}, P0}", > + "{{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, = 0x21, > 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x00, > 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 11, IPPROTO_UDP}, P1}= ", > + "{{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, = 0x21, > 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x00, > 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 11, IPPROTO_UDP}, P1}= ", > + "{{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, = 0x21, > 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x00, > 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 12, IPPROTO_UDP}, P2}= ", > + "{{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, = 0x21, > 0xff, 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x00, > 0x02, 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 12, IPPROTO_UDP}, P2}= ", > + "{{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, = 0x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x02, > 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 13, IPPROTO_UDP}, P3}", > + "{{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1b, = 0x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, {0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,= 0x02, > 0x1e, 0x67, 0xff, 0xfe, 0x0d, 0xb6, 0x0a}, 1, 13, IPPROTO_UDP}, P3}", > + ] >=20 > - # > - # Test cases. > - # > + ipv6_lpm_table =3D [ > + "{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P0}", > + "{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P0}", > + "{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P1}", > + "{{0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P1}", > + "{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P2}", > + "{{0x2b, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P2}", > + "{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P3}", > + "{{0x2c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1b, 0= x21, 0xff, > 0xfe, 0x91, 0x38, 0x05}, 64,P3}", > + ] >=20 > def set_up_all(self): > """ > Run at the start of each test suite. > - > - > L3fwd Prerequisites > """ > + self.tester.extend_external_packet_generator(TestL3fwd, self) > # Based on h/w type, choose how many ports to use > - ports =3D self.dut.get_ports(socket=3D1) > - if not ports: > - ports =3D self.dut.get_ports(socket=3D0) > + self.dut_ports =3D self.dut.get_ports(self.nic) > + global valports > + valports =3D [_ for _ in self.dut_ports if > + self.tester.get_local_port(_) !=3D -1] >=20 > - self.tester.extend_external_packet_generator(TestL3fwd, self) > # Verify that enough ports are available > - self.verify(len(ports) >=3D 2, "Insufficient ports for speed tes= ting") > - > - netdev =3D self.dut.ports_info[ports[0]]['port'] > - > - self.port_socket =3D netdev.socket > - if self.port_socket =3D=3D -1: > - self.port_socket =3D 0 > - > - > - # Verify that enough threads are available > - cores =3D self.dut.get_core_list("1S/4C/1T") > - self.verify(cores is not None, "Insufficient cores for speed tes= ting") > + self.verify(len(valports) =3D=3D 2 or len(valports) =3D=3D 4, "P= ort > + number must be 2 or 4.") >=20 > - global valports > - valports =3D [_ for _ in ports if self.tester.get_local_port(_) = !=3D -1] > - > - self.verify(len(valports) >=3D 2, "Insufficient active ports for= speed testing") > + # get socket and cores > + self.socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.cores =3D self.dut.get_core_list("1S/8C/1T", socket=3Dself.= socket) > + self.verify(self.cores is not None, "Insufficient cores for > + speed testing") > + > + # self.frame_sizes =3D [64, 128, 256, 512, 1024, 1518] # 65, 12= 8 > + self.frame_sizes =3D [64, 128] >=20 > - pat =3D re.compile("P([0123])") > # Update config file and rebuild to get best perf on FVL > - self.dut.send_expect("sed -i -e > 's/CONFIG_RTE_PCI_CONFIG=3Dn/CONFIG_RTE_PCI_CONFIG=3Dy/' ./config/comm > on_base", "#", 20) > - self.dut.send_expect("sed -i -e > 's/CONFIG_RTE_PCI_EXTENDED_TAG=3D.*$/CONFIG_RTE_PCI_EXTENDED_TAG=3D > \"on\"/' ./config/common_base", "#", 20) > - self.dut.send_expect("sed -i -e 's/define > RTE_TEST_RX_DESC_DEFAULT.*$/define RTE_TEST_RX_DESC_DEFAULT > 2048/' ./examples/l3fwd/main.c", "#", 20) > - self.dut.send_expect("sed -i -e 's/define > RTE_TEST_TX_DESC_DEFAULT.*$/define RTE_TEST_TX_DESC_DEFAULT > 2048/' ./examples/l3fwd/main.c", "#", 20) > - self.dut.build_install_dpdk(self.target) > - > - # Prepare long prefix match table, replace P(x) port pattern > - lpmStr =3D "static struct ipv4_l3fwd_lpm_route > ipv4_l3fwd_lpm_route_array[] =3D {\\\n" > - for idx in range(len(TestL3fwd.lpm_table)): > - TestL3fwd.lpm_table[idx] =3D pat.sub(self.portRepl, > TestL3fwd.lpm_table[idx]) > - lpmStr =3D lpmStr + ' ' * 4 + TestL3fwd.lpm_table[idx] + ",\= \\n" > - lpmStr =3D lpmStr + "};" > - self.logger.debug(lpmStr) > - > - # Prepare host route table, replace P(x) port pattern > - exactStr =3D "static struct ipv4_l3fwd_em_route > ipv4_l3fwd_em_route_array[] =3D {\\\n" > - for idx in range(len(TestL3fwd.host_table)): > - TestL3fwd.host_table[idx] =3D pat.sub(self.portRepl, > TestL3fwd.host_table[idx]) > - exactStr =3D exactStr + ' ' * 4 + TestL3fwd.host_table[idx] = + ",\\\n" > - exactStr =3D exactStr + "};" > - self.logger.debug(exactStr) > - > - # Compile l3fwd with LPM lookup. > - self.dut.send_expect(r"sed -i > '/ipv4_l3fwd_lpm_route_array\[\].*{/,/^\}\;/c\\%s' > examples/l3fwd/l3fwd_lpm.c" % lpmStr, "# ") > - out =3D self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS= =3D- > DAPP_LOOKUP_METHOD=3D1") > - self.verify("Error" not in out, "compilation error 1") > - self.verify("No such file" not in out, "compilation error 2") > + if self.nic in ["fortville_sprit", "fortville_eagle", "fortville= _25g"]: > + self.dut.send_expect("sed -i -e > 's/CONFIG_RTE_LIBRTE_I40E_16BYTE_RX_DESC=3Dn/CONFIG_RTE_LIBRTE_" > + "I40E_16BYTE_RX_DESC=3Dy/' ./config/com= mon_base", "#", > 20) > + self.dut.build_install_dpdk(self.target) > + > + self.logger.info("Configure RX/TX descriptor to 2048, and re- > build ./examples/l3fwd") > + self.dut.send_expect("sed -i -e 's/define > RTE_TEST_RX_DESC_DEFAULT.*$/" > + + "define RTE_TEST_RX_DESC_DEFAULT > 2048/' ./examples/l3fwd/main.c", "#", 20) > + self.dut.send_expect("sed -i -e 's/define > RTE_TEST_TX_DESC_DEFAULT.*$/" > + + "define RTE_TEST_TX_DESC_DEFAULT > 2048/' ./examples/l3fwd/main.c", "#", 20) > + self.method_table =3D {"ipv4_l3fwd_lpm": TestL3fwd.ipv4_lpm_tabl= e, > "ipv4_l3fwd_em": TestL3fwd.ipv4_em_table, > + "ipv6_l3fwd_lpm": > + TestL3fwd.ipv6_lpm_table, "ipv6_l3fwd_em": TestL3fwd.ipv6_em_table} > + > + self.pat =3D re.compile("P([0123])") > + self.test_results =3D {'header': [], 'data': []} >=20 > - # Backup the LPM exe and clean up the build. > - self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd > examples/l3fwd/build/l3fwd_lpm", "# ") > - out =3D self.dut.send_expect("make clean -C examples/l3fwd", "# = ") > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass >=20 > - # Compile l3fwd with hash/exact lookup. > - self.dut.send_expect(r"sed -i -e > '/ipv4_l3fwd_em_route_array\[\].*{/,/^\}\;/c\\%s' > examples/l3fwd/l3fwd_em.c" % exactStr, "# ") > - out =3D self.dut.build_dpdk_apps("./examples/l3fwd", "USER_FLAGS= =3D- > DAPP_LOOKUP_METHOD=3D0") > + def portRepl(self, match): > + """ > + Function to replace P([0123]) pattern in tables > + """ > + portid =3D match.group(1) > + self.verify(int(portid) in range(4), "invalid port id") > + if int(portid) >=3D len(valports): > + return '0' > + else: > + return '%s' % valports[int(portid)] >=20 > + def install_l3fwd_application(self, l3_proto, mode): > + """ > + Prepare long prefix match table, replace P(x) port pattern > + """ > + l3fwd_method =3D l3_proto + "_l3fwd_" + mode > + l3fwdStr =3D "static struct %s_route %s_route_array[] =3D {\\\n"= % > (l3fwd_method, l3fwd_method) > + for idx in range(len(self.method_table[l3fwd_method])): > + self.method_table[l3fwd_method][idx] =3D self.pat.sub(self.p= ortRepl, > self.method_table[l3fwd_method][idx]) > + l3fwdStr =3D l3fwdStr + '' * 4 + self.method_table[l3fwd_met= hod][idx] + > ",\\\n" > + l3fwdStr =3D l3fwdStr + "};" > + self.dut.send_expect(r"sed -i '/%s_route_array\[\].*{/,/^\}\;/c\= \%s' > examples/l3fwd/l3fwd_%s.c" > + % (l3fwd_method, l3fwdStr, mode), "# ") > + self.dut.send_expect("make clean -C examples/l3fwd", "# ") > + if "lpm" in l3fwd_method: > + out =3D self.dut.build_dpdk_apps("./examples/l3fwd", "USER_F= LAGS=3D- > DAPP_LOOKUP_METHOD=3D1") > + elif "em" in l3fwd_method: > + out =3D self.dut.build_dpdk_apps("./examples/l3fwd", > + "USER_FLAGS=3D-DAPP_LOOKUP_METHOD=3D0") > self.verify("Error" not in out, "compilation error 1") > self.verify("No such file" not in out, "compilation error 2") >=20 > - # Backup the Hash/Exact exe. > - self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd > examples/l3fwd/build/l3fwd_exact", "# ") > - > - self.l3fwd_test_results =3D {'header': [], > - 'data': []} > + # Backup the l3fwd exe. > + self.dut.send_expect("mv -f examples/l3fwd/build/l3fwd > + examples/l3fwd/build/%s" % l3fwd_method, "# ") >=20 > def flows(self): > """ > Return a list of packets that implements the flows described in = the > l3fwd test plan. > - > - """ > - return [ > - 'IP(src=3D"1.2.3.4",dst=3D"11.100.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"11.101.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"10.100.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"10.101.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"13.100.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"13.101.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"12.100.0.1")', > - 'IP(src=3D"1.2.3.4",dst=3D"12.101.0.1")'] > + """ > + return {"ipv4": ['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")'], > + "ipv6": [ > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"fe80:0000:00= 00:000 > 0:021b:21ff:fe91:3805")/UDP(sport=3D10,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"fe80:0000:00= 00:000 > 0:031b:21ff:fe91:3805")/UDP(sport=3D10,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2a80:0000:00= 00:00 > 00:021b:21ff:fe91:3805")/UDP(sport=3D11,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2a80:0000:00= 00:00 > 00:031b:21ff:fe91:3805")/UDP(sport=3D11,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2b80:0000:00= 00:00 > 00:021b:21ff:fe91:3805")/UDP(sport=3D12,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2b80:0000:00= 00:00 > 00:031b:21ff:fe91:3805")/UDP(sport=3D12,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2c80:0000:00= 00:000 > 0:021b:21ff:fe91:3805")/UDP(sport=3D13,dport=3D1)', > + > 'IPv6(src=3D"fe80:0000:0000:0000:021e:67ff:fe0d:b60a",dst=3D"2c80:0000:00= 00:000 > 0:031b:21ff:fe91:3805")/UDP(sport=3D13,dport=3D1)' > + ]} >=20 > def repl(self, match): > pid =3D match.group(1) > @@ -222,141 +217,179 @@ class TestL3fwd(TestCase,IxiaPacketGenerator): >=20 > global corelist > corelist.append(int(lcid)) > - > self.verify(int(pid) in range(4), "invalid port id") > self.verify(lcid, "invalid thread id") > - > return '%s,%s,%s' % (str(valports[int(pid)]), qid, lcid) >=20 > - def set_up(self): > + def perpare_commandline(self, ports): > """ > - Run before each test case. > + Generate the command line based on the number of ports > """ > - pass > - > - def test_perf_rfc2544(self): > - > - ports =3D self.dut.get_ports() > - ports_num =3D len(ports) > - header_row =3D ["Frame_size(byte)", "mode", "S/C/T", > "zero_loss_throughput(Mpps)", " % zero_loss_rate"]# "LR_tx_pkts(1min)", > "LR_rx_pkts(1min)", "LR_loss_pkts(1min)", "% zero_loss_rate", > "zero_loss_throughput(Mpps)"] > - self.l3fwd_test_results['header'] =3D header_row > + global corelist > + pat =3D re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})") > + core_mask =3D {} > + if ports =3D=3D 2: > + rtCmdLines =3D dict(TestL3fwd.cmdline_2_ports) > + elif ports =3D=3D 4: > + rtCmdLines =3D dict(TestL3fwd.cmdline_4_ports) > + > + for key in rtCmdLines.keys(): > + corelist =3D [] > + while pat.search(rtCmdLines[key]): > + print rtCmdLines[key] > + rtCmdLines[key] =3D pat.sub(self.repl, rtCmdLines[key]) > + core_mask[key] =3D utils.create_mask(set(corelist)) > + return rtCmdLines, core_mask > + > + def create_pcap_file(self, frame_size, l3_proto): > + """ > + Prepare traffic flow for packet generator > + """ > + if l3_proto =3D=3D 'ipv4': > + payload_size =3D frame_size - HEADER_SIZE['eth'] - HEADER_SI= ZE['ip'] - > HEADER_SIZE['udp'] > + else: > + # l3_proto =3D=3D 'ipv6' > + payload_size =3D frame_size - HEADER_SIZE['eth'] - HEADER_SI= ZE['ipv6'] > - HEADER_SIZE['udp'] > + if frame_size =3D=3D 64: > + payload_size =3D frame_size + 2 - HEADER_SIZE['eth'] - > + HEADER_SIZE['ipv6'] - HEADER_SIZE['udp'] > + > + for _port in valports: > + dmac =3D self.dut.get_mac_address(valports[_port]) > + layer3s =3D self.flows()[l3_proto][_port * 2:(_port + 1) * 2= ] > + for l3 in layer3s: > + flow =3D ['Ether(dst=3D"%s")/%s/UDP()/("X"*%d)' % (dmac,= l3, > payload_size)] > + self.tester.scapy_append('wrpcap("dst%d.pcap", [%s])' % > (valports[_port], string.join(flow, ','))) > + self.tester.scapy_execute() > + > + def prepare_steam(self): > + """ > + create streams for ports, one port one stream > + """ > + tgen_input =3D [] > + for rxPort in valports: > + if rxPort % len(valports) =3D=3D 0 or rxPort % len(valports)= =3D=3D 2: > + txIntf =3D self.tester.get_local_port(valports[rxPort + = 1]) > + rxIntf =3D self.tester.get_local_port(valports[rxPort]) > + tgen_input.append((txIntf, rxIntf, "dst%d.pcap" % valpor= ts[rxPort > + 1])) > + elif rxPort % len(valports) =3D=3D 1 or rxPort % len(valport= s) =3D=3D 3: > + txIntf =3D self.tester.get_local_port(valports[rxPort - = 1]) > + rxIntf =3D self.tester.get_local_port(valports[rxPort]) > + tgen_input.append((txIntf, rxIntf, "dst%d.pcap" % valpor= ts[rxPort - > 1])) > + return tgen_input > + > + def create_result_table(self, ttl, ttl1, ttl2, ttl3, ttl4): > + > + header_row =3D [ttl, ttl1, ttl2, ttl3, ttl4] > + self.test_results['header'] =3D header_row > self.result_table_create(header_row) > - self.l3fwd_test_results['data'] =3D [] > - > - for frame_size in TestL3fwd.frame_sizes: > - > - # Prepare traffic flow > - payload_size =3D frame_size - \ > - HEADER_SIZE['ip'] - HEADER_SIZE['eth'] - HEADER_SIZE['tc= p'] > - > - for _port in range(ports_num): > - dmac =3D self.dut.get_mac_address(valports[_port]) > - flows =3D ['Ether(dst=3D"%s")/%s/TCP()/("X"*%d)' % (dmac= , flow, > payload_size) for flow in self.flows()[_port *2:(_port +1)*2]] > - self.tester.scapy_append('wrpcap("dst%d.pcap", > [%s])' %(valports[_port],string.join(flows,','))) > - self.tester.scapy_execute() > - > - self.rst_report("Flows for %d ports, %d frame size.\n" % (po= rts_num, > frame_size), > - annex=3DTrue) > - self.rst_report("%s" % string.join(flows, '\n'), > - frame=3DTrue, annex=3DTrue) > - > - # Prepare the command line > - global corelist > - pat =3D re.compile("P([0123]),([0123]),(C\{\d.\d.\d\})") > - > - pat2 =3D re.compile("C\{\d") > - repl1 =3D "C{" + str(self.port_socket) > - > - coreMask =3D {} > - rtCmdLines =3D {} > - cmdlist =3D [] > - if ports_num =3D=3D 4: > - for i in TestL3fwd.test_cases_4_ports: > - cmdlist.append(i) > - else: > - for i in TestL3fwd.test_cases_2_ports: > - cmdlist.append(i) > - if 'eagle' in self.nic: > - del cmdlist[2] > - else: > - del cmdlist[1] > - for cmdline_pat in cmdlist: > - corelist =3D [] > - rtCmdLines[cmdline_pat[1]] =3D cmdline_pat[2] > - while pat.search(rtCmdLines[cmdline_pat[1]]): > - # Change the socket to the NIC's socket > - if cmdline_pat[1].find('1S')>=3D0: > - rtCmdLines[cmdline_pat[1]] =3D pat2.sub(repl1, > rtCmdLines[cmdline_pat[1]]) > - rtCmdLines[cmdline_pat[1]] =3D pat.sub(self.repl, > rtCmdLines[cmdline_pat[1]]) > - > - self.logger.info("%s\n" % str(corelist)) > - coreMask[cmdline_pat[1]] =3D utils.create_mask(set(corel= ist)) > - > - # measure by two different mode > - for mode in TestL3fwd.methods: > - > - # start l3fwd > - index =3D 0 > - subtitle =3D [] > - for cores in rtCmdLines.keys(): > - > - #in order to save time, only some of the cases will = be run. > - if mode =3D=3D "lpm" and (cores =3D=3D "1S/2C/1T" or= cores =3D=3D > "1S/4C/1T"): > - info =3D "Executing l3fwd using %s mode, %d port= s, %s and %d > frame size.\n" % ( > - mode, ports_num, cores, frame_size) > - > - self.logger.info(info) > - self.rst_report(info, annex=3DTrue) > - > - subtitle.append(cores) > - cmdline =3D rtCmdLines[cores] % (TestL3fwd.path = + "l3fwd_" + > mode, coreMask[cores], > - self.dut.get_memo= ry_channels(), > utils.create_mask(valports[:ports_num])) > - if self.nic =3D=3D "niantic": > - cmdline =3D cmdline + " --parse-ptype" > - > - if frame_size > 1518: > - cmdline =3D cmdline + " --enable-jumbo --max= -pkt-len %d" % > frame_size > - self.rst_report(cmdline + "\n", frame=3DTrue, an= nex=3DTrue) > - > - out =3D self.dut.send_expect(cmdline, "L3FWD:", = 120) > - > - # Measure test > - tgenInput =3D [] > - for rxPort in range(ports_num): > - # No use on rx/tx limitation > - if rxPort % 2 =3D=3D 0: > - txIntf =3D self.tester.get_local_port(va= lports[rxPort + 1]) > - else: > - txIntf =3D self.tester.get_local_port(va= lports[rxPort - 1]) > - > - rxIntf =3D self.tester.get_local_port(valpor= ts[rxPort]) > - if rxPort % 2 =3D=3D 0: > - tgenInput.append((txIntf, rxIntf, > "dst%d.pcap" %valports[rxPort+1])) > - else: > - tgenInput.append((txIntf, rxIntf, > "dst%d.pcap" %valports[rxPort-1])) > - > - zero_loss_rate, tx_pkts, rx_pkts =3D > self.tester.run_rfc2544(tgenInput, delay=3D60) > - loss_pkts =3D tx_pkts - rx_pkts > - self.dut.send_expect("^C", "#") > - linerate =3D self.wirespeed(self.nic, frame_size= , ports_num) > - zero_loss_throughput =3D (linerate * zero_loss_r= ate) / 100 > - > - tx_pkts =3D utils.human_read_number(tx_pkts) > - rx_pkts =3D utils.human_read_number(rx_pkts) > - loss_pkts =3D utils.human_read_number(loss_pkts) > - > - > - #data_row =3D [frame_size, mode, cores, tx_pkts,= rx_pkts, > loss_pkts, zero_loss_rate, zero_loss_throughput] > - data_row =3D [frame_size, mode, cores, zero_loss= _throughput, > zero_loss_rate] > - self.result_table_add(data_row) > - self.l3fwd_test_results['data'].append(data_row) > - else: > - pass > - > - index +=3D 1 > + self.test_results['data'] =3D [] >=20 > + def measure_throughput(self, l3_proto, mode): > + """ > + measure throughput according to Layer-3 Protocal and Lookup Mode > + """ > + # create result table > + self.create_result_table("Frame Size", "Mode", "S/C/T", "Mpps", = "% > Linerate") > + # build application > + self.install_l3fwd_application(l3_proto, mode) > + # perpare commandline and core mask > + rtCmdLines, core_mask =3D self.perpare_commandline(len(valports)= ) > + > + for cores in rtCmdLines.keys(): > + # Start L3fwd appliction > + command_line =3D rtCmdLines[cores] % (TestL3fwd.path + l3_pr= oto + > "_l3fwd_" + mode, core_mask[cores], > + self.dut.get_memory_chan= nels(), > utils.create_mask(valports)) > + self.dut.send_expect(command_line, "L3FWD:", 120) > + for frame_size in self.frame_sizes: > + # crete traffic flow > + self.create_pcap_file(frame_size, l3_proto) > + # send the traffic and Measure test > + tgenInput =3D self.prepare_steam() > + _, pps =3D self.tester.traffic_generator_throughput(tgen= Input, > rate_percent=3D100, delay=3D10) > + self.verify(pps > 0, "No traffic detected") > + # statistical result > + pps /=3D 1000000.0 > + linerate =3D self.wirespeed(self.nic, frame_size, len(va= lports)) > + percentage =3D pps * 100 / linerate > + if mode =3D=3D "ipv6" and frame_size =3D=3D 64: > + frame_size +=3D 2 > + data_row =3D [frame_size, mode, cores, str(pps), str(per= centage)] > + self.result_table_add(data_row) > + self.test_results['data'].append(data_row) > + # Stop L3fwd > + self.dut.send_expect("^C", "#") > + time.sleep(1) > + # Print result > + self.result_table_print() > + > + def measure_rfc2544(self, l3_proto, mode): > + """ > + measure RFC2544 according to Layer-3 Protocal and Lookup Mode > + """ > + # create result table > + self.create_result_table("Frame Size", "Mode", "S/C/T", "Zero Lo= ss > Throughput(Mpps)", " % Zero Loss Rate") > + # build application > + self.install_l3fwd_application(l3_proto, mode) > + # perpare commandline and core mask > + rtCmdLines, core_mask =3D self.perpare_commandline(len(valports)= ) > + > + for frame_size in self.frame_sizes: > + for cores in rtCmdLines.keys(): > + # in order to save time, only some of the cases will be = run. > + if cores in ["1S/2C/1T", "1S/4C/1T"]: > + # Start L3fwd appliction > + command_line =3D rtCmdLines[cores] % (TestL3fwd.path= + > l3_proto + "_l3fwd_" + mode, core_mask[cores], > + self.dut.get_mem= ory_channels(), > utils.create_mask(valports)) > + if self.nic =3D=3D "niantic": > + command_line +=3D " --parse-ptype" > + if frame_size > 1518: > + command_line +=3D " --enable-jumbo --max-pkt-len= %d" % > frame_size > + self.dut.send_expect(command_line, "L3FWD:", 120) > + self.logger.info("Executing l3fwd using %s mode, %d = ports, %s > and %d frame size" > + % (mode, len(valports), cores, fram= e_size)) > + # crete traffic flow > + self.create_pcap_file(frame_size, l3_proto) > + # send the traffic and Measure test > + tgenInput =3D self.prepare_steam() > + zero_loss_rate, tx_pkts, rx_pkts =3D > self.tester.run_rfc2544(tgenInput, delay=3D60) > + # statistical result > + linerate =3D self.wirespeed(self.nic, frame_size, le= n(valports)) > + zero_loss_throughput =3D (linerate * zero_loss_rate)= / 100 > + if mode =3D=3D "ipv6" and frame_size =3D=3D 64: > + frame_size +=3D 2 > + data_row =3D [frame_size, mode, cores, str(zero_loss= _throughput), > str(zero_loss_rate)] > + self.result_table_add(data_row) > + self.test_results['data'].append(data_row) > + # Stop L3fwd > + self.dut.send_expect("^C", "#") > + time.sleep(1) > + # Print result > self.result_table_print() >=20 > + def test_perf_rfc2544_ipv4_lpm(self): > + self.measure_rfc2544(l3_proto=3D"ipv4", mode=3D"lpm") > + > + def test_perf_rfc2544_ipv4_em(self): > + self.measure_rfc2544(l3_proto=3D"ipv4", mode=3D"em") > + > + def test_perf_throughput_ipv4_lpm(self): > + self.measure_throughput(l3_proto=3D"ipv4", mode=3D"lpm") > + > + def test_perf_throughput_ipv4_em(self): > + self.measure_throughput(l3_proto=3D"ipv4", mode=3D"em") > + > + def test_perf_rfc2544_ipv6_lpm(self): > + self.measure_rfc2544(l3_proto=3D"ipv6", mode=3D"lpm") > + > + def test_perf_rfc2544_ipv6_em(self): > + self.measure_rfc2544(l3_proto=3D"ipv6", mode=3D"em") > + > + def test_perf_throughput_ipv6_lpm(self): > + self.measure_throughput(l3_proto=3D"ipv6", mode=3D"lpm") > + > + def test_perf_throughput_ipv6_em(self): > + self.measure_throughput(l3_proto=3D"ipv6", mode=3D"em") > + > def ip(self, port, frag, src, proto, tos, dst, chksum, len, options,= version, > flags, ihl, ttl, id): > self.add_tcl_cmd("protocol config -name ip") > self.add_tcl_cmd('ip config -sourceIpAddr "%s"' % src) @@ -375,7 > +408,7 @@ class TestL3fwd(TestCase,IxiaPacketGenerator): > """ > Run after each test case. > """ > - pass > + self.dut.kill_all() >=20 > def tear_down_all(self): > """ > -- > 2.17.1