test suite reviews and discussions
 help / color / mirror / Atom feed
From: "Peng, Yuan" <yuan.peng@intel.com>
To: "Jiang, YuX" <yux.jiang@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Subject: RE: [dts][PATCH V2 3/3] tests/generic_flow_api: add case test_fdir_for_match_report
Date: Wed, 17 Nov 2021 08:09:32 +0000	[thread overview]
Message-ID: <CO1PR11MB50582F760BC0ADAAB2484CC7FE9A9@CO1PR11MB5058.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1636080565-26720-4-git-send-email-yux.jiang@intel.com>

Acked-by Peng, Yuan <yuan.peng@intel.com>

-----Original Message-----
From: Jiang, YuX <yux.jiang@intel.com> 
Sent: Friday, November 5, 2021 10:49 AM
To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
Cc: Jiang, YuX <yux.jiang@intel.com>
Subject: [dts][PATCH V2 3/3] tests/generic_flow_api: add case test_fdir_for_match_report

add case test_fdir_for_match_report

Signed-off-by: Yu Jiang <yux.jiang@intel.com>
---
 conf/test_case_supportlist.json     |  15 +++++
 tests/TestSuite_generic_flow_api.py | 111 +++++++++++++++++++++++++++++++++++-
 2 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/conf/test_case_supportlist.json b/conf/test_case_supportlist.json index e3eefd4..4ad90b2 100644
--- a/conf/test_case_supportlist.json
+++ b/conf/test_case_supportlist.json
@@ -791,6 +791,21 @@
             "Comments": "This case only support on twinville, sagepond and sageville"
         }
     ],
