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 468E1A05D3 for ; Sun, 24 Mar 2019 19:21:59 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CF54B25D9; Sun, 24 Mar 2019 19:21:58 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2F50A14EC for ; Sun, 24 Mar 2019 19:21:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Mar 2019 11:21:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="125479464" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga007.jf.intel.com with ESMTP; 24 Mar 2019 11:21:54 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 24 Mar 2019 11:21:53 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 24 Mar 2019 11:21:53 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.158]) by shsmsx102.ccr.corp.intel.com ([169.254.2.163]) with mapi id 14.03.0415.000; Mon, 25 Mar 2019 02:21:51 +0800 From: "Tu, Lijuan" To: "Li, WenjieX A" , "dts@dpdk.org" CC: "Li, WenjieX A" Thread-Topic: [dts] [PATCH V2 2/2] add metering_and_policing script Thread-Index: AQHU3grYyOsVYrFsbEWjwLzcG4ep3KYbIMUg Date: Sun, 24 Mar 2019 18:21:50 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BA45B49@SHSMSX101.ccr.corp.intel.com> References: <1552969342-67612-1-git-send-email-wenjiex.a.li@intel.com> <1552969342-67612-2-git-send-email-wenjiex.a.li@intel.com> In-Reply-To: <1552969342-67612-2-git-send-email-wenjiex.a.li@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.400.15 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDI3YTAwMDUtMDk2OC00ZTZiLTk1ZjktOTAwNTQ2YmRhMjg5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZlllVXhTZlJxUmVXcW1ueElVb0dCZjVueWpvUnZhc1wvRFlPcThoR0dpOEFVVGpEMFlPWXhNdngwZGF3Nk8xZHcifQ== 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 V2 2/2] add metering_and_policing script 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 Wenjie Li > Sent: Monday, March 18, 2019 9:22 PM > To: dts@dpdk.org > Cc: Li, WenjieX A > Subject: [dts] [PATCH V2 2/2] add metering_and_policing script >=20 > add metering_and_policing script >=20 > Signed-off-by: Wenjie Li >=20 > V2: update the functions to make the script clear > V1: add new test suite script > --- > tests/TestSuite_metering_and_policing.py | 650 +++++++++++++++++++++++ > 1 file changed, 650 insertions(+) > create mode 100644 tests/TestSuite_metering_and_policing.py >=20 > diff --git a/tests/TestSuite_metering_and_policing.py > b/tests/TestSuite_metering_and_policing.py > new file mode 100644 > index 0000000..38687e6 > --- /dev/null > +++ b/tests/TestSuite_metering_and_policing.py > @@ -0,0 +1,650 @@ > +#BSD LICENSE > +# > +# Copyright(c) 2010-2016 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 metering_and_policing. > +""" > +import utils > +import string > +import time > +import re > +from test_case import TestCase > +from plotting import Plotting > +from settings import HEADER_SIZE > +from dut import Dut > + > + > +class TestMeteringAndPolicing(TestCase): > + > + def copy_config_files_to_dut(self): > + """ > + Copy firmware.cli, dscp_*.sh from tester to DUT. > + """ > + file =3D 'meter_and_policy_config.tar.gz' > + src_file =3D r'./dep/%s' % file > + dst1 =3D '/tmp' > + dst2 =3D '/root/dpdk/drivers/net/softnic' > + self.dut.session.copy_file_to(src_file, dst1) > + self.dut.send_expect("tar xf %s/%s -C %s" % (dst1, file, dst2), > + "#", 30) > + > + def update_firmware_cli(self, caseID): > + """ > + Update firmware.cli. > + """ > + self.ori_firmware_cli =3D > "/root/dpdk/drivers/net/softnic/meter_and_policing_firmware.cli" > + if len(self.dut_ports) =3D=3D 4: > + self.ori_firmware_cli =3D > "/root/dpdk/drivers/net/softnic/meter_and_policing_firmware_4ports.cli" > + self.new_firmware_cli =3D "%s-%s" % (self.ori_firmware_cli, case= ID) > + self.dut.send_expect("rm -f %s" % self.new_firmware_cli, "#") > + self.dut.send_expect("cp %s %s" % (self.ori_firmware_cli, > + self.new_firmware_cli), "#") > + > + # link dev > + self.dut.send_expect("sed -i -e 's/^.*link LINK0 dev.*$/link LIN= K0 > dev %s/g' %s" > + % (self.dut_p0_pci, self.new_firmware_cli),= "#") > + self.dut.send_expect("sed -i -e 's/^.*link LINK1 dev.*$/link LIN= K1 > dev %s/g' %s" > + % (self.dut_p1_pci, self.new_firmware_cli),= "#") > + if len(self.dut_ports) =3D=3D 4: > + self.dut.send_expect("sed -i -e 's/^.*link LINK2 dev.*$/link= LINK2 > dev %s/g' %s" > + % (self.dut_p2_pci, self.new_firmware_c= li), "#") > + self.dut.send_expect("sed -i -e 's/^.*link LINK3 dev.*$/link= LINK3 > dev %s/g' %s" > + % (self.dut_p3_pci, > + self.new_firmware_cli), "#") > + > + # table action > + temp =3D "table action profile AP0" > + if caseID =3D=3D 8: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s ipv6 offset 2= 70 fwd meter > trtcm tc 1 stats pkts/g' %s" > + % (temp, temp, self.new_firmware_cli), = "#") > + else: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s ipv4 offset 2= 70 fwd meter > trtcm tc 1 stats pkts/g' %s" > + % (temp, temp, self.new_firmware_cli), > + "#") > + > + # pipeline RX table > + temp =3D "pipeline RX table match" > + if caseID =3D=3D 7: > + target =3D "hash ext key 16 mask 00FF0000FFFFFFFFFFFFFFFFFFF= FFFFF > offset 278 buckets 16K size 65K action AP0" > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s %s/g' %s" > + % (temp, temp, target, self.new_firmwar= e_cli), "#") > + elif caseID =3D=3D 8: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s acl ipv6 offs= et 270 size 4K > action AP0/g' %s" > + % (temp, temp, self.new_firmware_cli), = "#") > + else: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s acl ipv4 offs= et 270 size 4K > action AP0/g' %s" > + % (temp, temp, self.new_firmware_cli), > + "#") > + > + # use .sh file as RX table > + temp =3D "pipeline RX table 0 dscp" > + if caseID =3D=3D 10: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s > \/root\/dpdk\/drivers\/net\/softnic\/dscp_red.sh/g' %s" > + % (temp, temp, self.new_firmware_cli), = "#") > + elif caseID =3D=3D 11: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s > \/root\/dpdk\/drivers\/net\/softnic\/dscp_yellow.sh/g' %s" > + % (temp, temp, self.new_firmware_cli), = "#") > + elif caseID =3D=3D 12: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s > \/root\/dpdk\/drivers\/net\/softnic\/dscp_green.sh/g' %s" > + % (temp, temp, self.new_firmware_cli), = "#") > + elif caseID =3D=3D 13: > + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s > \/root\/dpdk\/drivers\/net\/softnic\/dscp_default.sh/g' %s" > + % (temp, temp, self.new_firmware_cli), > + "#") > + > + # thread * pipeline RX/TX enable > + self.dut.send_expect("sed -i -e 's/thread 5 pipeline RX enable/t= hread %d > pipeline RX enable/g' %s" > + % (len(self.dut_ports), self.new_firmware_c= li), "#") > + self.dut.send_expect("sed -i -e 's/thread 5 pipeline TX enable/t= hread %d > pipeline TX enable/g' %s" > + % (len(self.dut_ports), > + self.new_firmware_cli), "#") > + > + def start_testpmd(self, filename): > + """ > + Start testpmd. > + """ > + if len(self.dut_ports) =3D=3D 2: > + portmask =3D "0x4" > + Corelist =3D "0x7" > + Servicecorelist =3D "0x4" > + if len(self.dut_ports) =3D=3D 4: > + portmask =3D "0x10" > + Corelist =3D "0x1f" > + Servicecorelist =3D "0x10" > + self.path =3D "./%s/app/testpmd" % self.target > + cmd =3D self.path + " -c %s -s %s -n %d --vdev > 'net_softnic0,firmware=3D%s,cpu_id=3D0,conn_port=3D8086' \ > + -- -i --rxq=3D%d --txq=3D%d --portmask=3D%s" \ > + % (Corelist, Servicecorelist, self.dut.get_memory_channels= (), filename, > self.port_id, self.port_id, portmask) > + self.dut.send_expect(cmd, "testpmd>", 60) > + > + def add_port_meter_profile(self, profile_id, cbs=3D400, pbs=3D500): > + """ > + Add port meter profile (trTCM rfc2968). > + """ > + cir =3D 3125000000 > + pir =3D 3125000000 > + self.dut.send_expect("add port meter profile > trtcm_rfc2698 %d %d %d %d %d %d" > + % (self.port_id, profile_id, cir, pir, > + cbs, pbs), "testpmd>") > + > + def create_port_meter(self, mtr_id, profile_id, gyrd_action): > + """ > + Create new meter object for the ethernet device. > + """ > + self.dut.send_expect("create port meter %d %d %d yes %s" > + % (self.port_id, mtr_id, profile_id, > + gyrd_action), "testpmd>") > + > + def create_flow_rule(self, ret_id, ip_ver, protocol, spec_id, mtr_i= d, > queue_index_id): > + """ > + Create flow rule based on port meter. > + """ > + if ip_ver =3D=3D "ipv4": > + src_mask =3D "255.255.255.255" > + dst_mask =3D "255.255.255.255" > + src_ip =3D "1.10.11.12" > + dst_ip =3D "2.20.21.22" > + if ip_ver =3D=3D "ipv6": > + src_mask =3D "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" > + dst_mask =3D "0:0:0:0:0:0:0:0" > + src_ip =3D "ABCD:EF01:2345:6789:ABCD:EF01:2345:5789" > + dst_ip =3D "0:0:0:0:0:0:0:0" > + protocol =3D protocol.lower() > + if protocol =3D=3D "tcp": > + proto_id =3D 6 > + if protocol =3D=3D "udp": > + proto_id =3D 17 > + if protocol =3D=3D "sctp": > + proto_id =3D 132 > + > + out =3D self.dut.send_expect("flow create %d group 0 ingress pat= tern eth > / %s proto mask 255 src mask %s dst mask" > + " %s src spec %s dst spec %s proto sp= ec %d / %s src mask > 65535 dst mask 65535 src " > + "spec %d dst spec %d / end actions me= ter mtr_id %d / > queue index %d / end" > + % (self.port_id, ip_ver, src_mask, ds= t_mask, src_ip, dst_ip, > proto_id, protocol, > + spec_id, spec_id, mtr_id, queue_in= dex_id), "testpmd>") > + if ret_id =3D=3D 1: > + self.verify("Flow rule #" in out, "flow create fail") > + else: > + self.verify("METER: Meter already attached to a flow: Invali= d argument" > in out, > + "flow create should fail, but NOT failed") > + > + def scapy_send_packet(self, ip_ver, protocol, fwd_port, pktsize): > + """ > + Send a packet to DUT port 0 > + """ > + source_port =3D > self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) > + protocol =3D protocol.upper() > + if ip_ver =3D=3D "ipv4": > + src_ip =3D "1.10.11.12" > + dst_ip =3D "2.20.21.22" > + tag =3D "IP" > + if protocol =3D=3D "TCP": > + proto_str =3D "proto=3D6" > + if protocol =3D=3D "UDP": > + proto_str =3D "proto=3D17" > + if protocol =3D=3D "SCTP": > + proto_str =3D "proto=3D132" > + > + if ip_ver =3D=3D "ipv6": > + src_ip =3D "ABCD:EF01:2345:6789:ABCD:EF01:2345:5789" > + dst_ip =3D "2001::1" > + tag =3D "IPv6" > + if protocol =3D=3D "TCP": > + proto_str =3D "nh=3D6" > + if protocol =3D=3D "UDP": > + proto_str =3D "nh=3D17" > + > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/%s(src=3D"%s",dst=3D"%s",%s)/%s(sport=3D%d,dpor= t=3D%d)/Ra > w(load=3D"P"*%d)], iface=3D"%s")' > + % (self.dut_p0_mac, tag, src_ip, dst_ip, proto_str, protocol= , fwd_port, > fwd_port, pktsize, source_port)) > + self.tester.scapy_execute() > + > + def send_packet_and_check(self, ip_ver, protocol, fwd_port, pktsize, > expect_port): > + """ > + Send packet and check the stats. If expect_port =3D=3D -1, the p= acket should be > dropped. > + """ > + time.sleep(3) > + rx_before =3D [] > + tx_before =3D [] > + for i in range(0, len(self.dut_ports)): > + output =3D self.dut.send_expect("show port stats %d" %(i),"t= estpmd>") > + if i =3D=3D 0: > + rx_before.append(re.compile('RX-packets:\s+(.*?)\s+?').f= indall(output, > re.S)) > + > + tx_before.append(re.compile('TX-packets:\s+(.*?)\s+?').findall(output, > + re.S)) > + > + self.scapy_send_packet(ip_ver, protocol, fwd_port, pktsize) > + > + rx_after =3D [] > + tx_after =3D [] > + for i in range(0, len(self.dut_ports)): > + output =3D self.dut.send_expect("show port stats %d" %(i),"t= estpmd>") > + if i =3D=3D 0: > + rx_after.append(re.compile('RX-packets:\s+(.*?)\s+?').fi= ndall(output, > re.S)) > + > + tx_after.append(re.compile('TX-packets:\s+(.*?)\s+?').findall(output, > + re.S)) > + > + rx_packets_port =3D [] > + tx_packets_port =3D [] > + temp1 =3D int(rx_after[0][0]) - int(rx_before[0][0]) > + rx_packets_port.append(temp1) > + for i in range(0, len(self.dut_ports)): > + temp2 =3D int(tx_after[i][0]) - int(tx_before[i][0]) > + tx_packets_port.append(temp2) > + self.verify(int(rx_packets_port[0]) =3D=3D 1, "Wrong: port 0 did= not recieve any > packet") > + if expect_port =3D=3D -1: > + for i in range(0, len(self.dut_ports)): > + self.verify(int(tx_packets_port[i]) =3D=3D 0, "Wrong: th= e packet is not > dropped") > + else: > + self.verify(int(tx_packets_port[expect_port]) =3D=3D 1, "Wro= ng: > + can't forward package to port %d " % expect_port) > + > + def run_param(self, cbs, pbs, head): > + """ > + Set cbs, pbs and head; return the packet size > + """ > + pkt1 =3D pbs - head + 1 > + pkt2 =3D pbs - head > + pkt3 =3D cbs - head + 1 > + pkt4 =3D cbs - head > + pkt_list =3D [pkt1,pkt2,pkt3,pkt4] > + return pkt_list > + > + def run_port_list(self,ip_ver,protocol,fwd_port,pkt_list,port_list): > + for i in range(len(port_list)): > + self.send_packet_and_check(ip_ver=3Dip_ver, > + protocol=3Dprotocol, fwd_port=3Dfwd_port, pktsize=3Dpkt_list[i], > + expect_port=3Dport_list[i]) > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.dut_ports =3D self.dut.get_ports() > + self.port_nums =3D 2 > + self.verify(len(self.dut_ports) >=3D self.port_nums, > + "Insufficient ports for speed testing") > + self.dut_p0_pci =3D self.dut.get_port_pci(self.dut_ports[0]) > + self.dut_p1_pci =3D self.dut.get_port_pci(self.dut_ports[1]) > + if len(self.dut_ports) =3D=3D 4: > + self.dut_p2_pci =3D self.dut.get_port_pci(self.dut_ports[2]) > + self.dut_p3_pci =3D self.dut.get_port_pci(self.dut_ports[3]) > + self.dut_p0_mac =3D self.dut.get_mac_address(self.dut_ports[0]) > + self.port_id =3D len(self.dut_ports) > + self.copy_config_files_to_dut() > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def test_ipv4_ACL_table_RFC2698_GYR(self): > + """ > + Test Case 1: ipv4 ACL table RFC2698 GYR > + """ > + self.update_firmware_cli(caseID=3D1) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + def test_ipv4_ACL_table_RFC2698_GYD(self): > + """ > + Test Case 2: ipv4 ACL table RFC2698 GYD > + """ > + self.update_firmware_cli(caseID=3D2) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,0,0,0]) > + > + def test_ipv4_ACL_table_RFC2698_GDR(self): > + """ > + Test Case 3: ipv4 ACL table RFC2698 GDR > + """ > + self.update_firmware_cli(caseID=3D3) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D32) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"s= ctp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D1) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","sctp",2,pkt_list,[1,-1,-1,1]) > + > + def test_ipv4_ACL_table_RFC2698_DYR(self): > + """ > + Test Case 4: ipv4 ACL table RFC2698 DYR > + """ > + self.update_firmware_cli(caseID=3D4) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D28) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"u= dp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","udp",2,pkt_list,[0,0,0,-1]) > + > + def test_ipv4_ACL_table_RFC2698_DDD(self): > + """ > + Test Case 5: ipv4 ACL table RFC2698 DDD > + """ > + self.update_firmware_cli(caseID=3D5) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"d d d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,-1,-1,-1]) > + > + def test_ipv4_with_same_cbs_and_pbs_GDR(self): > + """ > + Test Case 6: ipv4 with same cbs and pbs GDR > + """ > + self.update_firmware_cli(caseID=3D6) > + cbs =3D 500 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D32) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"s= ctp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","sctp",2,pkt_list,[0,0]) > + > + def test_ipv4_HASH_table_RFC2698(self): > + """ > + Test Case 7: ipv4 HASH table RFC2698 > + """ > + self.update_firmware_cli(caseID=3D7) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + > + # test 1 'g y r 0 0 0' > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + self.dut.send_expect("quit", "#", 30) > + > + # test 2 'g y d 0 0 0' > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,0,0,0]) > + self.dut.send_expect("quit", "#", 30) > + > + # test 5 'd d d 0 0 0' > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"d d d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,-1,-1,-1]) > + self.dut.send_expect("quit", "#", 30) > + > + # test 3 'g d r 0 0 0' > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D32) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"s= ctp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D1) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","sctp",2,pkt_list,[1,-1,-1,1]) > + self.dut.send_expect("quit", "#", 30) > + > + # test 4 'd y r 0 0 0' > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D28) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"u= dp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.dut.send_expect("start", "testpmd>") > + self.run_port_list("ipv4","udp",2,pkt_list,[0,0,0,-1]) > + self.dut.send_expect("quit", "#", 30) > + > + def test_ipv6_ACL_table_RFC2698(self): > + """ > + Test Case 8: ipv6 ACL table RFC2698 > + """ > + self.update_firmware_cli(caseID=3D8) > + cbs =3D 400 > + pbs =3D 500 > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_port_meter(mtr_id=3D1, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv6", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv6", protocol=3D"u= dp", spec_id=3D2, > mtr_id=3D1, queue_index_id=3D1) > + self.dut.send_expect("start","testpmd>") > + > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D60) > + self.run_port_list("ipv6","tcp",2,pkt_list,[-1,0,0,0]) > + > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D48) > + self.run_port_list("ipv6","udp",2,pkt_list,[1,1,1,-1]) > + > + def test_ipv4_multiple_meter_and_profile(self): > + """ > + Test Case 9: multiple meter and profile > + """ > + self.update_firmware_cli(caseID=3D9) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3D400, pbs=3D500= ) > + self.add_port_meter_profile(profile_id=3D1, cbs=3D300, pbs=3D400= ) > + > + gyrd_action_list =3D ["g y r 0 0 0", "g y d 0 0 0", "g d r 0 0 0= ", "d y r 0 0 0", "g y > d 0 0 0", "g d r 0 0 0", "d y r 0 0 0", "d d d 0 0 0"] > + for i in range(0,len(gyrd_action_list)): > + self.create_port_meter(mtr_id=3Di, profile_id=3Di*2/len(gyrd= _action_list), > gyrd_action=3Dgyrd_action_list[i]) > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol= =3D"tcp", spec_id=3Di, > mtr_id=3Di, queue_index_id=3Di%len(self.dut_ports)) > + self.create_flow_rule(ret_id=3D0, ip_ver=3D"ipv4", protocol=3D"t= cp", > + spec_id=3D8, mtr_id=3D7, queue_index_id=3D0) > + > + self.dut.send_expect("start", "testpmd>") > + output =3D self.dut.send_expect("flow list %d" % (self.port_id),= "testpmd>") > + print(output) > + > + pkt_list =3D self.run_param(cbs=3D400,pbs=3D500,head=3D40) > + if len(self.dut_ports) =3D=3D 4: > + self.run_port_list("ipv4","tcp",0,pkt_list,[0,0,0,0]) > + self.run_port_list("ipv4","tcp",1,pkt_list,[-1,1,1,1]) > + self.run_port_list("ipv4","tcp",2,pkt_list,[2,-1,-1,2]) > + self.run_port_list("ipv4","tcp",3,pkt_list,[3,3,3,-1]) > + if len(self.dut_ports) =3D=3D 2: > + self.run_port_list("ipv4","tcp",0,pkt_list,[0,0,0,0]) > + self.run_port_list("ipv4","tcp",1,pkt_list,[-1,1,1,1]) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,-1,-1,0]) > + self.run_port_list("ipv4","tcp",3,pkt_list,[1,1,1,-1]) > + > + > + pkt_list =3D self.run_param(cbs=3D300,pbs=3D400,head=3D40) > + if len(self.dut_ports) =3D=3D 4: > + self.run_port_list("ipv4","tcp",4,pkt_list,[-1,0,0,0]) > + self.run_port_list("ipv4","tcp",5,pkt_list,[1,-1,-1,1]) > + self.run_port_list("ipv4","tcp",6,pkt_list,[2,2,2,-1]) > + self.run_port_list("ipv4","tcp",7,pkt_list,[-1,-1,-1,-1]) > + if len(self.dut_ports) =3D=3D 2: > + self.run_port_list("ipv4","tcp",4,pkt_list,[-1,0,0,0]) > + self.run_port_list("ipv4","tcp",5,pkt_list,[1,-1,-1,1]) > + self.run_port_list("ipv4","tcp",6,pkt_list,[0,0,0,-1]) > + self.run_port_list("ipv4","tcp",7,pkt_list,[-1,-1,-1,-1]) > + > + def test_ipv4_RFC2698_pre_colored_red_by_DSCP_table(self): > + """ > + Test Case 10: ipv4 RFC2698 pre-colored red by DSCP table > + """ > + self.update_firmware_cli(caseID=3D10) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.dut.send_expect("start", "testpmd>") > + > + # test 0: GYR > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + # test 1: GYD > + self.create_port_meter(mtr_id=3D1, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D1, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,-1,-1,-1]) > + > + # test 2: GDR > + self.create_port_meter(mtr_id=3D2, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D2, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + # test 3: DYR > + self.create_port_meter(mtr_id=3D3, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D3, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + def test_ipv4_RFC2698_pre_colored_yellow_by_DSCP_table(self): > + """ > + Test Case 11: ipv4 RFC2698 pre-colored yellow by DSCP table > + """ > + self.update_firmware_cli(caseID=3D11) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.dut.send_expect("start", "testpmd>") > + > + # test 0: GYR > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + # test 1: GYD > + self.create_port_meter(mtr_id=3D1, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D1, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,0,0,0]) > + > + # test 2: GDR > + self.create_port_meter(mtr_id=3D2, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D2, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,-1,-1,-1]) > + > + # test 3: DYR > + self.create_port_meter(mtr_id=3D3, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D3, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + def test_ipv4_RFC2698_pre_colored_green_by_DSCP_table(self): > + """ > + Test Case 12: ipv4 RFC2698 pre-colored green by DSCP table > + """ > + self.update_firmware_cli(caseID=3D12) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.dut.send_expect("start", "testpmd>") > + > + # test 0: GYR > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + # test 1: GYD > + self.create_port_meter(mtr_id=3D1, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D1, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,0,0,0]) > + > + # test 2: GDR > + self.create_port_meter(mtr_id=3D2, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D2, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,-1,-1,0]) > + > + # test 3: DYR > + self.create_port_meter(mtr_id=3D3, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D3, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,-1]) > + > + def test_ipv4_RFC2698_pre_colored_default_by_DSCP_table(self): > + """ > + Test Case 13: ipv4 RFC2698 pre-colored by default DSCP table > + """ > + self.update_firmware_cli(caseID=3D13) > + cbs =3D 400 > + pbs =3D 500 > + pkt_list =3D self.run_param(cbs=3Dcbs, pbs=3Dpbs, head=3D40) > + self.start_testpmd(self.new_firmware_cli) > + self.add_port_meter_profile(profile_id=3D0, cbs=3Dcbs, pbs=3Dpbs= ) > + self.dut.send_expect("start", "testpmd>") > + > + # test 0: GYR > + self.create_port_meter(mtr_id=3D0, profile_id=3D0, gyrd_action= =3D"g y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D0, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,0]) > + > + # test 1: GYD > + self.create_port_meter(mtr_id=3D1, profile_id=3D0, gyrd_action= =3D"g y d 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D1, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[-1,0,0,0]) > + > + # test 2: GDR > + self.create_port_meter(mtr_id=3D2, profile_id=3D0, gyrd_action= =3D"g d r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D2, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,-1,-1,0]) > + > + # test 3: DYR > + self.create_port_meter(mtr_id=3D3, profile_id=3D0, gyrd_action= =3D"d y r 0 0 0") > + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv4", protocol=3D"t= cp", spec_id=3D2, > mtr_id=3D3, queue_index_id=3D0) > + self.run_port_list("ipv4","tcp",2,pkt_list,[0,0,0,-1]) > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.kill_all() > + time.sleep(2) > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.17.2