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

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

Closing ports is a standard configuration feature that is available in
testpmd but the framework lacks the ability to access this command
through the Testpmd API. This patch adds a method that performs this
action and verifies the results of sending the command to allow
developers to have more control over the state of the ports that
testpmd is aware of.

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

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

diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index ca24b28070..51593c61f5 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -805,6 +805,27 @@ def start_all_ports(self, verify: bool = True) -> None:
 
         self.ports_started = True
 
+    @requires_stopped_ports
+    def close_all_ports(self, verify: bool = True) -> None:
+        """Close all ports.
+
+        Args:
+            verify: If :data:`True` the output of the close command will be scanned in an attempt
+                to verify that all ports were stopped successfully. Defaults to :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and at lease one port
+                failed to close.
+        """
+        port_close_output = self.send_command("port close all")
+        if verify:
+            if type(self._app_params.ports) is list:
+                num_ports = len(self._app_params.ports)
+                if not all(
+                    f"Port {p_id} is closed" in port_close_output for p_id in range(num_ports)
+                ):
+                    raise InteractiveCommandExecutionError("Ports were not closed successfully.")
+
     def show_port_info_all(self) -> list[TestPmdPort]:
         """Returns the information of all the ports.
 
-- 
2.45.2


  reply	other threads:[~2024-08-14 18:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 18:20 [PATCH v1 0/2] dts: port over port_control testing suite jspewock
2024-08-14 18:20 ` jspewock [this message]
2024-08-14 18:20 ` [PATCH v1 2/2] dts: add port control " jspewock
2024-09-23 16:44 ` [PATCH v2 0/2] dts: port over port_control " jspewock
2024-09-23 16:44   ` [PATCH v2 1/2] dts: add method for closing ports to testpmd jspewock
2024-09-23 16:44   ` [PATCH v2 2/2] dts: add port control testing suite jspewock

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