diff mbox series

[V1] tests/cvl_limit_value_test: adapt to cvl island platform

Message ID 20210301163954.29103-1-qinx.sun@intel.com (mailing list archive)
State Changes Requested
Headers show
Series [V1] tests/cvl_limit_value_test: adapt to cvl island platform | expand

Commit Message

Sun, QinX March 1, 2021, 4:39 p.m. UTC
Signed-off-by: sunqin <qinx.sun@intel.com>
---
 tests/TestSuite_cvl_limit_value_test.py | 106 +++++++++++++++++-------
 1 file changed, 74 insertions(+), 32 deletions(-)

Comments

Tu, Lijuan March 2, 2021, 5:02 a.m. UTC | #1
> +    def is_cvl_island(self, port_id=0):
> +        """
> +        Judge whether it is a CVL Island card according to the value of fd_fltr_guar
> +        """
> +        pf_pci = self.dut.ports_info[port_id]['pci']
> +        self.dut.send_expect('usertools/dpdk-devbind.py --force --bind=vfio-pci
> {}'.format(pf_pci), '#')
> +        out = PmdOutput(self.dut).start_testpmd('default', eal_param='-a %s --log-
> level=ice,7' % pf_pci)
> +        self.dut.kill_all()
> +        self.logger.info(f'outinfo:{out}')
> +        res = re.search(r"fd_fltr_guar\s+=\s+(\d+)", out)
> +        self.verify(res, "'fd_fltr_guar' not found'")
> +        if int(res.group(1)) == 2048:
> +            return True
> +        return False

It's really a bad approach.
diff mbox series

Patch

diff --git a/tests/TestSuite_cvl_limit_value_test.py b/tests/TestSuite_cvl_limit_value_test.py
index 77ce0162..4937a25d 100644
--- a/tests/TestSuite_cvl_limit_value_test.py
+++ b/tests/TestSuite_cvl_limit_value_test.py
@@ -94,6 +94,7 @@  class TestCvlLimitValue(TestCase):
         localPort = self.tester.get_local_port(self.dut_ports[0])
         self.__tx_iface = self.tester.get_interface(localPort)
         self.pkt = Packet()
+        self.island = self.is_cvl_island()
 
     def set_up_for_iavf_dir(self):
         """
@@ -222,7 +223,7 @@  class TestCvlLimitValue(TestCase):
     def launch_testpmd(self):
         self.pmd_output.start_testpmd(cores="1S/4C/1T",
                                       param="--rxq={} --txq={}".format(self.cvlq_num, self.cvlq_num),
-                                      eal_param="-w %s -w %s" % (
+                                      eal_param="-a %s -a %s" % (
                                           self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci),
                                       socket=self.ports_socket)
         self.config_testpmd()
@@ -337,6 +338,22 @@  class TestCvlLimitValue(TestCase):
         out = session_name.send_expect("stop", "testpmd> ", 15)
         dic["check_func"]["func"](out, dic["check_func"]["param"], dic["expect_results"])
 
+
+    def is_cvl_island(self, port_id=0):
+        """
+        Judge whether it is a CVL Island card according to the value of fd_fltr_guar
+        """
+        pf_pci = self.dut.ports_info[port_id]['pci']
+        self.dut.send_expect('usertools/dpdk-devbind.py --force --bind=vfio-pci {}'.format(pf_pci), '#')
+        out = PmdOutput(self.dut).start_testpmd('default', eal_param='-a %s --log-level=ice,7' % pf_pci)
+        self.dut.kill_all()
+        self.logger.info(f'outinfo:{out}')
+        res = re.search(r"fd_fltr_guar\s+=\s+(\d+)", out)
+        self.verify(res, "'fd_fltr_guar' not found'")
+        if int(res.group(1)) == 2048:
+            return True
+        return False
+
     def test_maxnum_14336rules_1vf(self):
         """
         vfs share 14336 rules table
@@ -357,7 +374,7 @@  class TestCvlLimitValue(TestCase):
         self.verify(count == 14336, "failed to create 14336 fdir rules on vf.")
         self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)
 
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (
         self.cvlq_num, self.cvlq_num) + " --cmdline-file=%s" % (dut_file_dir + src_file)
         self.dut.send_expect(command, "testpmd> ", 300)
@@ -435,8 +452,9 @@  class TestCvlLimitValue(TestCase):
         flows.close()
         self.verify(count == 14336, "failed to create 14336 fdir rules on 2 vfs.")
         self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)
