[RFC,v3,1/5] dts: allow binding only a single port to a different driver

Message ID 20240821213042.24814-2-jspewock@iol.unh.edu (mailing list archive)
State Superseded
Delegated to: Juraj Linkeš
Headers
Series dts: add VFs to the framework |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation warning apply patch failure
ci/iol-testing warning apply patch failure

Commit Message

Jeremy Spewock Aug. 21, 2024, 9:30 p.m. UTC
From: Jeremy Spewock <jspewock@iol.unh.edu>

Previously the DTS framework only included methods that bind all ports
that the test run was aware of to either the DPDK driver or the OS
driver. There are however some cases, like creating virtual functions,
where you would want some ports bound to the OS driver and others bound
to their DPDK driver. This patch adds the ability to bind individual
ports to their respective drviers to solve this problem.

Depends-on: patch-143101 ("dts: add binding to different drivers to TG
node")

Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 dts/framework/testbed_model/node.py | 21 ++++++++++++---------
 dts/tests/TestSuite_os_udp.py       |  4 ++--
 2 files changed, 14 insertions(+), 11 deletions(-)
  

Patch

diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index 8e6181e424..85d4eb1f7c 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -167,12 +167,12 @@  def set_up_build_target(self, build_target_config: BuildTargetConfiguration) ->
                 the setup steps will be taken.
         """
         self._copy_dpdk_tarball()
-        self.bind_ports_to_driver()
+        self.bind_all_ports_to_driver()
 
     def tear_down_build_target(self) -> None:
         """Reset DPDK variables and bind port driver to the OS driver."""
         self.__remote_dpdk_dir = None
-        self.bind_ports_to_driver(for_dpdk=False)
+        self.bind_all_ports_to_driver(for_dpdk=False)
 
     def create_session(self, name: str) -> OSSession:
         """Create and return a new OS-aware remote session.
@@ -317,7 +317,7 @@  def _copy_dpdk_tarball(self) -> None:
         # then extract to remote path
         self.main_session.extract_remote_tarball(remote_tarball_path, self._remote_dpdk_dir)
 
-    def bind_ports_to_driver(self, for_dpdk: bool = True) -> None:
+    def bind_all_ports_to_driver(self, for_dpdk: bool = True) -> None:
         """Bind all ports on the node to a driver.
 
         Args:
@@ -325,12 +325,15 @@  def bind_ports_to_driver(self, for_dpdk: bool = True) -> None:
                 If :data:`False`, binds to os_driver.
         """
         for port in self.ports:
-            driver = port.os_driver_for_dpdk if for_dpdk else port.os_driver
-            self.main_session.send_command(
-                f"{self.path_to_devbind_script} -b {driver} --force {port.pci}",
-                privileged=True,
-                verify=True,
-            )
+            self._bind_port_to_driver(port, for_dpdk)
+
+    def _bind_port_to_driver(self, port: Port, for_dpdk: bool = True) -> None:
+        driver = port.os_driver_for_dpdk if for_dpdk else port.os_driver
+        self.main_session.send_command(
+            f"{self.path_to_devbind_script} -b {driver} --force {port.pci}",
+            privileged=True,
+            verify=True,
+        )
 
 
 def create_session(node_config: NodeConfiguration, name: str, logger: DTSLogger) -> OSSession:
diff --git a/dts/tests/TestSuite_os_udp.py b/dts/tests/TestSuite_os_udp.py
index a78bd74139..5e9469bbac 100644
--- a/dts/tests/TestSuite_os_udp.py
+++ b/dts/tests/TestSuite_os_udp.py
@@ -23,7 +23,7 @@  def set_up_suite(self) -> None:
             Bind the SUT ports to the OS driver, configure the ports and configure the SUT
             to route traffic from if1 to if2.
         """
-        self.sut_node.bind_ports_to_driver(for_dpdk=False)
+        self.sut_node.bind_all_ports_to_driver(for_dpdk=False)
         self.configure_testbed_ipv4()
 
     def test_os_udp(self) -> None:
@@ -50,4 +50,4 @@  def tear_down_suite(self) -> None:
         """
         self.configure_testbed_ipv4(restore=True)
         # Assume other suites will likely need dpdk driver
-        self.sut_node.bind_ports_to_driver(for_dpdk=True)
+        self.sut_node.bind_all_ports_to_driver(for_dpdk=True)