DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nicholas Pratte <npratte@iol.unh.edu>
To: yoan.picchi@foss.arm.com, ian.stokes@intel.com,
	probb@iol.unh.edu, stephen@networkplumber.org,
	Honnappa.Nagarahalli@arm.com, luca.vizzarro@arm.com,
	thomas@monjalon.net, thomas.wilks@arm.com, dmarx@iol.unh.edu,
	paul.szczepanek@arm.com
Cc: dev@dpdk.org, Nicholas Pratte <npratte@iol.unh.edu>
Subject: [PATCH v1 1/2] dts: add fwd restart decorator to rx capabilities
Date: Fri, 17 Jan 2025 09:58:37 -0500	[thread overview]
Message-ID: <20250117145838.40206-2-npratte@iol.unh.edu> (raw)
In-Reply-To: <20250117145838.40206-1-npratte@iol.unh.edu>

Some testpmd runtime functions require that forwarding be stopped before
attempting to execute them, depending on the NIC and vendor. Adding a
decorator to these testpmdshell methods to stop, execute, and then start
forwarding again abstracts this concern away for test suite developers,
and makes for cleaner, easier to read code.

Signed-off-by: Nicholas Pratte <npratte@iol.unh.edu>
---
 dts/framework/remote_session/testpmd_shell.py | 26 ++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index c01ee74b21..c008cb3792 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1390,6 +1390,28 @@ def _wrapper(self: "TestPmdShell", *args: P.args, **kwargs: P.kwargs):
     return _wrapper
 
 
+def requires_forwarding_restart(func: TestPmdShellMethod) -> TestPmdShellMethod:
+    """Decorator for :class:`TestPmdShell` commands methods that requires forwarding restart.
+
+    If the decorated method is called while a :class:`TestPmdShell` is actively forwarding, then
+    forwarding is ceased, the wrapped function is executed, and forwarding is started again.
+
+    Args:
+        func: The :class:`TestPmdShell` method to decorate.
+    """
+
+    @functools.wraps(func)
+    def _wrapper(self: "TestPmdShell", *args: P.args, **kwargs: P.kwargs):
+        if self.currently_forwarding:
+            self._logger.debug("Forwarding needs to be restarted to continue.")
+            self.stop()
+            retval = func(self, *args, **kwargs)
+            self.start()
+            return retval
+
+    return _wrapper
+
+
 def add_remove_mtu(mtu: int = 1500) -> Callable[[TestPmdShellMethod], TestPmdShellMethod]:
     """Configure MTU to `mtu` on all ports, run the decorated function, then revert.
 
@@ -1438,6 +1460,7 @@ class TestPmdShell(DPDKShell):
     _command_extra_chars: ClassVar[str] = "\n"
 
     ports_started: bool
+    currently_forwarding: bool
 
     def __init__(
         self,
@@ -1462,6 +1485,7 @@ def __init__(
             name,
         )
         self.ports_started = not self._app_params.disable_device_start
+        self.currently_forwarding = not self._app_params.auto_start
         self._ports = None
 
     @property
@@ -1836,7 +1860,7 @@ def csum_set_hw(
                                                            {port_id}:\n{csum_output}"""
                     )
 
-    @requires_started_ports
+    @requires_forwarding_restart
     @requires_stopped_ports
     def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None:
         """Change the MTU of a port using testpmd.
-- 
2.47.1


  reply	other threads:[~2025-01-17 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-17 14:58 [PATCH v1 0/2] dts: mtu update and jumbo frames test suite Nicholas Pratte
2025-01-17 14:58 ` Nicholas Pratte [this message]
2025-01-17 14:58 ` [PATCH v1 2/2] dts: add " Nicholas Pratte

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=20250117145838.40206-2-npratte@iol.unh.edu \
    --to=npratte@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=dmarx@iol.unh.edu \
    --cc=ian.stokes@intel.com \
    --cc=luca.vizzarro@arm.com \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=stephen@networkplumber.org \
    --cc=thomas.wilks@arm.com \
    --cc=thomas@monjalon.net \
    --cc=yoan.picchi@foss.arm.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).