-
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf1[0].pci)
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf1[0].pci)
+        if self.island:
+            eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (
         self.cvlq_num, self.cvlq_num) + " --cmdline-file=%s" % (dut_file_dir + src_file)
         self.dut.send_expect(command, "testpmd> ", 1200)
@@ -457,9 +475,12 @@  class TestCvlLimitValue(TestCase):
         self.check_rule_number(port_id=0, num=1)
 
         pkt_0 = 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.20",dst="192.168.0.0")/Raw("x" * 80)'
-        pkt_1 = 'Ether(dst="00:11:22:33:44:77")/IP(src="192.168.0.20",dst="192.168.0.0")/Raw("x" * 80)'
-        pkt_14335 = 'Ether(dst="00:11:22:33:44:77")/IP(src="192.168.0.20",dst="192.168.55.254")/Raw("x" * 80)'
-        pkt_14336 = 'Ether(dst="00:11:22:33:44:77")/IP(src="192.168.0.20",dst="192.168.56.0")/Raw("x" * 80)'
+        dst = '00:11:22:33:44:77'
+        if self.island:
+            dst = '00:11:22:33:44:66'
+        pkt_1 = 'Ether(dst="{}")/IP(src="192.168.0.20",dst="192.168.0.0")/Raw("x" * 80)'.format(dst)
+        pkt_14335 = 'Ether(dst="{}")/IP(src="192.168.0.20",dst="192.168.55.254")/Raw("x" * 80)'.format(dst)
+        pkt_14336 = 'Ether(dst="{}")/IP(src="192.168.0.20",dst="192.168.56.0")/Raw("x" * 80)'.format(dst)
 
         self.session_secondary.send_expect("ifconfig %s up" % self.pf0_intf, "# ", 15)
         self.session_secondary.send_expect("ifconfig %s up" % self.pf1_intf, "# ", 15)
@@ -468,19 +489,22 @@  class TestCvlLimitValue(TestCase):
         # check packet match rule 0 and rule 14335 can be redirected to expected queue
         out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)
         rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={"port_id": 0, "mark_id": 0, "queue": 5}, stats=True)
-        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=1)
+        pf_id = 1
+        if self.island:
+            pf_id = 0
+        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5}, stats=True)
 
-        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=1)
+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5}, stats=True)
         # check packet match rule 14336 can't be redirected to expected queue.
-        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=1)
+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={"port_id": 1, "queue": 5}, stats=False)
 
         # destroy rule 0 on vf0, then create a new rule on vf1 successfully.
         self.dut.send_expect("flow flush 0", "testpmd> ")
         self.create_fdir_rule(rule_14335_vf1, check_stats=True)
-        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=1)
+        out_14336 = self.send_pkts_getouput(pkts=pkt_14336, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_14336, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5}, stats=True)
 
         self.dut.send_expect("flow flush 1", "testpmd> ", timeout=300)
@@ -489,8 +513,8 @@  class TestCvlLimitValue(TestCase):
         self.check_fdir_rule(port_id=1, stats=False)
 
         out_0 = self.send_pkts_getouput(pkts=pkt_0, pf_id=0)
-        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=1)
-        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=1)
+        out_1 = self.send_pkts_getouput(pkts=pkt_1, pf_id=pf_id)
+        out_14335 = self.send_pkts_getouput(pkts=pkt_14335, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_0, pkt_num=1, check_param={"port_id": 0, "mark_id": 0, "queue": 5}, stats=False)
         rfc.check_iavf_fdir_mark(out_1, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5}, stats=False)
         rfc.check_iavf_fdir_mark(out_14335, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5},
@@ -511,18 +535,23 @@  class TestCvlLimitValue(TestCase):
         src_file = 'create_1025_kernel_rules'
         flows = open(self.src_file_dir + src_file, mode='w')
         count = 0
+        pf_intf = self.pf1_intf
+        num = 4
+        if self.island:
+            pf_intf = self.pf0_intf
+            num = 8
         if self.nic in ["columbiaville_100g"]:
-            for i in range(4):
+            for i in range(num):
                 for j in range(256):
                     flows.write(
                         'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % (
-                        self.pf1_intf, i, j))
+                        pf_intf, i, j))
                     count = count + 1
             flows.write(
-                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % self.pf1_intf)
+                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % pf_intf)
             count = count + 1
             flows.close()
