From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 98AF91B670 for ; Wed, 16 May 2018 08:02:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2018 23:02:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,404,1520924400"; d="scan'208";a="42176656" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga006.jf.intel.com with ESMTP; 15 May 2018 23:02:34 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 15 May 2018 23:02:33 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 15 May 2018 23:02:32 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by shsmsx102.ccr.corp.intel.com ([169.254.2.79]) with mapi id 14.03.0319.002; Wed, 16 May 2018 14:02:31 +0800 From: "Liu, Yong" To: "Peng, Yuan" , "dts@dpdk.org" CC: "Peng, Yuan" Thread-Topic: [dts] [PATCH] tests: add TestSuite_generic_flow_api.py Thread-Index: AQHT3GwAeTSIUhWdI0aSG8USm11nwqQx81CQ Date: Wed, 16 May 2018 06:02:30 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E63041B75@SHSMSX103.ccr.corp.intel.com> References: <1524643503-130196-1-git-send-email-yuan.peng@intel.com> In-Reply-To: <1524643503-130196-1-git-send-email-yuan.peng@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTY2NjdjY2EtMTI1ZS00ZTdmLWJjZWEtNDc0ZDEzNTIwMWE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJMcitHb3lieWlsRTlXYWp1ZVJDN3ArWHRxY01WOGdBSDZYbnUwVWNOc01cL1JZZ2JIMVZ3YUpaNGtiZkJqczhDVyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action 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] tests: add TestSuite_generic_flow_api.py 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: , X-List-Received-Date: Wed, 16 May 2018 06:02:38 -0000 Yuan,=20 Some comments are inline. Since this suite cover multiple kinds of filters,= we need to think about how to benefit other suites from this implementatio= n. Thanks, Marvin > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Peng Yuan > Sent: Wednesday, April 25, 2018 4:05 PM > To: dts@dpdk.org > Cc: Peng, Yuan > Subject: [dts] [PATCH] tests: add TestSuite_generic_flow_api.py >=20 > Add a new test suite "TestSuite_generic_flow_api.py" >=20 > Signed-off-by: Peng Yuan >=20 > diff --git a/tests/TestSuite_generic_flow_api.py > b/tests/TestSuite_generic_flow_api.py > new file mode 100644 > index 0000000..1185f4f > --- /dev/null > +++ b/tests/TestSuite_generic_flow_api.py > @@ -0,0 +1,1537 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2017 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 the support of VLAN Offload Features by Poll Mode Drivers. > + > +""" > + > +import utils > +import time > +import re > + > +from test_case import TestCase > +from settings import HEADER_SIZE > +from pmd_output import PmdOutput > +from settings import DRIVERS > +from crb import Crb Some imports look like not useful like Crb and DRIVERS, pleasre remove them= . > + > +from virt_dut import VirtDut > +from project_dpdk import DPDKdut > +from dut import Dut No need to import DPDKdut and Dut module.=20 > +from packet import Packet > + > +import os > +import random > +from exception import VerifyFailure > +import scapy.layers.inet > +from scapy.utils import rdpcap Rdpcap is not used in this suite. > + > +MAX_VLAN =3D 4095 > +MAX_QUEUE =3D 15 > +MAX_VFQUEUE =3D 3 > +MAX_PORT =3D 65535 > +MAX_PROTO =3D 133 > +MAX_TTL =3D 255 > +MAX_TOS =3D 255 MAX_QUEUE and MAX_VFQUEUE may different between NICS, is it only meaningfu= l in this suite or the constant value for NIC? > + > +class TestGeneric_flow_api(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + Generic filter Prerequistites > + """ > + > + # Based on h/w type, choose how many ports to use > + self.dut_ports =3D self.dut.get_ports(self.nic) > + # Verify that enough ports are available > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") > + self.cores =3D "1S/8C/1T" > + self.pf_cores =3D "1S/16C/1T" > + self.pmdout =3D PmdOutput(self.dut) As I known, some users environment can't allocate so much cores. Could you = please reduce the number of cores? Like one or two. > + > + localPort =3D self.tester.get_local_port(self.dut_ports[0]) > + self.tester_itf =3D self.tester.get_interface(localPort) > + self.pf_interface =3D self.dut.ports_info[self.dut_ports[0]]['in= tf'] > + self.pf_mac =3D self.dut.get_mac_address(0) > + self.pf_pci =3D self.dut.ports_info[self.dut_ports[0]]['pci'] > + > + self.session_secondary =3D self.dut.new_session() > + self.session_third =3D self.dut.new_session() Please named the session with more meaningful name like self.host_dpdk_sess= ion. > + self.outer_mac =3D "00:11:22:33:44:55" > + self.inner_mac =3D "00:11:22:33:44:66" > + self.wrong_mac =3D "00:11:22:33:44:77" > + self.vf_flag =3D 0 > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + self.dut.kill_all() > + > + def setup_env(self): > + """ > + This is to set up 1pf and 2vfs environment. > + The pf is bound to dpdk driver. > + """ > + self.vf_flag =3D 1=20 Flag should be set at the end of this function.=20 > + # create two vfs > + self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 2, > self.drivername) > + self.sriov_vfs_port =3D > self.dut.ports_info[self.dut_ports[0]]['vfs_port'] > + try: > + for port in self.sriov_vfs_port: > + port.bind_driver(driver=3D"vfio-pci") Module should be configured in conf/global_suite, you can retrieve it by se= lf.get_suite_cfg()['vf_driver']. > + except Exception as e: > + self.destroy_env() > + raise Exception(e) > + > + def destroy_env(self): > + """ > + This is to stop testpmd and destroy 1pf and 2vfs environment. > + """ > + if self.vf_flag =3D=3D 1: > + self.session_third.send_expect("quit", "# ") > + time.sleep(2) > + self.session_secondary.send_expect("quit", "# ") > + time.sleep(2) > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0]) > + else: > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + self.vf_flag =3D 0 > + > + def verify_result(self, pf_vf, expect_rxpkts, expect_queue): > + """ > + verify the packet to the expected queue or be dropped > + """ > + self.tester.scapy_execute() > + time.sleep(2) > + > + if self.vf_flag =3D=3D 1: Should this flag the prerequisite this function? If that, no need to check = this. > + outstring_vf0 =3D self.session_secondary.send_expect("stop", > "testpmd> ", 120) > + outstring_vf1 =3D self.session_third.send_expect("stop", > "testpmd> ", 120) > + outstring_pf =3D self.dut.send_expect("stop", "testpmd> ", 120) > + time.sleep(2) > + if expect_rxpkts =3D=3D "0": > + if pf_vf =3D=3D "pf": > + self.verify("Queue" not in outstring_pf, "the packet is > not dropped.") > + elif pf_vf =3D=3D "vf0": > + self.verify("Queue" not in outstring_vf0, "the packet is > not dropped.") > + else: > + self.verify("Queue" not in outstring_vf1, "the packet is > not dropped.") > + else: > + result_scanner =3D r"Forward Stats for RX > Port=3D %s/Queue=3D\s?([0-9]+)" % self.dut_ports[0] > + scanner =3D re.compile(result_scanner, re.DOTALL) > + if pf_vf =3D=3D "pf": > + m =3D scanner.search(outstring_pf) > + elif pf_vf =3D=3D "vf0": > + m =3D scanner.search(outstring_vf0) > + else: > + m =3D scanner.search(outstring_vf1) > + queue_id =3D m.group(1) > + self.verify(int(expect_queue) =3D=3D int(queue_id), "the act= ual > queue doesn't equal to the expected queue.") > + > + self.dut.send_expect("start", "testpmd> ") > + > + if self.vf_flag =3D=3D 1: > + self.session_secondary.send_expect("start", "testpmd> ") > + self.session_third.send_expect("start", "testpmd> ") Recommend to add one function for striping queue id and packet statistic fr= om testpmd session. Which can make verification function simple. > + > + def compare_memory_rules(self, expectedRules): > + """ > + dump all flow rules that have been created in memory and compare > that total rules number with the given expected number > + to see if they are equal, as to get your conclusion after you > have deleted any flow rule entry. > + """ > + outstring =3D self.dut.send_expect("flow list 0", "testpmd> ") > + result_scanner =3D r'\d*.*?\d*.*?\d*.*?=3D>*' > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.findall(outstring) > + print "All flow entries are: " > + for i in range(len(m)): > + print m[i] > + print 'Expected rules are: %d - actual are: %d' % (expectedRules= , > len(m)) > + self.verify(expectedRules =3D=3D len(m), 'Total rules number > mismatched') > + > + def all_flows_process(self, basic_flow_actions): > + """ > + Verify all the flows' action and return the created rule number. > + Return all the rules' elements to create inconsistet packets. Typo here, " inconsistet " should be inconsistent. > + Return all the expect queues which are consistent to the rules. > + """ > + extra_packet =3D [] > + expected_queue =3D [] > + rule_num =3D 0 > + for flow_action in basic_flow_actions: > + # generate the flow rule and corresponding packet. > + flow_process =3D self.generate_random_command(**flow_action) > + expected_queue.append(flow_process['queue']) > + # caculate the rule number created. > + rule_created =3D self.flow_test_process(flow_process, > flow_action) > + if rule_created: > + rule_num +=3D 1 > + extra_packet.append(flow_process['extrapacket']) > + # Configure a return value. > + extrapkt_rulenum =3D {'extrapacket': extra_packet, 'rulenum': > rule_num, 'queue': expected_queue} > + > + return extrapkt_rulenum > + > + def verify_rulenum(self, rule_num): > + """ > + Verify all the rules created. > + """ > + # check if there are expected flow rules have been created > + self.compare_memory_rules(rule_num) > + # check if one rule destoried with success > + self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ") > + self.compare_memory_rules(rule_num - 1) > + # check if all flow rules have been removed with success > + self.dut.send_expect("flow flush 0", "testpmd> ") > + self.compare_memory_rules(0) > + > + def flow_test_process(self, flow_process, flow_action): > + """ > + Add a flow rule and verify the action > + """ > + rule_created =3D 0 > + flow_cmd =3D flow_process['cmd'] > + flow_pkt =3D flow_process['pkt'] > + flow_queue =3D flow_process['queue'] > + if "validate" in flow_cmd: > + # ethertype invalid or queue id exceeds max queue number. > + if "86dd" in flow_cmd or "0800" in flow_cmd or "index %s" % > str(MAX_QUEUE + 1) in flow_cmd: > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single", "fortpark_TLV", "niantic", "kawela_4", "kawela= ", > "bartonhills", "twinville", "sagepond", "sageville", "powerville"]: > + self.dut.send_expect(flow_cmd, "error") > + elif "88cc" in flow_cmd or "type is 0x8100" in flow_cmd: > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single", "fortpark_TLV"]: > + self.dut.send_expect(flow_cmd, "error") > + # vf queue id exceeds max vf queue number. > + elif (("vf0" in flow_action['flows']) or ("vf1" in > flow_action['flows']) or ("vf0" in flow_action['actions']) or ("vf1" in > flow_action['actions'])) and (("index %s" % str(MAX_VFQUEUE + 1)) in > flow_cmd): > + self.dut.send_expect(flow_cmd, "error") > + else: > + self.dut.send_expect(flow_cmd, "validated") > + elif "create" in flow_cmd: > + # ethertype invalid or queue id exceeds max queue number. > + if "86dd" in flow_cmd or "0800" in flow_cmd or "index %s" % > str(MAX_QUEUE + 1) in flow_cmd: > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single", "fortpark_TLV", "niantic", "kawela_4", "kawela= ", > "bartonhills", "twinville", "sagepond", "sageville", "powerville"]: > + self.dut.send_expect(flow_cmd, "error") > + elif "88cc" in flow_cmd or "type is 0x8100" in flow_cmd: > + if self.nic in ["fortville_eagle", "fortville_spirit", > "fortville_spirit_single", "fortpark_TLV"]: > + self.dut.send_expect(flow_cmd, "error") > + # vf queue id exceeds max vf queue number. > + elif (("vf0" in flow_action['flows']) or ("vf1" in > flow_action['flows']) or ("vf0" in flow_action['actions']) or ("vf1" in > flow_action['actions'])) and (("index %s" % str(MAX_VFQUEUE + 1)) in > flow_cmd): > + self.dut.send_expect(flow_cmd, "error") > + else: > + self.dut.send_expect(flow_cmd, "created") > + rule_created =3D 1 > + # the rule is created successfully, so send the > consistent packet. > + self.tester.scapy_append('sendp(%s, iface=3D"%s")' % > (flow_pkt, self.tester_itf)) > + if ("queue" in flow_action['actions']) or ("passthru" in > flow_action['actions']): > + if ("vf0" in flow_action['flows']) or ("vf0" in > flow_action['actions']): > + self.verify_result("vf0", expect_rxpkts=3D"1", > expect_queue=3Dflow_queue) > + elif "vf1" in flow_action['flows'] or "vf1" in > flow_action['actions']: > + self.verify_result("vf1", expect_rxpkts=3D"1", > expect_queue=3Dflow_queue) > + else: > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dflow_queue) > + elif "drop" in flow_action['actions']: > + if ("vf0" in flow_action['flows']) or ("vf0" in > flow_action['actions']): > + self.verify_result("vf0", expect_rxpkts=3D"0", > expect_queue=3D"NULL") > + elif ("vf1" in flow_action['flows']) or ("vf1" in > flow_action['actions']): > + self.verify_result("vf1", expect_rxpkts=3D"0", > expect_queue=3D"NULL") > + else: > + self.verify_result("pf", expect_rxpkts=3D"0", > expect_queue=3D"NULL") > + # L2-tunnel filter > + else: > + if "vf0" in flow_action['actions']: > + self.verify_result("vf0", expect_rxpkts=3D"1", > expect_queue=3D"0") > + elif "vf1" in flow_action['actions']: > + self.verify_result("vf1", expect_rxpkts=3D"1", > expect_queue=3D"0") > + elif "pf" in flow_action['actions']: > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + # Return the status of the rule. > + return rule_created > + > + def generate_random_mac(self): > + return ':'.join('%02x' % random.randint(0, 255) for i in range(6= )) > + > + def generate_random_ip(self, is_ipv4): > + if is_ipv4 =3D=3D True: > + return '.'.join('%s' % random.randint(0, 255) for i in > range(4)) > + else: > + return ':'.join('{:x}'.format(random.randint(0, 2**16 - 1)) > for i in range(8)) > + > + def generate_random_int(self, minimum, maximum): > + return random.randint(minimum, maximum) > + > + def generate_random_command(self, create, flows=3D[], actions=3D[]): > + """ > + Return random content for flow and action commands > + Parameters: > + create : create the rule or validate the > rule > + flows [] : assigned flow layers > + actions [] : flow actions > + Return the packets including the consistent packet and > inconsistent > + packet. > + Return the expected queue which the packet distributed. > + """ > + # Define the flow rule command. > + cmd_fmt =3D "flow %(create)s 0 ingress pattern %(flow)s / end > actions %(action)s end" > + # Record the elements of the rule, ready for the configuration > + # of packets inconsistent to the rule. > + extrapacket =3D {'vlan': '', 'etag': '', 'ipv4': '', 'ipv6': '', > 'sip': '', 'dip': '', 'proto': '', 'tos': '', 'ttl': '', 'tcp': '', 'udp'= : > '', 'sctp': '', 'sport': '', 'dport': '', 'vni': '', 'tni': '', 'ineth': > '', 'invlan': ''} > + # Define the packet string, which is consistent to the flow rule= . > + if ('vf0' in flows) or ('vf1' in flows) or ('vf0' in actions) or > ('vf1' in actions): > + pkt =3D "Ether(dst=3D'%s')" % self.wrong_mac > + else: > + pkt =3D "Ether(dst=3D'%s')" % self.pf_mac > + # Define the flow string of the rule > + # Signature mode > + if 'fuzzy' in flows: > + thresh =3D self.generate_random_int(1, 15) > + flow_str =3D "fuzzy thresh is %d " % thresh > + # L2 tunnel > + elif 'etag' in flows: > + ecid =3D self.generate_random_int(4096, 8191) > + flow_str =3D "e_tag grp_ecid_b is %s " % hex(ecid) > + pkt +=3D "/Dot1BR(GRP=3D0x1, ECIDbase=3D%s)" % hex(ecid - 40= 96) > + extrapacket['etag'] =3D hex(ecid - 4096) > + else: > + flow_str =3D "eth " > + # Configure the flow and packet and extrapacket string > + for flow_type in flows: > + if flow_type =3D=3D "dst_mac": > + dmac =3D self.outer_mac > + flow_str +=3D "dst is %s " % dmac > + pkt =3D "Ether(dst=3D'%s')" % dmac > + elif flow_type =3D=3D "ether": > + if "dst_mac" in flows: > + dmac =3D self.outer_mac > + pkt =3D "Ether(dst=3D'%s'" % dmac > + else: > + pkt =3D "Ether(dst=3D'%s'" % self.pf_mac > + if 'eaps' in flows: > + eth_type =3D "0x8100" > + pkt +=3D ",type=3D0x8100)/Raw('x' * 20)" > + elif 'lwapp' in flows: > + eth_type =3D "0x86bb" > + pkt +=3D ",type=3D0x86bb)/Raw('x' * 20)" > + elif 'lldp' in flows: > + eth_type =3D "0x88cc" > + pkt +=3D ",type=3D0x88cc)/Raw('x' * 20)" > + elif 'ipv6_eth' in flows: > + eth_type =3D "0x86dd" > + pkt +=3D ",type=3D0x86dd)/Raw('x' * 20)" > + elif 'arp' in flows: > + eth_type =3D "0x0806" > + pkt =3D > "Ether(dst=3D'ff:ff:ff:ff:ff:ff')/ARP(pdst=3D'192.168.1.1')" > + elif 'ip_eth' in flows: > + eth_type =3D "0x0800" > + pkt +=3D ",type=3D0x0800)/Raw('x' * 20)" > + elif 'ppp' in flows: > + eth_type =3D "0x8864" > + pkt +=3D ",type=3D0x8864)/Raw('x' * 20)" > + elif 'mpls' in flows: > + eth_type =3D "0x8847" > + pkt +=3D ",type=3D0x8847)/Raw('x' * 20)" > + else: > + eth_type =3D "0x8000" > + pkt +=3D ",type=3D0x8000)/Raw('x' * 20)" > + flow_str +=3D "type is %s " % eth_type > + elif flow_type =3D=3D "vlan": > + vlan =3D self.generate_random_int(0, MAX_VLAN) > + flow_str +=3D "/ vlan tci is %d " % vlan > + pkt +=3D "/Dot1Q(vlan=3D%d)" % vlan > + extrapacket['vlan'] =3D str(vlan) > + elif flow_type =3D=3D "tpid": > + flow_str +=3D "tpid is 0x8100 " > + elif flow_type =3D=3D "ipv4": > + is_ipv4 =3D True > + flow_str +=3D "/ ipv4 " > + pkt +=3D "/IP(" > + sip =3D self.generate_random_ip(is_ipv4) > + dip =3D self.generate_random_ip(is_ipv4) > + if 'sip' in flows: > + flow_str +=3D "src is %s " % sip > + extrapacket['sip'] =3D sip > + pkt +=3D "src=3D'%s'" % sip > + if 'dip' in flows: > + flow_str +=3D "dst is %s " % dip > + extrapacket['dip'] =3D dip > + pkt +=3D ", dst=3D'%s'" % dip > + if 'proto' in flows: > + if "udp" in flows: > + proto =3D 17 > + extrapacket['proto'] =3D '17' > + elif "tcp" in flows: > + proto =3D 6 > + extrapacket['proto'] =3D '6' > + elif "sctp" in flows: > + proto =3D 132 > + extrapacket['proto'] =3D '132' > + else: > + proto =3D self.generate_random_int(0, MAX_PROTO) > + extrapacket['proto'] =3D str(proto) > + flow_str +=3D "proto is %d " % proto > + if 'sip' in flows or 'dip' in flows: > + pkt +=3D ", proto=3D%d" % proto > + # for 2-tuple > + else: > + pkt +=3D "proto=3D%d" % proto > + if 'tos' in flows: > + tos =3D self.generate_random_int(0, MAX_TOS) > + flow_str +=3D "tos is %d " % tos > + pkt +=3D ", tos=3D%d" % tos > + extrapacket['tos'] =3D tos > + if 'ttl' in flows: > + ttl =3D self.generate_random_int(0, MAX_TTL) > + flow_str +=3D "ttl is %d " % ttl > + pkt +=3D ", ttl=3D%d" % ttl > + extrapacket['ttl'] =3D ttl > + pkt +=3D ")" > + elif flow_type =3D=3D "ipv6": > + is_ipv4 =3D False > + flow_str +=3D "/ ipv6 " > + sip =3D self.generate_random_ip(is_ipv4) > + dip =3D self.generate_random_ip(is_ipv4) > + if 'sip' in flows: > + flow_str +=3D "src is %s " % sip > + extrapacket['sip'] =3D sip > + if 'dip' in flows: > + flow_str +=3D "dst is %s " % dip > + extrapacket['dip'] =3D dip > + pkt +=3D "/IPv6(src=3D'%s', dst=3D'%s'" % (sip, dip) > + if 'proto' in flows: > + if "udp" in flows: > + proto =3D 17 > + extrapacket['proto'] =3D '17' > + elif "tcp" in flows: > + proto =3D 6 > + extrapacket['proto'] =3D '6' > + elif "sctp" in flows: > + proto =3D 132 > + extrapacket['proto'] =3D '132' > + else: > + proto =3D self.generate_random_int(0, MAX_PROTO) > + extrapacket['proto'] =3D str(proto) > + flow_str +=3D "proto is %d " % proto > + pkt +=3D ", nh=3D%d" % proto > + if 'tc' in flows: > + tc =3D self.generate_random_int(0, 255) > + flow_str +=3D "tc is %d " % tc > + pkt +=3D ", tc=3D%d" % tc > + extrapacket['tos'] =3D str(tc) > + if 'hop' in flows: > + hop =3D self.generate_random_int(0, 255) > + flow_str +=3D "hop is %d " % hop > + pkt +=3D ", hlim=3D%d" % hop > + extrapacket['ttl'] =3D str(hop) > + if 'sctp' in flows: > + pkt +=3D ", nh=3D132" > + extrapacket['proto'] =3D '132' > + pkt +=3D ")" > + elif flow_type =3D=3D "tcp": > + flow_str +=3D "/ tcp " > + pkt +=3D "/TCP(" > + dport =3D self.generate_random_int(0, MAX_PORT) > + sport =3D self.generate_random_int(0, MAX_PORT) > + if 'dport' in flows: > + flow_str +=3D "dst is %s " % dport > + extrapacket['dport'] =3D dport > + pkt +=3D "dport=3D%s" % dport > + if 'sport' in flows: > + flow_str +=3D "src is %s " % sport > + extrapacket['sport'] =3D sport > + pkt +=3D ", sport=3D%s" % sport > + pkt +=3D ")" > + elif flow_type =3D=3D "udp": > + flow_str +=3D "/ udp " > + pkt +=3D "/UDP(" > + dport =3D self.generate_random_int(0, MAX_PORT) > + sport =3D self.generate_random_int(0, MAX_PORT) > + if 'dport' in flows: > + flow_str +=3D "dst is %s " % dport > + extrapacket['dport'] =3D dport > + pkt +=3D "dport=3D%s" % dport > + if 'sport' in flows: > + flow_str +=3D "src is %s " % sport > + extrapacket['sport'] =3D sport > + pkt +=3D ", sport=3D%s" % sport > + pkt +=3D ")" > + elif flow_type =3D=3D "sctp": > + flow_str +=3D "/ sctp " > + pkt +=3D "/SCTP(" > + dport =3D self.generate_random_int(0, MAX_PORT) > + sport =3D self.generate_random_int(0, MAX_PORT) > + if 'dport' in flows: > + flow_str +=3D "dst is %s " % dport > + extrapacket['dport'] =3D dport > + pkt +=3D "dport=3D%s" % dport > + if 'sport' in flows: > + flow_str +=3D "src is %s " % sport > + extrapacket['sport'] =3D sport > + pkt +=3D ", sport=3D%s" % sport > + if 'tag' in flows: > + flow_str +=3D "tag is 1 " > + pkt +=3D ", tag=3D1" > + pkt +=3D ")" > + elif flow_type =3D=3D "vxlan": > + flow_str +=3D "/ vxlan " > + if 'vni' in flows: > + vni =3D self.generate_random_int(0, MAX_VLAN) > + flow_str +=3D "vni is %d " % vni > + pkt +=3D "/Vxlan(vni=3D%d)" % vni > + extrapacket['vni'] =3D str(vni) > + else: > + pkt +=3D "/Vxlan()" > + elif flow_type =3D=3D "nvgre": > + flow_str +=3D "/ nvgre " > + if 'tni' in flows: > + vni =3D self.generate_random_int(0, MAX_VLAN) > + flow_str +=3D "tni is %d " % vni > + pkt +=3D "/NVGRE(TNI=3D%d)" % vni > + extrapacket['tni'] =3D str(vni) > + else: > + pkt +=3D "/NVGRE()" > + elif flow_type =3D=3D "ineth": > + inmac =3D self.inner_mac > + flow_str +=3D "/ eth dst is %s " % inmac > + pkt +=3D "/Ether(dst=3D'%s')" % inmac > + extrapacket['ineth'] =3D inmac > + elif flow_type =3D=3D "invlan": > + invlan =3D self.generate_random_int(0, MAX_VLAN) > + flow_str +=3D "/ vlan tci is %d " % invlan > + pkt +=3D "/Dot1Q(vlan=3D%d)" % invlan > + extrapacket['invlan'] =3D str(invlan) > + elif flow_type =3D=3D "vf0": > + flow_str +=3D "/ vf id is 0" > + elif flow_type =3D=3D "vf1": > + flow_str +=3D "/ vf id is 1" > + pkt +=3D "/Raw('x' * 20)" > + # Define the action string of the rule. > + act_str =3D "" > + index =3D 0 > + for action in actions: > + if action =3D=3D "pf": > + act_str +=3D "pf / " > + elif action =3D=3D "vf0": > + act_str +=3D "vf id 0 / " > + elif action =3D=3D "vf1": > + act_str +=3D "vf id 1 / " > + elif action =3D=3D "queue": > + if ("vf0" in flows) or ("vf1" in flows) or ("vf0" in > actions) or ("vf1" in actions): > + index =3D self.generate_random_int(0, MAX_VFQUEUE) > + else: > + index =3D self.generate_random_int(0, MAX_QUEUE) > + act_str +=3D "queue index %d / " % index > + elif action =3D=3D "invalid": > + if ("vf0" in flows) or ("vf1" in flows): > + index =3D MAX_VFQUEUE + 1 > + else: > + index =3D MAX_QUEUE + 1 > + act_str +=3D "queue index %d / " % index > + elif action =3D=3D "drop": > + act_str +=3D "drop / " > + index =3D "NULL" > + elif action =3D=3D "passthru": > + act_str +=3D "passthru / " > + index =3D 0 > + elif action =3D=3D "flag": > + act_str +=3D "flag / " > + elif action =3D=3D "mark": > + act_str +=3D "mark id 3 / " > + # Configure the whole flow rule. > + command =3D cmd_fmt % { "create": create, > + "flow": flow_str, > + "action": act_str} > + # Configure the return value. > + flow_process =3D {'cmd': command, 'pkt': pkt, 'queue': index, > 'extrapacket': extrapacket} > + > + return flow_process > + > + def test_syn_filter(self): > + """ > + Only supported by ixgbe and igb. > + """ > + self.verify(self.nic in ["niantic", "kawela_4", "kawela", > "bartonhills", "twinville", "sagepond", "sageville", > + "powerville"], "%s nic not support SYN > filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss -- > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # create the flow rules Could this case utilize all_flows_process function? Look like packet and fl= ow commands be can verified in that function. And inconsistent packet check can also be done in that function. If so, eac= h test case only need to define the flow format which need to verified. > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 / tcp flags spec > 0x02 flags mask 0x02 / end actions queue index 3 / end", "created") > + # send the packets and verify the results > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(dport=3D80,flags=3D"S")/Raw("x" * 20)], iface=3D= "%s")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"3"= ) > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(dport=3D80,flags=3D"PA")/Raw("x" * 20)], iface= =3D"%s")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + > + # the ipv6 rule is conflicted with ipv4 rule. > + self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ", 120) > + > + # create the flow rules > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv6 / tcp flags spec > 0x02 flags mask 0x02 / end actions queue index 4 / end", "created") > + # send the packets and verify the results > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/TCP(dport=3D80,flags=3D"S")/Raw("x" * 20)], iface=3D"%s"= )' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"4"= ) > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/TCP(dport=3D80,flags=3D"PA")/Raw("x" * 20)], iface=3D"%s= ")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + > + self.verify_rulenum(1) > + > + def test_n_tuple_filter(self): > + """ > + only supported by ixgbe and igb > + """ > + self.verify(self.nic in ["niantic", "kawela_4", "kawela", > + "twinville"], "%s nic not support n- > tuple filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss -- > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', 'proto'= , > 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', 'proto'= , > 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', 'proto'= , > 'sctp', 'sport', 'dport'], 'actions': ['queue']} > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] As previous comments, could inconsistent check also be done in all_flows_pr= ocess? May need more suiteable name for that function.=20 > + # send the packets inconsistent to the rules. > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", dst=3D"%s")/Raw("x"= * 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[0]['dip'], > extra_packet[0]['sip'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", > dst=3D"%s")/SCTP(sport=3D%s,dport=3D%s)/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[3]['dip'], extra_packet[3]['sip'], > extra_packet[3]['sport'], extra_packet[3]['dport'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", > dst=3D"%s")/SCTP(sport=3D%s,dport=3D%s)/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[0]['sip'], extra_packet[0]['dip'], > extra_packet[3]['sport'], extra_packet[3]['dport'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][0]) > + > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_2_tuple_filter(self): > + """ > + only supported by igb > + """ > + self.verify(self.nic in ["bartonhills", "powerville"], "%s nic > not support 2-tuple filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss -- > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # i350 and 82580 only support 2-tuple, and don't support SCTP > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'proto', 'udp', > 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'proto', 'tcp', > 'dport'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + # send the packets inconsistent to the rules. > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/UDP(sport=3D22,dport=3D24)/Raw("x" * 20)], iface=3D"= %s")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D32,dport=3D34)/Raw("x" * 20)], iface=3D"= %s")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_ethertype_filter(self): > + """ > + supported by i40e, ixgbe and igb > + """ > + self.verify(self.nic in ["niantic", "kawela_4", "kawela", > "bartonhills", "twinville", "sagepond", "sageville", > + "powerville", "fortville_eagle", > "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support ethertype filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss -- > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1), "-w %s --file- > prefix=3Dtest1" % self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # i40e,ixgbe and igb support different packet types. > + if (self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", "fortpark_TLV"]): > + > + basic_flow_actions =3D [ > + {'create': 'validate', 'flows': ['ether', 'arp'], > 'actions': ['queue']}, > + {'create': 'validate', 'flows': ['ether', 'arp'], > 'actions': ['invalid']}, > + {'create': 'validate', 'flows': ['ether', 'lldp'], > 'actions': ['queue']}, > + {'create': 'validate', 'flows': ['ether', 'ipv6_eth'], > 'actions': ['queue']}, > + {'create': 'validate', 'flows': ['ether', 'ip_eth'], > 'actions': ['queue']}, > + {'create': 'validate', 'flows': ['ether', 'eaps'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ether', 'arp'], 'actions= ': > ['invalid']}, > + {'create': 'create', 'flows': ['ether', 'arp'], 'actions= ': > ['queue']}, > + {'create': 'create', 'flows': ['ether', 'lwapp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ether', 'ppp'], 'actions= ': > ['drop']}, > + {'create': 'create', 'flows': ['dst_mac', 'ether', > 'mpls'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actio= ns) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + else: > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'validate', 'flows': ['ether', 'arp'], > 'actions': ['queue']}, > + {'create': 'validate', 'flows': ['ether', 'lldp'], > 'actions': ['invalid']}, > + {'create': 'validate', 'flows': ['ether', 'ipv6_eth'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ether', 'lldp'], > 'actions': ['invalid']}, > + {'create': 'create', 'flows': ['ether', 'arp'], 'actions= ': > ['queue']}, > + {'create': 'create', 'flows': ['ether', 'lldp'], > 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actio= ns) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s",type=3D0x88E5)/Raw("x" * 20)], > iface=3D"%s")' % (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_L2_tunnel_filter(self): > + """ > + only supported by ixgbe > + """ > + self.verify(self.nic in ["sagepond", "sageville"], "%s nic not > support fdir L2 payload filter" % self.nic) > + > + self.setup_env() > + # start testpmd on pf > + self.pmdout.start_testpmd("1S/4C/1T", "--rxq=3D4 --txq=3D4", "-w= %s - > -file-prefix=3Dpf -m 1024" % self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + # start testpmd on vf0 > + self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0 -n > 4 -m 1024 -w %s --file-prefix=3Dvf1 -- -i --rxq=3D4 --txq=3D4" % (self.ta= rget, > self.sriov_vfs_port[0].pci), "testpmd>", 120) > + self.session_secondary.send_expect("set fwd rxonly", "testpmd> "= ) > + self.session_secondary.send_expect("set verbose 1", "testpmd> ") > + self.session_secondary.send_expect("start", "testpmd> ") > + time.sleep(2) > + # start testpmd on vf1 > + self.session_third.send_expect("./%s/app/testpmd -c 0x1e00 -n 4 = - > m 1024 -w %s --file-prefix=3Dvf2 -- -i --rxq=3D4 --txq=3D4" % (self.targe= t, > self.sriov_vfs_port[1].pci), "testpmd>", 120) > + self.session_third.send_expect("set fwd rxonly", "testpmd> ") > + self.session_third.send_expect("set verbose 1", "testpmd> ") > + self.session_third.send_expect("start", "testpmd> ") > + time.sleep(2) > + > + # Enabling ability of parsing E-tag packet > + self.dut.send_expect("port config 0 l2-tunnel E-tag enable", > "testpmd> ") > + # Enable E-tag packet forwarding, set on pf > + self.dut.send_expect("E-tag set forwarding on port 0", "testpmd> > ") > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['etag'], 'actions': ['vf0']}, > + {'create': 'create', 'flows': ['etag'], 'actions': ['vf1']}, > + {'create': 'create', 'flows': ['etag'], 'actions': ['pf']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1BR(GRP=3D0x2, ECIDbase=3D%s)/R= aw("x" > * 20)], iface=3D"%s")' % (self.pf_mac, extra_packet[0]['etag'], > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"0", expect_queue=3D"NU= LL") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_L2_payload(self): > + """ > + only supported by i40e > + """ > + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support fdir L2 payload filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter- > mode=3Dperfect --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1), "-w %= s -- > file-prefix=3Dtest1" % self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['vlan'], 'actions': ['queue']= }, > + {'create': 'create', 'flows': ['ether', 'ppp'], 'actions': > ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_vlan(self): > + """ > + only supported by i40e > + """ > + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support fdir L2 payload filter" % self.nic) > + self.setup_env() > + # start testpmd on pf > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter- > mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_Q= UEUE+1), > "-w %s --file-prefix=3Dpf --socket-mem 1024,1024" % self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + # start testpmd on vf0 > + self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 > -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf1 -- -i --rxq=3D4 --t= xq=3D4 > --disable-rss --pkt-filter-mode=3Dperfect" % (self.target, > self.sriov_vfs_port[0].pci), "testpmd>", 120) > + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") > + self.session_secondary.send_expect("set verbose 1", "testpmd>") > + self.session_secondary.send_expect("start", "testpmd>") > + time.sleep(2) > + # start testpmd on vf1 > + self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -= n > 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf2 -- -i --rxq=3D4 --txq= =3D4 -- > disable-rss --pkt-filter-mode=3Dperfect" % (self.target, > self.sriov_vfs_port[1].pci), "testpmd>", 120) > + self.session_third.send_expect("set fwd rxonly", "testpmd>") > + self.session_third.send_expect("set verbose 1", "testpmd>") > + self.session_third.send_expect("start", "testpmd>") > + time.sleep(2) > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['vlan', 'ipv4'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'udp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'tcp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sctp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'vf0'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sctp', 'vf1'= ], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sctp'], > 'actions': ['drop']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'udp', 'vf1']= , > 'actions': ['drop']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'udp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'tcp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sctp'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'vf0'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'tcp', 'vf1']= , > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sctp'], > 'actions': ['drop']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'tcp', 'vf1']= , > 'actions': ['drop']} > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + # send the packets with dst/src ip and dst/src port. > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.1", > dst=3D"192.168.0.2", proto=3D3)/Raw("x" * 20)], iface=3D"%s")' % (self.pf= _mac, > extra_packet[0]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][0]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.1", > dst=3D"192.168.0.2", tos=3D3)/UDP()/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[1]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][1]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.1", > dst=3D"192.168.0.2", ttl=3D3)/TCP()/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[2]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][2]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.1", > dst=3D"192.168.0.2", tos=3D3, ttl=3D3)/SCTP()/Raw("x" * 20)], iface=3D"%s= ")' % > (self.pf_mac, extra_packet[3]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][3]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.1", > dst=3D"192.168.0.2", ttl=3D3)/TCP()/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[3]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP()/UDP()/Raw("x= " * > 20)], iface=3D"%s")' % (self.pf_mac, extra_packet[2]['vlan'], > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.5", > dst=3D"192.168.0.6", tos=3D3, ttl=3D3)/SCTP(sport=3D44,dport=3D45,tag=3D1= )/Raw("x" * > 20)], iface=3D"%s")' % (self.pf_mac, extra_packet[6]['vlan'], > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"0", expect_queue=3D"NU= LL") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IP(src=3D"192.168= .0.5", > dst=3D"192.168.0.6", tos=3D3, > ttl=3D3)/UDP(sport=3D44,dport=3D45)/SCTPChunkData(data=3D"X" * 20)], ifac= e=3D"%s")' % > (self.outer_mac, extra_packet[7]['vlan'], self.tester_itf)) > + self.verify_result("vf1", expect_rxpkts=3D"0", expect_queue=3D"N= ULL") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D1, nh=3D5, hlim=3D10)/Raw("x" * 20)], iface=3D"%s")= ' % > (self.pf_mac, extra_packet[8]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][8]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D2, hlim=3D20)/UDP(sport=3D22,dport=3D23)/Raw("x" * = 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[9]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][9]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D2, hlim=3D20)/TCP(sport=3D32,dport=3D33)/Raw("x" * = 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[10]['vlan'], self.tester_itf)= ) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][10]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D4, nh=3D132, > hlim=3D40)/SCTP(sport=3D44,dport=3D45,tag=3D1)/SCTPChunkData(data=3D"X" *= 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[11]['vlan'], self.tester_itf)= ) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][11]) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D4, nh=3D132, > hlim=3D40)/SCTP(sport=3D44,dport=3D45,tag=3D1)/SCTPChunkData(data=3D"X" *= 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[14]['vlan'], self.tester_itf)= ) > + self.verify_result("pf", expect_rxpkts=3D"0", expect_queue=3D"NU= LL") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2001:= :1", > dst=3D"2001::2", tc=3D2, hlim=3D20)/TCP(sport=3D32,dport=3D33)/Raw("x" * = 20)], > iface=3D"%s")' % (self.outer_mac, extra_packet[15]['vlan'], self.tester_i= tf)) > + self.verify_result("vf1", expect_rxpkts=3D"0", expect_queue=3D"N= ULL") > + > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_ipv4(self): > + """ > + only supported by i40e and ixgbe > + """ > + self.verify(self.nic in ["niantic", "twinville", "sagepond", > "sageville", > + "fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support fdir ipv4 filter" % self.nic) > + # i40e > + if (self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", "fortpark_TLV"]): > + self.setup_env() > + # start testpmd on pf > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt- > filter-mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1), "-w %s --file-prefix=3Dpf --socket-mem 1024,1024" % > self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + # start testpmd on vf0 > + self.session_secondary.send_expect("./%s/app/testpmd -c > 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf1 -- -i --rx= q=3D4 > --txq=3D4 --disable-rss --pkt-filter-mode=3Dperfect" % (self.target, > self.sriov_vfs_port[0].pci), "testpmd>", 120) > + self.session_secondary.send_expect("set fwd rxonly", > "testpmd>") > + self.session_secondary.send_expect("set verbose 1", > "testpmd>") > + self.session_secondary.send_expect("start", "testpmd>") > + time.sleep(2) > + # start testpmd on vf1 > + self.session_third.send_expect("./%s/app/testpmd -c > 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf2 -- -i -- > rxq=3D4 --txq=3D4 --disable-rss --pkt-filter-mode=3Dperfect" % (self.targ= et, > self.sriov_vfs_port[1].pci), "testpmd>", 120) > + self.session_third.send_expect("set fwd rxonly", "testpmd>") > + self.session_third.send_expect("set verbose 1", "testpmd>") > + self.session_third.send_expect("start", "testpmd>") > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'proto'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'ttl', 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'tos', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sip', > 'dip', 'tos', 'ttl', 'sctp', 'sport', 'dport', 'tag'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sip', > 'dip', 'tos', 'ttl', 'sctp', 'sport', 'dport', 'tag'], 'actions': > ['drop']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'proto', 'vf0'], 'actions': ['invalid']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'proto', 'vf0'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sip', > 'dip', 'tos', 'ttl', 'sctp', 'sport', 'dport', 'tag', 'vf1'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv4', 'sip', > 'dip', 'tos', 'ttl', 'sctp', 'sport', 'dport', 'tag'], 'actions': > ['passthru', 'flag']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'ttl', 'udp', 'sport', 'dport'], 'actions': ['queue', 'flag']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'tos', 'tcp', 'sport', 'dport'], 'actions': ['queue', 'mark']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'proto'], 'actions': ['passthru', 'mark']} > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actio= ns) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", > dst=3D"192.168.0.4", proto=3D%s)/Raw("x" * 20)], iface=3D"%s")' % (self.p= f_mac, > extra_packet[0]['proto'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + # ixgbe > + else: > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_Q= UEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + if (self.nic in ["sagepond", "sageville"]): > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'sctp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'sctp', 'sport', 'dport'], 'actions': ['drop']}, > + ] > + extrapkt_rulenum =3D > self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", > dst=3D"%s")/SCTP(sport=3D%s,dport=3D%s)/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[2]['sip'], extra_packet[2]['dip'], > extra_packet[2]['dport'], extra_packet[2]['sport'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") I expected that packet string has been=20 > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + else: > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'sctp'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv4', 'sip', 'dip', > 'sctp'], 'actions': ['drop']}, > + ] > + extrapkt_rulenum =3D > self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", > dst=3D"%s")/SCTP()/Raw("x" * 20)], iface=3D"%s")' % (self.pf_mac, > extra_packet[2]['dip'], extra_packet[2]['sip'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_ipv6(self): > + """ > + only supported by i40e and ixgbe > + """ > + self.verify(self.nic in ["niantic", "twinville", "sagepond", > "sageville", > + "fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support fdir ipv6 filter" % self.nic) > + # i40e > + if (self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", "fortpark_TLV"]): > + self.setup_env() > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt- > filter-mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1), "-w %s --file-prefix=3Dpf --socket-mem 1024,1024" % > self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + self.session_secondary.send_expect("./%s/app/testpmd -c > 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf1 -- -i --rx= q=3D4 > --txq=3D4 --disable-rss --pkt-filter-mode=3Dperfect" % (self.target, > self.sriov_vfs_port[0].pci), "testpmd>", 120) > + self.session_secondary.send_expect("set fwd rxonly", > "testpmd>") > + self.session_secondary.send_expect("set verbose 1", > "testpmd>") > + self.session_secondary.send_expect("start", "testpmd>") > + time.sleep(2) > + self.session_third.send_expect("./%s/app/testpmd -c > 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf2 -- -i -- > rxq=3D4 --txq=3D4 --disable-rss --pkt-filter-mode=3Dperfect" % (self.targ= et, > self.sriov_vfs_port[1].pci), "testpmd>", 120) > + self.session_third.send_expect("set fwd rxonly", "testpmd>") > + self.session_third.send_expect("set verbose 1", "testpmd>") > + self.session_third.send_expect("start", "testpmd>") > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'proto', 'tc', 'hop'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'sctp', 'sport', 'dport', 'tag'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'proto', 'tc', 'hop', 'vf0'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'tcp', 'sport', 'dport', 'vf1'], 'actions': > ['queue']}, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'sctp', 'sport', 'dport', 'tag'], 'actions': ['drop']= }, > + {'create': 'create', 'flows': ['vlan', 'ipv6', 'sip', > 'dip', 'tc', 'hop', 'tcp', 'sport', 'dport', 'vf1'], 'actions': ['drop']}= , > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actio= ns) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D%s)/IPv6(src=3D"2= 001::1", > dst=3D"2001::2", tc=3D2, hlim=3D20)/UDP(sport=3D22,dport=3D23)/Raw("x" * = 20)], > iface=3D"%s")' % (self.pf_mac, extra_packet[1]['vlan'], self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + # ixgbe signature > + else: > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dsignature --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + if (self.nic in ["niantic", "twinville"]): > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['fuzzy', 'ipv6', 'sip= ', > 'dip'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv6', 'sip= ', > 'dip', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv6', 'sip= ', > 'dip', 'sctp'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'sctp'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D > self.all_flows_process(basic_flow_actions) > + self.dut.send_expect( > + "flow create 0 ingress pattern fuzzy thresh spec 2 > thresh last 5 thresh mask 0xffffffff / ipv6 src is 2001::1 dst is 2001::2 > / udp src is 22 dst is 23 / end actions queue index 1 / end", "created") > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2",nh=3D132)/SCTP()/Raw("x" * 20)], iface=3D"%s")' % (self.p= f_mac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/SCTP()/Raw("x" * 20)], iface=3D"%s")' % (self.pf_mac= , > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/UDP(sport=3D22,dport=3D23)/Raw("x" * 20)], iface=3D"%s")= ' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"1") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num+1) > + elif (self.nic in ["sagepond", "sageville"]): > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'udp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv6', 'sip= ', > 'dip', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'tcp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv6', 'sip= ', > 'dip', 'sctp', 'sport', 'dport'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['fuzzy', 'ipv4', 'sip= ', > 'dip', 'sctp', 'sport', 'dport'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D > self.all_flows_process(basic_flow_actions) > + self.dut.send_expect( > + "flow create 0 ingress pattern fuzzy thresh spec 2 > thresh last 5 thresh mask 0xffffffff / ipv6 src is 2001::1 dst is 2001::2 > / udp src is 22 dst is 23 / end actions queue index 1 / end", "created") > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"%s", dst=3D"%s= ", > nh=3D132)/SCTP(sport=3D32,dport=3D33,tag=3D1)/Raw("x" * 20)], iface=3D"%s= ")' % > (self.pf_mac, extra_packet[3]['sip'], extra_packet[3]['dip'], > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"%s", dst=3D"%s", > proto=3D132)/SCTP(sport=3D32,dport=3D33)/Raw("x" * 20)], iface=3D"%s")' % > (self.pf_mac, extra_packet[4]['dip'], extra_packet[4]['sip'], > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/UDP(sport=3D22,dport=3D23)/Raw("x" * 20)], iface=3D"%s")= ' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"1") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num+1) > + > + def test_fdir_for_flexbytes(self): > + """ > + The filter structure is different between igb, ixgbe and i40e > + """ > + self.verify(self.nic in ["niantic", "twinville", "sagepond", > "sageville", > + "fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support fdir flexbytes filter" % self.nic) > + # i40e > + if (self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", "fortpark_TLV"]): > + > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt- > filter-mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1), "-w %s --file-prefix=3Dpf --socket-mem 1024,1024" % > self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # creat the flow rules > + # l2-payload exceeds the max length of raw match is 16bytes > + self.dut.send_expect( > + "flow create 0 ingress pattern eth type is 0x0807 / raw > relative is 1 pattern is abcdefghijklmnopq / end actions queue index 1 / > end", "Exceeds maxmial payload limit") > + # l2-payload equal the max length of raw match is 16bytes > + self.dut.send_expect( > + "flow create 0 ingress pattern eth type is 0x0807 / raw > relative is 1 pattern is abcdefghijklmnop / end actions queue index 1 / > end", "created") > + # ipv4-other the most 3 fields can be matched, and the max > sum bytes of the three fields is 16 bytes. > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / vlan tci is 4095 / > ipv4 proto is 255 ttl is 40 / raw relative is 1 offset is 2 pattern is ab > / raw relative is 1 offset is 10 pattern is abcdefghij / raw relative is = 1 > offset is 0 pattern is abcd / end actions queue index 2 / end", "created"= ) > + # ipv4-udp > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 > dst is 2.2.2.5 / udp src is 22 dst is 23 / raw relative is 1 offset is 2 > pattern is fhds / end actions queue index 3 / end", "created") > + # ipv4-tcp > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 > dst is 2.2.2.5 tos is 4 ttl is 3 / tcp src is 32 dst is 33 / raw relative > is 1 offset is 2 pattern is hijk / end actions queue index 4 / end", > "created") > + # ipv4-sctp > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 > dst is 2.2.2.5 / sctp src is 42 / raw relative is 1 offset is 2 pattern i= s > abcd / end actions queue index 5 / end", "created") > + > + # send the packets and verify the results > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s", > type=3D0x0807)/Raw(load=3D"abcdefghijklmnop")], iface=3D"%s")' % (self.pf= _mac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"1") > + > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D4095)/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2", proto=3D255, > ttl=3D40)/Raw(load=3D"xxabxxxxxxxxxxabcdefghijabcdefg")], iface=3D"%s")' = % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"2") > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"2.2.2.4", > dst=3D"2.2.2.5")/UDP(sport=3D22,dport=3D23)/Raw(load=3D"fhfhdsdsfwef")], > iface=3D"%s")' % (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"3") > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"2.2.2.4", dst=3D"2.2= .2.5", > tos=3D4, ttl=3D3)/TCP(sport=3D32,dport=3D33)/Raw(load=3D"fhhijk")], iface= =3D"%s")' % > (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"4") > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"2.2.2.4", > dst=3D"2.2.2.5")/SCTP(sport=3D42,dport=3D43,tag=3D1)/Raw(load=3D"xxabcdef= ghijklmnopq > rst")], iface=3D"%s")' % (self.pf_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"5") > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"2.2.2.4", > dst=3D"2.2.2.5")/SCTP(sport=3D42,dport=3D43,tag=3D1)/Raw(load=3D"xxabxxxa= bcddxxabcde > fghijklmn")], iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + > + self.verify_rulenum(5) > + > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt- > filter-mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1), "-w %s --file-prefix=3Dpf --socket-mem 1024,1024" % > self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # ipv6-tcp > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / vlan tci is 1 / ipv= 6 > src is 2001::1 dst is 2001::2 tc is 3 hop is 30 / tcp src is 32 dst is 33 > / raw relative is 1 offset is 0 pattern is hijk / raw relative is 1 offse= t > is 8 pattern is abcdefgh / end actions queue index 6 / end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Dot1Q(vlan=3D1)/IPv6(src=3D"20= 01::1", > dst=3D"2001::2", tc=3D3, > hlim=3D30)/TCP(sport=3D32,dport=3D33)/Raw(load=3D"hijkabcdefghabcdefghijk= lmn")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"6") > + > + # ixgbe > + else: > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_Q= UEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # ipv4-udp-flexbytes > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 src is > 192.168.0.1 dst is 192.168.0.2 / udp src is 24 dst is 25 / raw relative i= s > 0 search is 0 offset is 44 limit is 0 pattern is 86 / end actions queue > index 1 / end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/UDP(sport=3D24,dport=3D25)/Raw(load=3D"xx86ddef")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"1") > + > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + > + # the second flexbytes rule should be created after the > testpmd reset, because the flexbytes rule is global bit masks > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_Q= UEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # ipv4-tcp-flexbytes spec-mask > + self.dut.send_expect( > + "flow create 0 ingress pattern eth / ipv4 src is > 192.168.0.3 dst is 192.168.0.4 / tcp src is 22 dst is 23 / raw relative > spec 0 relative mask 1 search spec 0 search mask 1 offset spec 54 offset > mask 0xffffffff limit spec 0 limit mask 0xffff pattern is ab pattern is c= d > / end actions queue index 2 / end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", > dst=3D"192.168.0.4")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"abcdxxx")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.3", > dst=3D"192.168.0.4")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"cdcdxxx")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"2") > + > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + > + # signature mode > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dsignature --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # ipv4-sctp-flexbytes > + if (self.nic in ["sagepond", "sageville"]): > + self.dut.send_expect( > + "flow create 0 ingress pattern fuzzy thresh is 6 / > eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp src is 24 dst is > 25 / raw relative is 0 search is 0 offset is 48 limit is 0 pattern is ab = / > end actions queue index 3 / end", "created") > + else: > + self.dut.send_expect( > + "flow create 0 ingress pattern fuzzy thresh is 6 / > eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp / raw relative is > 0 search is 0 offset is 48 limit is 0 pattern is ab / end actions queue > index 3 / end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/SCTP(sport=3D24,dport=3D25)/Raw(load=3D"xxabcdef")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"3") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/SCTP(sport=3D24,dport=3D25)/Raw(load=3D"xxaccdef")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue= =3D"0") > + > + # ipv6-other-flexbytes > + if (self.nic in ["niantic", "twinville"]): > + self.dut.send_expect("quit", "# ") > + time.sleep(2) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt- > filter-mode=3Dsignature --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE= +1, > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + self.dut.send_expect( > + "flow create 0 ingress pattern fuzzy thresh is 6 / > ipv6 src is 2001::1 dst is 2001::2 / raw relative is 0 search is 0 offset > is 56 limit is 0 pattern is 86 / end actions queue index 4 / end", > "created") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/Raw(load=3D"xx86abcd")], iface=3D"%s")' % (self.outer_ma= c, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"4") > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/Raw(load=3D"xxx86abcd")], iface=3D"%s")' % (self.outer_m= ac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3D"0") > + > + def test_flexbytes_filter(self): > + """ > + The filter structure is different between igb, ixgbe and i40e > + """ > + self.verify(self.nic in ["bartonhills", "powerville"], "%s nic > not support flexbytes filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss -= - > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + Could flexbytes format generation also can be done by function, maybe plus = some kind of random check? > + # create the flow rules > + # l2_payload > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 1= 4 > pattern is fhds / end actions queue index 1 / end", "created") > + # ipv4 packet > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 3= 4 > pattern is ab / end actions queue index 2 / end", "created") > + # ipv6 packet > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 5= 8 > pattern is efgh / end actions queue index 3 / end", "created") > + # 3 fields relative is 0 > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 3= 8 > pattern is ab / raw relative is 0 offset is 34 pattern is cd / raw > relative is 0 offset is 42 pattern is efgh / end actions queue index 4 / > end", "created") > + # 4 fields relative is 0 and 1 > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 4= 8 > pattern is ab / raw relative is 1 offset is 0 pattern is cd / raw relativ= e > is 0 offset is 44 pattern is efgh / raw relative is 1 offset is 10 patter= n > is hijklmnopq / end actions queue index 5 / end", "created") > + # 3 fields offset confilict > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 6= 4 > pattern is ab / raw relative is 1 offset is 4 pattern is cdefgh / raw > relative is 0 offset is 68 pattern is klmn / end actions queue index 6 / > end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Raw(load=3D"fhdsab")], iface=3D"%s= ")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"1"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/Raw(load=3D"afhdsb")], iface=3D"%s= ")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/Raw(load=3D"abcdef")], iface=3D"%s")' % (self.outer_= mac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"2"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/Raw(load=3D"xxxxefgh")], iface=3D"%s")' % (self.outer_ma= c, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"3"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IPv6(src=3D"2001::1", > dst=3D"2001::2")/TCP(sport=3D32,dport=3D33)/Raw(load=3D"abcdefgh")], ifac= e=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/Raw(load=3D"cdxxabxxefghxxxx")], iface=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"4"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2", tos=3D4, > ttl=3D3)/UDP(sport=3D32,dport=3D33)/Raw(load=3D"xxefghabcdxxxxxxhijklmnop= qxxxx")], > iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"5"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxabx= xklmnefgh > ")], iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"6"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxabx= xklcdefgh > ")], iface=3D"%s")' % (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + > + self.dut.send_expect("flow flush 0", "testpmd> ", 120) > + > + # 1 field 128bytes > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is > 128 pattern is ab / end actions queue index 1 / end", "Failed to create > flow") > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is > 126 pattern is abcd / end actions queue index 1 / end", "Failed to create > flow") > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is > 126 pattern is ab / end actions queue index 1 / end", "created") > + # 2 field 128bytes > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 6= 8 > pattern is ab / raw relative is 1 offset is 58 pattern is cd / end action= s > queue index 2 / end", "Failed to create flow") > + self.dut.send_expect( > + "flow create 0 ingress pattern raw relative is 0 offset is 6= 8 > pattern is ab / raw relative is 1 offset is 56 pattern is cd / end action= s > queue index 2 / end", "created") > + > + # send the packet and verify the result > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxxxx= xxxxxxxxx > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxab")], iface=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"1"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxxxx= xxxxxxxxx > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcb")], iface=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxxxx= xabxxxxxx > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcd")], iface=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"2"= ) > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(src=3D"192.168.0.1", > dst=3D"192.168.0.2")/TCP(sport=3D22,dport=3D23)/Raw(load=3D"xxxxxxxxxxxxx= xabxxxxxx > xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxce")], iface=3D"%s")' % > (self.outer_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + > + self.verify_rulenum(2) > + > + def test_fdir_for_mac_vlan(self): > + """ > + only supported by ixgbe > + """ > + self.verify(self.nic in ["twinville", "sagepond", "sageville"], > "%s nic not support fdir flexbytes filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect-mac-vlan --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE= +1, > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("vlan set strip off 0", "testpmd> ", 120) > + self.dut.send_expect("vlan set filter off 0", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['dst_mac', 'vlan', 'tpid'], > 'actions': ['queue']}, > + {'create': 'create', 'flows': ['dst_mac', 'vlan', 'tpid'], > 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_vxlan(self): > + """ > + only supported by ixgbe > + """ > + self.verify(self.nic in ["twinville", "sagepond", "sageville"], > "%s nic not support fdir flexbytes filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect-tunnel --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', 'vni'= , > 'ineth', 'invlan', 'tpid'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv6', 'udp', 'vxlan', 'vni'= , > 'ineth', 'invlan', 'tpid'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_fdir_for_nvgre(self): > + """ > + only supported by ixgbe > + """ > + self.verify(self.nic in ["twinville", "sagepond", "sageville"], > "%s nic not support fdir flexbytes filter" % self.nic) > + > + self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter- > mode=3Dperfect-tunnel --disable-rss --rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1= , > MAX_QUEUE+1)) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'tni', > 'ineth', 'invlan'], 'actions': ['queue']}, > + {'create': 'create', 'flows': ['ipv6', 'nvgre', 'tni', > 'ineth', 'invlan'], 'actions': ['queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_tunnel_filter_vxlan(self): > + """ > + only supported by i40e > + """ > + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support tunnel vxlan filter" % self.nic) > + > + self.setup_env() > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss -= - > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1), "-w %s --file-prefix= =3Dpf -- > socket-mem 1024,1024" % self.pf_pci) > + self.dut.send_expect("rx_vxlan_port add 4789 0", "testpmd> ", 12= 0) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 > -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf1 -- -i --rxq=3D4 --t= xq=3D4 > --disable-rss" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", > 120) > + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") > + self.session_secondary.send_expect("set verbose 1", "testpmd>") > + self.session_secondary.send_expect("start", "testpmd>") > + time.sleep(2) > + self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -= n > 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf2 -- -i --rxq=3D4 --txq= =3D4 -- > disable-rss" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120= ) > + self.session_third.send_expect("set fwd rxonly", "testpmd>") > + self.session_third.send_expect("set verbose 1", "testpmd>") > + self.session_third.send_expect("start", "testpmd>") > + time.sleep(2) Some setup functions are duplicated, may need one function for testpmd star= tup and set verbose rx mode. > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', > 'ineth'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', 'vni'= , > 'ineth'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', > 'ineth', 'invlan'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', 'vni'= , > 'ineth', 'invlan'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['dst_mac', 'ipv4', 'udp', > 'vxlan', 'vni', 'ineth'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'udp', 'vxlan', 'vni'= , > 'ineth', 'invlan'], 'actions': ['vf0', 'queue']}, > + {'create': 'create', 'flows': ['dst_mac', 'ipv4', 'udp', > 'vxlan', 'vni', 'ineth'], 'actions': ['vf1', 'queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/UDP()/Vxlan()/Ether(dst=3D"%s")/Dot1Q(vlan= =3D11)/ > IP()/TCP()/Raw("x" * 20)], iface=3D"%s")' % (self.outer_mac, self.inner_m= ac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][0]) > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/UDP()/Vxlan(vni=3D5)/Ether(dst=3D"%s")/IP(= )/TCP() > /Raw("x" * 20)], iface=3D"%s")' % (self.outer_mac, self.wrong_mac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/UDP()/Vxlan(vni=3D%s)/Ether(dst=3D"%s")/Do= t1Q(vla > n=3D%s)/IP()/TCP()/Raw("x" * 20)], iface=3D"%s")' % (self.outer_mac, > extra_packet[5]['vni'], self.wrong_mac, extra_packet[5]['invlan'], > self.tester_itf)) > + self.verify_result("vf0", expect_rxpkts=3D"1", expect_queue=3D"0= ") > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/UDP()/Vxlan(vni=3D%s)/Ether(dst=3D"%s")/IP= ()/TCP( > )/Raw("x" * 20)], iface=3D"%s")' % (self.wrong_mac, extra_packet[6]['vni'= ], > self.inner_mac, self.tester_itf)) > + self.verify_result("vf1", expect_rxpkts=3D"0", expect_queue=3D"N= ULL") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def test_tunnel_filter_nvgre(self): > + """ > + only supported by i40e > + """ > + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", > "fortpark_TLV"], "%s nic not support tunnel nvgre filter" % self.nic) > + > + self.setup_env() > + self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss -= - > rxq=3D%d --txq=3D%d" % (MAX_QUEUE+1, MAX_QUEUE+1), "-w %s --file-prefix= =3Dpf -- > socket-mem 1024,1024" % self.pf_pci) > + self.dut.send_expect("set fwd rxonly", "testpmd> ", 120) > + self.dut.send_expect("set verbose 1", "testpmd> ", 120) > + self.dut.send_expect("start", "testpmd> ", 120) > + time.sleep(2) > + self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 > -n 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf1 -- -i --rxq=3D4 --t= xq=3D4 > --disable-rss" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", > 120) > + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") > + self.session_secondary.send_expect("set verbose 1", "testpmd>") > + self.session_secondary.send_expect("start", "testpmd>") > + time.sleep(2) > + self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -= n > 4 --socket-mem 1024,1024 -w %s --file-prefix=3Dvf2 -- -i --rxq=3D4 --txq= =3D4 -- > disable-rss" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120= ) > + self.session_third.send_expect("set fwd rxonly", "testpmd>") > + self.session_third.send_expect("set verbose 1", "testpmd>") > + self.session_third.send_expect("start", "testpmd>") > + time.sleep(2) > + > + # create the flow rules > + basic_flow_actions =3D [ > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'ineth'], > 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'tni', > 'ineth'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'ineth', > 'invlan'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'tni', > 'ineth', 'invlan'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['dst_mac', 'ipv4', 'nvgre', > 'tni', 'ineth'], 'actions': ['pf', 'queue']}, > + {'create': 'create', 'flows': ['ipv4', 'nvgre', 'tni', > 'ineth', 'invlan'], 'actions': ['vf0', 'queue']}, > + {'create': 'create', 'flows': ['dst_mac', 'ipv4', 'nvgre', > 'tni', 'ineth'], 'actions': ['vf1', 'queue']}, > + ] > + extrapkt_rulenum =3D self.all_flows_process(basic_flow_actions) > + extra_packet =3D extrapkt_rulenum['extrapacket'] > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/NVGRE()/Ether(dst=3D"%s")/Dot1Q(vlan=3D1)/= IP()/TC > P()/Raw("x" * 20)], iface=3D"%s")' % (self.outer_mac, self.inner_mac, > self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", > expect_queue=3Dextrapkt_rulenum['queue'][0]) > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/NVGRE(TNI=3D%s)/Ether(dst=3D"%s")/IP()/TCP= ()/Raw( > "x" * 20)], iface=3D"%s")' % (self.outer_mac, extra_packet[4]['tni'], > self.wrong_mac, self.tester_itf)) > + self.verify_result("pf", expect_rxpkts=3D"1", expect_queue=3D"0"= ) > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/NVGRE(TNI=3D%s)/Ether(dst=3D"%s")/Dot1Q(vl= an=3D%s)/ > IP()/TCP()/Raw("x" * 20)], iface=3D"%s")' % (self.outer_mac, > extra_packet[5]['tni'], self.wrong_mac, extra_packet[5]['invlan'], > self.tester_itf)) > + self.verify_result("vf0", expect_rxpkts=3D"1", expect_queue=3D"0= ") > + self.tester.scapy_append( > + > 'sendp([Ether(dst=3D"%s")/IP()/NVGRE(TNI=3D%s)/Ether(dst=3D"%s")/IP()/TCP= ()/Raw( > "x" * 20)], iface=3D"%s")' % (self.wrong_mac, extra_packet[6]['tni'], > self.inner_mac, self.tester_itf)) > + self.verify_result("vf1", expect_rxpkts=3D"0", expect_queue=3D"N= ULL") > + rule_num =3D extrapkt_rulenum['rulenum'] > + self.verify_rulenum(rule_num) > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.destroy_env() > + self.dut.kill_all() > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.dut.kill_all() > + self.dut.close_session(self.session_secondary) > + self.dut.close_session(self.session_third) > -- > 2.5.0