DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] dts: automatically bring up link on interfaces
@ 2025-01-25  0:10 Patrick Robb
  0 siblings, 0 replies; only message in thread
From: Patrick Robb @ 2025-01-25  0:10 UTC (permalink / raw)
  To: paul.szczepanek
  Cc: dev, luca.vizzarro, npratte, dmarx, thomas.wilks, Patrick Robb

Adds a method to os_session for bringing up port interface links,
an implementation for linux_session, and a call to this at node
init. This removes the current requirement that users bring
up the link on their TG interfaces before running DTS.

Tested-by: Patrick Robb <probb@iol.unh.edu>
Signed-off-by: Patrick Robb <probb@iol.unh.edu>
---

A couple more things to note:
1. I ran into this after a server reboot, when the NIC interfaces
started without the link up. I didn't realize this was the case
and was briefly confused about why send_packet_and_capture was
returning 0 packets. I think it makes sense to remove this possible
point of failure from the user by incorporating automatic link setup.
2. The real requirement that the link be up is on the TG side - not
the SUT side. I initially wrote this as something only called from the
TG node init, but after discussing with Nick Pratte, we concluded that
it is good sense to try to up the link on the SUT ports too - even
though this "should" be handled by testpmd at EAL bring up.
3. Legacy DTS did run an ifconfig up on both nodes' interfaces
during testsuite setup, and I believe this is a practice which
we should copy for the new framework.
4. Why didn't I just throw the ip link command into linux_session
update_ports method? Well, initially I did, but I think there may
be a separation of concerns reason (gathering port info for Port object
vs os port config) for why these should be kept as separate methods.

 dts/framework/testbed_model/linux_session.py | 5 +++++
 dts/framework/testbed_model/node.py          | 1 +
 dts/framework/testbed_model/os_session.py    | 8 ++++++++
 3 files changed, 14 insertions(+)

diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
index e3732f0827..f507bbf825 100644
--- a/dts/framework/testbed_model/linux_session.py
+++ b/dts/framework/testbed_model/linux_session.py
@@ -169,6 +169,11 @@ def update_ports(self, ports: list[Port]) -> None:
             else:
                 self._logger.warning(f"No port at pci address {port.pci} found.")
 
+    def bring_up_link(self, ports: list[Port]) -> None:
+        """Overrides :meth:`~.os_session.OSSession.bring_up_link`."""
+        for port in ports:
+            self.send_command(f"ip link set dev {port.logical_name} up")
+
     def _get_lshw_info(self) -> list[LshwOutput]:
         output = self.send_command("lshw -quiet -json -C network", verify=True)
         return json.loads(output.stdout)
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py
index c6f12319ca..69644dba33 100644
--- a/dts/framework/testbed_model/node.py
+++ b/dts/framework/testbed_model/node.py
@@ -94,6 +94,7 @@ def __init__(self, node_config: NodeConfiguration):
     def _init_ports(self) -> None:
         self.ports = [Port(self.name, port_config) for port_config in self.config.ports]
         self.main_session.update_ports(self.ports)
+        self.main_session.bring_up_link(self.ports)
 
     def set_up_test_run(
         self,
diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py
index 28eccc05ed..45c987ae9e 100644
--- a/dts/framework/testbed_model/os_session.py
+++ b/dts/framework/testbed_model/os_session.py
@@ -520,6 +520,14 @@ def update_ports(self, ports: list[Port]) -> None:
             ports: The ports to update.
         """
 
+    @abstractmethod
+    def bring_up_link(self, ports: list[Port]) -> None:
+        """Send operating system specific command for bringing up link on node interfaces.
+
+        Args:
+            ports: The ports to apply the link up command to.
+        """
+
     @abstractmethod
     def configure_port_mtu(self, mtu: int, port: Port) -> None:
         """Configure `mtu` on `port`.
-- 
2.47.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-25  0:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-25  0:10 [PATCH] dts: automatically bring up link on interfaces Patrick Robb

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).