From: Dean Marx <dmarx@iol.unh.edu>
To: probb@iol.unh.edu, npratte@iol.unh.edu, luca.vizzarro@arm.com,
yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com,
paul.szczepanek@arm.com
Cc: dev@dpdk.org, Dean Marx <dmarx@iol.unh.edu>
Subject: [PATCH v6 2/2] dts: add flow create/delete to testpmd shell
Date: Tue, 21 Jan 2025 15:41:35 -0500 [thread overview]
Message-ID: <20250121204135.28944-2-dmarx@iol.unh.edu> (raw)
In-Reply-To: <20250121204135.28944-1-dmarx@iol.unh.edu>
Add flow create/delete methods to TestPmdShell class
for initializing flow rules.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 51 +++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 3e86f52a7e..01c05bceda 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1910,6 +1910,57 @@ def csum_set_hw(
{port_id}:\n{csum_output}"""
)
+ def flow_create(self, flow_rule: FlowRule, port_id: int, verify: bool = True) -> int:
+ """Creates a flow rule in the testpmd session.
+
+ Args:
+ flow_rule: :class:`FlowRule` object used for creating testpmd flow rule.
+ port_id: Integer representing the port to use.
+ verify: If :data:`True`, the output of the command is scanned
+ to ensure the flow rule was created successfully.
+
+ Raises:
+ InteractiveCommandExecutionError: If flow rule is invalid.
+
+ Returns:
+ Id of created flow rule as an integer.
+ """
+ flow_output = self.send_command(f"flow create {port_id} {flow_rule}")
+ if verify:
+ if "created" not in flow_output:
+ self._logger.debug(f"Failed to create flow rule:\n{flow_output}")
+ raise InteractiveCommandExecutionError(
+ f"Failed to create flow rule:\n{flow_output}"
+ )
+ match = re.search(r"#(\d+)", flow_output)
+ if match is not None:
+ match_str = match.group(1)
+ flow_id = int(match_str)
+ return flow_id
+ else:
+ self._logger.debug(f"Failed to create flow rule:\n{flow_output}")
+ raise InteractiveCommandExecutionError(f"Failed to create flow rule:\n{flow_output}")
+
+ def flow_delete(self, flow_id: int, port_id: int, verify: bool = True) -> None:
+ """Deletes the specified flow rule from the testpmd session.
+
+ Args:
+ flow_id: :class:`FlowRule` id used for deleting testpmd flow rule.
+ port_id: Integer representing the port to use.
+ verify: If :data:`True`, the output of the command is scanned
+ to ensure the flow rule was deleted successfully.
+
+ Raises:
+ InteractiveCommandExecutionError: If flow rule is invalid.
+ """
+ flow_output = self.send_command(f"flow destroy {port_id} rule {flow_id}")
+ if verify:
+ if "destroyed" not in flow_output:
+ self._logger.debug(f"Failed to delete flow rule:\n{flow_output}")
+ raise InteractiveCommandExecutionError(
+ f"Failed to delete flow rule:\n{flow_output}"
+ )
+
@requires_started_ports
@requires_stopped_ports
def set_port_mtu(self, port_id: int, mtu: int, verify: bool = True) -> None:
--
2.44.0
prev parent reply other threads:[~2025-01-21 20:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-26 14:22 [PATCH v1] dts: add flow rule dataclass " Dean Marx
2024-08-02 20:49 ` Jeremy Spewock
2024-08-06 16:42 ` [PATCH v2] " Dean Marx
2024-08-13 14:39 ` [PATCH v3] " Dean Marx
2024-08-13 14:41 ` Dean Marx
2024-09-25 8:17 ` Juraj Linkeš
2024-10-10 21:06 ` [PATCH v4] " Dean Marx
2024-11-14 12:19 ` Luca Vizzarro
2024-12-04 23:22 ` [PATCH v5 1/2] " Dean Marx
2024-12-04 23:22 ` [PATCH v5 2/2] dts: add flow create/delete " Dean Marx
2025-01-21 20:41 ` [PATCH v6 1/2] dts: add flow rule dataclass " Dean Marx
2025-01-21 20:41 ` Dean Marx [this message]
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=20250121204135.28944-2-dmarx@iol.unh.edu \
--to=dmarx@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=dev@dpdk.org \
--cc=luca.vizzarro@arm.com \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--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).