Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/90461/?format=api
http://patches.dpdk.org/api/patches/90461/?format=api", "web_url": "http://patches.dpdk.org/project/dts/patch/20210402103433.94545-1-junx.w.zhou@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": "<20210402103433.94545-1-junx.w.zhou@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dts/20210402103433.94545-1-junx.w.zhou@intel.com", "date": "2021-04-02T10:34:33", "name": "[V1] tests: add new suite cvl ecpri", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9dd0c59aef53e7055c70ddec255924ae1399eff5", "submitter": { "id": 1646, "url": "http://patches.dpdk.org/api/people/1646/?format=api", "name": "Zhou, JunX W", "email": "junx.w.zhou@intel.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dts/patch/20210402103433.94545-1-junx.w.zhou@intel.com/mbox/", "series": [ { "id": 16081, "url": "http://patches.dpdk.org/api/series/16081/?format=api", "web_url": "http://patches.dpdk.org/project/dts/list/?series=16081", "date": "2021-04-02T10:34:33", "name": "[V1] tests: add new suite cvl ecpri", "version": 1, "mbox": "http://patches.dpdk.org/series/16081/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/90461/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/90461/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 mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id DC5D1A0548;\n\tFri, 2 Apr 2021 12:36:09 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CFD9D140E96;\n\tFri, 2 Apr 2021 12:36:09 +0200 (CEST)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by mails.dpdk.org (Postfix) with ESMTP id A1CD040141\n for <dts@dpdk.org>; Fri, 2 Apr 2021 12:36:07 +0200 (CEST)", "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 02 Apr 2021 03:36:06 -0700", "from unknown (HELO localhost.localdomain) ([10.240.183.222])\n by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 02 Apr 2021 03:36:02 -0700" ], "IronPort-SDR": [ "\n DCa1Qh+seu3tH8sPa+9dkOFds1yqum5I+KpPGSHpn1n5Z3OAwUzQ2hGDFUdPabFost2/b4D7Cl\n L3f1pMUPMDxg==", "\n ETvd0E4RE8mzTXGc/ml8sKNfQPM/8nFLhmP0YCCAqLsRIHRnA0JsJuawWNeYO68Q3guN0eY6mP\n UvzT66MvgXCw==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6000,8403,9941\"; a=\"212720902\"", "E=Sophos;i=\"5.81,299,1610438400\"; d=\"scan'208\";a=\"212720902\"", "E=Sophos;i=\"5.81,299,1610438400\"; d=\"scan'208\";a=\"419615548\"" ], "From": "Zhou Jun <junx.w.zhou@intel.com>", "To": "dts@dpdk.org", "Cc": "Zhou Jun <junx.w.zhou@intel.com>", "Date": "Fri, 2 Apr 2021 18:34:33 +0800", "Message-Id": "<20210402103433.94545-1-junx.w.zhou@intel.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "quoted-printable", "Subject": "[dts] [PATCH V1] tests: add new suite cvl ecpri", "X-BeenThere": "dts@dpdk.org", "X-Mailman-Version": "2.1.29", "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": "ecpri only support by wireless pkg so split it to a new suite\n\nSigned-off-by: Zhou Jun <junx.w.zhou@intel.com>\n---\n tests/TestSuite_cvl_ecpri.py | 898 +++++++++++++++++++++++++++++++++++\n 1 file changed, 898 insertions(+)\n create mode 100644 tests/TestSuite_cvl_ecpri.py", "diff": "diff --git a/tests/TestSuite_cvl_ecpri.py b/tests/TestSuite_cvl_ecpri.py\nnew file mode 100644\nindex 00000000..af018ffd\n--- /dev/null\n+++ b/tests/TestSuite_cvl_ecpri.py\n@@ -0,0 +1,898 @@\n+import re\r\n+from packet import Packet\r\n+from pmd_output import PmdOutput\r\n+from test_case import TestCase\r\n+import rte_flow_common as rfc\r\n+import utils\r\n+from utils import GREEN, RED\r\n+import time\r\n+\r\n+Mac_list = ['00:11:22:33:44:55', '00:11:22:33:44:11', '00:11:22:33:44:22', '00:11:22:33:44:33']\r\n+\r\n+pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x00\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x00\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02')/Raw('x'*11)/Raw(\\'\\\\x01')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x03\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x05\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x06\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x07\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x02\\')/Raw('x'*11)/Raw(\\'\\\\x08\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x05\\')\",\r\n+ \"Ether(dst='{}')/IP()/UDP(dport={})/Raw(\\'\\\\x10\\\\x06\\')\"\r\n+ ]\r\n+\r\n+ptype_match_lst = ['ptype=' + str(i) for i in range(372, 382)]\r\n+ptype_nomatch_lst = ['ptype=24'] * 10\r\n+\r\n+# eCPRI over Ethernet header data.\r\n+eCPRI_over_Ethernet_rule = \"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions rss types ecpri end key_len 0 queues end / end\"\r\n+over_eth_header_packets = {\r\n+ 'match': [\"Ether(dst='00:11:22:33:44:11', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\x45\\')\"],\r\n+ 'unmatched': [\"Ether(dst='00:11:22:33:44:11', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\x46\\')\"]\r\n+}\r\n+\r\n+tv_over_eth_queue_index = {\r\n+ \"name\": \"test_eth_queue_index\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions queue index 3 / mark id 1 / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"queue\": 3, \"mark_id\": 1, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth_rss_queues = {\r\n+ \"name\": \"test_eth_rss_queues\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions rss queues 5 6 end / mark id 2 / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"queue\": [5, 6], \"mark_id\": 2, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth_drop = {\r\n+ \"name\": \"test_eth_drop\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions drop / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"drop\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth_passthru = {\r\n+ \"name\": \"test_eth_passthru\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions passthru / mark id 1 / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"rss\": True, \"mark_id\": 1, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth_mark_rss = {\r\n+ \"name\": \"test_eth_mark_rss\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions mark / rss / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"mark_id\": 0, \"rss\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth_mark = {\r\n+ \"name\": \"test_eth_mark\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions mark / end\",\r\n+ \"scapy_str\": over_eth_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"mark_id\": 0, \"rss\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+# eCPRI over IP/UDP header data.\r\n+eCPRI_over_IP_UDP_rule = \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end actions rss types ecpri end key_len 0 queues end / end\"\r\n+over_ip_udp_header_packets = {\r\n+ 'match': [\"Ether(dst='00:11:22:33:44:11')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\x45\\')\"],\r\n+ 'unmatched': [\"Ether(dst='00:11:22:33:44:11')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\x46\\')\"]\r\n+}\r\n+\r\n+tv_over_ip_udp_queue_index = {\r\n+ \"name\": \"test_ip_udp_queue_index\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions queue index 2 / mark / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"queue\": 2, \"mark_id\": 0, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_ip_udp_rss_queues = {\r\n+ \"name\": \"test_ip_udp_rss_queues\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions rss queues 5 6 end / mark id 2 / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"queue\": [5, 6], \"mark_id\": 2, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_ip_udp_drop = {\r\n+ \"name\": \"test_ip_udp_drop\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions drop / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"drop\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_ip_udp_passthru = {\r\n+ \"name\": \"test_ip_udp_passthru\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions passthru / mark id 1 / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"rss\": True, \"mark_id\": 1, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_ip_udp_mark_rss = {\r\n+ \"name\": \"test_ip_udp_mark_rss\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions mark / rss / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"mark_id\": 0, \"rss\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_ip_udp_mark = {\r\n+ \"name\": \"test_ip_udp_mark\",\r\n+ \"rule\": \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end actions mark / end\",\r\n+ \"scapy_str\": over_ip_udp_header_packets,\r\n+ \"check_func\": rfc.check_mark,\r\n+ \"check_param\": {\"port_id\": 1, \"mark_id\": 0, \"rss\": True, 'rxq': 16},\r\n+ \"send_port\": {\"port_id\": 0}\r\n+}\r\n+\r\n+tv_over_eth = [tv_over_eth_queue_index, tv_over_eth_rss_queues, tv_over_eth_drop, tv_over_eth_passthru, tv_over_eth_mark_rss, tv_over_eth_mark]\r\n+\r\n+tv_over_ip_udp = [tv_over_ip_udp_queue_index, tv_over_ip_udp_rss_queues, tv_over_ip_udp_drop, tv_over_ip_udp_passthru, tv_over_ip_udp_mark_rss, tv_over_ip_udp_mark]\r\n+\r\n+class TestCVLEcpri(TestCase):\r\n+ def set_up_all(self):\r\n+ \"\"\"\r\n+ Run at the start of each test suite.\r\n+ prerequisites.\r\n+ \"\"\"\r\n+ # Based on h/w type, choose how many ports to use\r\n+ self.dut_ports = self.dut.get_ports(self.nic)\r\n+ self.verify(len(self.dut_ports) >= 2, \"Insufficient ports for testing\")\r\n+ # Verify that enough threads are available\r\n+ cores = self.dut.get_core_list(\"1S/4C/1T\")\r\n+ self.verify(cores is not None, \"Insufficient cores for speed testing\")\r\n+ self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])\r\n+ self.tester_port0 = self.tester.get_local_port(self.dut_ports[0])\r\n+ self.tester_port1 = self.tester.get_local_port(self.dut_ports[1])\r\n+ self.tester_iface0 = self.tester.get_interface(self.tester_port0)\r\n+ self.tester_iface1 = self.tester.get_interface(self.tester_port1)\r\n+\r\n+ self.used_dut_port = self.dut_ports[0]\r\n+ self.pf_interface = self.dut.ports_info[self.dut_ports[0]]['intf']\r\n+ self.file_path = './drivers/net/iavf/iavf_rxtx.c'\r\n+ self.compile_dpdk()\r\n+ self.vf_flag = False\r\n+ self.create_iavf()\r\n+\r\n+ self.pass_flag = 'passed'\r\n+ self.fail_flag = 'failed'\r\n+ self.pkt = Packet()\r\n+ self.pmd_output = PmdOutput(self.dut)\r\n+ self.right_ecpri = '0x5123'\r\n+ self.wrong_ecpri = '0x5121'\r\n+\r\n+ def set_up(self):\r\n+ \"\"\"\r\n+ Run before each test case.\r\n+ \"\"\"\r\n+ self.launch_testpmd()\r\n+ self.pkt = Packet()\r\n+\r\n+ def create_iavf(self):\r\n+ if self.vf_flag is False:\r\n+ self.dut.bind_interfaces_linux('ice')\r\n+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4)\r\n+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']\r\n+ self.vf_flag = True\r\n+\r\n+ try:\r\n+ for i in range(len(self.sriov_vfs_port)):\r\n+ if i != len(self.sriov_vfs_port):\r\n+ self.sriov_vfs_port[i].bind_driver(self.drivername)\r\n+ self.dut.send_expect(\"ip link set %s vf %s mac %s\" % (self.pf_interface, i, Mac_list[i]), \"# \")\r\n+\r\n+ #self.vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}\r\n+ #self.dut.send_expect(\"ifconfig %s up\" % self.pf_interface, \"# \")\r\n+ self.dut.send_expect(\"ip link set %s vf 0 trust on\" % self.pf_interface, \"# \")\r\n+ except Exception as e:\r\n+ self.destroy_iavf()\r\n+ raise Exception(e)\r\n+\r\n+ def destroy_iavf(self):\r\n+ if self.vf_flag is True:\r\n+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)\r\n+ self.vf_flag = False\r\n+\r\n+ def launch_testpmd(self):\r\n+ eal_param = \" -a {},cap=dcf -a {} -a {}\".format(self.sriov_vfs_port[0].pci, self.sriov_vfs_port[1].pci,\r\n+ self.sriov_vfs_port[2].pci)\r\n+ param = \" --rxq=16 --txq=16\"\r\n+ out = self.pmd_output.start_testpmd(cores=[0, 1, 2, 3], eal_param=eal_param, param=param, socket=self.ports_socket)\r\n+ # check the VF0 driver is net_ice_dcf\r\n+ self.check_dcf_status(out, stats=True)\r\n+ self.pmd_output.execute_cmd(\"set fwd rxonly\")\r\n+ self.pmd_output.execute_cmd(\"set verbose 1\")\r\n+ self.pmd_output.execute_cmd(\"start\")\r\n+\r\n+ def check_dcf_status(self, out_testpmd, stats=True):\r\n+ \"\"\"\r\n+ check if request for DCF is accepted.\r\n+ \"\"\"\r\n+ if stats:\r\n+ self.verify(\"Failed to init DCF parent adapter\" not in out_testpmd, \"request for DCF is rejected.\")\r\n+ out_portinfo = self.dut.send_expect(\"show port info 0\", \"testpmd> \", 15)\r\n+ self.verify(\"net_ice_dcf\" in out_portinfo, \"request for DCF is rejected.\")\r\n+ else:\r\n+ self.verify(\"Failed to init DCF parent adapter\" in out_testpmd, \"request for DCF is accepted.\")\r\n+ out_portinfo = self.dut.send_expect(\"show port info 0\", \"testpmd> \", 15)\r\n+ self.verify(\"net_ice_dcf\" not in out_portinfo, \"request for DCF is accepted.\")\r\n+\r\n+ def test_add_and_delete_eCPRI_port_config_in_DCF(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ self.send_and_verify(Mac_list[1], self.right_ecpri, if_match=True)\r\n+ self.send_and_verify(Mac_list[1], self.wrong_ecpri, if_match=False)\r\n+ self.send_and_verify(Mac_list[2], self.right_ecpri, if_match=True)\r\n+ # remove rule and test\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port rm ecpri {}\".format(self.right_ecpri))\r\n+\r\n+ self.send_and_verify(Mac_list[1], self.right_ecpri, if_match=False)\r\n+\r\n+ def test_add_and_delete_eCPRI_port_config_in_DCF(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ self.pmd_output.execute_cmd(\"quit\", expected=\"#\")\r\n+ self.launch_testpmd()\r\n+ self.send_and_verify(Mac_list[1], self.right_ecpri, if_match=False)\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ # use new mac to test\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ new_mac = \"00:11:22:33:44:66\"\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac {}\".format(self.pf_interface, new_mac), \"#\", timeout=10)\r\n+ self.send_and_verify(Mac_list[1], self.right_ecpri, if_match=False)\r\n+ self.pmd_output.execute_cmd(\"quit\", expected=\"#\")\r\n+ # set port vf 0 trust off and test\r\n+ self.launch_testpmd()\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust off\".format(self.pf_interface), \"#\", timeout=10)\r\n+ self.send_and_verify(Mac_list[1], self.right_ecpri, if_match=False)\r\n+ new_session.close()\r\n+\r\n+ def test_DCF_port_config_and_linux_port_config(self):\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ new_session.send_expect(\"dmesg -c\", \"#\")\r\n+ new_session.send_expect(\"ip link add vx0 type vxlan id 100 local 1.1.1.1 remote \"\r\n+ \"2.2.2.2 dev {} dstport 0x1234\".format(self.pf_interface), \"#\")\r\n+ new_session.send_expect(\"ifconfig vx0 up\", \"#\")\r\n+ new_session.send_expect(\"ifconfig vx0 down\", \"#\")\r\n+ out = new_session.send_expect(\"dmesg\", \"#\")\r\n+ self.verify(\"Cannot config tunnel, the capability is used by DCF\" in out, \"port can used by another thread!\")\r\n+ # delete eCPRI port config and test\r\n+ new_session.send_expect(\"dmesg -c\", \"#\")\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port rm ecpri {}\".format(self.right_ecpri))\r\n+ new_session.send_expect(\"ifconfig vx0 up\", \"#\")\r\n+ new_session.send_expect(\"ifconfig vx0 down\", \"# \")\r\n+ out = new_session.send_expect(\"dmesg\", \"#\")\r\n+ self.verify(\"Cannot config tunnel, the capability is used by DCF\" not in out, \"port can't used by another thread!\")\r\n+ self.pmd_output.execute_cmd(\"quit\", \"#\")\r\n+ # do ecpri test\r\n+ self.launch_testpmd()\r\n+ new_session.send_expect(\"ip link add vx0 type vxlan id 100 local 1.1.1.1 remote \"\r\n+ \"2.2.2.2 dev {} dstport 0x1234\".format(self.pf_interface), \"#\")\r\n+ new_session.send_expect(\"ifconfig vx0 up\", \"#\")\r\n+ out = self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ self.verify(\"ice_dcf_send_aq_cmd(): No response (201 times) or return failure (desc: -63 / buff: -63)\" in out,\r\n+ \"test fail\")\r\n+ # set vx0 down and test\r\n+ new_session.send_expect(\"ifconfig vx0 down\", \"#\")\r\n+ out = self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ self.verify(\"ice_dcf_send_aq_cmd(): No response (201 times) or return failure (desc: -63 / buff: -63)\"\r\n+ not in out, \"test fail\")\r\n+ new_session.close()\r\n+\r\n+ def test_negative_eCPRI_port_config_in_DCF(self):\r\n+ ecpri_and_expect_dic = {\"1\": \"Operation not supported\",\r\n+ \"5\": \"Invalid port\",\r\n+ \"15\": \"Invalid port\",\r\n+ \"a\": \"Bad arguments\"\r\n+ }\r\n+ # set wrong port to test\r\n+ for ecpri in ecpri_and_expect_dic.keys():\r\n+ out = self.pmd_output.execute_cmd(\"port config {} udp_tunnel_port add ecpri {}\".format(ecpri, self.right_ecpri))\r\n+ self.verify(ecpri_and_expect_dic[ecpri] in out, \"test fail\")\r\n+ # set an invalid ecpri to test\r\n+ ecpri_and_expect_dic = {\"ffff\": \"Bad arguments\",\r\n+ \"65536\": \"Bad arguments\"}\r\n+\r\n+ for ecpri in ecpri_and_expect_dic.keys():\r\n+ out = self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(ecpri))\r\n+ self.verify(ecpri_and_expect_dic[ecpri] in out, \"test fail\")\r\n+ if ecpri == \"0\":\r\n+ # test remove an invalid ecpri\r\n+ out = self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port rm ecpri {}\".format(ecpri))\r\n+ self.verify(\"Operation not permitted\" in out, \"test fail\")\r\n+\r\n+ def test_rss_for_udp_ecpri(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri {}\".format(self.right_ecpri))\r\n+ self.pmd_output.execute_cmd(\"flow validate 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / \"\r\n+ \"end actions rss types ecpri end key_len 0 queues end / end\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / \"\r\n+ \"end actions rss types ecpri end key_len 0 queues end / end\")\r\n+ tag_lst = ['x45', 'x46', 'x47']\r\n+ pkt_str = \"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(\r\n+ Mac_list[1])\r\n+ data_lst = self.get_receive_lst(tag_lst, [pkt_str])\r\n+ hash_lst = [i.get('RSS hash') for i in data_lst]\r\n+ self.verify(len(set(hash_lst)) == len(tag_lst) == len(set([i.get('queue') for i in data_lst])), \"test fail, RSS hash is same.\")\r\n+ # destroy rule and test\r\n+ self.pmd_output.execute_cmd(\"flow destroy 1 rule 0\")\r\n+ out = self.pmd_output.execute_cmd(\"flow list 1\")\r\n+ data_lst = self.get_receive_lst(tag_lst, [pkt_str], stats=False)\r\n+ hash_lst = [i.get('RSS hash') for i in data_lst]\r\n+ self.verify(len(hash_lst) == 0 or len(set(hash_lst)) == 1, \"test fail, rule still worked.\")\r\n+\r\n+ def test_rss_for_eth_ecpri(self):\r\n+ self.dut.send_expect(\"quit\", \"# \")\r\n+ eal_param = \" -a {} -a {}\".format(self.sriov_vfs_port[0].pci, self.sriov_vfs_port[1].pci)\r\n+ param = \" --rxq=16 --txq=16\"\r\n+ self.pmd_output.start_testpmd(cores=[0, 1, 2, 3], eal_param=eal_param, param=param, socket=self.ports_socket)\r\n+ self.pmd_output.execute_cmd(\"set fwd rxonly\")\r\n+ self.pmd_output.execute_cmd(\"set verbose 1\")\r\n+ self.pmd_output.execute_cmd(\"start\")\r\n+ self.pmd_output.execute_cmd(\"flow validate 1 ingress pattern eth / ecpri common type iq_data / \"\r\n+ \"end actions rss types ecpri end key_len 0 queues end / end\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions \"\r\n+ \"rss types ecpri end key_len 0 queues end / end\")\r\n+ tag_lst = ['x45', 'x46', 'x47']\r\n+ pkt_str = \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])\r\n+ data_lst = self.get_receive_lst(tag_lst, [pkt_str])\r\n+ hash_lst = [i.get('RSS hash') for i in data_lst]\r\n+ self.verify(len(set(hash_lst)) == len(tag_lst), \"test fail, RSS hash is same.\")\r\n+ # destroy rule and test\r\n+ self.pmd_output.execute_cmd(\"flow destroy 1 rule 0\")\r\n+ self.pmd_output.execute_cmd(\"flow list 1\")\r\n+ data_lst = self.get_receive_lst(tag_lst, [pkt_str], stats=False)\r\n+ hash_lst = [i.get('RSS hash') for i in data_lst]\r\n+ self.verify(len(hash_lst) == 0 or len(set(hash_lst)) == 1, \"test fail, rule still worked.\")\r\n+\r\n+ def test_rss_multirules_multiports(self):\r\n+ dst_mac_lst = Mac_list[1:3]\r\n+ tag_lst = ['x45', 'x46']\r\n+ module_pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\",\r\n+ \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\"]\r\n+ rule_lst = [\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end actions rss \"\r\n+ \"types ecpri end key_len 0 queues end / end\",\r\n+ \"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions rss types ecpri end \"\r\n+ \"key_len 0 queues end / end\",\r\n+ \"flow create 2 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end actions rss types\"\r\n+ \" ecpri end key_len 0 queues end / end\",\r\n+ \"flow create 2 ingress pattern eth / ecpri common type iq_data / end actions rss types ecpri end \"\r\n+ \"key_len 0 queues end / end\"]\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ for rule in rule_lst:\r\n+ self.pmd_output.execute_cmd(rule)\r\n+ out_data = {}\r\n+ for dst_mac in dst_mac_lst:\r\n+ pkt_lst = [pkt.format(dst_mac) for pkt in module_pkt_lst]\r\n+ reta_line = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ out_data.setdefault(dst_mac, reta_line)\r\n+ # verify\r\n+ for key in out_data.keys():\r\n+ hash_lst = [i.get('RSS hash') for i in out_data[key]]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, RSS hash is same.')\r\n+\r\n+ # destroy rule to test\r\n+ self.pmd_output.execute_cmd(\"flow destroy 1 rule 0\")\r\n+ self.pmd_output.execute_cmd(\"flow destroy 1 rule 1\")\r\n+ self.pmd_output.execute_cmd(\"flow list 1\")\r\n+ self.pmd_output.execute_cmd(\"flow destroy 2 rule 0\")\r\n+ self.pmd_output.execute_cmd(\"flow destroy 2 rule 1\")\r\n+ self.pmd_output.execute_cmd(\"flow list 2\")\r\n+ out_data = {}\r\n+ for dst_mac in dst_mac_lst:\r\n+ pkt_lst = [pkt.format(dst_mac) for pkt in module_pkt_lst]\r\n+ reta_line = self.get_receive_lst(tag_lst[:1], pkt_lst, stats=False)\r\n+ out_data.setdefault(dst_mac, reta_line)\r\n+ # verify\r\n+ for key in out_data.keys():\r\n+ hash_lst = [i.get('RSS hash') for i in out_data[key]]\r\n+ self.verify(len(set(hash_lst)) == 1, 'test fail, RSS hash is same.')\r\n+\r\n+ def test_rss_without_or_with_udp_port_set_for_udp_ecpri_rule(self):\r\n+ tag_lst = ['x45', 'x46', 'x47', 'x48']\r\n+ pkt = \"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end \"\r\n+ \"actions rss types ecpri end key_len 0 queues end / end\")\r\n+ out_data = self.get_receive_lst(tag_lst, [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 1, 'test fail, rule worked!')\r\n+ # set ecpri and test\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ out_data = self.get_receive_lst(tag_lst[:2], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, rule not worked!')\r\n+\r\n+ def test_DCF_reset_for_udp_ecpri_rss(self):\r\n+ tag_lst = ['x45', 'x46', 'x47']\r\n+ pkt = \"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end \"\r\n+ \"actions rss types ecpri end key_len 0 queues end / end\")\r\n+ out_data = self.get_receive_lst(tag_lst[:2], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac 00:11:22:33:44:66\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst, [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 1, 'test fail, RSS hash is not same')\r\n+\r\n+ # restart testpmd and test\r\n+ new_mac = \"00:11:22:33:44:55\"\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac {}\".format(self.pf_interface, new_mac), \"#\")\r\n+ self.dut.send_expect(\"quit\", \"# \")\r\n+ self.launch_testpmd()\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end \"\r\n+ \"actions rss types ecpri end key_len 0 queues end / end\")\r\n+ out_data = self.get_receive_lst(tag_lst[:2], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac 00:11:22:33:44:66\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst, [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 1, 'test fail, RSS hash is not same')\r\n+\r\n+ self.dut.send_expect(\"quit\", \"# \")\r\n+ self.launch_testpmd()\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust off\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst, [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 1, 'test fail, RSS hash is not same')\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust on\".format(self.pf_interface), \"#\")\r\n+ new_session.close()\r\n+\r\n+ def test_DCF_reset_for_eth_ecpri_rss(self):\r\n+ tag_lst = ['x45', 'x46', 'x47', 'x48']\r\n+ pkt = \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\"\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions rss types\"\r\n+ \" ecpri end key_len 0 queues end / end\")\r\n+\r\n+ out_data = self.get_receive_lst(tag_lst[:2], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac 00:11:22:33:44:66\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst[1:], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 3 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust off\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst[:2], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 2 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac 00:11:22:33:44:66\".format(self.pf_interface), \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst[1:], [pkt])\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 3 and None not in hash_lst, 'test fail, RSS hash is same')\r\n+\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust on\".format(self.pf_interface), \"#\")\r\n+ new_session.send_expect(\"ip link set {} vf 0 mac 00:11:22:33:44:55\".format(self.pf_interface), \"#\")\r\n+ new_session.close()\r\n+\r\n+ def test_DCF_exit_for_eth_ecpri_and_udp_ecpri_rss(self):\r\n+ self.dut.send_expect(\"quit\", \"# \")\r\n+ eal_param = \" -a {},cap=dcf\".format(self.sriov_vfs_port[0].pci)\r\n+ self.pmd_output.start_testpmd(cores=list(range(8)), eal_param=eal_param, prefix=\"test1\", socket=self.ports_socket)\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ pmd_output1 = PmdOutput(self.dut, new_session)\r\n+ eal_param1 = \" -a {} -a {}\".format(self.sriov_vfs_port[1].pci, self.sriov_vfs_port[2].pci)\r\n+ param = \" --rxq=16 --txq=16\"\r\n+ pmd_output1.start_testpmd(cores=list(range(8)), eal_param=eal_param1, param=param, prefix=\"test2\",\r\n+ socket=self.ports_socket)\r\n+ pmd_output1.execute_cmd(\"flow create 0 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end \"\r\n+ \"actions rss types ecpri end key_len 0 queues end / end\")\r\n+ pmd_output1.execute_cmd(\"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions rss \"\r\n+ \"types ecpri end key_len 0 queues end / end\")\r\n+ pmd_output1.execute_cmd(\"set verbose 1\")\r\n+ pmd_output1.execute_cmd(\"set fwd rxonly\")\r\n+ pmd_output1.execute_cmd(\"start\")\r\n+ tag_lst = ['x45', 'x46']\r\n+ pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s')\".format(Mac_list[1]),\r\n+ \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[2])\r\n+ ]\r\n+ out_data = self.get_receive_lst(tag_lst, pkt_lst, pmd_output1)\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(len(set(hash_lst)) == 4 and None not in hash_lst, 'test fail, Rss hash is same.')\r\n+ self.pmd_output.execute_cmd(\"quit\", \"#\")\r\n+ out_data = self.get_receive_lst(tag_lst, pkt_lst, pmd_output1)\r\n+ # verify\r\n+ hash_lst = [i.get('RSS hash') for i in out_data]\r\n+ self.verify(hash_lst[0] == hash_lst[2] and hash_lst[1] != hash_lst[3], 'test fail, hash value is wrong.')\r\n+ pmd_output1.execute_cmd(\"quit\", '#')\r\n+ new_session.close()\r\n+\r\n+ def create_fdir_rule(self, rule: (list, str), check_stats=None, msg=None, validate=True):\r\n+ if validate:\r\n+ if isinstance(rule, list):\r\n+ validate_rule = [i.replace('create', 'validate') for i in rule]\r\n+ else:\r\n+ validate_rule = rule.replace('create', 'validate')\r\n+ self.validate_fdir_rule(validate_rule, check_stats=check_stats)\r\n+ p = re.compile(r\"Flow rule #(\\d+) created\")\r\n+ rule_list = []\r\n+ if isinstance(rule, list):\r\n+ for i in rule:\r\n+ out = self.pmd_output.execute_cmd(i, timeout=1)\r\n+ if msg:\r\n+ self.verify(msg in out, \"failed: expect %s in %s\" % (msg, out))\r\n+ m = p.search(out)\r\n+ if m:\r\n+ rule_list.append(m.group(1))\r\n+ else:\r\n+ rule_list.append(False)\r\n+ elif isinstance(rule, str):\r\n+ out = self.pmd_output.execute_cmd(rule, timeout=1)\r\n+ if msg:\r\n+ self.verify(msg in out, \"failed: expect %s in %s\" % (msg, out))\r\n+ m = p.search(out)\r\n+ if m:\r\n+ rule_list.append(m.group(1))\r\n+ else:\r\n+ rule_list.append(False)\r\n+ else:\r\n+ raise Exception(\"unsupported rule type, only accept list or str\")\r\n+ if check_stats:\r\n+ self.verify(all(rule_list), \"some rules create failed, result %s\" % rule_list)\r\n+ elif check_stats == False:\r\n+ self.verify(not any(rule_list), \"all rules should create failed, result %s\" % rule_list)\r\n+ return rule_list\r\n+\r\n+ def validate_fdir_rule(self, rule, check_stats=True, check_msg=None):\r\n+ flag = 'Flow rule validated'\r\n+ if isinstance(rule, str):\r\n+ out = self.pmd_output.execute_cmd(rule, timeout=1)\r\n+ if check_stats:\r\n+ self.verify(flag in out.strip(), \"rule %s validated failed, result %s\" % (rule, out))\r\n+ else:\r\n+ if check_msg:\r\n+ self.verify(flag not in out.strip() and check_msg in out.strip(),\r\n+ \"rule %s validate should failed with msg: %s, but result %s\" % (rule, check_msg, out))\r\n+ else:\r\n+ self.verify(flag not in out.strip(), \"rule %s validate should failed, result %s\" % (rule, out))\r\n+ elif isinstance(rule, list):\r\n+ for r in rule:\r\n+ out = self.pmd_output.execute_cmd(r, timeout=1)\r\n+ if check_stats:\r\n+ self.verify(flag in out.strip(), \"rule %s validated failed, result %s\" % (r, out))\r\n+ else:\r\n+ if not check_msg:\r\n+ self.verify(flag not in out.strip(), \"rule %s validate should failed, result %s\" % (r, out))\r\n+ else:\r\n+ self.verify(flag not in out.strip() and check_msg in out.strip(),\r\n+ \"rule %s should validate failed with msg: %s, but result %s\" % (\r\n+ r, check_msg, out))\r\n+\r\n+ def check_fdir_rule(self, port_id=0, stats=True, rule_list=None):\r\n+ out = self.pmd_output.execute_cmd(\"flow list %s\" % port_id)\r\n+ p = re.compile(r\"ID\\s+Group\\s+Prio\\s+Attr\\s+Rule\")\r\n+ matched = p.search(out)\r\n+ if stats:\r\n+ self.verify(matched, \"flow rule on port %s is not existed\" % port_id)\r\n+ if rule_list:\r\n+ p = re.compile(\"^(\\d+)\\s\")\r\n+ li = out.splitlines()\r\n+ res = list(filter(bool, list(map(p.match, li))))\r\n+ result = [i.group(1) for i in res]\r\n+ self.verify(sorted(result) == sorted(rule_list),\r\n+ \"check rule list failed. expect %s, result %s\" % (rule_list, result))\r\n+ else:\r\n+ if rule_list:\r\n+ p = re.compile(\"^(\\d+)\\s\")\r\n+ li = out.splitlines()\r\n+ res = list(filter(bool, list(map(p.match, li))))\r\n+ result = [i.group(1) for i in res]\r\n+ self.verify(not [i for i in rule_list if i in result],\r\n+ \"check rule list failed. flow rule %s on port %s is existed\" % (rule_list, port_id))\r\n+ else:\r\n+ self.verify(not matched, \"flow rule on port %s is existed\" % port_id)\r\n+\r\n+ def destroy_fdir_rule(self, port_id=0, rule_id=None):\r\n+ if rule_id is None:\r\n+ rule_id = 0\r\n+ if isinstance(rule_id, list):\r\n+ for i in rule_id:\r\n+ out = self.dut.send_command(\"flow destroy %s rule %s\" % (port_id, i), timeout=1)\r\n+ p = re.compile(r\"Flow rule #(\\d+) destroyed\")\r\n+ m = p.search(out)\r\n+ self.verify(m, \"flow rule %s delete failed\" % rule_id)\r\n+ else:\r\n+ out = self.dut.send_command(\"flow destroy %s rule %s\" % (port_id, rule_id), timeout=1)\r\n+ p = re.compile(r\"Flow rule #(\\d+) destroyed\")\r\n+ m = p.search(out)\r\n+ self.verify(m, \"flow rule %s delete failed\" % rule_id)\r\n+\r\n+ def send_packets(self, packets, tx_port=None, count=1):\r\n+ self.pkt.update_pkt(packets)\r\n+ tx_port = self.tester_iface0 if not tx_port else tx_port\r\n+ self.pkt.send_pkt(crb=self.tester, tx_port=tx_port, count=count)\r\n+\r\n+ def send_pkts_getouput(self, pkts, port_id=0, count=1, drop=False):\r\n+ tx_port = self.tester_iface0 if port_id == 0 else self.tester_iface1\r\n+\r\n+ time.sleep(1)\r\n+ if drop:\r\n+ self.pmd_output.execute_cmd(\"clear port stats all\")\r\n+ time.sleep(0.5)\r\n+ self.send_packets(pkts, tx_port=tx_port, count=count)\r\n+ out = self.pmd_output.execute_cmd(\"stop\")\r\n+ self.pmd_output.execute_cmd(\"start\")\r\n+ else:\r\n+ self.send_packets(pkts, tx_port=tx_port, count=count)\r\n+ out = self.pmd_output.get_output()\r\n+ return out\r\n+\r\n+ def _rte_flow_validate(self, vectors):\r\n+ test_results = {}\r\n+ for tv in vectors:\r\n+ try:\r\n+ count = 1\r\n+ port_id = tv[\"send_port\"][\"port_id\"] if tv[\"send_port\"].get(\"port_id\") is not None else 0\r\n+ dut_port_id = tv[\"check_param\"][\"port_id\"] if tv[\"check_param\"].get(\"port_id\") is not None else 0\r\n+ drop = tv[\"check_param\"].get(\"drop\")\r\n+ # create rule\r\n+ rule_li = self.create_fdir_rule(tv[\"rule\"], check_stats=True)\r\n+ # send and check match packets\r\n+ out1 = self.send_pkts_getouput(pkts=tv[\"scapy_str\"][\"match\"], port_id=port_id,\r\n+ count=count, drop=drop)\r\n+ matched_queue = tv[\"check_func\"](out1, pkt_num=len(tv[\"scapy_str\"][\"match\"]),\r\n+ check_param=tv[\"check_param\"])\r\n+ # send and check unmatched packets\r\n+ out2 = self.send_pkts_getouput(pkts=tv[\"scapy_str\"][\"unmatched\"], port_id=port_id,\r\n+ count=count, drop=drop)\r\n+ tv[\"check_func\"](out2, pkt_num=len(tv[\"scapy_str\"][\"unmatched\"]), check_param=tv[\"check_param\"],\r\n+ stats=False)\r\n+ # list and destroy rule\r\n+ self.check_fdir_rule(port_id=tv[\"check_param\"][\"port_id\"], rule_list=['0'] + rule_li)\r\n+ self.destroy_fdir_rule(rule_id=rule_li, port_id=dut_port_id)\r\n+ # send matched packet\r\n+ out3 = self.send_pkts_getouput(pkts=tv[\"scapy_str\"][\"match\"], port_id=port_id,\r\n+ count=count, drop=drop)\r\n+ matched_queue2 = tv[\"check_func\"](out3, pkt_num=len(tv[\"scapy_str\"][\"match\"]),\r\n+ check_param=tv[\"check_param\"],\r\n+ stats=False)\r\n+ if tv[\"check_param\"].get(\"rss\"):\r\n+ self.verify(matched_queue == matched_queue2 and None not in matched_queue,\r\n+ \"send twice matched packet, received in deferent queues\")\r\n+ # check not rule exists\r\n+ self.check_fdir_rule(port_id=dut_port_id, rule_list=rule_li, stats=False)\r\n+ test_results[tv[\"name\"]] = True\r\n+ self.logger.info((GREEN(\"case passed: %s\" % tv[\"name\"])))\r\n+ except Exception as e:\r\n+ self.logger.warning((RED(e)))\r\n+ self.dut.send_command(\"flow flush 0\", timeout=1)\r\n+ self.dut.send_command(\"flow flush 1\", timeout=1)\r\n+ test_results[tv[\"name\"]] = False\r\n+ self.logger.info((GREEN(\"case failed: %s\" % tv[\"name\"])))\r\n+ continue\r\n+ failed_cases = []\r\n+ for k, v in list(test_results.items()):\r\n+ if not v:\r\n+ failed_cases.append(k)\r\n+ self.verify(all(test_results.values()), \"{} failed.\".format(failed_cases))\r\n+\r\n+ def test_eCPRI_over_Ethernet_header_pattern_fdir(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.create_fdir_rule(rule=eCPRI_over_Ethernet_rule, check_stats=True)\r\n+ self._rte_flow_validate(tv_over_eth)\r\n+\r\n+ def test_eCPRI_over_IP_or_UDP_header_pattern_fdir(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.create_fdir_rule(rule=eCPRI_over_IP_UDP_rule, check_stats=True)\r\n+ self._rte_flow_validate(tv_over_ip_udp)\r\n+\r\n+ def test_ecpri_fdir_multirules(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ rule_lst = [\"flow create 1 ingress pattern eth / ecpri common type iq_data / end actions rss types ecpri end \"\r\n+ \"key_len 0 queues end / end\",\r\n+ \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end actions rss \"\r\n+ \"types ecpri end key_len 0 queues end / end\",\r\n+ \"flow create 2 ingress pattern eth / ecpri common type iq_data / end actions rss types ecpri end \"\r\n+ \"key_len 0 queues end / end\",\r\n+ \"flow create 2 ingress pattern eth / ipv4 / udp / ecpri common type iq_data / end actions rss \"\r\n+ \"types ecpri end key_len 0 queues end / end\",\r\n+ \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2345 / end \"\r\n+ \"actions rss queues 5 6 end / mark id 0 / end\",\r\n+ \"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2346 / end \"\r\n+ \"actions passthru / mark id 1 / end\",\r\n+ \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end actions \"\r\n+ \"drop / end\",\r\n+ \"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is 0x2346 / end actions \"\r\n+ \"queue index 1 / mark id 2 / end\",\r\n+ \"flow create 2 ingress pattern eth / ecpri common type iq_data pc_id is 0x2346 / end actions \"\r\n+ \"mark id 3 / end\",\r\n+ \"flow create 2 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is 0x2346 / end \"\r\n+ \"actions mark / rss / end\"]\r\n+ for rule in rule_lst:\r\n+ self.pmd_output.execute_cmd(rule)\r\n+ tag_lst = ['x45', 'x46']\r\n+ module_pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\",\r\n+ \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\"]\r\n+ pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])]\r\n+ data_lst = self.get_receive_lst(tag_lst[: 1], pkt_lst, stats=False)\r\n+ queue = [data.get('queue') for data in data_lst]\r\n+ self.verify([i for i in queue if i in ['5', '6']], 'pkt go to wrong queue!')\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == ['0x0'], 'pkt has wrong mark id!')\r\n+ data_lst = self.get_receive_lst(tag_lst[1: ], pkt_lst)\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == ['0x1'], 'pkt has wrong mark id!')\r\n+ pkt_lst = [\"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])]\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst, stats=False)\r\n+ self.verify([data.get('queue') for data in data_lst] == [None, '1'], 'pkt go to wrong queue!')\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == [None, '0x2'], 'pkt has wrong mark id!')\r\n+ pkt_lst = [pkt.format(Mac_list[2]) for pkt in module_pkt_lst]\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == [None, None, '0x0', '0x3'], 'pkt has wrong mark id!') \r\n+\r\n+ def test_ecpri_fdir_negative_case(self):\r\n+ out = self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id is \"\r\n+ \"0x2345 / end actions rss queues 5 6 end / mark id 0 / end\")\r\n+ self.verify(\"Failed to create parser engine.: Invalid argument\" in out, \"test fail, bad rule set success.\")\r\n+ out = self.pmd_output.execute_cmd(\"flow list 1\")\r\n+ r = r'flow list 1(\\s+)(.*)'\r\n+ m = re.match(r, out)\r\n+ self.verify(m.group(2) == '', 'bad rule set successful!')\r\n+\r\n+ def test_ecpri_fdir_when_DCF_reset(self):\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id \"\r\n+ \"is 0x2345 / end actions queue index 1 / mark id 1 / end\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is \"\r\n+ \"0x2345 / end actions queue index 2 / mark id 2 / end\")\r\n+ pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1]),\r\n+ \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])]\r\n+ tag_lst = ['x45']\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ # verify\r\n+ self.verify([data.get('queue') for data in data_lst] == ['1', '2'], \"pkt to the wrong queue!\")\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == ['0x1', '0x2'], \"pkt with wrong FDIR matched ID!\")\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ new_session.send_expect('ip link set {} vf 0 mac 00:11:22:33:44:66'.format(self.pf_interface), '#')\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ # verify\r\n+ self.verify(data_lst[1].get('queue') == '2', \"pkt to the wrong queue!\")\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == [None, '0x2'], \"pkt with wrong FDIR matched ID!\")\r\n+ self.dut.send_expect(\"quit\", \"#\")\r\n+ self.launch_testpmd()\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id \"\r\n+ \"is 0x2345 / end actions queue index 1 / mark id 1 / end\")\r\n+ self.pmd_output.execute_cmd(\"flow create 1 ingress pattern eth / ecpri common type iq_data pc_id is \"\r\n+ \"0x2345 / end actions queue index 2 / mark id 2 / end\")\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ self.verify([data.get('queue') for data in data_lst] == ['1', '2'], \"pkt to the wrong queue!\")\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == ['0x1', '0x2'], \"pkt with wrong FDIR matched ID!\")\r\n+ new_session.send_expect(\"ip link set {} vf 0 trust off\".format(self.pf_interface), \"#\")\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst)\r\n+ self.verify(data_lst[1].get('queue') == '2', \"pkt to the wrong queue!\")\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == [None, '0x2'], \"pkt with wrong FDIR matched ID!\")\r\n+ new_session.close()\r\n+\r\n+ def test_ecpri_fdir_when_DCF_exit(self):\r\n+ self.dut.send_expect(\"quit\", \"#\")\r\n+ eal_param = \" -a {},cap=dcf\".format(self.sriov_vfs_port[0].pci)\r\n+ self.pmd_output.start_testpmd(cores=list(range(8)), eal_param=eal_param, prefix=\"test1\",\r\n+ socket=self.ports_socket)\r\n+ self.pmd_output.execute_cmd(\"port config 0 udp_tunnel_port add ecpri 0x5123\")\r\n+ new_session = self.dut.create_session(name=\"new_session\")\r\n+ pmd_output1 = PmdOutput(self.dut, new_session)\r\n+ eal_param1 = \" -a {} -a {}\".format(self.sriov_vfs_port[1].pci, self.sriov_vfs_port[2].pci)\r\n+ param = \" --rxq=16 --txq=16\"\r\n+ pmd_output1.start_testpmd(cores=list(range(8)), eal_param=eal_param1, param=param, prefix=\"test2\",\r\n+ socket=self.ports_socket)\r\n+ pmd_output1.execute_cmd(\"flow create 0 ingress pattern eth / ipv4 / udp / ecpri common type iq_data pc_id \"\r\n+ \"is 0x2345 / end actions queue index 1 / mark id 1 / end\")\r\n+ pmd_output1.execute_cmd(\"flow create 0 ingress pattern eth / ecpri common type iq_data pc_id is 0x2345 / end \"\r\n+ \"actions queue index 2 / mark id 2 / end\")\r\n+ pmd_output1.execute_cmd(\"set verbose 1\")\r\n+ pmd_output1.execute_cmd(\"set fwd rxonly\")\r\n+ pmd_output1.execute_cmd(\"start\")\r\n+ pkt_lst = [\"Ether(dst='{}')/IP()/UDP(dport=0x5123)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1]),\r\n+ \"Ether(dst='{}', type=0xAEFE)/Raw(\\'\\\\x10\\\\x00\\\\x02\\\\x24\\\\x23\\\\%s\\')\".format(Mac_list[1])]\r\n+ tag_lst = ['x45']\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst, pmd_output=pmd_output1)\r\n+ # verify\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == ['0x1', '0x2'] and [data.get('queue') for data in data_lst] == ['1', '2'], 'mark id or queue wrong!')\r\n+\r\n+ self.dut.send_expect(\"quit\", \"#\")\r\n+ data_lst = self.get_receive_lst(tag_lst, pkt_lst, pmd_output=pmd_output1)\r\n+ # verify\r\n+ self.verify([data.get('FDIR matched ID') for data in data_lst] == [None, '0x2'] and data_lst[1].get('queue') == '2', 'mark id or queue wrong!')\r\n+\r\n+ def get_receive_lst(self, tag_lst=[], pkt_lst=[], pmd_output='', stats=True):\r\n+ data_lst = []\r\n+ for tag in tag_lst:\r\n+ for pkt in pkt_lst:\r\n+ pkt_str = pkt % tag\r\n+ out = self.send_pkt(pkt_str=pkt_str, pmd_output=pmd_output)\r\n+ rfc.verify_directed_by_rss(out, rxq=16, stats=stats) \r\n+ reta_line = self.get_receive_data(out)\r\n+ data_lst.append(reta_line)\r\n+ return data_lst\r\n+\r\n+ def get_receive_data(self, out):\r\n+ reta_line = {}\r\n+ lines = out.split(\"\\r\\n\")\r\n+ for line in lines:\r\n+ line = line.strip()\r\n+ if len(line) != 0 and line.strip().startswith(\"port \"):\r\n+ reta_line = {}\r\n+ rexp = r\"port (\\d)/queue (\\d{1,2}): received (\\d) packets\"\r\n+ m = re.match(rexp, line.strip())\r\n+ if m:\r\n+ reta_line[\"port\"] = m.group(1)\r\n+ reta_line[\"queue\"] = m.group(2)\r\n+\r\n+ elif len(line) != 0 and line.startswith((\"src=\",)):\r\n+ for item in line.split(\"-\"):\r\n+ item = item.strip()\r\n+ if item.startswith(\"RSS hash\"):\r\n+ name, value = item.split(\"=\", 1)\r\n+ reta_line[name.strip()] = value.strip()\r\n+ elif item.startswith(\"FDIR matched ID\"):\r\n+ name, value = item.split(\"=\", 1)\r\n+ reta_line[name.strip()] = value.strip()\r\n+ return reta_line\r\n+\r\n+ def compile_dpdk(self):\r\n+ cmd_lst = [r\"sed -i '/iavf_flex_rxd_to_vlan_tci(rxm, &rxd, rxq->rx_flags);/i\\printf(\\\"++++++++++++ptype=%u\\\\n\\\",IAVF_RX_FLEX_DESC_PTYPE_M & rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0));' \",\r\n+ r\"sed -i '/IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);/{:a;n;s/ifdef RTE_ARCH_X86/if 0/g;/struct iavf_rx_queue/!ba}' \",\r\n+ r\"sed -i '/rx_pkt_burst = iavf_recv_pkts;/{n;s/\\}/\\}dev->rx_pkt_burst = iavf_recv_pkts_flex_rxd;\\n/g}' \"]\r\n+ for cmd in cmd_lst:\r\n+ self.dut.send_expect(cmd + self.file_path, \"#\")\r\n+ self.dut.build_install_dpdk(self.target)\r\n+\r\n+ def send_and_verify(self, dts_mac, ecpri, if_match=True):\r\n+ ptype_lst = ptype_match_lst if if_match else ptype_nomatch_lst\r\n+ for i in range(len(pkt_lst)):\r\n+ out = self.send_pkt(pkt_lst[i], dts_mac=dts_mac, ecpri=ecpri)\r\n+ self.verify(ptype_lst[i] in out, 'ptype is error, expect {}'.format(ptype_lst[i]))\r\n+\r\n+ def send_pkt(self, pkt_str='', dts_mac='00:11:22:33:44:11', ecpri='0x5123', pmd_output=''):\r\n+ self.pkt.append_pkt(pkt_str.format(dts_mac, ecpri))\r\n+ self.pkt.send_pkt(crb=self.tester, tx_port=self.tester_iface0, count=1)\r\n+ out = pmd_output.get_output() if pmd_output else self.pmd_output.get_output()\r\n+ self.pkt.update_pkt([])\r\n+ return out\r\n+\r\n+ def tear_down(self):\r\n+ self.dut.kill_all()\r\n+\r\n+ def tear_down_all(self):\r\n+ self.dut.kill_all()\r\n", "prefixes": [ "V1" ] }{ "id": 90461, "url": "