[dts] [PATCH v4] tests: add TestSuite_generic_flow_api.py

Peng Yuan yuan.peng at intel.com
Fri Dec 29 09:02:52 CET 2017


Signed-off-by: Peng Yuan <yuan.peng at intel.com>

diff --git a/tests/TestSuite_generic_flow_api.py b/tests/TestSuite_generic_flow_api.py
new file mode 100644
index 0000000..a05f7a4
--- /dev/null
+++ b/tests/TestSuite_generic_flow_api.py
@@ -0,0 +1,1749 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#   * Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#   * Neither the name of Intel Corporation nor the names of its
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""
+DPDK Test suite.
+
+Test the support of VLAN Offload Features by Poll Mode Drivers.
+
+"""
+
+import utils
+import time
+import re
+
+from test_case import TestCase
+from settings import HEADER_SIZE
+from pmd_output import PmdOutput
+from settings import DRIVERS
+from crb import Crb
+
+from virt_dut import VirtDut
+from project_dpdk import DPDKdut
+from dut import Dut
+from packet import Packet
+
+
+class TestGeneric_flow_api(TestCase):
+
+    def set_up_all(self):
+        """
+        Run at the start of each test suite.
+        Generic filter Prerequistites
+        """
+
+        # Based on h/w type, choose how many ports to use
+        self.dut_ports = self.dut.get_ports(self.nic)
+        # Verify that enough ports are available
+        self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
+        self.cores = "1S/8C/1T"
+        self.pf_cores = "1S/16C/1T"
+        self.pmdout = PmdOutput(self.dut)
+
+        localPort = self.tester.get_local_port(self.dut_ports[0])
+        self.tester_itf = self.tester.get_interface(localPort)
+        self.pf_interface = self.dut.ports_info[self.dut_ports[0]]['intf']
+        self.pf_mac = self.dut.get_mac_address(0)
+        self.pf_pci = self.dut.ports_info[self.dut_ports[0]]['pci']
+
+        self.session_secondary = self.dut.new_session()
+        self.session_third = self.dut.new_session()
+        self.outer_mac = "00:11:22:33:44:55"
+        self.inner_mac = "00:11:22:33:44:66"
+        self.wrong_mac = "00:11:22:33:44:77"
+        self.vf_flag = 0
+
+    def set_up(self):
+        """
+        Run before each test case.
+        """
+        self.dut.kill_all()
+
+    def setup_env(self):
+        """
+        This is to set up 1pf and 2vfs environment.
+        The pf is bound to dpdk driver.
+        """
+        self.vf_flag = 1
+        # create two vfs
+        self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 2, self.drivername)
+        self.sriov_vfs_port = self.dut.ports_info[self.dut_ports[0]]['vfs_port']
+        try:
+            for port in self.sriov_vfs_port:
+                port.bind_driver(driver="vfio-pci")
+        except Exception as e:
+            self.destroy_env()
+            raise Exception(e)
+
+    def destroy_env(self):
+        """
+        This is to stop testpmd and destroy 1pf and 2vfs environment.
+        """
+        if self.vf_flag == 1:
+            self.session_third.send_expect("quit", "# ")
+            time.sleep(2)
+            self.session_secondary.send_expect("quit", "# ")
+            time.sleep(2)
+            self.dut.send_expect("quit", "# ")
+            time.sleep(2)
+            self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0])
+        else:
+            self.dut.send_expect("quit", "# ")
+            time.sleep(2)
+        self.vf_flag = 0
+
+    def verify_result(self, pf_vf, expect_rxpkts, expect_queue):
+        """
+        verify the packet to the expected queue or be dropped
+        """
+        self.tester.scapy_execute()
+        time.sleep(2)
+
+        if self.vf_flag == 1:
+            outstring_vf1 = self.session_secondary.send_expect("stop", "testpmd> ")
+            outstring_vf2 = self.session_third.send_expect("stop", "testpmd> ")
+        outstring_pf = self.dut.send_expect("stop", "testpmd> ", 120)
+
+        if expect_rxpkts == "0":
+            if pf_vf == "pf":
+                self.verify("Queue" not in outstring_pf, "the packet is not dropped.")
+            elif pf_vf == "vf1":
+                self.verify("Queue" not in outstring_vf1, "the packet is not dropped.")
+            else:
+                self.verify("Queue" not in outstring_vf2, "the packet is not dropped.")
+        else:
+            result_scanner = r"Forward Stats for RX Port= %s/Queue=\s?([0-9]+)" % self.dut_ports[0]
+            scanner = re.compile(result_scanner, re.DOTALL)
+            if pf_vf == "pf":
+                m = scanner.search(outstring_pf)
+            elif pf_vf == "vf1":
+                m = scanner.search(outstring_vf1)
+            else:
+                m = scanner.search(outstring_vf2)
+            queue_id = m.group(1)
+            self.verify(expect_queue == queue_id, "the actual queue doesn't equal to the expected queue.")
+
+        self.dut.send_expect("start", "testpmd> ")
+
+        if self.vf_flag == 1:
+            self.session_secondary.send_expect("start", "testpmd> ")
+            self.session_third.send_expect("start", "testpmd> ")
+
+    def compare_memory_rules(self, outstring, expectedRules):
+        """
+        dump all flow rules that have been created in memory and compare that total rules number with the given expected number
+        to see if they are equal, as to get your conclusion after you have deleted any flow rule entry.
+        """
+        result_scanner = r'\d*.*?\d*.*?\d*.*?=>*'
+        scanner = re.compile(result_scanner, re.DOTALL)
+        m = scanner.findall(outstring)
+        print "All flow entries are: "
+        for i in range(len(m)):
+            print m[i]
+        print 'Expected rules are: %d - actual are: %d' % (expectedRules, len(m))
+        self.verify(expectedRules == len(m), 'Total rules number mismatched')
+
+    def test_SYN_filter(self):
+
+        self.verify(self.nic in ["niantic", "kawela_4", "kawela", "bartonhills", "twinville", "sagepond", "sageville",
+                                 "powerville"], "%s nic not support SYN filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss --rxq=8 --txq=8")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # create the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / tcp flags spec 0x02 flags mask 0x02 / end actions queue index 3 / end", "created")
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(dport=80,flags="S")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(dport=80,flags="PA")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        # the ipv6 rule is conflicted with ipv4 rule.
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ", 120)
+
+        # create the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv6 / tcp flags spec 0x02 flags mask 0x02 / end actions queue index 4 / end", "created")
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/TCP(dport=80,flags="S")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/TCP(dport=80,flags="PA")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        # check if there are 1 flow rule has been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_n_tuple_filter(self):
+
+        self.verify(self.nic in ["niantic", "kawela_4", "kawela",
+                                 "twinville"], "%s nic not support n-tuple filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss --rxq=8 --txq=8")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # create the flow rules
+        # ipv4-other
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / end actions queue index 1 / end", "created")
+        # ipv4-udp
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.3 proto is 17 / udp src is 22 dst is 23 / end actions queue index 2 / end", "created")
+        # ipv4-tcp
+        self.dut.send_expect(
+            "flow create 0 ingress pattern ipv4 src is 192.168.0.1 dst is 192.168.0.3 proto is 6 / tcp src is 32 dst is 33 / end actions queue index 3 / end", "created")
+        # ipv4-sctp
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.3 proto is 132 / sctp src is 44 dst is 45 / end actions queue index 4 / end", "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/SCTP(sport=44,dport=45)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/SCTP(sport=44,dport=46)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=44,dport=45)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        # check if there are 4 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 4)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 3)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_2_tuple_filter(self):
+
+        self.verify(self.nic in ["bartonhills", "powerville"], "%s nic not support 2-tuple filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss --rxq=8 --txq=8")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # i350 and 82580 only support 2-tuple, and don't support SCTP
+        # ipv4-udp
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 proto is 17 / udp dst is 23 / end actions queue index 1 / end", "created")
+        # ipv4-tcp
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 proto is 6 / tcp dst is 33 / end actions queue index 2 / end", "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=22,dport=24)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=34)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 1", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_ethertype_filter(self):
+
+        self.verify(self.nic in ["niantic", "kawela_4", "kawela", "bartonhills", "twinville", "sagepond", "sageville",
+                                 "powerville", "fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support ethertype filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--disable-rss --rxq=8 --txq=8", "-w %s --file-prefix=test1" % self.pf_pci)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # i40e,ixgbe and igb support different packet types.
+        if (self.nic in ["fortville_eagle", "fortville_spirit",
+                         "fortville_spirit_single", "fortpark_TLV"]):
+            # create the flow rules
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x0806 / end actions queue index 1 / end", "Flow rule validated")
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x08bb / end actions queue index 8 / end", "Invalid queue ID for FDIR")
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x88cc / end actions queue index 5 / end", "Check the mode in fdir_conf")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x08bb / end actions queue index 8 / end", "Invalid queue ID for FDIR")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x0806 / end actions queue index 2 / end", "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x88bb / end actions queue index 3 / end", "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth dst is %s type is 0x88e5 / end actions queue index 4 / end" % self.pf_mac, "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x8864 / end actions drop / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.1")], iface="%s")' % self.tester_itf)
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s",type=0x88BB)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s",type=0x88E5)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s",type=0x8864)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+            # check if there are 4 flow rules have been created
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 4)
+            # check if one rule destoried with success
+            self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 3)
+            # check if all flow rules have been removed with success
+            self.dut.send_expect("flow flush 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 0)
+
+        else:
+            # create the flow rules
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x0806 / end actions queue index 1 / end", "Flow rule validated")
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x88cc / end actions queue index 8 / end", "Caught error")
+            self.dut.send_expect(
+                "flow validate 0 ingress pattern eth type is 0x86dd / end actions queue index 5 / end", "Caught error")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x88cc / end actions queue index 8 / end", "Caught error")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x0806 / end actions queue index 2 / end", "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x88cc / end actions queue index 3 / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.1")], iface="%s")' % self.tester_itf)
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s",type=0x88CC)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s",type=0x88E5)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            # check if there are 2 flow rules have been created
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 2)
+            # check if one rule destoried with success
+            self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 1)
+            # check if all flow rules have been removed with success
+            self.dut.send_expect("flow flush 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 0)
+
+    def test_L2_tunnel_filter(self):
+
+        self.verify(self.nic in ["sagepond", "sageville"], "%s nic not support fdir L2 payload filter" % self.nic)
+
+        self.vf_flag = 1
+        self.setup_env()
+        # start testpmd on pf
+        self.pmdout.start_testpmd("1S/4C/1T", "--rxq=4 --txq=4", "-w %s --file-prefix=pf -m 1024" % self.pf_pci)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+        # start testpmd on vf0
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0 -n 4 -m 1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd> ")
+        self.session_secondary.send_expect("set verbose 1", "testpmd> ")
+        self.session_secondary.send_expect("start", "testpmd> ")
+        time.sleep(2)
+        # start testpmd on vf1
+        self.session_third.send_expect("./%s/app/testpmd -c 0x1e00 -n 4 -m 1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_third.send_expect("set fwd rxonly", "testpmd> ")
+        self.session_third.send_expect("set verbose 1", "testpmd> ")
+        self.session_third.send_expect("start", "testpmd> ")
+        time.sleep(2)
+
+        # Enabling ability of parsing E-tag packet
+        self.dut.send_expect("port config 0 l2-tunnel E-tag enable", "testpmd> ")
+        # Enable E-tag packet forwarding, set on pf
+        self.dut.send_expect("E-tag set forwarding on port 0", "testpmd> ")
+
+        # create the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern e_tag grp_ecid_b is 0x1309 / end actions vf id 0 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern e_tag grp_ecid_b is 0x1308 / end actions vf id 1 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern e_tag grp_ecid_b is 0x1307 / end actions pf / end", "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1BR(GRP=0x1, ECIDbase=0x309)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1BR(GRP=0x1, ECIDbase=0x308)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1BR(GRP=0x1, ECIDbase=0x307)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1BR(GRP=0x2, ECIDbase=0x309)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+        # check if there are 3 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 3)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_L2_payload(self):
+
+        self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support fdir L2 payload filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --rxq=16 --txq=16", "-w %s --file-prefix=test1" % self.pf_pci)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # create the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 1 / end actions queue index 1 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth type is 0x0807 / end actions queue index 2 / end", "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s", type=0x0807)/Dot1Q(vlan=1)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s", type=0x0807)/IP(src="192.168.0.5", dst="192.168.0.6")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_vlan(self):
+
+        self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support fdir L2 payload filter" % self.nic)
+        self.vf_flag = 1
+        self.setup_env()
+        # start testpmd on pf
+        self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+        # start testpmd on vf0
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set verbose 1", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+        # start testpmd on vf1
+        self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_third.send_expect("set fwd rxonly", "testpmd>")
+        self.session_third.send_expect("set verbose 1", "testpmd>")
+        self.session_third.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        # create the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 1 / ipv4 / end actions queue index 1 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 2 / ipv4 / udp / end actions queue index 2 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 3 / ipv4 / tcp / end actions queue index 3 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 4 / ipv4 / sctp / end actions queue index 4 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 5 / ipv4 / vf id is 0 / end actions queue index 1 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 6 / ipv4 / sctp / vf id is 1 / end actions queue index 2 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 7 / ipv4 / sctp / end actions drop / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 8 / ipv4 / udp / vf id is 1 / end actions drop / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 1 / ipv6 / end actions queue index 5 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 2 / ipv6 / udp / end actions queue index 6 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 3 / ipv6 / tcp / end actions queue index 7 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 4 / ipv6 / sctp / end actions queue index 8 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 5 / ipv6 / vf id is 0 / end actions queue index 1 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 4095 / ipv6 / tcp / vf id is 1 / end actions queue index 3 / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 7 / ipv6 / sctp / end actions drop / end", "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / vlan tci is 8 / ipv6 / tcp / vf id is 1 / end actions drop / end", "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.1", dst="192.168.0.2", proto=3)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IP(src="192.168.0.1", dst="192.168.0.2", ttl=3)/UDP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IP()/UDP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IP(src="192.168.0.1", dst="192.168.0.2", tos=3)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IP(src="192.168.0.1", dst="192.168.0.2", tos=3)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IP(src="192.168.0.1", dst="192.168.0.2", tos=3)/UDP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IP(src="192.168.0.1", dst="192.168.0.2", tos=3, ttl=3)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IP()/SCTP()/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=5)/IP(src="192.168.0.1", dst="192.168.0.3")/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=6)/IP(src="192.168.0.1", dst="192.168.0.2", tos=4, ttl=4)/SCTP(sport=46,dport=47,tag=1)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IP(src="192.168.0.5", dst="192.168.0.6", tos=3, ttl=3)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IP()/SCTP()/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IP()/UDP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=8)/IP(src="192.168.0.5", dst="192.168.0.6", tos=3, ttl=3)/UDP(sport=44,dport=45)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=8)/IP()/UDP()/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IPv6(src="2001::1", dst="2001::2", tc=1, nh=5, hlim=10)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IPv6()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IPv6(src="2001::1", dst="2001::2", tc=2, hlim=20)/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IPv6()/UDP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IPv6(src="2001::1", dst="2001::2", tc=2, hlim=20)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="7")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IPv6()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="7")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IPv6(src="2001::1", dst="2001::2", tc=4, nh=132, hlim=40)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="8")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IPv6(nh=132)/SCTP()/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="8")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=5)/IPv6()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4095)/IPv6()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IPv6(src="2001::1", dst="2001::2", tc=4, nh=132, hlim=40)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IPv6(nh=132)/SCTP()/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=8)/IPv6(src="2001::1", dst="2001::2", tc=2, hlim=20)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=8)/IPv6()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        # check if there are 16 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 16)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 15)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_ipv4(self):
+
+        self.verify(self.nic in ["niantic", "twinville", "sagepond", "sageville",
+                                 "fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support fdir ipv4 filter" % self.nic)
+        # i40e
+        if (self.nic in ["fortville_eagle", "fortville_spirit",
+                         "fortville_spirit_single", "fortpark_TLV"]):
+            self.vf_flag = 1
+            self.setup_env()
+            # start testpmd on pf
+            self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+            # start testpmd on vf0
+            self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+            self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+            self.session_secondary.send_expect("set verbose 1", "testpmd>")
+            self.session_secondary.send_expect("start", "testpmd>")
+            time.sleep(2)
+            # start testpmd on vf1
+            self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+            self.session_third.send_expect("set fwd rxonly", "testpmd>")
+            self.session_third.send_expect("set verbose 1", "testpmd>")
+            self.session_third.send_expect("start", "testpmd>")
+            time.sleep(2)
+
+            # create the flow rules
+            # ipv4-other
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 proto is 3 / end actions queue index 1 / end", "created")
+            # ipv4-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 ttl is 3 / udp src is 22 dst is 23 / end actions queue index 2 / end", "created")
+            # ipv4-tcp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 3 / tcp src is 32 dst is 33 / end actions queue index 3 / end", "created")
+            # ipv4-sctp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 1 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 3 ttl is 3 / sctp src is 44 dst is 45 tag is 1 / end actions queue index 4 / end", "created")
+            # ipv4-sctp drop
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 1 / ipv4 src is 192.168.0.5 dst is 192.168.0.6 tos is 3 ttl is 3 / sctp src is 44 dst is 45 tag is 1 / end actions drop / end", "created")
+            # ipv4-other-vf0-exceed-max-queue
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.3 proto is 3 / vf id is 0 / end actions queue index 4 / end", "Invalid queue ID for FDIR")
+            # ipv4-other-vf0
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.3 proto is 3 / vf id is 0 / end actions queue index 1 / end", "created")
+            # ipv4-sctp-vf1
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 2 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 4 ttl is 4 / sctp src is 46 dst is 47 tag is 1 / vf id is 1 / end actions queue index 2 / end", "created")
+            # ipv4-sctp passthru-flag
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 3 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 4 ttl is 4 / sctp src is 44 dst is 45 tag is 1 / end actions passthru / flag / end", "created")
+            # ipv4-udp queue-flag
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 ttl is 4 / udp src is 22 dst is 23 / end actions queue index 5 / flag / end", "created")
+            # ipv4-tcp queue-mark
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 tos is 4 / tcp src is 32 dst is 33 / end actions queue index 6 / mark id 3 / end", "created")
+            # ipv4-other passthru-mark
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 proto is 3 / end actions passthru / mark id 4 / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", proto=3)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", ttl=3)/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", tos=3)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.1", dst="192.168.0.2", tos=3, ttl=3)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3", proto=3)/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IP(src="192.168.0.1", dst="192.168.0.2", tos=4, ttl=4)/SCTP(sport=46,dport=47,tag=1)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("vf2", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.5", dst="192.168.0.6", tos=3, ttl=3)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IP(src="192.168.0.1", dst="192.168.0.2", tos=4, ttl=4)/SCTP(sport=44,dport=45,tag=1)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", ttl=4)/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", tos=4)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4", proto=3)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            # check if there are 11 flow rules have been created
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 11)
+            # check the result if set an illegal value
+            self.dut.send_expect("flow destroy 0 rule 11", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 11)
+            # check if one rule destoried with success
+            self.dut.send_expect("flow destroy 0 rule 10", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 10)
+            # check if all flow rules have been removed with success
+            self.dut.send_expect("flow flush 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 0)
+            self.destroy_env()
+
+        # ixgbe
+        else:
+            self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16")
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # create the flow rules
+            # ipv4-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / udp src is 22 dst is 23 / end actions queue index 2 / end", "created")
+            # ipv4-tcp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern ipv4 src is 192.168.0.3 dst is 192.168.0.4 / tcp src is 32 dst is 33 / end actions queue index 3 / end", "created")
+
+            if (self.nic in ["sagepond", "sageville"]):
+                # ipv4-sctp
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / sctp src is 44 dst is 45 / end actions queue index 4 / end", "created")
+                # ipv4-sctp drop
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / sctp src is 46 dst is 47 / end actions drop / end", "created")
+            else:
+                # ipv4-sctp
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / sctp / end actions queue index 4 / end", "created")
+                # ipv4-sctp drop
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.5 dst is 192.168.0.6 / sctp / end actions drop / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            if (self.nic in ["sagepond", "sageville"]):
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/SCTP(sport=44,dport=45)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/SCTP(sport=42,dport=43)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/SCTP(sport=46,dport=47)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+            else:
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/SCTP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.5")/SCTP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.5", dst="192.168.0.6")/SCTP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+    def test_fdir_for_ipv6(self):
+
+        self.verify(self.nic in ["niantic", "twinville", "sagepond", "sageville",
+                                 "fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support fdir ipv6 filter" % self.nic)
+        # i40e
+        if (self.nic in ["fortville_eagle", "fortville_spirit",
+                         "fortville_spirit_single", "fortpark_TLV"]):
+            self.vf_flag = 1
+            self.setup_env()
+            self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+            self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+            self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+            self.session_secondary.send_expect("set verbose 1", "testpmd>")
+            self.session_secondary.send_expect("start", "testpmd>")
+            time.sleep(2)
+            self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss --pkt-filter-mode=perfect" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+            self.session_third.send_expect("set fwd rxonly", "testpmd>")
+            self.session_third.send_expect("set verbose 1", "testpmd>")
+            self.session_third.send_expect("start", "testpmd>")
+            time.sleep(2)
+
+            # create the flow rules
+            # ipv6-other
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 1 / ipv6 src is 2001::1 dst is 2001::2 tc is 1 proto is 5 hop is 10 / end actions queue index 1 / end", "created")
+            # ipv6-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 2 / ipv6 src is 2001::1 dst is 2001::2 tc is 2 hop is 20 / udp src is 22 dst is 23 / end actions queue index 2 / end", "created")
+            # ipv6-tcp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 3 / ipv6 src is 2001::1 dst is 2001::2 tc is 3 hop is 30 / tcp src is 32 dst is 33 / end actions queue index 3 / end", "created")
+            # ipv6-sctp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 4 / ipv6 src is 2001::1 dst is 2001::2 tc is 4 hop is 40 / sctp src is 44 dst is 45 tag is 1 / end actions queue index 4 / end", "created")
+            # ipv6-other-vf0
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 5 / ipv6 src is 2001::3 dst is 2001::4 tc is 5 proto is 5 hop is 50 / vf id is 0 / end actions queue index 1 / end", "created")
+            # ipv6-tcp-vf1
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 4095 / ipv6 src is 2001::3 dst is 2001::4 tc is 6 hop is 60 / tcp src is 32 dst is 33 / vf id is 1 / end actions queue index 3 / end", "created")
+            # ipv6-sctp-drop
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 7 / ipv6 src is 2001::1 dst is 2001::2 tc is 7 hop is 70 / sctp src is 44 dst is 45 tag is 1 / end actions drop / end", "created")
+            # ipv6-tcp-vf1-drop
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 8 / ipv6 src is 2001::3 dst is 2001::4 tc is 8 hop is 80 / tcp src is 32 dst is 33 / vf id is 1 / end actions drop / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IPv6(src="2001::1", dst="2001::2", tc=1, nh=5, hlim=10)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IPv6(src="2001::1", dst="2001::2", tc=1, nh=5, hlim=10)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=2)/IPv6(src="2001::1", dst="2001::2", tc=2, hlim=20)/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=3)/IPv6(src="2001::1", dst="2001::2", tc=3, hlim=30)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=4)/IPv6(src="2001::1", dst="2001::2", tc=4, nh=132, hlim=40)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=5)/IPv6(src="2001::3", dst="2001::4", tc=5, nh=5, hlim=50)/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=4095)/IPv6(src="2001::3", dst="2001::4", tc=6, hlim=60)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("vf2", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=7)/IPv6(src="2001::1", dst="2001::2", tc=7, nh=132, hlim=70)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="X" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="0", expect_queue="NULL")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=8)/IPv6(src="2001::3", dst="2001::4", tc=8, hlim=80)/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+            # check if there are 8 flow rules have been created
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 8)
+            # check if one rule destoried with success
+            self.dut.send_expect("flow destroy 0 rule 7", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 7)
+            # check if all flow rules have been removed with success
+            self.dut.send_expect("flow flush 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 0)
+            self.destroy_env()
+
+        # ixgbe signature
+        else:
+            self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=signature --disable-rss --rxq=16 --txq=16")
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # create the flow rules
+            # ipv6-other and ipv4-other
+            if (self.nic in ["niantic", "twinville"]):
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 1 / ipv6 src is 2001::1 dst is 2001::2 / end actions queue index 1 / end", "created")
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 1 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / end actions queue index 6 / end", "created")
+
+            # ipv6-udp and ipv4-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern fuzzy thresh spec 2 thresh last 5 thresh mask 0xffffffff / ipv6 src is 2001::1 dst is 2001::2 / udp src is 22 dst is 23 / end actions queue index 2 / end", "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern fuzzy thresh is 2 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / udp src is 22 dst is 23 / end actions queue index 7 / end", "created")
+
+            # ipv6-tcp and ipv4-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern fuzzy thresh is 3 / ipv6 src is 2001::1 dst is 2001::2 / tcp src is 32 dst is 33 / end actions queue index 3 / end", "created")
+            self.dut.send_expect(
+                "flow create 0 ingress pattern fuzzy thresh is 3 / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / tcp src is 32 dst is 33 / end actions queue index 8 / end", "created")
+
+            if (self.nic in ["sagepond", "sageville"]):
+                # ipv6-sctp and ipv4-sctp
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 4 / ipv6 src is 2001::1 dst is 2001::2 / sctp src is 44 dst is 45 / end actions queue index 4 / end", "created")
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 4 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp src is 44 dst is 45 / end actions queue index 9 / end", "created")
+
+            else:
+                # ipv6-sctp and ipv4-sctp
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 4 / ipv6 src is 2001::1 dst is 2001::2 / sctp / end actions queue index 4 / end", "created")
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 5 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp / end actions queue index 9 / end", "created")
+
+            # send the packets and verify the results
+            if (self.nic in ["niantic", "twinville"]):
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=22,dport=23)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="7")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=32,dport=33)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="8")
+
+            if (self.nic in ["sagepond", "sageville"]):
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2",nh=132)/SCTP(sport=44,dport=45,tag=1)/SCTPChunkData(data="cdxxxx")], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2",nh=132)/SCTP(sport=46,dport=47,tag=1)/SCTPChunkData(data="cdxxxx")/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=44,dport=45)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="9")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=42,dport=43)/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            else:
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2",nh=132)/SCTP()/SCTPChunkData(data="cdxxxx")], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::3", dst="2001::4",nh=132)/SCTP()/SCTPChunkData(data="cdxxxx")], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="9")
+
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.3")/SCTP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+    def test_fdir_for_flexbytes(self):
+
+        self.verify(self.nic in ["niantic", "twinville", "sagepond", "sageville",
+                                 "fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support fdir flexbytes filter" % self.nic)
+        # i40e
+        if (self.nic in ["fortville_eagle", "fortville_spirit",
+                         "fortville_spirit_single", "fortpark_TLV"]):
+
+            self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # creat the flow rules
+            # l2-payload exceeds the  max length of raw match is 16bytes
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x0807 / raw relative is 1 pattern is abcdefghijklmnopq / end actions queue index 1 / end", "Exceeds maxmial payload limit")
+            # l2-payload equal the max length of raw match is 16bytes
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth type is 0x0807 / raw relative is 1 pattern is abcdefghijklmnop / end actions queue index 1 / end", "created")
+            # ipv4-other the most 3 fields can be matched, and the max sum bytes of the three fields is 16 bytes.
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 4095 / ipv4 proto is 255 ttl is 40 / raw relative is 1 offset is 2 pattern is ab / raw relative is 1 offset is 10 pattern is abcdefghij / raw relative is 1 offset is 0 pattern is abcd / end actions queue index 2 / end", "created")
+            # ipv4-udp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 dst is 2.2.2.5 / udp src is 22 dst is 23 / raw relative is 1 offset is 2 pattern is fhds / end actions queue index 3 / end", "created")
+            # ipv4-tcp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 dst is 2.2.2.5 tos is 4 ttl is 3 / tcp src is 32 dst is 33 / raw relative is 1 offset is 2 pattern is hijk / end actions queue index 4 / end", "created")
+            # ipv4-sctp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 2.2.2.4 dst is 2.2.2.5 / sctp src is 42 / raw relative is 1 offset is 2 pattern is abcd / end actions queue index 5 / end", "created")
+
+            # send the packets and verify the results
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s", type=0x0807)/Raw(load="abcdefghijklmnop")], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=4095)/IP(src="192.168.0.1", dst="192.168.0.2", proto=255, ttl=40)/Raw(load="xxabxxxxxxxxxxabcdefghijabcdefg")], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="2.2.2.4", dst="2.2.2.5")/UDP(sport=22,dport=23)/Raw(load="fhfhdsdsfwef")], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="2.2.2.4", dst="2.2.2.5", tos=4, ttl=3)/TCP(sport=32,dport=33)/Raw(load="fhhijk")], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="2.2.2.4", dst="2.2.2.5")/SCTP(sport=42,dport=43,tag=1)/Raw(load="xxabcdefghijklmnopqrst")], iface="%s")' % (self.pf_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="2.2.2.4", dst="2.2.2.5")/SCTP(sport=42,dport=43,tag=1)/Raw(load="xxabxxxabcddxxabcdefghijklmn")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            # check if there are 5 flow rules have been created
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 5)
+            # check if one rule destoried with success
+            self.dut.send_expect("flow destroy 0 rule 4", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 4)
+            # check if all flow rules have been removed with success
+            self.dut.send_expect("flow flush 0", "testpmd> ")
+            out = self.dut.send_expect("flow list 0", "testpmd> ")
+            self.compare_memory_rules(out, 0)
+
+            self.dut.send_expect("quit", "# ")
+            time.sleep(2)
+
+            self.pmdout.start_testpmd("%s" % self.pf_cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # ipv6-tcp
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / vlan tci is 1 / ipv6 src is 2001::1 dst is 2001::2 tc is 3 hop is 30 / tcp src is 32 dst is 33 / raw relative is 1 offset is 0 pattern is hijk / raw relative is 1 offset is 8 pattern is abcdefgh / end actions queue index 6 / end", "created")
+
+            # send the packet and verify the result
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IPv6(src="2001::1", dst="2001::2", tc=3, hlim=30)/TCP(sport=32,dport=33)/Raw(load="hijkabcdefghabcdefghijklmn")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+
+        # ixgbe
+        else:
+            self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16")
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # ipv4-udp-flexbytes
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / udp src is 24 dst is 25 / raw relative is 0 search is 0 offset is 44 limit is 0 pattern is 86 / end actions queue index 1 / end", "created")
+
+            # send the packet and verify the result
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/UDP(sport=24,dport=25)/Raw(load="xx86ddef")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+            self.dut.send_expect("quit", "# ")
+            time.sleep(2)
+
+            # the second flexbytes rule should be created after the testpmd reset, because the flexbytes rule is global bit masks
+            self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect --disable-rss --rxq=16 --txq=16")
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # ipv4-tcp-flexbytes spec-mask
+            self.dut.send_expect(
+                "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.3 dst is 192.168.0.4 / tcp src is 22 dst is 23 / raw relative spec 0 relative mask 1 search spec 0 search mask 1 offset spec 54 offset mask 0xffffffff limit spec 0 limit mask 0xffff pattern is ab pattern is cd / end actions queue index 2 / end", "created")
+
+            # send the packet and verify the result
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/TCP(sport=22,dport=23)/Raw(load="abcdxxx")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.3", dst="192.168.0.4")/TCP(sport=22,dport=23)/Raw(load="cdcdxxx")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+            self.dut.send_expect("quit", "# ")
+            time.sleep(2)
+
+            # signature mode
+            self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=signature --disable-rss --rxq=16 --txq=16")
+            self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+            self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ", 120)
+            time.sleep(2)
+
+            # ipv4-sctp-flexbytes
+            if (self.nic in ["sagepond", "sageville"]):
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 6 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp src is 24 dst is 25 / raw relative is 0 search is 0 offset is 48 limit is 0 pattern is ab / end actions queue index 3 / end", "created")
+            else:
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 6 / eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / sctp / raw relative is 0 search is 0 offset is 48 limit is 0 pattern is ab / end actions queue index 3 / end", "created")
+
+            # send the packet and verify the result
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=24,dport=25)/Raw(load="xxabcdef")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+            self.tester.scapy_append(
+                'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/SCTP(sport=24,dport=25)/Raw(load="xxaccdef")], iface="%s")' % (self.outer_mac, self.tester_itf))
+            self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+            # ipv6-other-flexbytes
+            if (self.nic in ["niantic", "twinville"]):
+                self.dut.send_expect("quit", "# ")
+                time.sleep(2)
+
+                self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=signature --disable-rss --rxq=16 --txq=16")
+                self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+                self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+                self.dut.send_expect("start", "testpmd> ", 120)
+                time.sleep(2)
+
+                self.dut.send_expect(
+                    "flow create 0 ingress pattern fuzzy thresh is 6 / ipv6 src is 2001::1 dst is 2001::2 / raw relative is 0 search is 0 offset is 56 limit is 0 pattern is 86 / end actions queue index 4 / end", "created")
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/Raw(load="xx86abcd")], iface="%s")' % (self.outer_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+                self.tester.scapy_append(
+                    'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/Raw(load="xxx86abcd")], iface="%s")' % (self.outer_mac, self.tester_itf))
+                self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+    def test_flexbytes_filter(self):
+
+        self.verify(self.nic in ["bartonhills", "powerville"], "%s nic not support flexbytes filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss --rxq=8 --txq=8")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # create the flow rules
+        # l2_payload
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 14 pattern is fhds / end actions queue index 1 / end", "created")
+        # ipv4 packet
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 34 pattern is ab / end actions queue index 2 / end", "created")
+        # ipv6 packet
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 58 pattern is efgh / end actions queue index 3 / end", "created")
+        # 3 fields relative is 0
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 38 pattern is ab / raw relative is 0 offset is 34 pattern is cd / raw relative is 0 offset is 42 pattern is efgh / end actions queue index 4 / end", "created")
+        # 4 fields relative is 0 and 1
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 48 pattern is ab / raw relative is 1 offset is 0 pattern is cd / raw relative is 0 offset is 44 pattern is efgh / raw relative is 1 offset is 10 pattern is hijklmnopq / end actions queue index 5 / end", "created")
+        # 3 fields offset confilict
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 64 pattern is ab / raw relative is 1 offset is 4 pattern is cdefgh / raw relative is 0 offset is 68 pattern is klmn / end actions queue index 6 / end", "created")
+
+        # send the packet and verify the result
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Raw(load="fhdsab")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Raw(load="afhdsb")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="abcdef")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/Raw(load="xxxxefgh")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6(src="2001::1", dst="2001::2")/TCP(sport=32,dport=33)/Raw(load="abcdefgh")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw(load="cdxxabxxefghxxxx")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2", tos=4, ttl=3)/UDP(sport=32,dport=33)/Raw(load="xxefghabcdxxxxxxhijklmnopqxxxx")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxabxxklmnefgh")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="6")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxabxxklcdefgh")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.dut.send_expect("flow flush 0", "testpmd> ", 120)
+
+        # 1 field 128bytes
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 128 pattern is ab / end actions queue index 1 / end", "Failed to create flow")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 126 pattern is abcd / end actions queue index 1 / end", "Failed to create flow")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 126 pattern is ab / end actions queue index 1 / end", "created")
+        # 2 field 128bytes
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 68 pattern is ab / raw relative is 1 offset is 58 pattern is cd / end actions queue index 2 / end", "Failed to create flow")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern raw relative is 0 offset is 68 pattern is ab / raw relative is 1 offset is 56 pattern is cd / end actions queue index 2 / end", "created")
+
+        # send the packet and verify the result
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxab")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcb")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxxxxxabxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcd")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP(src="192.168.0.1", dst="192.168.0.2")/TCP(sport=22,dport=23)/Raw(load="xxxxxxxxxxxxxxabxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxce")], iface="%s")' % (self.outer_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_mac_vlan(self):
+
+        self.verify(self.nic in ["twinville", "sagepond", "sageville"], "%s nic not support fdir flexbytes filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect-mac-vlan --disable-rss --rxq=16 --txq=16")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", 120)
+        self.dut.send_expect("vlan set filter off 0", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # creat the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / vlan tpid is 0x8100 tci is 1 / end actions queue index 9 / end" % self.pf_mac, "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / vlan tpid is 0x8100 tci is 4095 / end actions queue index 10 / end" % self.pf_mac, "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="9")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/Dot1Q(vlan=4095)/IP()/UDP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="10")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_vxlan(self):
+
+        self.verify(self.nic in ["twinville", "sagepond", "sageville"], "%s nic not support fdir flexbytes filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect-tunnel --disable-rss --rxq=16 --txq=16")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # creat the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 8 / eth dst is %s / vlan tci is 2 tpid is 0x8100 / end actions queue index 1 / end" % self.inner_mac, "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv6 / udp / vxlan vni is 9 / eth dst is %s / vlan tci is 4095 tpid is 0x8100 / end actions queue index 2 / end" % self.inner_mac, "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=8)/Ether(dst="%s")/Dot1Q(vlan=2)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6()/UDP()/Vxlan(vni=9)/Ether(dst="%s")/Dot1Q(vlan=4095)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_fdir_for_nvgre(self):
+
+        self.verify(self.nic in ["twinville", "sagepond", "sageville"], "%s nic not support fdir flexbytes filter" % self.nic)
+
+        self.pmdout.start_testpmd("%s" % self.cores, "--pkt-filter-mode=perfect-tunnel --disable-rss --rxq=16 --txq=16")
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+
+        # creat the flow rules
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre tni is 0x112244 / eth dst is %s / vlan tci is 20 / end actions queue index 3 / end" % self.inner_mac, "created")
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv6 / nvgre tni is 0x112233 / eth dst is %s / vlan tci is 21 / end actions queue index 4 / end" % self.inner_mac, "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112244)/Ether(dst="%s")/Dot1Q(vlan=20)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IPv6()/NVGRE(TNI=0x112233)/Ether(dst="%s")/Dot1Q(vlan=21)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.pf_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        # check if there are 2 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 2)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 1)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_tunnel_filter_vxlan(self):
+
+        self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support tunnel vxlan filter" % self.nic)
+
+        self.vf_flag = 1
+        self.setup_env()
+        self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+        self.dut.send_expect("rx_vxlan_port add 4789 0", "testpmd> ", 120)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set verbose 1", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_third.send_expect("set fwd rxonly", "testpmd>")
+        self.session_third.send_expect("set verbose 1", "testpmd>")
+        self.session_third.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        # create the flow rules
+        # inner mac + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan / eth dst is %s / end actions pf / queue index 1 / end" % self.inner_mac, "created")
+        # vni + inner mac + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 2 / eth dst is %s / end actions pf / queue index 2 / end" % self.inner_mac, "created")
+        # inner mac + inner vlan +actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan / eth dst is %s / vlan tci is 10 / end actions pf / queue index 3 / end" % self.inner_mac, "created")
+        # vni + inner mac + inner vlan + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 4 / eth dst is %s / vlan tci is 20 / end actions pf / queue index 4 / end" % self.inner_mac, "created")
+        # inner mac + outer mac + vni + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / ipv4 / udp / vxlan vni is 5 /  eth dst is %s / end actions pf / queue index 5 / end" % (self.outer_mac, self.inner_mac), "created")
+        # vni + inner mac + inner vlan + actions vf1
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / udp / vxlan vni is 6 / eth dst is %s / vlan tci is 30 / end actions vf id 0 / queue index 1 / end" % self.inner_mac, "created")
+        # inner mac + outer mac + vni + actions vf2
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / ipv4 / udp / vxlan vni is 7 /  eth dst is %s / end actions vf id 1 / queue index 3 / end" % (self.outer_mac, self.inner_mac), "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan()/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=2)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan()/Ether(dst="%s")/Dot1Q(vlan=10)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan()/Ether(dst="%s")/Dot1Q(vlan=11)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=4)/Ether(dst="%s")/Dot1Q(vlan=20)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=5)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=5)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.wrong_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=6)/Ether(dst="%s")/Dot1Q(vlan=30)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.wrong_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=6)/Ether(dst="%s")/Dot1Q(vlan=30)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.wrong_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=7)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/UDP()/Vxlan(vni=7)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.wrong_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        # check if there are 7 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 7)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 6)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+
+    def test_tunnel_filter_nvgre(self):
+
+        self.verify(self.nic in ["fortville_eagle", "fortville_spirit",
+                                 "fortville_spirit_single", "fortpark_TLV"], "%s nic not support tunnel nvgre filter" % self.nic)
+
+        self.vf_flag = 1
+        self.setup_env()
+        self.pmdout.start_testpmd("%s" % self.pf_cores, "--disable-rss --rxq=16 --txq=16", "-w %s --file-prefix=pf --socket-mem 1024,1024" % self.pf_pci)
+        self.dut.send_expect("set fwd rxonly", "testpmd> ", 120)
+        self.dut.send_expect("set verbose 1", "testpmd> ", 120)
+        self.dut.send_expect("start", "testpmd> ", 120)
+        time.sleep(2)
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0x1e0000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf1 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set verbose 1", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.session_third.send_expect("./%s/app/testpmd -c 0x1e000000 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=vf2 -- -i --rxq=4 --txq=4 --txqflags=0x0 --disable-rss" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_third.send_expect("set fwd rxonly", "testpmd>")
+        self.session_third.send_expect("set verbose 1", "testpmd>")
+        self.session_third.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        # create the flow rules
+        # inner mac + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre / eth dst is %s / end actions pf / queue index 1 / end" % self.inner_mac, "created")
+        # tni + inner mac + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre tni is 2 / eth dst is %s / end actions pf / queue index 2 / end" % self.inner_mac, "created")
+        # inner mac + inner vlan +actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre / eth dst is %s / vlan tci is 10 / end actions pf / queue index 3 / end" % self.inner_mac, "created")
+        # tni + inner mac + inner vlan + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre tni is 0x112244 / eth dst is %s / vlan tci is 20 / end actions pf / queue index 4 / end" % self.inner_mac, "created")
+        # inner mac + outer mac + tni + actions pf
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / ipv4 / nvgre tni is 0x112255 /  eth dst is %s / end actions pf / queue index 5 / end" % (self.outer_mac, self.inner_mac), "created")
+        # tni + inner mac + inner vlan + actions vf1
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth / ipv4 / nvgre tni is 0x112266 / eth dst is %s / vlan tci is 30 / end actions vf id 0 / queue index 1 / end" % self.inner_mac, "created")
+        # inner mac + outer mac + tni + actions vf2
+        self.dut.send_expect(
+            "flow create 0 ingress pattern eth dst is %s / ipv4 / nvgre tni is 0x112277 /  eth dst is %s / end actions vf id 1 / queue index 3 / end" % (self.outer_mac, self.inner_mac), "created")
+
+        # send the packets and verify the results
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE()/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=2)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE()/Ether(dst="%s")/Dot1Q(vlan=10)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE()/Ether(dst="%s")/Dot1Q(vlan=11)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112244)/Ether(dst="%s")/Dot1Q(vlan=20)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="4")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112255)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="5")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112255)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.wrong_mac, self.tester_itf))
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112266)/Ether(dst="%s")/Dot1Q(vlan=30)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.wrong_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="1")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112266)/Ether(dst="%s")/Dot1Q(vlan=30)/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.wrong_mac, self.tester_itf))
+        self.verify_result("vf1", expect_rxpkts="1", expect_queue="0")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112277)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.outer_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="1", expect_queue="3")
+
+        self.tester.scapy_append(
+            'sendp([Ether(dst="%s")/IP()/NVGRE(TNI=0x112277)/Ether(dst="%s")/IP()/TCP()/Raw("x" * 20)], iface="%s")' % (self.wrong_mac, self.inner_mac, self.tester_itf))
+        self.verify_result("vf2", expect_rxpkts="0", expect_queue="NULL")
+
+        # check if there are 7 flow rules have been created
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 7)
+        # check if one rule destoried with success
+        self.dut.send_expect("flow destroy 0 rule 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 6)
+        # check if all flow rules have been removed with success
+        self.dut.send_expect("flow flush 0", "testpmd> ")
+        out = self.dut.send_expect("flow list 0", "testpmd> ")
+        self.compare_memory_rules(out, 0)
+        self.destroy_env()
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        self.destroy_env()
+        self.dut.kill_all()
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        self.dut.kill_all()
+        self.dut.close_session(self.session_secondary)
+        self.dut.close_session(self.session_third)
-- 
2.5.0



More information about the dts mailing list