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 v5 2/2] dts: add flow create/delete to testpmd shell
Date: Wed, 4 Dec 2024 18:22:46 -0500 [thread overview]
Message-ID: <20241204232246.30339-2-dmarx@iol.unh.edu> (raw)
In-Reply-To: <20241204232246.30339-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 | 59 ++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 177fcf2e81..bdb0e760b9 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -22,7 +22,15 @@
from enum import Flag, auto
from os import environ
from pathlib import PurePath
-from typing import TYPE_CHECKING, Any, ClassVar, Concatenate, Literal, ParamSpec, TypeAlias
+from typing import (
+ TYPE_CHECKING,
+ Any,
+ ClassVar,
+ Concatenate,
+ Literal,
+ ParamSpec,
+ TypeAlias,
+)
if TYPE_CHECKING or environ.get("DTS_DOC_BUILD"):
from enum import Enum as NoAliasEnum
@@ -1878,6 +1886,55 @@ 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.
+ 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.
+ verify: If :data:`True`, the output of the command is scanned
+ to ensure the flow rule was deleted successfully.
+
+ Raises:
+ InteractiveCommandExectuionError: 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_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.44.0
prev parent reply other threads:[~2024-12-04 22:21 UTC|newest]
Thread overview: 10+ 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 ` 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=20241204232246.30339-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).