[V2,2/2] tests/ice_dcf_switch_filter: optimize max vfs scrip

Message ID 20230308174857.25857-2-hongbox.li@intel.com (mailing list archive)
State Accepted
Headers
Series [V2,1/2] test_plans/ice_dcf_switch_filter: optimize max vfs script |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-doc-test success Testing OK
ci/Intel-dts-suite-test success Testing OK

Commit Message

Li, HongboX March 8, 2023, 5:48 p.m. UTC
  Change the method of obtaining the maximum number of VF that can be created on one PF

Signed-off-by: Hongbo Li <hongbox.li@intel.com>
---
 tests/TestSuite_ice_dcf_switch_filter.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
  

Patch

diff --git a/tests/TestSuite_ice_dcf_switch_filter.py b/tests/TestSuite_ice_dcf_switch_filter.py
index c5c3ae0b..0731199a 100644
--- a/tests/TestSuite_ice_dcf_switch_filter.py
+++ b/tests/TestSuite_ice_dcf_switch_filter.py
@@ -3203,10 +3203,21 @@  class ICEDCFSwitchFilterTest(TestCase):
 
     def test_max_vfs(self):
         # get max vfs number
-        port_count = (1, 1, 2, 4, 4)[len(self.dut_ports)]
-        max_vf_number = int(256 / (port_count))
-        # set up max_vf_number vfs on 1 pf environment
         self.used_dut_port_0 = self.dut_ports[0]
+        self.domain_id_0 = self.dut.ports_info[self.used_dut_port_0]["port"].domain_id
+        self.bus_id_0 = self.dut.ports_info[self.used_dut_port_0]["port"].bus_id
+        self.devfun_id_0 = self.dut.ports_info[self.used_dut_port_0]["port"].devfun_id
+        cmd_max_vfs = (
+            "cat /sys/bus/pci/devices/"
+            + self.domain_id_0
+            + "\\:"
+            + self.bus_id_0
+            + "\\:"
+            + self.devfun_id_0
+            + "/sriov_totalvfs"
+        )
+        max_vf_number = int(self.dut.send_expect(cmd_max_vfs, "#"))
+        # set up max_vf_number vfs on 1 pf environment
         self.pf0_intf = self.dut.ports_info[self.used_dut_port_0]["intf"]
         out = self.dut.send_expect("ethtool -i %s" % self.pf0_intf, "#")
         # generate max_vf_number VFs on PF0