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 3B996A00E6 for ; Tue, 19 Mar 2019 10:00:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 32CB225A1; Tue, 19 Mar 2019 10:00:47 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 67DD911A4 for ; Tue, 19 Mar 2019 10:00:45 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 02:00:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,497,1544515200"; d="scan'208";a="283903016" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2019 02:00:43 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 19 Mar 2019 02:00:43 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 19 Mar 2019 02:00:42 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.134]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.26]) with mapi id 14.03.0415.000; Tue, 19 Mar 2019 17:00:40 +0800 From: "Peng, Yuan" To: "Xiao, QimaiX" , "Li, WenjieX A" , "dts@dpdk.org" CC: "Li, WenjieX A" Thread-Topic: [dts] [PATCH V2 2/2] add metering_and_policing script Thread-Index: AQHU3grY/FD7PsBJWkqdFDqQgJ6jfaYSIfcAgACGWiA= Date: Tue, 19 Mar 2019 09:00:40 +0000 Message-ID: <67D543A150B29E4CAAE53918F64EDAEA376A56D5@SHSMSX103.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> <5C5FA1EBCC0D164EAD0302E258A5234B6E5291@SHSMSX103.ccr.corp.intel.com> In-Reply-To: <5C5FA1EBCC0D164EAD0302E258A5234B6E5291@SHSMSX103.ccr.corp.intel.com> Accept-Language: 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-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="iso-8859-1" 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" Acked-by:=A0 Peng Yuan =20 -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Xiao, QimaiX Sent: Tuesday, March 19, 2019 5:00 PM To: Li, WenjieX A ; dts@dpdk.org Cc: Li, WenjieX A Subject: Re: [dts] [PATCH V2 2/2] add metering_and_policing script Tested-by: Xiao,Qimai -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Wenjie Li Sent: Tuesday, March 19, 2019 12:22 PM To: dts@dpdk.org Cc: Li, WenjieX A Subject: [dts] [PATCH V2 2/2] add metering_and_policing script add metering_and_policing script Signed-off-by: Wenjie Li 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 diff --git a/tests/TestSuite_metering_and_policing.py b/tests/TestSuite_met= ering_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 #=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. +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),=20 + "#", 30) + + def update_firmware_cli(self, caseID): + """ + Update firmware.cli. + """ + self.ori_firmware_cli =3D "/root/dpdk/drivers/net/softnic/meter_an= d_policing_firmware.cli" + if len(self.dut_ports) =3D=3D 4: + self.ori_firmware_cli =3D "/root/dpdk/drivers/net/softnic/mete= r_and_policing_firmware_4ports.cli" + self.new_firmware_cli =3D "%s-%s" % (self.ori_firmware_cli, caseID= ) + self.dut.send_expect("rm -f %s" % self.new_firmware_cli, "#") + self.dut.send_expect("cp %s %s" % (self.ori_firmware_cli,=20 + self.new_firmware_cli), "#") + + # link dev + self.dut.send_expect("sed -i -e 's/^.*link LINK0 dev.*$/link LINK0= dev %s/g' %s" + % (self.dut_p0_pci, self.new_firmware_cli), "= #") + self.dut.send_expect("sed -i -e 's/^.*link LINK1 dev.*$/link LINK1= 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 L= INK2 dev %s/g' %s" + % (self.dut_p2_pci, self.new_firmware_cli= ), "#") + self.dut.send_expect("sed -i -e 's/^.*link LINK3 dev.*$/link L= INK3 dev %s/g' %s" + % (self.dut_p3_pci,=20 + 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 270= 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 270= 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 00FF0000FFFFFFFFFFFFFFFFFFFFF= FFF 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_firmware_= cli), "#") + elif caseID =3D=3D 8: + self.dut.send_expect("sed -i -e 's/^.*%s.*$/%s acl ipv6 offset= 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 offset= 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/thr= ead %d pipeline RX enable/g' %s" + % (len(self.dut_ports), self.new_firmware_cli= ), "#") + self.dut.send_expect("sed -i -e 's/thread 5 pipeline TX enable/thr= ead %d pipeline TX enable/g' %s" + % (len(self.dut_ports),=20 + 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,firmw= are=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,=20 + 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,=20 + gyrd_action), "testpmd>") + + def create_flow_rule(self, ret_id, ip_ver, protocol, spec_id, mtr_id,= 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 patte= rn eth / %s proto mask 255 src mask %s dst mask" + " %s src spec %s dst spec %s proto spec= %d / %s src mask 65535 dst mask 65535 src " + "spec %d dst spec %d / end actions mete= r mtr_id %d / queue index %d / end" + % (self.port_id, ip_ver, src_mask, dst_= mask, src_ip, dst_ip, proto_id, protocol, + spec_id, spec_id, mtr_id, queue_inde= x_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: Invalid = 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_po= rt(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(spor= t=3D%d,dport=3D%d)/Raw(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, e= xpect_port): + """ + Send packet and check the stats. If expect_port =3D=3D -1, the pac= ket 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),"tes= tpmd>") + if i =3D=3D 0: + =20 + rx_before.append(re.compile('RX-packets:\s+(.*?)\s+?').findall(output,=20 + re.S)) + =20 + 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),"tes= tpmd>") + if i =3D=3D 0: + =20 + rx_after.append(re.compile('RX-packets:\s+(.*?)\s+?').findall(output,=20 + re.S)) + =20 + 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 n= ot 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: the = packet is not dropped") + else: + self.verify(int(tx_packets_port[expect_port]) =3D=3D 1, "Wrong= :=20 + 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"tcp= ", 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"tcp= ", 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"sct= p", 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"udp= ", 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"tcp= ", 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"sct= p", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"sct= p", 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"udp= ", 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"tcp= ", spec_id=3D2, mtr_id=3D0, queue_index_id=3D0) + self.create_flow_rule(ret_id=3D1, ip_ver=3D"ipv6", protocol=3D"udp= ", 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_a= ction_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"tcp= ",=20 + 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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"tcp= ", 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