-            self.verify(count == 1025, "failed to create 1025 fdir rules on pf.")
+            self.verify(count == num*256+1, "failed to create %s fdir rules on pf."%(num*256+1))
         elif self.nic in ["columbiaville_25g"]:
             for i in range(2):
                 for j in range(256):
@@ -531,7 +560,7 @@  class TestCvlLimitValue(TestCase):
                         self.pf1_intf, i, j))
                     count = count + 1
             flows.write(
-                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % self.pf1_intf)
+                'ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % pf_intf)
             count = count + 1
             flows.close()
             self.verify(count == 513, "failed to create 1025 fdir rules on pf.")
@@ -562,7 +591,7 @@  class TestCvlLimitValue(TestCase):
         self.verify(count == 14335, "failed to create 14335 fdir rules on vfs.")
         self.dut.session.copy_file_to(self.src_file_dir + src_file_vf, dut_file_dir)
         # start testpmd with creating rules in commandline
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (
         self.cvlq_num, self.cvlq_num) + " --cmdline-file=%s" % (dut_file_dir + src_file_vf)
         fdw = open("15360_rules_vf_result.txt", "w")
@@ -579,7 +608,7 @@  class TestCvlLimitValue(TestCase):
         out = self.check_rule_number(port_id=1, num=14334)
         self.verify("14334" not in out, "more than 15360 rules are created on 2vf")
         # delete a rule on pf0
-        self.session_secondary.send_expect("ethtool -N %s delete 14847" % self.pf1_intf, "# ")
+        self.session_secondary.send_expect("ethtool -N %s delete 14847" % pf_intf, "# ")
         # then can create one more rule on vf01
         self.create_fdir_rule(rule_14334_vf1, check_stats=True)
         out_14334 = self.send_pkts_getouput(pkts=pkt_14334, pf_id=0)
@@ -609,21 +638,26 @@  class TestCvlLimitValue(TestCase):
         src_file = 'create_15360_kernel_rules'
         flows = open(self.src_file_dir + src_file, mode='w')
         count = 0
+        num = 60
+        pf_intf = self.pf1_intf
+        if self.island:
+            num = 64
+            pf_intf = self.pf0_intf
         if self.nic in ["columbiaville_100g"]:
-            for i in range(60):
+            for i in range(num):
                 for j in range(256):
                     flows.write(
                         'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % (
-                        self.pf1_intf, i, j))
+                        pf_intf, i, j))
                     count = count + 1
             flows.close()
-            self.verify(count == 15360, "failed to create 15360 fdir rules on pf.")
+            self.verify(count == num*256, "failed to create %s fdir rules on pf."%(num*256))
         elif self.nic in ["columbiaville_25g"]:
             for i in range(58):
                 for j in range(256):
                     flows.write(
                         'ethtool -N %s flow-type tcp4 src-ip 192.168.%d.%d dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8 \n' % (
-                        self.pf1_intf, i, j))
+                        pf_intf, i, j))
                     count = count + 1
             flows.close()
             self.verify(count == 14848, "failed to create 14848 fdir rules on pf.")
@@ -636,10 +670,13 @@  class TestCvlLimitValue(TestCase):
         time.sleep(200)
         # failed to create 1 more rule on pf1
         self.dut.send_expect(
-            "ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8" % self.pf1_intf,
+            "ethtool -N %s flow-type tcp4 src-ip 192.168.100.0 dst-ip 192.168.100.2 src-port 32 dst-port 33 action 8" % pf_intf,
             "Cannot insert RX class rule: No space left on device")
         # start testpmd with creating rules in commandline
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf1[0].pci)
+        vfs_pf1_pci = self.sriov_vfs_pf1[0].pci
+        if self.island:
+            vfs_pf1_pci = self.sriov_vfs_pf0[1].pci
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, vfs_pf1_pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (self.cvlq_num, self.cvlq_num)
         self.dut.send_expect(command, "testpmd> ", 20)
 
@@ -648,6 +685,10 @@  class TestCvlLimitValue(TestCase):
         pkt_0_vf00 = 'Ether(dst="00:11:22:33:44:55")/IP(src="192.168.0.20",dst="192.168.56.0")/Raw("x" * 80)'
         rule_0_vf10 = "flow create 1 ingress pattern eth / ipv4 src is 192.168.0.20 dst is 192.168.56.0 / end actions queue index 5 / mark / end"
         pkt_0_vf10 = 'Ether(dst="00:11:22:33:44:77")/IP(src="192.168.0.20",dst="192.168.56.0")/Raw("x" * 80)'
