* [dts] [PATCH V1] tests: add test suite for ipfragment
@ 2021-06-09 16:47 Zhimin Huang
2021-06-09 8:19 ` Huang, ZhiminX
0 siblings, 1 reply; 2+ messages in thread
From: Zhimin Huang @ 2021-06-09 16:47 UTC (permalink / raw)
To: dts; +Cc: qi.fu, Zhimin Huang
add new feature ipfragment test suite
this feature enable ipfragment pkt rss and fdir by IPID
Signed-off-by: Zhimin Huang <zhiminx.huang@intel.com>
---
tests/TestSuite_ip_fragment.py | 755 +++++++++++++++++++++++++++++++++
1 file changed, 755 insertions(+)
create mode 100644 tests/TestSuite_ip_fragment.py
diff --git a/tests/TestSuite_ip_fragment.py b/tests/TestSuite_ip_fragment.py
new file mode 100644
index 00000000..1c104b46
--- /dev/null
+++ b/tests/TestSuite_ip_fragment.py
@@ -0,0 +1,755 @@
+# BSD LICENSE
+#
+# Copyright(c) 2021 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+from packet import Packet
+from pmd_output import PmdOutput
+from test_case import TestCase
+import re
+from utils import GREEN, RED
+import time
+from scapy.all import *
+import rte_flow_common as rfc
+
+LAUNCH_QUEUE = 16
+
+tv_mac_ipv4_frag_fdir_queue_index = {
+ "name": "tv_mac_ipv4_frag_fdir_queue_index",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 1 / mark / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "queue": 1, "mark_id": 0}
+}
+
+tv_mac_ipv4_frag_fdir_rss_queues = {
+ "name": "tv_mac_ipv4_frag_fdir_rss_queues",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions rss queues 2 3 end / mark / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "queue": [2, 3], "mark_id": 0}
+}
+
+tv_mac_ipv4_frag_fdir_passthru = {
+ "name": "tv_mac_ipv4_frag_fdir_passthru",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions passthru / mark / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 0}
+}
+
+tv_mac_ipv4_frag_fdir_drop = {
+ "name": "tv_mac_ipv4_frag_fdir_drop",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions drop / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "drop": True}
+}
+
+tv_mac_ipv4_frag_fdir_mark_rss = {
+ "name": "tv_mac_ipv4_frag_fdir_mark_rss",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions mark / rss / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 0, "rss": True}
+}
+
+tv_mac_ipv4_frag_fdir_mark = {
+ "name": "tv_mac_ipv4_frag_fdir_mark",
+ "rule": "flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions mark id 1 / end",
+ "scapy_str": {"matched": ["Ether()/IP(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 1}
+}
+
+tvs_mac_ipv4_fragment_fdir = [
+ tv_mac_ipv4_frag_fdir_queue_index,
+ tv_mac_ipv4_frag_fdir_rss_queues,
+ tv_mac_ipv4_frag_fdir_passthru,
+ tv_mac_ipv4_frag_fdir_drop,
+ tv_mac_ipv4_frag_fdir_mark_rss,
+ tv_mac_ipv4_frag_fdir_mark,
+]
+
+tvs_mac_ipv4_fragment_fdir_l2dst = [eval(str(element).replace('mac_ipv4_frag', 'mac_ipv4_frag_l2dst')
+ .replace('eth /', 'eth dst is 00:00:00:00:00:01 /')
+ .replace("Ether()", "Ether(dst='00:00:00:00:00:01')")
+ )
+ for element in tvs_mac_ipv4_fragment_fdir]
+
+tvs_mac_ipv4_frag_fdir_with_l2 = tvs_mac_ipv4_fragment_fdir_l2dst
+
+tvs_mac_ipv4_fragment_fdir_l3src = [eval(str(element).replace('mac_ipv4_frag', 'mac_ipv4_frag_l3src')
+ .replace('ipv4 packet_id', 'ipv4 src is 192.168.1.1 packet_id')
+ .replace("IP(id=47750)", "IP(id=47750, src='192.168.1.1')"))
+ for element in tvs_mac_ipv4_fragment_fdir]
+
+tvs_mac_ipv4_fragment_fdir_l3dst = [eval(str(element).replace('mac_ipv4_frag', 'mac_ipv4_frag_l3dst')
+ .replace('ipv4 packet_id', 'ipv4 dst is 192.168.1.2 packet_id')
+ .replace("IP(id=47750)", "IP(id=47750, dst='192.168.1.2')"))
+ for element in tvs_mac_ipv4_fragment_fdir]
+
+tvs_mac_ipv4_frag_fdir_with_l3 = tvs_mac_ipv4_fragment_fdir_l3src + tvs_mac_ipv4_fragment_fdir_l3dst
+
+tv_mac_ipv6_frag_fdir_queue_index = {
+ "name": "tv_mac_ipv6_frag_fdir_queue_index",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions queue index 1 / mark / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "queue": 1, "mark_id": 0}
+}
+
+tv_mac_ipv6_frag_fdir_rss_queues = {
+ "name": "tv_mac_ipv6_frag_fdir_rss_queues",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions rss queues 2 3 end / mark / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "queue": [2, 3], "mark_id": 0}
+}
+
+tv_mac_ipv6_frag_fdir_passthru = {
+ "name": "tv_mac_ipv6_frag_fdir_passthru",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions passthru / mark / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 0}
+}
+
+tv_mac_ipv6_frag_fdir_drop = {
+ "name": "tv_mac_ipv6_frag_fdir_drop",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions drop / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "drop": True}
+}
+
+tv_mac_ipv6_frag_fdir_mark_rss = {
+ "name": "tv_mac_ipv6_frag_fdir_mark_rss",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions mark / rss / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 0, "rss": True}
+}
+
+tv_mac_ipv6_frag_fdir_mark = {
+ "name": "tv_mac_ipv6_frag_fdir_mark",
+ "rule": "flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffffffff packet_id mask 0xffffffff frag_data spec 0x0001 frag_data last 0xffff frag_data mask 0xffff / end actions mark id 1 / end",
+ "scapy_str": {"matched": ["Ether()/IPv6()/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"],
+ "unmatched": ["Ether()/IP(id=47750)/Raw('X'*666)"]
+ },
+ "check_param": {"port_id": 0, "rxq": LAUNCH_QUEUE, "mark_id": 1}
+}
+
+tvs_mac_ipv6_fragment_fdir = [
+ tv_mac_ipv6_frag_fdir_queue_index,
+ tv_mac_ipv6_frag_fdir_rss_queues,
+ tv_mac_ipv6_frag_fdir_passthru,
+ tv_mac_ipv6_frag_fdir_drop,
+ tv_mac_ipv6_frag_fdir_mark_rss,
+ tv_mac_ipv6_frag_fdir_mark,
+]
+
+tvs_mac_ipv6_fragment_fdir_l2dst = [eval(str(element).replace('mac_ipv6_frag', 'mac_ipv6_frag_l2dst')
+ .replace('eth /', 'eth dst is 00:00:00:00:00:01 /')
+ .replace("Ether()", "Ether(dst='00:00:00:00:00:01')")
+ )
+ for element in tvs_mac_ipv6_fragment_fdir]
+
+tvs_mac_ipv6_frag_fdir_with_l2 = tvs_mac_ipv6_fragment_fdir_l2dst
+
+tvs_mac_ipv6_fragment_fdir_l3src = [eval(str(element).replace('mac_ipv6_frag', 'mac_ipv6_frag_l3src')
+ .replace('/ ipv6 /', '/ ipv6 src is 2001::1 /')
+ .replace("IPv6()", "IPv6(src='2001::1')"))
+ for element in tvs_mac_ipv6_fragment_fdir]
+
+tvs_mac_ipv6_fragment_fdir_l3dst = [eval(str(element).replace('mac_ipv6_frag', 'mac_ipv6_frag_l3dst')
+ .replace('/ ipv6 /', '/ ipv6 dst is 2001::2 /')
+ .replace("IPv6()", "IPv6(dst='2001::2')"))
+ for element in tvs_mac_ipv6_fragment_fdir]
+
+tvs_mac_ipv6_frag_fdir_with_l3 = tvs_mac_ipv6_fragment_fdir_l3src + tvs_mac_ipv6_fragment_fdir_l3dst
+
+tv_rss_basic_packets = {
+ 'ipv4_rss_fragment':
+ "Ether(src='00:11:22:33:44:55', dst='00:11:22:33:55:66')/IP(src='192.168.6.11', dst='10.11.12.13', id=47750)/Raw('X'*666)",
+ 'ipv6_rss_fragment':
+ "Ether(src='00:11:22:33:44:55', dst='00:11:22:33:55:66')/IPv6(src='CDCD:910A:2222:5498:8475:1111:3900:1537', dst='CDCD:910A:2222:5498:8475:1111:3900:2020')/IPv6ExtHdrFragment(id=47750)/Raw('X'*666)"
+}
+
+tv_mac_ipv4_fragment_rss = {
+ 'sub_casename': 'tv_mac_ipv4_fragment_rss',
+ 'rule': 'flow create 0 ingress pattern eth / ipv4 / end actions rss types eth ipv4-frag end key_len 0 queues end / end',
+ 'port_id': 0,
+ 'test': [
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'],
+ 'action': {'save_hash': 'ipv4'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'].replace('00:11:22:33:44:55', '00:11:22:33:44:66'),
+ 'action': {'check_hash_different': 'ipv4'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'].replace('192.168.6.11', '192.168.6.12'),
+ 'action': {'check_hash_different': 'ipv4'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'].replace('10.11.12.13', '10.11.12.14'),
+ 'action': {'check_hash_different': 'ipv4'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'].replace('id=47750', 'id=47751'),
+ 'action': {'check_hash_different': 'ipv4'},
+ },
+ {
+ 'send_packet': "Ether()/IPv6()/IPv6ExtHdrFragment(id=47751)/Raw('X'*666)",
+ 'action': {'check_no_hash': 'ipv4'},
+ },
+ ],
+ 'post-test': [
+ {
+ 'send_packet': tv_rss_basic_packets['ipv4_rss_fragment'],
+ 'action': {'check_no_hash': 'ipv4'},
+ },
+ ]
+}
+
+tv_mac_ipv6_fragment_rss = {
+ 'sub_casename': 'tv_mac_ipv6_fragment_rss',
+ 'rule': 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext / end actions rss types eth ipv6-frag end key_len 0 queues end / end',
+ 'port_id': 0,
+ 'test': [
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'],
+ 'action': {'save_hash': 'ipv6'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'].replace('00:11:22:33:44:55', '00:11:22:33:44:66'),
+ 'action': {'check_hash_different': 'ipv6'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'].replace('3900:1537', '3900:1538'),
+ 'action': {'check_hash_different': 'ipv6'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'].replace('3900:2020', '3900:2021'),
+ 'action': {'check_hash_different': 'ipv6'},
+ },
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'].replace('id=47750', 'id=47751'),
+ 'action': {'check_hash_different': 'ipv6'},
+ },
+ {
+ 'send_packet': "Ether()/IP(id=47750)/Raw('X'*666)",
+ 'action': {'check_no_hash': 'ipv6'},
+ },
+ ],
+ 'post-test': [
+ {
+ 'send_packet': tv_rss_basic_packets['ipv6_rss_fragment'],
+ 'action': {'check_no_hash': 'ipv6'},
+ },
+ ]
+}
+
+
+class TestIpFragment(TestCase):
+ def set_up_all(self):
+ self.ports = self.dut.get_ports(self.nic)
+
+ # init pkt
+ self.pkt = Packet()
+ # set default app parameter
+ self.pmd_out = PmdOutput(self.dut)
+ self.tester_mac = self.tester.get_mac(0)
+ self.tester_port0 = self.tester.get_local_port(self.ports[0])
+ self.tester_iface0 = self.tester.get_interface(self.tester_port0)
+
+ self.tester.send_expect('ifconfig {} up'.format(self.tester_iface0), '# ')
+ self.param = '--rxq={} --txq={} --disable-rss --txd=384 --rxd=384'.format(LAUNCH_QUEUE, LAUNCH_QUEUE)
+ self.param_fdir = '--rxq={} --txq={}'.format(LAUNCH_QUEUE, LAUNCH_QUEUE)
+ self.vf_flag = False
+ self.cores = self.dut.get_core_list("1S/4C/1T")
+
+ self.ports_pci = [self.dut.ports_info[self.ports[0]]['pci']]
+
+ self.rssprocess = rfc.RssProcessing(self, self.pmd_out, [self.tester_iface0], LAUNCH_QUEUE)
+
+ def set_up(self):
+ self.dut.bind_interfaces_linux('vfio-pci')
+
+ def setup_1pf_vfs_env(self):
+ """
+ create vf and set vf mac
+ """
+ self.vf_flag = True
+ self.dut.bind_interfaces_linux('ice')
+ self.pf_interface = self.dut.ports_info[0]['intf']
+ self.dut.send_expect("ifconfig {} up".format(self.pf_interface), "# ")
+ self.dut.generate_sriov_vfs_by_port(self.ports[0], 1, driver=self.kdriver)
+ self.dut.send_expect('ip link set {} vf 0 mac 00:11:22:33:55:66'.format(self.pf_interface), '# ')
+ self.vf_port = self.dut.ports_info[0]['vfs_port']
+ self.verify(len(self.vf_port) != 0, "VF create failed")
+ self.vf_driver = self.get_suite_cfg()['vf_driver']
+ if self.vf_driver is None:
+ self.vf_assign_method = 'vfio-pci'
+ self.vf_port[0].bind_driver(self.vf_driver)
+
+ self.vf_ports_pci = [self.vf_port[0].pci]
+
+ def launch_testpmd(self, param_fdir=False):
+ """
+ start testpmd with fdir or rss param, and pf or vf
+
+ :param param_fdir: True: Fdir param/False: rss param
+ """
+ if param_fdir == True:
+ if self.vf_flag == True:
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.vf_ports_pci, param=self.param_fdir)
+ else:
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports_pci, param=self.param_fdir)
+ else:
+ if self.vf_flag == True:
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.vf_ports_pci, param=self.param)
+ else:
+ self.pmd_out.start_testpmd(cores=self.cores, ports=self.ports_pci, param=self.param)
+ self.dut.send_expect("set fwd rxonly", "testpmd> ")
+ self.dut.send_expect("set verbose 1", "testpmd> ")
+ self.dut.send_expect("start", "testpmd> ")
+
+ def _rte_flow_validate(self, vectors):
+ """
+ FDIR test: validate/create rule, check match pkts and unmatched pkts, destroy rule...
+
+ :param vectors: test vectors
+ """
+ test_results = {}
+ for tv in vectors:
+ try:
+ self.logger.info("====================sub_case: {}=========================".format(tv["name"]))
+ port_id = tv["check_param"]["port_id"] if tv["check_param"].get("port_id") is not None else 0
+ drop = tv["check_param"].get("drop")
+ # create rule
+ self.dut.send_expect("flow flush %d" % port_id, "testpmd> ", 120)
+ rule_li = self.rssprocess.create_rule(tv["rule"])
+ # send and check match packets
+ out1 = self.send_pkts_getouput(pkts=tv["scapy_str"]["matched"], port_id=port_id, drop=drop)
+ matched_queue = rfc.check_mark(out1, pkt_num=len(tv["scapy_str"]["matched"])*2, check_param=tv[
+ "check_param"])
+
+ # send and check unmatched packets
+ out2 = self.send_pkts_getouput(pkts=tv["scapy_str"]["unmatched"], port_id=port_id, drop=drop)
+ rfc.check_mark(out2, pkt_num=len(tv["scapy_str"]["unmatched"])*2, check_param=tv["check_param"], stats=False)
+
+ # list and destroy rule
+ self.rssprocess.check_rule(port_id=tv["check_param"]["port_id"], rule_list=rule_li)
+ self.rssprocess.destroy_rule(rule_id=rule_li, port_id=port_id)
+ # send matched packet
+ out3 = self.send_pkts_getouput(pkts=tv["scapy_str"]["matched"], port_id=port_id, drop=drop)
+ matched_queue2 = rfc.check_mark(out3, pkt_num=len(tv["scapy_str"]["matched"])*2,
+ check_param=tv["check_param"], stats=False)
+ if tv["check_param"].get("rss"):
+ self.verify(matched_queue == matched_queue2 and None not in matched_queue,
+ "send twice matched packet, received in deferent queues")
+ # check not rule exists
+ self.rssprocess.check_rule(port_id=port_id, stats=False)
+ test_results[tv["name"]] = True
+ self.logger.info((GREEN("case passed: %s" % tv["name"])))
+ except Exception as e:
+ self.logger.warning((RED(e)))
+ self.dut.send_command("flow flush 0", timeout=1)
+ test_results[tv["name"]] = False
+ self.logger.info((GREEN("case failed: %s" % tv["name"])))
+ continue
+ self.output_result_list(test_results)
+
+ def _rss_distribute_validate(self, vectors):
+ """
+ RSS test: validate/create rule, check different hash values, destroy rule...
+
+ :param vectors: test vectors
+ """
+ test_results = {}
+ if not isinstance(vectors, list):
+ vectors = [vectors]
+ for vector in vectors:
+ try:
+ self.rssprocess.error_msgs = []
+ self.logger.info("====================sub_case: {}=======================".format(vector["sub_casename"]))
+ port_id = vector.get("port_id") if vector.get("port_id") is not None else 0
+ rules = vector.get('rule') if vector.get('rule') else []
+ rule_ids = []
+ # handle tests
+ tests = vector['test']
+ self.logger.info('------------handle test--------------')
+ # validate rule
+ if rules:
+ self.rssprocess.validate_rule(rule=rules, check_stats=True)
+ rule_ids = self.rssprocess.create_rule(rule=vector['rule'], check_stats=True)
+ self.rssprocess.check_rule(port_id=port_id, rule_list=rule_ids)
+ for test in tests:
+ out1 = ''
+ if 'send_packet' in test:
+ out1 = self.send_pkts_getouput(test['send_packet'], port_id)
+ if 'action' in test:
+ self.rssprocess.handle_actions(out1, test['action'])
+ # handle post-test
+ if 'post-test' in vector:
+ self.logger.info('------------handle post-test--------------')
+ self.rssprocess.destroy_rule(port_id=port_id, rule_id=rule_ids)
+ self.rssprocess.check_rule(port_id=port_id, stats=False)
+ post_tests = vector['post-test']
+ for post_test in post_tests:
+ out2 = ''
+ if 'send_packet' in post_test:
+ out2 = self.send_pkts_getouput(post_test['send_packet'], port_id)
+ if 'action' in post_test:
+ self.rssprocess.handle_actions(out2, post_test['action'])
+ if self.rssprocess.error_msgs:
+ self.verify(False, str(self.rssprocess.error_msgs[:500]))
+ except Exception as e:
+ self.logger.warning('sub_case %s failed: %s' % (vector['sub_casename'], e))
+ test_results[vector['sub_casename']] = False
+ else:
+ pass
+ self.logger.info('sub_case %s passed' % vector['sub_casename'])
+ test_results[vector['sub_casename']] = True
+ finally:
+ self.pmd_out.execute_cmd('flow flush 0')
+ self.output_result_list(test_results)
+
+ def output_result_list(self, result_dic):
+ """
+ verified test result pass or failed
+
+ :param result_dic: FDIR or RSS result dic
+ """
+ failed_cases = []
+ for k, v in list(result_dic.items()):
+ if not v:
+ failed_cases.append(k)
+ self.verify(all(result_dic.values()), "{} failed".format(failed_cases))
+
+ def send_pkts_getouput(self, pkts, port_id=0, drop=False):
+ """
+ send fragment pkts and get output
+
+ :param pkts: pkts list
+ :param port_id: default port_id = 0
+ :param drop: if validate drop, need re-start testpmd to show output
+ :return: return pmd output
+ """
+ tx_port = self.tester_iface0 if port_id == 0 else self.tester_iface1
+ time.sleep(1)
+ if isinstance(pkts, str):
+ pkts = [pkts]
+ if drop:
+ self.pmd_out.execute_cmd("clear port stats all")
+ time.sleep(1)
+ self.send_pkt(pkts, tx_port=tx_port)
+ out = self.pmd_out.execute_cmd("stop")
+ self.pmd_out.execute_cmd("start")
+ else:
+ self.send_pkt(pkts, tx_port=tx_port)
+ out = self.pmd_out.get_output()
+ return out
+
+ def destroy_testpmd_and_vf(self):
+ """
+ quit testpmd
+ if vf testpmd, destroy the vfs and set vf_flag = false
+ """
+ self.dut.send_expect("quit", "# ")
+ if self.vf_flag == True:
+ for port_id in self.ports:
+ self.dut.destroy_sriov_vfs_by_port(port_id)
+ self.vf_flag = False
+
+ def send_pkt(self, pkt, tx_port):
+ """
+ send fragment pkts
+
+ :param pkt: pkts list
+ :param tx_port: send pkts tester port
+ """
+ self.logger.info(" Send pkt:{}".format(pkt))
+ for i in range(len(pkt)):
+ self.tester.scapy_session.send_expect(
+ 'p=eval("{}")'.format(pkt[i]), '>>> ')
+
+ if 'IPv6ExtHdrFragment' in pkt[i]:
+ self.tester.scapy_session.send_expect(
+ 'pkts=fragment6(p, 500)', '>>> ')
+ else:
+ self.tester.scapy_session.send_expect(
+ 'pkts=fragment(p, fragsize=500)', '>>> ')
+ self.tester.scapy_session.send_expect(
+ 'sendp(pkts, iface="{}")'.format(tx_port), '>>> ')
+
+ def tear_down(self):
+ self.destroy_testpmd_and_vf()
+ self.dut.kill_all()
+
+ def tear_down_all(self):
+ self.dut.kill_all()
+
+ def test_mac_ipv4_frag_pf_fdir(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv4_fragment_fdir)
+
+ def test_mac_ipv6_frag_pf_fdir(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv6_fragment_fdir)
+
+ def test_mac_ipv4_frag_pf_fdir_with_l2(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv4_frag_fdir_with_l2)
+
+ def test_mac_ipv4_frag_pf_fdir_with_l3(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv4_frag_fdir_with_l3)
+
+ def test_mac_ipv6_frag_pf_fdir_with_l2(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv6_frag_fdir_with_l2)
+
+ def test_mac_ipv6_frag_pf_fdir_with_l3(self):
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv6_frag_fdir_with_l3)
+
+ def test_mac_ipv4_frag_vf_fdir(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv4_fragment_fdir)
+
+ def test_mac_ipv6_frag_vf_fdir(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv6_fragment_fdir)
+
+ def test_mac_ipv4_frag_vf_fdir_with_l3(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv4_frag_fdir_with_l3)
+
+ def test_mac_ipv6_frag_vf_fdir_with_l3(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=True)
+ self._rte_flow_validate(tvs_mac_ipv6_frag_fdir_with_l3)
+
+ def test_mac_ipv4_frag_pf_rss(self):
+ self.launch_testpmd(param_fdir=False)
+ self._rss_distribute_validate(tv_mac_ipv4_fragment_rss)
+
+ def test_mac_ipv4_frag_vf_rss(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=False)
+ self._rss_distribute_validate(tv_mac_ipv4_fragment_rss)
+
+ def test_mac_ipv6_frag_pf_rss(self):
+ self.launch_testpmd(param_fdir=False)
+ self._rss_distribute_validate(tv_mac_ipv6_fragment_rss)
+
+ def test_mac_ipv6_frag_vf_rss(self):
+ self.setup_1pf_vfs_env()
+ self.launch_testpmd(param_fdir=False)
+ self._rss_distribute_validate(tv_mac_ipv6_fragment_rss)
+
+ def exclusive_validation(self):
+ result = True
+ result_list = []
+ rule_list_pf = [
+ 'flow create 0 ingress pattern eth dst is 00:11:22:33:44:55 / ipv4 src is 192.168.0.20 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 2 / end']
+ rule_list_vf = [
+ 'flow create 0 ingress pattern eth / ipv4 src is 192.168.0.20 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 2 / end']
+ pkt_pf = "Ether(dst='00:11:22:33:44:55')/IP(src='192.168.0.20', id=47750)/Raw('X'*666)"
+ pkt_vf = "Ether()/IP(src='192.168.0.20', id=47750)/Raw('X'*666)"
+
+ self.logger.info('Subcase 1: exclusive validation fdir rule')
+ self.launch_testpmd(param_fdir=True)
+ try:
+ if self.vf_flag:
+ self.rssprocess.create_rule(rule_list_vf)
+ else:
+ self.rssprocess.create_rule(rule_list_pf)
+ except Exception as e:
+ self.logger.warning('Subcase 1 failed: %s' % e)
+ result = False
+ pkt = pkt_vf if self.vf_flag else pkt_pf
+ out = self.send_pkts_getouput(pkt)
+ hashes, queues = self.rssprocess.get_hash_and_queues(out)
+ for queue in queues:
+ if '0x2' != queue:
+ result = False
+ self.logger.error('Error: queue index {} != 2'.format(queue))
+ continue
+ result_list.append(result)
+ self.dut.send_expect("quit", "# ")
+ self.logger.info("*********subcase test result %s" % result_list)
+
+ self.logger.info('Subcase 2: exclusive validation fdir rule')
+ result = True
+ self.launch_testpmd(param_fdir=True)
+ try:
+ if self.vf_flag:
+ self.rssprocess.create_rule(rule_list_vf[::-1])
+ else:
+ self.rssprocess.create_rule(rule_list_pf[::-1])
+ except Exception as e:
+ self.logger.warning('Subcase 2 failed: %s' % e)
+ result = False
+ pkt = pkt_vf if self.vf_flag else pkt_pf
+ out = self.send_pkts_getouput(pkt)
+ hashes, queues = self.rssprocess.get_hash_and_queues(out)
+ for queue in queues:
+ if '0x2' != queue:
+ result = False
+ self.logger.error('Error: queue index {} != 2'.format(queue))
+ continue
+ result_list.append(result)
+ self.dut.send_expect("quit", "# ")
+ self.logger.info("*********subcase test result %s" % result_list)
+
+ self.logger.info('Subcase 3: exclusive validation rss rule')
+ result = True
+ self.launch_testpmd()
+ rule_list = [
+ 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4 end key_len 0 queues end / end',
+ 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-frag end key_len 0 queues end / end']
+ pkt = ["Ether()/IP(id=47750)/Raw('X'*666)",
+ "Ether()/IP(id=47751)/Raw('X'*666)"]
+ try:
+ self.rssprocess.create_rule(rule_list)
+ except Exception as e:
+ self.logger.warning('Subcase 3 failed: %s' % e)
+ result = False
+ out1 = self.send_pkts_getouput(pkt[0])
+ hashes1, queues1 = self.rssprocess.get_hash_and_queues(out1)
+ out2 = self.send_pkts_getouput(pkt[1])
+ hashes2, queues2 = self.rssprocess.get_hash_and_queues(out2)
+ if hashes1[0] != hashes1[1] and hashes2[0] != hashes2[1]:
+ result = False
+ self.logger.error("hash value is incorrect")
+ if hashes1[0] == hashes2[0]:
+ result = False
+ self.logger.error("hash value is incorrect")
+ result_list.append(result)
+ self.dut.send_expect("quit", "# ")
+ self.logger.info("*********subcase test result %s" % result_list)
+
+ self.logger.info('Subcase 4: exclusive validation rss rule')
+ result = True
+ self.launch_testpmd()
+ rule_list = [
+ 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-frag end key_len 0 queues end / end',
+ 'flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4 end key_len 0 queues end / end'
+ ]
+ pkt = ["Ether()/IP(id=47750)/Raw('X'*666)",
+ "Ether()/IP(id=47751)/Raw('X'*666)"]
+ try:
+ self.rssprocess.create_rule(rule_list)
+ except Exception as e:
+ self.logger.warning('Subcase 3 failed: %s' % e)
+ out1 = self.send_pkts_getouput(pkt[0])
+ hashes1, queues1 = self.rssprocess.get_hash_and_queues(out1)
+ out2 = self.send_pkts_getouput(pkt[1])
+ hashes2, queues2 = self.rssprocess.get_hash_and_queues(out2)
+ if hashes1[0] != hashes1[1] and hashes2[0] != hashes2[1]:
+ result = False
+ self.logger.error("hash value is incorrect")
+ if hashes1[0] != hashes2[0]:
+ result = False
+ self.logger.error("hash value is incorrect")
+ result_list.append(result)
+ self.dut.send_expect("quit", "# ")
+ self.logger.info("*********subcase test result %s" % result_list)
+ self.verify(all(result_list) is True, 'sub-case failed {}'.format(result_list))
+
+ def test_pf_exclusive_validation(self):
+ self.exclusive_validation()
+
+ def test_vf_exclusive_validation(self):
+ self.setup_1pf_vfs_env()
+ self.exclusive_validation()
+
+ def test_negative_case(self):
+ negative_rules = [
+ 'flow create 0 ingress pattern eth / ipv6 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 300 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 0x10000 fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset last 0x1 fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset last 0x1fff fragment_offset mask 0xf / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset last 0x1fff fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 fragment_offset spec 0x2000 fragment_offset last 0x1fff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 0x10000 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id is 47750 / end actions queue index 300 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id spec 0xfff packet_id last 0x0 packet_id mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id last 0xffff packet_id mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 packet_id spec 0 packet_id last 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 / ipv6_frag_ext packet_id is 47750 frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 47750 frag_data spec 0xfff8 frag_data last 0x0001 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 47750 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 47750 frag_data spec 0x0001 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 47750 frag_data spec 0x0001 frag_data last 0xfff8 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 47750 frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 300 / end',
+ 'flow create 0 ingress pattern eth / ipv4 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0xffff packet_id last 0x0 packet_id mask 0xffff frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff frag_data spec 0xfff8 frag_data last 0x0001 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / packet_id last 0xffff packet_id mask 0xffff frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id mask 0xffff frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff frag_data spec 0x0001 frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff frag_data last 0xfff8 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff frag_data spec 0x0001 frag_data last 0xfff8 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id spec 0 packet_id last 0xffff packet_id mask 0xffff frag_data spec 0x0001 frag_data mask 0xffff / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv4 / ipv6_frag_ext packet_id is 47750 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext packet_id is 0x10000 / end actions queue index 1 / end',
+ 'flow create 0 ingress pattern eth / ipv6 / end actions rss types ipv4-frag end key_len 0 queues end / end',
+ 'flow create 0 ingress pattern eth / ipv4 / ipv6_frag_ext / end actions rss types ipv6-frag end key_len 0 queues end / end',
+ 'flow create 0 ingress pattern eth / ipv6 / ipv6_frag_ext / end actions rss types ipv4-frag end key_len 0 queues end / end',
+ ]
+ self.launch_testpmd()
+ self.rssprocess.create_rule(negative_rules, check_stats=False)
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V1] tests: add test suite for ipfragment
2021-06-09 16:47 [dts] [PATCH V1] tests: add test suite for ipfragment Zhimin Huang
@ 2021-06-09 8:19 ` Huang, ZhiminX
0 siblings, 0 replies; 2+ messages in thread
From: Huang, ZhiminX @ 2021-06-09 8:19 UTC (permalink / raw)
To: dts; +Cc: Fu, Qi
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
> -----Original Message-----
> From: Huang, ZhiminX <zhiminx.huang@intel.com>
> Sent: Thursday, June 10, 2021 12:47 AM
> To: dts@dpdk.org
> Cc: Fu, Qi <qi.fu@intel.com>; Huang, ZhiminX <zhiminx.huang@intel.com>
> Subject: [dts] [PATCH V1] tests: add test suite for ipfragment
>
Tested-by: Zhimin Huang <zhiminx.huang@intel.com >
[-- Attachment #2: TestIpFragment.log --]
[-- Type: application/octet-stream, Size: 4668476 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-09 8:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 16:47 [dts] [PATCH V1] tests: add test suite for ipfragment Zhimin Huang
2021-06-09 8:19 ` Huang, ZhiminX
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).