From: jspewock@iol.unh.edu
To: thomas@monjalon.net, wathsala.vithanage@arm.com,
Luca.Vizzarro@arm.com, npratte@iol.unh.edu,
yoan.picchi@foss.arm.com, probb@iol.unh.edu,
Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com,
alex.chapman@arm.com, juraj.linkes@pantheon.tech
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [RFC PATCH v1 1/3] dts: add clearing port stats and verbose mode to testpmd
Date: Fri, 2 Aug 2024 13:29:26 -0400 [thread overview]
Message-ID: <20240802172928.212277-2-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240802172928.212277-1-jspewock@iol.unh.edu>
From: Jeremy Spewock <jspewock@iol.unh.edu>
Methods currently exist for querying the statistics of a port in
testpmd, but there weren't methods added for clearing the current
statistics on a port. This patch adds methods that allow you to clear
the statistics of a single port or all ports to account for situations
where the user only wants the port statistics after a certain point and
does not care about any existing prior values.
This patch also contains methods for modifying the verbose level of
testpmd so that users are able to utilize the extra information that it
provides.
Depends-on: patch-142762 ("dts: add text parser for testpmd verbose
output")
Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index dedf1553cf..cbea03464f 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -948,6 +948,68 @@ def extract_verbose_output(output: str) -> list[TestPmdVerboseOutput]:
iter = re.finditer(r"(port \d+/queue \d+:.*?(?=port \d+/queue \d+|$))", output, re.S)
return [TestPmdVerboseOutput.parse(s.group(0)) for s in iter]
+ def clear_port_stats(self, port_id: int, verify: bool = True) -> None:
+ """Clear statistics of a given port.
+
+ Args:
+ port_id: ID of the port to clear the statistics on.
+ verify: If :data:`True` the output of the command will be scanned to verify that it was
+ successful, otherwise failures will be ignored. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd fails to
+ clear the statistics of the given port.
+ """
+ clear_output = self.send_command(f"clear port stats {port_id}")
+ if verify and f"NIC statistics for port {port_id} cleared" not in clear_output:
+ raise InteractiveCommandExecutionError(
+ f"Test pmd failed to set clear forwarding stats on port {port_id}"
+ )
+
+ def clear_port_stats_all(self, verify: bool = True) -> None:
+ """Clear the statistics of all ports that testpmd is aware of.
+
+ Args:
+ verify: If :data:`True` the output of the command will be scanned to verify that all
+ ports had their statistics cleared, otherwise failures will be ignored. Defaults to
+ :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd fails to
+ clear the statistics of any of its ports.
+ """
+ clear_output = self.send_command("clear port stats all")
+ if verify:
+ if type(self._app_params.ports) is list:
+ for port_id in range(len(self._app_params.ports)):
+ if f"NIC statistics for port {port_id} cleared" not in clear_output:
+ raise InteractiveCommandExecutionError(
+ f"Test pmd failed to set clear forwarding stats on port {port_id}"
+ )
+
+ def set_verbose(self, level: int, verify: bool = True) -> None:
+ """Set debug verbosity level.
+
+ Args:
+ level: 0 - silent except for error
+ 1 - fully verbose except for Tx packets
+ 2 - fully verbose except for Rx packets
+ >2 - fully verbose
+ verify: if :data:`True` an additional command will be sent to verify that verbose level
+ is properly set. Defaults to :data:`True`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and verbose level
+ is not correctly set.
+ """
+ verbose_output = self.send_command(f"set verbose {level}")
+ if verify:
+ if "Change verbose level" not in verbose_output:
+ self._logger.debug(f"Failed to set verbose level to {level}: \n{verbose_output}")
+ raise InteractiveCommandExecutionError(
+ f"Testpmd failed to set verbose level to {level}."
+ )
+
def _close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.stop()
--
2.45.2
next prev parent reply other threads:[~2024-08-02 17:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 17:29 [RFC PATCH v1 0/3] dts: port over stats checks jspewock
2024-08-02 17:29 ` jspewock [this message]
2024-08-02 17:29 ` [RFC PATCH v1 2/3] dts: add port stats checks test suite jspewock
2024-08-02 17:29 ` [RFC PATCH v1 3/3] dts: add stats checks to schemai jspewock
2024-09-23 15:43 ` [PATCH v2 0/2] dts: port over stats checks jspewock
2024-09-23 15:43 ` [PATCH v2 1/2] dts: add clearing port stats and verbose mode to testpmd jspewock
2024-09-23 15:51 ` Jeremy Spewock
2024-09-23 15:43 ` [PATCH v2 2/2] dts: add port stats checks test suite jspewock
2024-09-23 15:49 ` [PATCH v3 0/2] dts: port over stats checks jspewock
2024-09-23 15:49 ` [PATCH v3 1/2] dts: add clearing port stats to testpmd shell jspewock
2024-09-23 15:49 ` [PATCH v3 2/2] dts: add port stats checks test 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=20240802172928.212277-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).