+    "fdir_for_match_report": [
+        {
+            "OS": [
+                "ALL"
+            ],
+            "NIC": [
+                "niantic"
+            ],
+            "Target": [
+                "ALL"
+            ],
+            "Bug ID": "",
+            "Comments": "This case only support on niantic"
+        }
+    ],
     "fdir_for_mac_vlan": [
         {
             "OS": [
diff --git a/tests/TestSuite_generic_flow_api.py b/tests/TestSuite_generic_flow_api.py
index e6b04ab..08ca032 100644
--- a/tests/TestSuite_generic_flow_api.py
+++ b/tests/TestSuite_generic_flow_api.py
@@ -158,9 +158,10 @@ class TestGeneric_flow_api(TestCase):
         """
         return 1024 * queue_num + 512
 
-    def verify_result(self, pf_vf, expect_rxpkts, expect_queue, verify_mac):
+    def verify_result(self, pf_vf, expect_rxpkts, expect_queue, verify_mac, check_fdir=''):
         """
         verify the packet to the expected queue or be dropped
+        : check_fdir=[exist|non-exist]
         """
         # self.tester.scapy_execute()
         # time.sleep(2)
@@ -217,12 +218,39 @@ class TestGeneric_flow_api(TestCase):
                 queue_index = len(m) - 1
             curr_queue = int(m[queue_index][len("port 0/queue"):])
             self.verify(int(expect_queue) == curr_queue, "the actual queue doesn't equal to the expected queue.")
-
+        if check_fdir == 'exist':
+            self.verify("RTE_MBUF_F_RX_FDIR" in out_pf, 'FDIR information should be printed.')
+        elif check_fdir == 'non-exist':
+            self.verify("FDIR" not in out_pf, 'FDIR information should 
+ not be printed.')
         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> ")
+        return out_pf
+
+    def launch_start_testpmd(self, queue='', pkt_filter_mode='', report_hash='', disable_rss=False, fwd='', verbose=''):
+        """
+        Launch and start testpmd
+        """
+        param = ''
+        eal_param = ''
+        if queue:
+            param += '--rxq={} --txq={} '.format(queue, queue)
+        if pkt_filter_mode:
+            param += '--pkt-filter-mode={} '.format(pkt_filter_mode)
+        if disable_rss:
+            param += '--disable-rss '
+        if report_hash:
+            param += '--pkt-filter-report-hash={} '.format(report_hash)
+        self.pmdout.start_testpmd("{}".format(self.cores), param=param, eal_param=eal_param)
+        if fwd:
+            self.pmdout.execute_cmd('set fwd rxonly', )
+        if verbose:
+            self.pmdout.execute_cmd('set verbose 1')
+        self.pmdout.execute_cmd('start')
+        self.pmdout.execute_cmd('show port info all')
+        self.pmdout.wait_link_status_up(self.dut_ports[0])
 
     def compare_memory_rules(self, expectedRules):
         """
@@ -2664,6 +2692,85 @@ class TestGeneric_flow_api(TestCase):
         else:
             self.verify(False, "%s not support this test" % self.nic)
 
+    def test_fdir_for_match_report(self):
+        """
+        Test case: IXGBE fdir for Control levels of FDir match reporting
+        only supported by ixgbe
+        """
+        fdir_scanner = re.compile("FDIR matched hash=(0x\w+) ID=(0x\w+)")
+        pkt0 = 'Ether(dst="{}")/IP(src="192.168.0.1", dst="192.168.0.2")/Raw("x" * 20)'.format(self.pf_mac)
+        pkt1 = 'Ether(dst="{}")/IP(src="192.168.1.1", dst="192.168.1.2")/Raw("x" * 20)'.format(self.pf_mac)
+        rule0 = "flow create 0 ingress pattern eth / ipv4 src is 192.168.0.1 dst is 192.168.0.2 / end actions queue index 1 / mark id 1 / end"
+        rule1 = "flow create 0 ingress pattern eth / ipv4 src is 192.168.1.1 dst is 192.168.1.2 / end actions queue index 2 / mark id 2 / end"
+
+        self.logger.info("Sub-case1: ``--pkt-filter-report-hash=none`` mode")
+        pkt_filter_report_hash = "none"
+        self.launch_start_testpmd(queue=MAX_QUEUE + 1, pkt_filter_mode='perfect', report_hash=pkt_filter_report_hash,
+                                  disable_rss=True, fwd='rxonly', 
+ verbose='1')
+
+        # Send the matched packet with Scapy on the traffic generator and check that no FDir information is printed
+        self.sendpkt(pktstr=pkt0)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0", 
+ verify_mac=self.pf_mac, check_fdir="non-exist")
+
+        # Add flow filter rule, and send the matched packet again.
+        # No FDir information is printed, but it can be seen that the packet went to queue 1
+        self.pmdout.execute_cmd(rule0)
+        self.sendpkt(pktstr=pkt0)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1", verify_mac=self.pf_mac, check_fdir="non-exist")
+        self.pmdout.quit()
+
+        self.logger.info("Sub-case2: ``--pkt-filter-report-hash=match`` mode")
+        pkt_filter_report_hash = "match"
+        self.launch_start_testpmd(queue=MAX_QUEUE + 1, pkt_filter_mode='perfect', report_hash=pkt_filter_report_hash,
+                                  disable_rss=True, fwd='rxonly', 
+ verbose='1')
+
+        # Send the matched packet with Scapy on the traffic generator and check that no FDir information is printed
+        self.sendpkt(pktstr=pkt0)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0", 
+ verify_mac=self.pf_mac, check_fdir="non-exist")
+
+        # Add flow filter rule, and send the matched packet again.
+        # the match is indicated (``RTE_MBUF_F_FDIR``), and its details (hash, id) printed
+        self.pmdout.execute_cmd(rule0)
+        self.sendpkt(pktstr=pkt0)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="1", 
+ verify_mac=self.pf_mac, check_fdir="exist")
+
+        # Add flow filter rule by using different scr,dst, and send the matched pkt1 packet again.
+        # the match is indicated (``RTE_MBUF_F_FDIR``), and its details (hash, id) printed
+        self.pmdout.execute_cmd(rule1)
+        self.sendpkt(pktstr=pkt1)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="2", 
+ verify_mac=self.pf_mac, check_fdir="exist")
+
+        # Remove rule1 and send the matched pkt0 packet again. Check that no FDir information is printed
+        self.pmdout.execute_cmd('flow destroy 0 rule 0')
+        self.sendpkt(pktstr=pkt0)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0", 
+ verify_mac=self.pf_mac, check_fdir="non-exist")
+
+        # Remove rule2, and send the match pkt1 packet again. Check that no FDir information is printed
+        self.pmdout.execute_cmd('flow destroy 0 rule 1')
+        self.sendpkt(pktstr=pkt1)
+        self.verify_result("pf", expect_rxpkts="1", expect_queue="0", verify_mac=self.pf_mac, check_fdir="non-exist")
+        self.pmdout.quit()
+
+        self.logger.info("Sub-case3: ``--pkt-filter-report-hash=always`` mode")
+        pkt_filter_report_hash = "always"
+        self.launch_start_testpmd(queue=MAX_QUEUE + 1, pkt_filter_mode='perfect', report_hash=pkt_filter_report_hash,
+                                  disable_rss=True, fwd='rxonly', 
+ verbose='1')
+
+        # Send matched pkt0 packet with Scapy on the traffic generator and check the output (FDIR id=0x0)
+        self.sendpkt(pktstr=pkt0)
+        out1 = self.verify_result("pf", expect_rxpkts="1", 
+ expect_queue="0", verify_mac=self.pf_mac, check_fdir="exist")
+
+        # Add flow filter rule, and send the matched pkt0 packet again.
+        # the filter ID is different, and the packet goes to queue 1Add flow filter rule, and send the matched packet again.
+        self.pmdout.execute_cmd(rule0)
+        self.sendpkt(pktstr=pkt0)
+        out2 = self.verify_result("pf", expect_rxpkts="1", 
+ expect_queue="1", verify_mac=self.pf_mac, check_fdir="exist")
+
+        # check fdir id is different
+        self.logger.info("FDIR ID1=" + fdir_scanner.search(out1).group(0) + "; FDIR ID2=" + fdir_scanner.search(out2).group(0))
+        self.verify(fdir_scanner.search(out1).group(0) != fdir_scanner.search(out2).group(0),
+                    'Sub-case3.3: FDIR ID should be different')
+
     def tear_down(self):
         """
         Run after each test case.
--
2.7.4


      parent reply	other threads:[~2021-11-17  8:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05  2:49 [dts] [PATCH V2 0/3] tests/generic_flow_api: add fdir's case Yu Jiang
2021-11-05  2:49 ` [dts] [PATCH V2 1/3] test_plans/fdir: move case: fdir for Control levels of FDir match reporting to generic_flow_api Yu Jiang
2021-11-05  2:49 ` [dts] [PATCH V2 2/3] test_plans/generic_flow_api: add case: fdir for Control levels of FDir match reporting Yu Jiang
2021-11-05  2:49 ` [dts] [PATCH V2 3/3] tests/generic_flow_api: add case test_fdir_for_match_report Yu Jiang
2021-11-05  2:51   ` Jiang, YuX
2021-11-17  8:09   ` Peng, Yuan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB50582F760BC0ADAAB2484CC7FE9A9@CO1PR11MB5058.namprd11.prod.outlook.com \
    --to=yuan.peng@intel.com \
    --cc=dts@dpdk.org \
    --cc=yux.jiang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).