get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/83630/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 83630,
    "url": "http://patches.dpdk.org/api/patches/83630/?format=api",
    "web_url": "http://patches.dpdk.org/project/dts/patch/20201104102528.6880-3-qinx.sun@intel.com/",
    "project": {
        "id": 3,
        "url": "http://patches.dpdk.org/api/projects/3/?format=api",
        "name": "DTS",
        "link_name": "dts",
        "list_id": "dts.dpdk.org",
        "list_email": "dts@dpdk.org",
        "web_url": "",
        "scm_url": "git://dpdk.org/tools/dts",
        "webscm_url": "http://git.dpdk.org/tools/dts/",
        "list_archive_url": "https://inbox.dpdk.org/dts",
        "list_archive_url_format": "https://inbox.dpdk.org/dts/{}",
        "commit_url_format": ""
    },
    "msgid": "<20201104102528.6880-3-qinx.sun@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dts/20201104102528.6880-3-qinx.sun@intel.com",
    "date": "2020-11-04T10:25:27",
    "name": "[V1,2/3] tests/cvl_limit_value_test add test suite",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "995ea7f7b05544a8c5b7cafa242d797da935f5d7",
    "submitter": {
        "id": 1956,
        "url": "http://patches.dpdk.org/api/people/1956/?format=api",
        "name": "Sun, QinX",
        "email": "qinx.sun@intel.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dts/patch/20201104102528.6880-3-qinx.sun@intel.com/mbox/",
    "series": [
        {
            "id": 13634,
            "url": "http://patches.dpdk.org/api/series/13634/?format=api",
            "web_url": "http://patches.dpdk.org/project/dts/list/?series=13634",
            "date": "2020-11-04T10:25:25",
            "name": "add test suite cvl_limit_value_test",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/13634/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/83630/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/83630/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dts-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 30E5FA04E7;\n\tWed,  4 Nov 2020 02:47:52 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 298ECBE61;\n\tWed,  4 Nov 2020 02:47:51 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n by dpdk.org (Postfix) with ESMTP id 26F3E5B30\n for <dts@dpdk.org>; Wed,  4 Nov 2020 02:47:48 +0100 (CET)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 03 Nov 2020 17:47:47 -0800",
            "from unknown (HELO localhost.localdomain) ([10.240.183.105])\n by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 03 Nov 2020 17:47:45 -0800"
        ],
        "IronPort-SDR": [
            "\n j0da/5nWByqLCE7HDcg6VoeJaRqSjpdS2IXhuojAErTy/kX+AfaXrnlmznIjF6vo20PZtACRrN\n 2MxMZkTBsdLg==",
            "\n FKaqbeqbGw0oF/ib6D+UtJAAp4pCWROvc8eShASl7fQG2Zwf0Gd7H0wBNVfSPcfMAHmIZrWqp8\n 3ApyU927larg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9794\"; a=\"156141940\"",
            "E=Sophos;i=\"5.77,449,1596524400\"; d=\"scan'208\";a=\"156141940\"",
            "E=Sophos;i=\"5.77,449,1596524400\"; d=\"scan'208\";a=\"538713715\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "From": "sunqin <qinx.sun@intel.com>",
        "To": "dts@dpdk.org",
        "Cc": "sunqin <qinx.sun@intel.com>",
        "Date": "Wed,  4 Nov 2020 10:25:27 +0000",
        "Message-Id": "<20201104102528.6880-3-qinx.sun@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20201104102528.6880-1-qinx.sun@intel.com>",
        "References": "<20201104102528.6880-1-qinx.sun@intel.com>",
        "Subject": "[dts]  [PATCH V1 2/3] tests/cvl_limit_value_test add test suite",
        "X-BeenThere": "dts@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "test suite reviews and discussions <dts.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dts>,\n <mailto:dts-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dts/>",
        "List-Post": "<mailto:dts@dpdk.org>",
        "List-Help": "<mailto:dts-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dts>,\n <mailto:dts-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dts-bounces@dpdk.org",
        "Sender": "\"dts\" <dts-bounces@dpdk.org>"
    },
    "content": "These 8 cases take a long time to run, so split them from 3 already existed\n\nsuites(iavf_fdir, cvl_fdir, cvl_dcf_switch_filter) and make them as a new test suite.\n\nSigned-off-by: sunqin <qinx.sun@intel.com>\n---\n tests/TestSuite_cvl_limit_value_test.py | 917 ++++++++++++++++++++++++\n 1 file changed, 917 insertions(+)\n create mode 100644 tests/TestSuite_cvl_limit_value_test.py",
    "diff": "diff --git a/tests/TestSuite_cvl_limit_value_test.py b/tests/TestSuite_cvl_limit_value_test.py\nnew file mode 100644\nindex 0000000..77ce016\n--- /dev/null\n+++ b/tests/TestSuite_cvl_limit_value_test.py\n@@ -0,0 +1,917 @@\n+# BSD LICENSE\n+#\n+# Copyright(c) 2020 Intel Corporation. All rights reserved.\n+# All rights reserved.\n+#\n+# Redistribution and use in source and binary forms, with or without\n+# modification, are permitted provided that the following conditions\n+# are met:\n+#\n+#   * Redistributions of source code must retain the above copyright\n+#     notice, this list of conditions and the following disclaimer.\n+#   * Redistributions in binary form must reproduce the above copyright\n+#     notice, this list of conditions and the following disclaimer in\n+#     the documentation and/or other materials provided with the\n+#     distribution.\n+#   * Neither the name of Intel Corporation nor the names of its\n+#     contributors may be used to endorse or promote products derived\n+#     from this software without specific prior written permission.\n+#\n+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+\n+import re\n+import time\n+import os\n+import copy\n+from packet import Packet\n+from pmd_output import PmdOutput\n+from test_case import TestCase\n+import rte_flow_common as rfc\n+from rte_flow_common import CVL_TXQ_RXQ_NUMBER\n+import utils\n+\n+# max rule number case: rte_flow_pattern and matched packets will be generated by code, and rte_flow_pattern will be writed to file.\n+tv_max_rule_number = {\n+    \"name\": \"tv_max_rule_number\",\n+    \"rte_flow_pattern\": [],\n+    \"matched\": {\"scapy_str\": [],\n+                \"check_func\": {\"func\": rfc.check_vf_rx_packets_number,\n+                               \"param\": {\"expect_port\": 1}},\n+                \"expect_results\": {\"expect_pkts\": 32563}},\n+    \"mismatched\": {\n+        \"scapy_str\": ['Ether(dst=\"68:05:ca:8d:ed:a8\")/IP(src=\"192.167.0.1\")/TCP(sport=25,dport=23)/(\"X\"*480)'],\n+        \"check_func\": {\"func\": rfc.check_vf_rx_packets_number,\n+                       \"param\": {\"expect_port\": 1}},\n+        \"expect_results\": {\"expect_pkts\": 0}}\n+}\n+\n+\n+class TestCvlLimitValue(TestCase):\n+\n+    def set_up_all(self):\n+        \"\"\"\n+        Run at the start of each test suite.\n+        prerequisites.\n+        \"\"\"\n+        # Based on h/w type, choose how many ports to use\n+        self.dut_ports = self.dut.get_ports(self.nic)\n+        self.verify(len(self.dut_ports) >= 2, \"Insufficient ports for testing\")\n+        # Verify that enough threads are available\n+        cores = self.dut.get_core_list(\"1S/4C/1T\")\n+        self.verify(cores is not None, \"Insufficient cores for testing\")\n+        self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])\n+        self.portMask = utils.create_mask([self.dut_ports[0], self.dut_ports[1]])\n+        localPort0 = self.tester.get_local_port(self.dut_ports[0])\n+        localPort1 = self.tester.get_local_port(self.dut_ports[1])\n+        self.tester_iface0 = self.tester.get_interface(localPort0)\n+        self.tester_iface1 = self.tester.get_interface(localPort1)\n+        self.pf0_intf = self.dut.ports_info[self.dut_ports[0]]['intf']\n+        self.pf1_intf = self.dut.ports_info[self.dut_ports[1]]['intf']\n+        self.pf0_mac = self.dut.get_mac_address(0)\n+        self.pf1_mac = self.dut.get_mac_address(1)\n+        self.pci0 = self.dut.ports_info[self.dut_ports[0]]['pci']\n+        self.pci1 = self.dut.ports_info[self.dut_ports[1]]['pci']\n+\n+        self.pkt = Packet()\n+        self.pmd_output = PmdOutput(self.dut)\n+        self.path = self.dut.apps_name['test-pmd']\n+\n+        self.src_file_dir = 'dep/'\n+        self.cvlq_num = CVL_TXQ_RXQ_NUMBER\n+\n+        #max_rule number\n+        localPort = self.tester.get_local_port(self.dut_ports[0])\n+        self.__tx_iface = self.tester.get_interface(localPort)\n+        self.pkt = Packet()\n+\n+    def set_up_for_iavf_dir(self):\n+        \"\"\"\n+        Run before each test case.\n+        \"\"\"\n+        #bind pf to kernel\n+        for port in self.dut_ports:\n+            netdev = self.dut.ports_info[port]['port']\n+            netdev.bind_driver(driver='ice')\n+        #set vf driver\n+        self.vf_driver = 'vfio-pci'\n+        self.dut.send_expect('modprobe vfio-pci', '#')\n+        self.suite_config = rfc.get_suite_config(self)\n+        self.setup_2pf_4vf_env()\n+\n+    def setup_2pf_4vf_env(self, driver='default'):\n+\n+        # get PF interface name\n+        self.used_dut_port_0 = self.dut_ports[0]\n+        self.used_dut_port_1 = self.dut_ports[1]\n+\n+        # generate 2 VFs on PF\n+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 2, driver=driver)\n+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_1, 2, driver=driver)\n+        self.sriov_vfs_pf0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']\n+        self.sriov_vfs_pf1 = self.dut.ports_info[self.used_dut_port_1]['vfs_port']\n+\n+        self.dut.send_expect('ip link set %s vf 0 mac 00:11:22:33:44:55' % self.pf0_intf, '#')\n+        self.dut.send_expect('ip link set %s vf 1 mac 00:11:22:33:44:66' % self.pf0_intf, '#')\n+        self.dut.send_expect('ip link set %s vf 0 mac 00:11:22:33:44:77' % self.pf1_intf, '#')\n+        self.dut.send_expect('ip link set %s vf 1 mac 00:11:22:33:44:88' % self.pf1_intf, '#')\n+\n+        # bind VF0 and VF1 to dpdk driver\n+        try:\n+            for vf_port in self.sriov_vfs_pf0:\n+                vf_port.bind_driver(self.vf_driver)\n+            for vf_port in self.sriov_vfs_pf1:\n+                vf_port.bind_driver(self.vf_driver)\n+\n+        except Exception as e:\n+            self.destroy_env()\n+            raise Exception(e)\n+        out = self.dut.send_expect('./usertools/dpdk-devbind.py -s', '#')\n+        print(out)\n+\n+    def setup_1pf_vfs_env(self, pf_port=0, driver='default'):\n+\n+        self.used_dut_port_0 = self.dut_ports[pf_port]\n+        #get PF interface name\n+        self.pf0_intf = self.dut.ports_info[self.used_dut_port_0]['intf']\n+        out = self.dut.send_expect('ethtool -i %s' % self.pf0_intf, '#')\n+        #generate 4 VFs on PF\n+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port_0, 4, driver=driver)\n+        self.sriov_vfs_port_0 = self.dut.ports_info[self.used_dut_port_0]['vfs_port']\n+        #set VF0 as trust\n+        self.dut.send_expect('ip link set %s vf 0 trust on' % self.pf0_intf, '#')\n+        #bind VFs to dpdk driver\n+        for port in self.sriov_vfs_port_0:\n+            port.bind_driver(self.vf_driver)\n+        time.sleep(5)\n+\n+    def bind_nics_driver(self, ports, driver=\"\"):\n+        # modprobe vfio driver\n+        if driver == \"vfio-pci\":\n+            for port in ports:\n+                netdev = self.dut.ports_info[port]['port']\n+                driver = netdev.get_nic_driver()\n+                if driver != 'vfio-pci':\n+                    netdev.bind_driver(driver='vfio-pci')\n+\n+        elif driver == \"igb_uio\":\n+            # igb_uio should insmod as default, no need to check\n+            for port in ports:\n+                netdev = self.dut.ports_info[port]['port']\n+                driver = netdev.get_nic_driver()\n+                if driver != 'igb_uio':\n+                    netdev.bind_driver(driver='igb_uio')\n+        else:\n+            for port in ports:\n+                netdev = self.dut.ports_info[port]['port']\n+                driver_now = netdev.get_nic_driver()\n+                if driver == \"\":\n+                    driver = netdev.default_driver\n+                if driver != driver_now:\n+                    netdev.bind_driver(driver=driver)\n+\n+    def destroy_env(self):\n+        \"\"\"\n+        This is to stop testpmd and destroy 1pf and 2vfs environment.\n+        \"\"\"\n+        self.dut.send_expect(\"quit\", \"# \", 60)\n+        time.sleep(2)\n+        self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0])\n+        self.dut.destroy_sriov_vfs_by_port(self.dut_ports[1])\n+\n+    def re_load_ice_driver(self):\n+        \"\"\"\n+        remove and reload the ice driver\n+        \"\"\"\n+        ice_driver_file_location = self.suite_config[\"ice_driver_file_location\"]\n+        self.dut.send_expect(\"rmmod ice\", \"# \", 15)\n+        self.dut.send_expect(\"insmod %s\" % ice_driver_file_location, \"# \", 60)\n+        time.sleep(5)\n+\n+    def config_testpmd(self):\n+        self.pmd_output.execute_cmd(\"set fwd rxonly\")\n+        self.pmd_output.execute_cmd(\"set verbose 1\")\n+        res = self.pmd_output.wait_link_status_up('all', timeout=15)\n+        self.verify(res is True, 'there have port link is down')\n+        self.pmd_output.execute_cmd(\"start\")\n+\n+    def config_testpmd_cvl_fidr(self):\n+        self.pmd_output.execute_cmd(\"set fwd rxonly\")\n+        self.pmd_output.execute_cmd(\"set verbose 1\")\n+        self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add vxlan 4789\")\n+        self.pmd_output.execute_cmd(\"port config 1 udp_tunnel_port add vxlan 4789\")\n+        self.pmd_output.execute_cmd(\"port config all rss all\")\n+        # specify a fixed rss-hash-key for cvl ether\n+        self.pmd_output.execute_cmd(\n+            \"port config 0 rss-hash-key ipv4 1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd\")\n+        self.pmd_output.execute_cmd(\n+            \"port config 1 rss-hash-key ipv4 1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd\")\n+        res = self.pmd_output.wait_link_status_up('all', timeout=15)\n+        self.verify(res is True, 'there have port link is down')\n+\n+    def launch_testpmd(self):\n+        self.pmd_output.start_testpmd(cores=\"1S/4C/1T\",\n+                                      param=\"--rxq={} --txq={}\".format(self.cvlq_num, self.cvlq_num),\n+                                      eal_param=\"-w %s -w %s\" % (\n+                                          self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci),\n+                                      socket=self.ports_socket)\n+        self.config_testpmd()\n+\n+    def send_packets(self, packets, pf_id=0):\n+        self.pkt.update_pkt(packets)\n+        tx_port = self.tester_iface0 if pf_id == 0 else self.tester_iface1\n+        self.pkt.send_pkt(crb=self.tester, tx_port=tx_port)\n+\n+    def send_pkts_getouput(self, pkts, pf_id=0):\n+        \"\"\"\n+        if pkt_info is True, we need to get packet infomation to check the RSS hash and FDIR.\n+        if pkt_info is False, we just need to get the packet number and queue number.\n+        \"\"\"\n+        self.send_packets(pkts, pf_id)\n+        time.sleep(1)\n+        out_info = self.dut.get_session_output(timeout=1)\n+        out_pkt = self.pmd_output.execute_cmd(\"stop\")\n+        out = out_info + out_pkt\n+        self.pmd_output.execute_cmd(\"start\")\n+        return out\n+\n+    def create_fdir_rule(self, rule, check_stats=None):\n+        p = re.compile(r\"Flow rule #(\\d+) created\")\n+        rule_list = []\n+        if isinstance(rule, list):\n+            for i in rule:\n+                out = self.pmd_output.execute_cmd(i)\n+                m = p.search(out)\n+                if m:\n+                    rule_list.append(m.group(1))\n+                else:\n+                    rule_list.append(False)\n+        elif isinstance(rule, str):\n+            out = self.pmd_output.execute_cmd(rule)\n+            m = p.search(out)\n+            if m:\n+                rule_list.append(m.group(1))\n+            else:\n+                rule_list.append(False)\n+        else:\n+            raise Exception(\"unsupported rule type, only accept list or str\")\n+        if check_stats:\n+            self.verify(all(rule_list), \"some rules create failed, result %s\" % rule_list)\n+        elif check_stats == False:\n+            self.verify(not any(rule_list), \"all rules should create failed, result %s\" % rule_list)\n+        return rule_list\n+\n+    def check_fdir_rule(self, port_id=0, stats=True, rule_list=None):\n+        out = self.pmd_output.execute_cmd(\"flow list %s\" % port_id)\n+        p = re.compile(r\"ID\\s+Group\\s+Prio\\s+Attr\\s+Rule\")\n+        if stats:\n+            self.verify(p.search(out), \"flow rule on port %s is not existed\" % port_id)\n+            if rule_list:\n+                p = re.compile(\"^(\\d+)\\s\")\n+                li = out.splitlines()\n+                res = list(filter(bool, list(map(p.match, li))))\n+                result = [i.group(1) for i in res]\n+                self.verify(sorted(result) == sorted(rule_list),\n+                            \"check rule list failed. expect %s, result %s\" % (rule_list, result))\n+        else:\n+            self.verify(not p.search(out), \"flow rule on port %s is existed\" % port_id)\n+\n+    def check_switch_filter_rule_list(self, port_id, rule_list, session_name=\"\", need_verify=True):\n+        \"\"\"\n+        check the rules in list identical to ones in rule_list\n+        \"\"\"\n+        if session_name == \"\":\n+            session_name = self.dut\n+        out = session_name.send_expect(\"flow list %d\" % port_id, \"testpmd> \", 15)\n+        p = re.compile(r\"ID\\s+Group\\s+Prio\\s+Attr\\s+Rule\")\n+        m = p.search(out)\n+        if not m:\n+            result = []\n+        else:\n+            p_spec = re.compile(\"^(\\d+)\\s\")\n+            out_lines = out.splitlines()\n+            res = filter(bool, map(p_spec.match, out_lines))\n+            result = [i.group(1) for i in res]\n+        if need_verify:\n+            self.verify(result == rule_list,\n+                        \"the rule list is not the same. expect %s, result %s\" % (rule_list, result))\n+        else:\n+            return result\n+\n+    def check_rule_number(self, port_id=0, num=0):\n+        out = self.dut.send_command(\"flow list %s\" % port_id, timeout=30)\n+        result_scanner = r'\\d*.*?\\d*.*?\\d*.*?=>*'\n+        scanner = re.compile(result_scanner, re.DOTALL)\n+        li = scanner.findall(out)\n+        if num == 0:\n+            self.verify(not li, \"there should be no rule listed\")\n+        else:\n+            print(len(li))\n+            self.verify(len(li) == num, \"the amount of rules is wrong.\")\n+        return out\n+\n+    def send_and_check_packets(self, dic, session_name=\"\", tx_iface=\"\"):\n+        \"\"\"\n+        general packets processing workflow.\n+        \"\"\"\n+        if session_name == \"\":\n+            session_name = self.dut\n+        if tx_iface == \"\":\n+            tx_iface = self.__tx_iface\n+        session_name.send_expect(\"start\", \"testpmd> \", 15)\n+        time.sleep(2)\n+        #send packets\n+        self.pkt.update_pkt(dic[\"scapy_str\"])\n+        self.pkt.send_pkt(self.tester, tx_port=tx_iface, count=1, timeout=370)\n+        time.sleep(3)\n+        out = session_name.send_expect(\"stop\", \"testpmd> \", 15)\n+        dic[\"check_func\"][\"func\"](out, dic[\"check_func\"][\"param\"], dic[\"expect_results\"])\n+\n+    def test_maxnum_14336rules_1vf(self):\n+        \"\"\"\n+        vfs share 14336 rules table\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        self.set_up_for_iavf_dir()\n+        self.dut.kill_all()\n+        src_file = 'create_14336_rules'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        count = 0\n+        for i in range(56):\n+            for j in range(256):\n+                flows.write(\n+                    'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.%d.%d / end actions queue index 5 / mark / end \\n' % (\n+                    i, j))\n+                count = count + 1\n+        flows.close()\n+        self.verify(count == 14336, \"failed to create 14336 fdir rules on vf.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (\n+        self.cvlq_num, self.cvlq_num) + \" --cmdline-file=%s\" % (dut_file_dir + src_file)\n+        self.dut.send_expect(command, \"testpmd> \", 300)\n+        self.config_testpmd()\n+\n+        # can't create more than 14336 rules on vf0\n+        rule_14336_vf0 = \"flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        self.create_fdir_rule(rule_14336_vf0, check_stats=False)\n+        # check there are 14336 rules created.\n+        out = self.check_rule_number(port_id=0, num=14336)\n+        self.verify(\"14336\" not in out, \"more than 14336 rules can be created on 1vf\")\n+\n+        # can't create rule on vf1\n+        rule_0_vf1 = \"flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        self.create_fdir_rule(rule_0_vf1, check_stats=False)\n+        self.check_fdir_rule(port_id=1, stats=False)\n+\n+        pkt_0 = 'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.0\")/Raw(\"x\" * 80)'\n+        pkt_14335 = 'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.55.255\")/Raw(\"x\" * 80)'\n+        pkt_14336 = 'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+\n+        # check packet match rule 0 and rule 14335 can be redirected to expected queue\n+        out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+        # check packet match rule 14336 can't be redirected to expected queue.\n+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=0)\n+        # #check 'FDIR matched ID' not in out_14336,not check queque number sometime it may be same as 5.\n+        rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={\"port_id\": 0, \"queue\": 5}, stats=False)\n+\n+        # delete one rule of vf0\n+        self.dut.send_expect(\"flow destroy 0 rule 0\", \"testpmd> \", timeout=200)\n+        self.create_fdir_rule(rule_0_vf1, check_stats=True)\n+        pkt_0_vf1 = 'Ether(dst=\"00:11:22:33:44:66\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+        out_0_vf1 = self.send_pkts_getouput(pkts=pkt_0_vf1, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0_vf1, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+\n+        # flush all the rules\n+        self.dut.send_expect(\"flow flush 0\", \"testpmd> \", timeout=500)\n+        self.check_fdir_rule(port_id=0, stats=False)\n+        out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)\n+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=False)\n+        rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5},\n+                                 stats=False)\n+\n+        self.create_fdir_rule(rule_14336_vf0, check_stats=True)\n+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+\n+    def test_maxnum_14336rules_2vf(self):\n+        \"\"\"\n+        vfs share 14336 rules table\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        self.dut.kill_all()\n+        self.set_up_for_iavf_dir()\n+        self.session_secondary = self.dut.new_session()\n+        src_file = 'create_14336_rules_2vf'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        flows.write(\n+            'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.0 / end actions queue index 5 / mark / end \\n')\n+        count = 1\n+        for i in range(55):\n+            for j in range(256):\n+                flows.write(\n+                    'flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.%d.%d / end actions queue index 5 / mark / end \\n' % (\n+                    i, j))\n+                count = count + 1\n+        for j in range(255):\n+            flows.write(\n+                'flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.55.%d / end actions queue index 5 / mark / end \\n' % j)\n+            count = count + 1\n+        flows.close()\n+        self.verify(count == 14336, \"failed to create 14336 fdir rules on 2 vfs.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf1[0].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (\n+        self.cvlq_num, self.cvlq_num) + \" --cmdline-file=%s\" % (dut_file_dir + src_file)\n+        self.dut.send_expect(command, \"testpmd> \", 1200)\n+\n+        self.config_testpmd()\n+        self.check_fdir_rule(port_id=0, rule_list=['0'])\n+\n+        # can't create more than 14336 rules on 2vf\n+        rule_14335_vf1 = \"flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        self.create_fdir_rule(rule_14335_vf1, check_stats=False)\n+        # check there are 14336 rules created.\n+        out = self.check_rule_number(port_id=1, num=14335)\n+        self.verify(\"14335\" not in out, \"more than 14336 rules are created on 2vf\")\n+\n+        # can't create new rule on vf0\n+        rule_1_vf0 = \"flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        self.create_fdir_rule(rule_1_vf0, check_stats=False)\n+        self.check_rule_number(port_id=0, num=1)\n+\n+        pkt_0 = 'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.0\")/Raw(\"x\" * 80)'\n+        pkt_1 = 'Ether(dst=\"00:11:22:33:44:77\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.0\")/Raw(\"x\" * 80)'\n+        pkt_14335 = 'Ether(dst=\"00:11:22:33:44:77\")/IP(src=\"192.168.0.20\",dst=\"192.168.55.254\")/Raw(\"x\" * 80)'\n+        pkt_14336 = 'Ether(dst=\"00:11:22:33:44:77\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+\n+        self.session_secondary.send_expect(\"ifconfig %s up\" % self.pf0_intf, \"# \", 15)\n+        self.session_secondary.send_expect(\"ifconfig %s up\" % self.pf1_intf, \"# \", 15)\n+        time.sleep(1)\n+\n+        # check packet match rule 0 and rule 14335 can be redirected to expected queue\n+        out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+\n+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+        # check packet match rule 14336 can't be redirected to expected queue.\n+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={\"port_id\": 1, \"queue\": 5}, stats=False)\n+\n+        # destroy rule 0 on vf0, then create a new rule on vf1 successfully.\n+        self.dut.send_expect(\"flow flush 0\", \"testpmd> \")\n+        self.create_fdir_rule(rule_14335_vf1, check_stats=True)\n+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+\n+        self.dut.send_expect(\"flow flush 1\", \"testpmd> \", timeout=300)\n+\n+        self.check_fdir_rule(port_id=0, stats=False)\n+        self.check_fdir_rule(port_id=1, stats=False)\n+\n+        out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)\n+        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=1)\n+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5}, stats=False)\n+        rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=False)\n+        rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5},\n+                                 stats=False)\n+        self.dut.close_session(self.session_secondary)\n+\n+    def test_maxnum_15360rules_1pf_2vf(self):\n+        \"\"\"\n+        2*100G NIC, each pf can create 1024 rules at least, vfs share 14336 rules table\n+        4*25G NIC, each pf can create 512 rules at least, vfs share 14336 rules table\n+        so if 2*25G NIC, max number is 14848 on 1pf and 2vfs.\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        self.dut.kill_all()\n+        self.set_up_for_iavf_dir()\n+        self.session_secondary = self.dut.new_session()\n+        # create 1025 rules on pf1\n+        src_file = 'create_1025_kernel_rules'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        count = 0\n+        if self.nic in [\"columbiaville_100g\"]:\n+            for i in range(4):\n+                for j in range(256):\n+                    flows.write(\n+                        'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % (\n+                        self.pf1_intf, i, j))\n+                    count = count + 1\n+            flows.write(\n+                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % self.pf1_intf)\n+            count = count + 1\n+            flows.close()\n+            self.verify(count == 1025, \"failed to create 1025 fdir rules on pf.\")\n+        elif self.nic in [\"columbiaville_25g\"]:\n+            for i in range(2):\n+                for j in range(256):\n+                    flows.write(\n+                        'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % (\n+                        self.pf1_intf, i, j))\n+                    count = count + 1\n+            flows.write(\n+                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % self.pf1_intf)\n+            count = count + 1\n+            flows.close()\n+            self.verify(count == 513, \"failed to create 1025 fdir rules on pf.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+        # create 1025 rules on pf1\n+        fkr = open(self.src_file_dir + src_file, \"r+\")\n+        kernel_rules = fkr.read()\n+        fkr.close()\n+        self.dut.send_expect(kernel_rules, \"# \")\n+        time.sleep(15)\n+        # create 1 rule on vf00, and 14334 rules on vf01\n+        src_file_vf = 'create_14335_rules_on_2vfs'\n+        flows = open(self.src_file_dir + src_file_vf, mode='w')\n+        flows.write(\n+            'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.0 / end actions queue index 5 / mark / end \\n')\n+        count = 1\n+        for i in range(55):\n+            for j in range(256):\n+                flows.write(\n+                    'flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.%d.%d / end actions queue index 5 / mark / end \\n' % (\n+                    i, j))\n+                count = count + 1\n+        for j in range(254):\n+            flows.write(\n+                'flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.55.%d / end actions queue index 5 / mark / end \\n' % j)\n+            count = count + 1\n+        flows.close()\n+        self.verify(count == 14335, \"failed to create 14335 fdir rules on vfs.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file_vf, dut_file_dir)\n+        # start testpmd with creating rules in commandline\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (\n+        self.cvlq_num, self.cvlq_num) + \" --cmdline-file=%s\" % (dut_file_dir + src_file_vf)\n+        fdw = open(\"15360_rules_vf_result.txt\", \"w\")\n+        fdw.write(self.dut.send_expect(command, \"testpmd> \", 360))\n+        fdw.close()\n+        self.config_testpmd()\n+        # check there is 1 rule created on vf00\n+        self.check_fdir_rule(port_id=0, rule_list=['0'])\n+        # can't create more than 14335 rules on 2vf, the rule index is from 0\n+        rule_14334_vf1 = \"flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        pkt_14334 = 'Ether(dst=\"00:11:22:33:44:66\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+        self.create_fdir_rule(rule_14334_vf1, check_stats=False)\n+        # check there are 14334 rules created on vf01\n+        out = self.check_rule_number(port_id=1, num=14334)\n+        self.verify(\"14334\" not in out, \"more than 15360 rules are created on 2vf\")\n+        # delete a rule on pf0\n+        self.session_secondary.send_expect(\"ethtool -N %s delete 14847\" % self.pf1_intf, \"# \")\n+        # then can create one more rule on vf01\n+        self.create_fdir_rule(rule_14334_vf1, check_stats=True)\n+        out_14334 = self.send_pkts_getouput(pkts=pkt_14334, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_14334, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5}, stats=True)\n+        self.dut.send_expect(\"flow flush 0\", \"testpmd> \", timeout=600)\n+        self.dut.send_expect(\"flow flush 1\", \"testpmd> \", timeout=600)\n+        self.check_fdir_rule(port_id=0, stats=False)\n+        self.check_fdir_rule(port_id=1, stats=False)\n+        out_14334 = self.send_pkts_getouput(pkts=pkt_14334, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_14334, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5},\n+                                 stats=False)\n+        self.dut.send_expect(\"quit\", \"# \")\n+        self.dut.close_session(self.session_secondary)\n+\n+    def test_maxnum_15360rules_1pf_0_rules_vf(self):\n+        \"\"\"\n+        2*100G NIC, each pf can create 1024 rules at least, vfs share 14336 rules table\n+        4*25G NIC, each pf can create 512 rules at least, vfs share 14336 rules table\n+        so if 2*25G NIC, max number is 14848 on 1pf and vfs.\n+        create 15360/14848 rules on pf1, check failed to create rule on vf00 and vf10\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        self.dut.kill_all()\n+        self.set_up_for_iavf_dir()\n+        self.session_secondary = self.dut.new_session()\n+        # create 15360 rules on pf1\n+        src_file = 'create_15360_kernel_rules'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        count = 0\n+        if self.nic in [\"columbiaville_100g\"]:\n+            for i in range(60):\n+                for j in range(256):\n+                    flows.write(\n+                        'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % (\n+                        self.pf1_intf, i, j))\n+                    count = count + 1\n+            flows.close()\n+            self.verify(count == 15360, \"failed to create 15360 fdir rules on pf.\")\n+        elif self.nic in [\"columbiaville_25g\"]:\n+            for i in range(58):\n+                for j in range(256):\n+                    flows.write(\n+                        'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \\n' % (\n+                        self.pf1_intf, i, j))\n+                    count = count + 1\n+            flows.close()\n+            self.verify(count == 14848, \"failed to create 14848 fdir rules on pf.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+        # create 15360 rules on pf1\n+        fkr = open(self.src_file_dir + src_file, \"r+\")\n+        kernel_rules = fkr.read()\n+        fkr.close()\n+        self.dut.send_expect(kernel_rules, \"# \")\n+        time.sleep(200)\n+        # failed to create 1 more rule on pf1\n+        self.dut.send_expect(\n+            \"ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8\" % self.pf1_intf,\n+            \"Cannot insert RX class rule: No space left on device\")\n+        # start testpmd with creating rules in commandline\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf1[0].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (self.cvlq_num, self.cvlq_num)\n+        self.dut.send_expect(command, \"testpmd> \", 20)\n+\n+        self.config_testpmd()\n+        rule_0_vf00 = \"flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        pkt_0_vf00 = 'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+        rule_0_vf10 = \"flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end\"\n+        pkt_0_vf10 = 'Ether(dst=\"00:11:22:33:44:77\")/IP(src=\"192.168.0.20\",dst=\"192.168.56.0\")/Raw(\"x\" * 80)'\n+\n+        # failed to create rule on vf00 and vf10\n+        self.create_fdir_rule(rule_0_vf00, check_stats=False)\n+        self.create_fdir_rule(rule_0_vf10, check_stats=False)\n+        self.check_rule_number(port_id=0, num=0)\n+        self.check_rule_number(port_id=1, num=0)\n+\n+        # delete a rule on pf1\n+        self.session_secondary.send_expect(\"ethtool -N %s delete 14847\" % self.pf1_intf, \"# \")\n+\n+        # then can create one rule on vf00\n+        self.create_fdir_rule(rule_0_vf00, check_stats=True)\n+        self.create_fdir_rule(rule_0_vf10, check_stats=False)\n+        self.check_rule_number(port_id=0, num=1)\n+        self.check_rule_number(port_id=1, num=0)\n+\n+        # delete a rule on pf1\n+        self.session_secondary.send_expect(\"ethtool -N %s delete 14846\" % self.pf1_intf, \"# \")\n+\n+        # then can create one rule on vf10\n+        self.create_fdir_rule(rule_0_vf10, check_stats=True)\n+        self.check_rule_number(port_id=1, num=1)\n+\n+        out_0_vf00 = self.send_pkts_getouput(pkts=pkt_0_vf00, pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0_vf00, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 5},\n+                                 stats=True)\n+\n+        out_0_vf10 = self.send_pkts_getouput(pkts=pkt_0_vf10, pf_id=1)\n+        rfc.check_iavf_fdir_mark(out_0_vf10, pkt_num=1, check_param={\"port_id\": 1, \"mark_id\": 0, \"queue\": 5},\n+                                 stats=True)\n+\n+        self.dut.send_expect(\"quit\", \"# \")\n+        self.dut.close_session(self.session_secondary)\n+\n+    def test_stress_add_delete_rules_1vf(self):\n+        \"\"\"\n+        add/delete rules 14336 times on 1 vf\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        rules = [\n+            \"flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / udp src is 22 dst is 23 / end actions queue index 6 / mark / end\",\n+            \"flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / tcp src is 22 dst is 23 / end actions rss queues 2 3 end / mark id 1 / end\"]\n+        pkts = [\n+            'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.21\")/UDP(sport=22,dport=23)/Raw(\"x\" * 80)',\n+            'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.21\")/TCP(sport=22,dport=23)/Raw(\"x\" * 80)']\n+        self.dut.kill_all()\n+        self.set_up_for_iavf_dir()\n+        src_file = 'add_delete_rules_1vf'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        count = 0\n+        for i in range(14336):\n+            flows.write('%s \\n' % rules[0])\n+            flows.write('%s \\n' % rules[1])\n+            flows.write('flow flush 0\\n')\n+            count = count + 1\n+        flows.close()\n+        self.verify(count == 14336, \"failed to add/delete 14336 times of fdir rules on vf.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (\n+        self.cvlq_num, self.cvlq_num) + \" --cmdline-file=%s\" % (dut_file_dir + src_file)\n+        self.dut.send_expect(command, \"testpmd> \", 900)\n+        self.config_testpmd()\n+        self.check_fdir_rule(port_id=0, stats=False)\n+        self.create_fdir_rule(rules, check_stats=True)\n+        out_0 = self.send_pkts_getouput(pkts=pkts[0])\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 0, \"queue\": 6}, stats=True)\n+        out_1 = self.send_pkts_getouput(pkts=pkts[1])\n+        rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={\"port_id\": 0, \"mark_id\": 1, \"queue\": [2, 3]},\n+                                 stats=True)\n+\n+    def test_stress_add_delete_rules_2vf(self):\n+        \"\"\"\n+        add/delete rules 14336 times on 2 vfs\n+        \"\"\"\n+        dut_file_dir = '/tmp/'\n+        rules = [\n+            \"flow create 0 ingress pattern eth / ipv4 src is 192.168.56.0 dst is 192.1.0.0 tos is 4 / tcp src is 22 dst is 23 / end actions queue index 5 / end\",\n+            \"flow create 1 ingress pattern eth / ipv4 src is 192.168.56.0 dst is 192.1.0.0 tos is 4 / tcp src is 22 dst is 23 / end actions queue index 5 / end\"]\n+        pkts = [\n+            'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.56.0\",dst=\"192.1.0.0\", tos=4)/TCP(sport=22,dport=23)/Raw(\"x\" * 80)',\n+            'Ether(dst=\"00:11:22:33:44:66\")/IP(src=\"192.168.56.0\",dst=\"192.1.0.0\", tos=4)/TCP(sport=22,dport=23)/Raw(\"x\" * 80)']\n+        self.dut.kill_all()\n+        self.set_up_for_iavf_dir()\n+        src_file = 'add_delete_rules_2vfs'\n+        flows = open(self.src_file_dir + src_file, mode='w')\n+        count = 0\n+        for i in range(14336):\n+            flows.write('%s \\n' % rules[0])\n+            flows.write('%s \\n' % rules[1])\n+            flows.write('flow flush 0\\n')\n+            flows.write('flow flush 1\\n')\n+            count = count + 1\n+        flows.close()\n+        self.verify(count == 14336, \"failed to add/delete 14336 times of fdir rules on 2 vfs.\")\n+        self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)\n+\n+        eal_param = \"-c f -n 6 -w %s -w %s\" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)\n+        command = self.path + eal_param + \" -- -i --rxq=%s --txq=%s\" % (\n+        self.cvlq_num, self.cvlq_num) + \" --cmdline-file=%s\" % (dut_file_dir + src_file)\n+        self.dut.send_expect(command, \"testpmd> \", 900)\n+        self.config_testpmd()\n+        self.check_fdir_rule(port_id=0, stats=False)\n+        self.check_fdir_rule(port_id=1, stats=False)\n+\n+        self.create_fdir_rule(rules, check_stats=True)\n+        out_0 = self.send_pkts_getouput(pkts=pkts[0], pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={\"port_id\": 0, \"queue\": 5}, stats=True)\n+        out_1 = self.send_pkts_getouput(pkts=pkts[1], pf_id=0)\n+        rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={\"port_id\": 1, \"queue\": 5}, stats=True)\n+\n+    def launch_testpmd_with_mark(self, rxq=64, txq=64):\n+        self.pmd_output.start_testpmd(cores=\"1S/4C/1T\",\n+                                      param=\"--portmask=%s --rxq=%d --txq=%d --port-topology=loop\" % (\n+                                          self.portMask, rxq, txq),\n+                                      eal_param=\"-w %s -w %s --log-level=ice,7\" % (\n+                                          self.pci0, self.pci1), socket=self.ports_socket)\n+        self.config_testpmd_cvl_fidr()\n+\n+    #this case copy from cvl_fdir\n+    def test_add_delete_rules(self):\n+        self.launch_testpmd_with_mark()\n+        self.pmd_output.execute_cmd(\"start\")\n+        self.pmd_output.execute_cmd(\"stop\")\n+        self.dut.send_command(\"quit\", timeout=2)\n+        cmd_path = '/tmp/add_delete_rules'\n+        cmds = [\n+                   'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / udp src is 22 dst is 23 / end actions queue index 1 / mark / end',\n+                   'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / tcp src is 22 dst is 23 / end actions rss queues 2 3 end / mark id 1 / end',\n+                   'flow list 0', 'flow flush 0'] * 15360\n+        cmds_li = map(lambda x: x + os.linesep, cmds)\n+        with open(cmd_path, 'w') as f:\n+            f.writelines(cmds_li)\n+        self.dut.session.copy_file_to(cmd_path, cmd_path)\n+        try:\n+            eal_param = self.dut.create_eal_parameters(cores=\"1S/4C/1T\", ports=[self.pci0,self.pci1], socket=self.ports_socket)\n+            param = \" --log-level='ice,7' -- -i --portmask=%s --rxq=%d --txq=%d --port-topology=loop --cmdline-file=%s\" % (\n+                self.portMask, 64, 64, cmd_path)\n+            command_line = self.dut.apps_name['test-pmd'] + eal_param + param\n+            out = self.dut.send_expect(command_line, 'testpmd>', timeout=1200)\n+            self.verify('Failed to create file' not in out, \"create some rule failed: %s\" % out)\n+            self.config_testpmd_cvl_fidr()\n+            self.pmd_output.execute_cmd('start')\n+            rules = [\n+                'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / udp src is 22 dst is 23 / end actions queue index 1 / mark / end',\n+                'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.0.21 / tcp src is 22 dst is 23 / end actions rss queues 2 3 end / mark id 1 / end']\n+            rule_li = self.create_fdir_rule(rule=rules, check_stats=True)\n+            self.check_fdir_rule(port_id=0, stats=True, rule_list=rule_li)\n+            pkts = [\n+                'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.21\")/UDP(sport=22,dport=23)/Raw(\"x\" * 80)',\n+                'Ether(dst=\"00:11:22:33:44:55\")/IP(src=\"192.168.0.20\",dst=\"192.168.0.21\")/TCP(sport=22,dport=23)/Raw(\"x\" * 80)']\n+            out1 = self.send_pkts_getouput(pkts=pkts[0], pf_id=0, )\n+            rfc.check_mark(out1, pkt_num=1, check_param={\"port_id\": 0, \"queue\": 1, \"mark_id\": 0}, stats=True)\n+            out2 = self.send_pkts_getouput(pkts=pkts[1], pf_id=0, )\n+            rfc.check_mark(out2, pkt_num=1, check_param={\"port_id\": 0, \"queue\": [2, 3], \"mark_id\": 1}, stats=True)\n+        except Exception as e:\n+            raise Exception(e)\n+        finally:\n+            self.dut.kill_all()\n+\n+    # this case copy from cvl_dcf_switch_filter\n+    def test_max_rule_number(self):\n+        #bind pf to kernel\n+        self.bind_nics_driver(self.dut_ports, driver=\"ice\")\n+        #move comms package to package folder\n+        self.suite_config = rfc.get_suite_config(self)\n+        comms_package_location = self.suite_config[\"comms_package_file_location\"]\n+        package_location = self.suite_config[\"package_file_location\"]\n+        self.dut.send_expect(\"cp %s %s\" % (comms_package_location, package_location), \"# \")\n+        self.re_load_ice_driver()\n+        #set vf driver\n+        self.vf_driver = 'vfio-pci'\n+        self.dut.send_expect('modprobe vfio-pci', '#')\n+        self.path = self.dut.apps_name['test-pmd']\n+\n+        # set up 4 vfs on 1 pf environment\n+        self.setup_1pf_vfs_env()\n+        # create 32563 rules with the same pattern, but different input set to file\n+        src_file = 'dep/testpmd_cmds_32k_switch_rules'\n+        flows = open(src_file, mode='w')\n+        rule_count = 1\n+        for i in range(0, 255):\n+            for j in range(0, 255):\n+                if not rule_count > 32563:\n+                    flows.write(\n+                        'flow create 0 ingress pattern eth / ipv4 src is 192.168.%d.%d / end actions vf id 1 / end \\n' % (\n+                        i, j))\n+                    matched_scapy_str = 'Ether(dst=\"68:05:ca:8d:ed:a8\")/IP(src=\"192.168.%d.%d\")/TCP(sport=25,dport=23)/Raw(\"X\"*480)' % (\n+                    i, j)\n+                    tv_max_rule_number[\"matched\"][\"scapy_str\"].append(matched_scapy_str)\n+                    rule_count += 1\n+                else:\n+                    break\n+            if rule_count > 32563:\n+                break\n+        flows.close()\n+        dut_file_dir = '/tmp/'\n+        self.dut.session.copy_file_to(src_file, dut_file_dir)\n+        # launch testpmd with 32563 rules\n+        vf0_pci = self.sriov_vfs_port_0[0].pci\n+        vf1_pci = self.sriov_vfs_port_0[1].pci\n+        all_eal_param = self.dut.create_eal_parameters(cores=\"1S/4C/1T\", ports=[vf0_pci, vf1_pci],\n+                                                       port_options={vf0_pci: \"cap=dcf\"})\n+        command = self.path + all_eal_param + \" -- -i --cmdline-file=/tmp/testpmd_cmds_32k_switch_rules\"\n+        out = self.dut.send_expect(command, \"testpmd> \", 360)\n+        self.testpmd_status = \"running\"\n+        self.dut.send_expect(\"set portlist 1\", \"testpmd> \", 15)\n+        self.dut.send_expect(\"set fwd rxonly\", \"testpmd> \", 15)\n+        # check the rule list with 32563 rules\n+        rule_list_num = list(range(0, 32563))\n+        rule_list = [str(x) for x in rule_list_num]\n+        self.check_switch_filter_rule_list(0, rule_list)\n+        # create other rules to make switch filter table full\n+        m = i\n+        t = j\n+        p = re.compile(r\"Flow rule #(\\d+) created\")\n+        switch_table_full_flag = False\n+        count = 0\n+        for i in range(m, 255):\n+            for j in range(t, 255):\n+                rule = 'flow create 0 ingress pattern eth / ipv4 src is 192.168.%d.%d / end actions vf id 1 / end \\n' % (\n+                i, j)\n+                matched_packet = 'Ether(dst=\"68:05:ca:8d:ed:a8\")/IP(src=\"192.168.%d.%d\")/TCP(sport=25,dport=23)/Raw(\"X\"*480)' % (\n+                i, j)\n+                out = self.dut.send_expect(rule, \"testpmd> \", timeout=2)  # create a rule\n+                m1 = p.search(out)\n+                if m1:\n+                    rule_list.append(m1.group(1))\n+                    tv_max_rule_number[\"matched\"][\"scapy_str\"].append(matched_packet)\n+                    count += 1\n+                else:\n+                    self.verify(\"Failed to create flow\" in out,\n+                                \"Log not provide a friendly output to indicate that the rule failed to create.\")\n+                    switch_table_full_flag = True\n+                    break\n+            if switch_table_full_flag:\n+                break\n+        tv_max_rule_number[\"matched\"][\"expect_results\"][\"expect_pkts\"] += count\n+        # check the rule list\n+        self.check_switch_filter_rule_list(0, rule_list)\n+        # send matched packets and check\n+        matched_dic = tv_max_rule_number[\"matched\"]\n+        self.send_and_check_packets(matched_dic)\n+        # send mismatched packets and check\n+        mismatched_dic = tv_max_rule_number[\"mismatched\"]\n+        self.send_and_check_packets(mismatched_dic)\n+        # destroy rules and send matched packets\n+        self.dut.send_expect(\"flow flush 0\", \"testpmd> \", 300)\n+        self.check_switch_filter_rule_list(0, [])\n+        # send matched packets and check\n+        destroy_dict = copy.deepcopy(matched_dic)\n+        destroy_dict[\"expect_results\"][\"expect_pkts\"] = 0\n+        self.send_and_check_packets(destroy_dict)\n+\n+    def tear_down(self):\n+        # destroy all flow rule on port 0\n+        self.dut.kill_all()\n+        self.destroy_env()\n+        if getattr(self, 'session_secondary', None):\n+            self.dut.close_session(self.session_secondary)\n+        if getattr(self, 'session_third', None):\n+            self.dut.close_session(self.session_third)\n+\n+    def tear_down_all(self):\n+        self.dut.kill_all()\n+        self.destroy_env()\n",
    "prefixes": [
        "V1",
        "2/3"
    ]
}