+        pf_id = 1
+        if self.island:
+            pf_id = 0
+            pkt_0_vf10 = 'Ether(dst="00:11:22:33:44:66")/IP(src="192.168.0.20",dst="192.168.56.0")/Raw("x" * 80)'
 
         # failed to create rule on vf00 and vf10
         self.create_fdir_rule(rule_0_vf00, check_stats=False)
@@ -656,7 +697,7 @@  class TestCvlLimitValue(TestCase):
         self.check_rule_number(port_id=1, num=0)
 
         # delete a rule on pf1
-        self.session_secondary.send_expect("ethtool -N %s delete 14847" % self.pf1_intf, "# ")
+        self.session_secondary.send_expect("ethtool -N %s delete 14847" % pf_intf, "# ")
 
         # then can create one rule on vf00
         self.create_fdir_rule(rule_0_vf00, check_stats=True)
@@ -665,7 +706,7 @@  class TestCvlLimitValue(TestCase):
         self.check_rule_number(port_id=1, num=0)
 
         # delete a rule on pf1
-        self.session_secondary.send_expect("ethtool -N %s delete 14846" % self.pf1_intf, "# ")
+        self.session_secondary.send_expect("ethtool -N %s delete 14846" % pf_intf, "# ")
 
         # then can create one rule on vf10
         self.create_fdir_rule(rule_0_vf10, check_stats=True)
@@ -675,7 +716,7 @@  class TestCvlLimitValue(TestCase):
         rfc.check_iavf_fdir_mark(out_0_vf00, pkt_num=1, check_param={"port_id": 0, "mark_id": 0, "queue": 5},
                                  stats=True)
 
-        out_0_vf10 = self.send_pkts_getouput(pkts=pkt_0_vf10, pf_id=1)
+        out_0_vf10 = self.send_pkts_getouput(pkts=pkt_0_vf10, pf_id=pf_id)
         rfc.check_iavf_fdir_mark(out_0_vf10, pkt_num=1, check_param={"port_id": 1, "mark_id": 0, "queue": 5},
                                  stats=True)
 
@@ -707,7 +748,7 @@  class TestCvlLimitValue(TestCase):
         self.verify(count == 14336, "failed to add/delete 14336 times of fdir rules on vf.")
         self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)
 
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (
         self.cvlq_num, self.cvlq_num) + " --cmdline-file=%s" % (dut_file_dir + src_file)
         self.dut.send_expect(command, "testpmd> ", 900)
@@ -746,7 +787,7 @@  class TestCvlLimitValue(TestCase):
         self.verify(count == 14336, "failed to add/delete 14336 times of fdir rules on 2 vfs.")
         self.dut.session.copy_file_to(self.src_file_dir + src_file, dut_file_dir)
 
-        eal_param = "-c f -n 6 -w %s -w %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
+        eal_param = "-c f -n 6 -a %s -a %s" % (self.sriov_vfs_pf0[0].pci, self.sriov_vfs_pf0[1].pci)
         command = self.path + eal_param + " -- -i --rxq=%s --txq=%s" % (
         self.cvlq_num, self.cvlq_num) + " --cmdline-file=%s" % (dut_file_dir + src_file)
         self.dut.send_expect(command, "testpmd> ", 900)
@@ -764,7 +805,7 @@  class TestCvlLimitValue(TestCase):
         self.pmd_output.start_testpmd(cores="1S/4C/1T",
                                       param="--portmask=%s --rxq=%d --txq=%d --port-topology=loop" % (
                                           self.portMask, rxq, txq),
-                                      eal_param="-w %s -w %s --log-level=ice,7" % (
+                                      eal_param="-a %s -a %s --log-level=ice,7" % (
                                           self.pci0, self.pci1), socket=self.ports_socket)
         self.config_testpmd_cvl_fidr()
 
@@ -874,6 +915,7 @@  class TestCvlLimitValue(TestCase):
                 matched_packet = 'Ether(dst="68:05:ca:8d:ed:a8")/IP(src="192.168.%d.%d")/TCP(sport=25,dport=23)/Raw("X"*480)' % (
                 i, j)
                 out = self.dut.send_expect(rule, "testpmd> ", timeout=2)  # create a rule
+                time.sleep(0.5)
                 m1 = p.search(out)
                 if m1:
                     rule_list.append(m1.group(1))