DPDK patches and discussions
 help / color / mirror / Atom feed
From: jspewock@iol.unh.edu
To: thomas@monjalon.net, alex.chapman@arm.com, Luca.Vizzarro@arm.com,
	yoan.picchi@foss.arm.com, paul.szczepanek@arm.com,
	probb@iol.unh.edu, Honnappa.Nagarahalli@arm.com,
	juraj.linkes@pantheon.tech, wathsala.vithanage@arm.com,
	npratte@iol.unh.edu
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [PATCH v4 1/1] dts: add methods for modifying MTU to testpmd shell
Date: Fri,  6 Sep 2024 14:00:36 -0400	[thread overview]
Message-ID: <20240906180036.19446-2-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240906180036.19446-1-jspewock@iol.unh.edu>

From: Jeremy Spewock <jspewock@iol.unh.edu>

There are methods within DTS currently that support updating the MTU of
ports on a node, but the methods for doing this in a linux session rely
on the ip command and the port being bound to the kernel driver. Since
test suites are run while bound to the driver for DPDK, there needs to
be a way to modify the value while bound to said driver as well. This is
done by using testpmd to modify the MTU.

Depends-on: patch-142952 ("dts: add ability to start/stop testpmd
ports")
Depends-on: patch-143360 ("dts: add testpmd port information caching")

Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 dts/framework/remote_session/testpmd_shell.py | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 349282d4c5..b4e1fcb75f 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -915,6 +915,50 @@ def show_port_stats(self, port_id: int) -> TestPmdPortStats:
 
         return TestPmdPortStats.parse(output)
 
+    @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.
+
+        Some PMDs require that the port be stopped before changing the MTU, and it does no harm to
+        stop the port before configuring in cases where it isn't required, so ports are stopped
+        prior to changing their MTU.
+
+        Args:
+            port_id: ID of the port to adjust the MTU on.
+            mtu: Desired value for the MTU to be set to.
+            verify: If `verify` is :data:`True` then the output will be scanned in an attempt to
+                verify that the mtu was properly set on the port. Defaults to :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and the MTU was not
+                properly updated on the port matching `port_id`.
+        """
+        set_mtu_output = self.send_command(f"port config mtu {port_id} {mtu}")
+        if verify and (f"MTU: {mtu}" not in self.send_command(f"show port info {port_id}")):
+            self._logger.debug(
+                f"Failed to set mtu to {mtu} on port {port_id}." f" Output was:\n{set_mtu_output}"
+            )
+            raise InteractiveCommandExecutionError(
+                f"Test pmd failed to update mtu of port {port_id} to {mtu}"
+            )
+
+    def set_port_mtu_all(self, mtu: int, verify: bool = True) -> None:
+        """Change the MTU of all ports using testpmd.
+
+        Runs :meth:`set_port_mtu` for every port that testpmd is aware of.
+
+        Args:
+            mtu: Desired value for the MTU to be set to.
+            verify: Whether to verify that setting the MTU on each port was successful or not.
+                Defaults to :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and the MTU was not
+                properly updated on at least one port.
+        """
+        for port in self.ports:
+            self.set_port_mtu(port.id, mtu, verify)
+
     def _close(self) -> None:
         """Overrides :meth:`~.interactive_shell.close`."""
         self.stop()
-- 
2.46.0


  reply	other threads:[~2024-09-06 18:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-26 20:02 [PATCH v1 0/1] dts: allow for updating MTU with testpmd jspewock
2024-08-26 20:02 ` [PATCH v1 1/1] dts: add methods for modifying MTU to testpmd shell jspewock
2024-08-26 21:13 ` [PATCH v2 0/1] dts: allow for updating MTU with testpmd jspewock
2024-08-26 21:13   ` [PATCH v2 1/1] dts: add methods for modifying MTU to testpmd shell jspewock
2024-09-05 14:21 ` [PATCH v3 0/1] dts: allow for updating MTU with testpmd jspewock
2024-09-05 14:21   ` [PATCH v3 1/1] dts: add methods for modifying MTU to testpmd shell jspewock
2024-09-06 13:58     ` Juraj Linkeš
2024-09-06 14:28       ` Jeremy Spewock
2024-09-06 18:00 ` [PATCH v4 0/1] dts: allow for updating MTU with testpmd jspewock
2024-09-06 18:00   ` jspewock [this message]
2024-09-09 12:32     ` [PATCH v4 1/1] dts: add methods for modifying MTU to testpmd shell Luca Vizzarro
2024-09-09 12:33     ` Luca Vizzarro
2024-09-09 15:52   ` [PATCH v4 0/1] dts: allow for updating MTU with testpmd Juraj Linkeš

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=20240906180036.19446-2-jspewock@iol.unh.edu \
    --to=jspewock@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=juraj.linkes@pantheon.tech \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --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).