From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: thomas@monjalon.net, Honnappa.Nagarahalli@arm.com,
jspewock@iol.unh.edu, probb@iol.unh.edu, paul.szczepanek@arm.com,
Luca.Vizzarro@arm.com, npratte@iol.unh.edu, dmarx@iol.unh.edu,
alex.chapman@arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v1] dts: add testpmd port information caching
Date: Mon, 9 Sep 2024 17:51:41 +0200 [thread overview]
Message-ID: <e7492914-8926-4855-9958-c18efe5f43ae@pantheon.tech> (raw)
In-Reply-To: <20240823074137.13989-1-juraj.linkes@pantheon.tech>
Applied to next-dts, thanks.
On 23. 8. 2024 9:41, Juraj Linkeš wrote:
> When using port information multiple times in a testpmd shell instance
> lifespan, it's desirable to not get the information each time, so
> caching is added. In case the information changes, there's a way to
> force the update with either TestPmdShell.show_port_info() or
> TestPmdShell.show_port_info_all().
>
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
> dts/framework/remote_session/testpmd_shell.py | 30 +++++++++++++++++--
> 1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
> index 43e9f56517..0a5cb385c9 100644
> --- a/dts/framework/remote_session/testpmd_shell.py
> +++ b/dts/framework/remote_session/testpmd_shell.py
> @@ -586,6 +586,7 @@ class TestPmdShell(DPDKShell):
> """
>
> _app_params: TestPmdParams
> + _ports: list[TestPmdPort] | None
>
> #: The path to the testpmd executable.
> path: ClassVar[PurePath] = PurePath("app", "dpdk-testpmd")
> @@ -618,6 +619,21 @@ def __init__(
> TestPmdParams(**app_params),
> name,
> )
> + self._ports = None
> +
> + @property
> + def ports(self) -> list[TestPmdPort]:
> + """The ports of the instance.
> +
> + This caches the ports returned by :meth:`show_port_info_all`.
> + To force an update of port information, execute :meth:`show_port_info_all` or
> + :meth:`show_port_info`.
> +
> + Returns: The list of known testpmd ports.
> + """
> + if self._ports is None:
> + return self.show_port_info_all()
> + return self._ports
>
> def start(self, verify: bool = True) -> None:
> """Start packet forwarding with the current configuration.
> @@ -747,7 +763,8 @@ def show_port_info_all(self) -> list[TestPmdPort]:
> # executed on a pseudo-terminal created by paramiko on the remote node, lines end with CRLF.
> # Therefore we also need to take the carriage return into account.
> iter = re.finditer(r"\*{21}.*?[\r\n]{4}", output + "\r\n", re.S)
> - return [TestPmdPort.parse(block.group(0)) for block in iter]
> + self._ports = [TestPmdPort.parse(block.group(0)) for block in iter]
> + return self._ports
>
> def show_port_info(self, port_id: int) -> TestPmdPort:
> """Returns the given port information.
> @@ -765,7 +782,16 @@ def show_port_info(self, port_id: int) -> TestPmdPort:
> if output.startswith("Invalid port"):
> raise InteractiveCommandExecutionError("invalid port given")
>
> - return TestPmdPort.parse(output)
> + port = TestPmdPort.parse(output)
> + self._update_port(port)
> + return port
> +
> + def _update_port(self, port: TestPmdPort) -> None:
> + if self._ports:
> + self._ports = [
> + existing_port if port.id != existing_port.id else port
> + for existing_port in self._ports
> + ]
>
> def show_port_stats_all(self) -> list[TestPmdPortStats]:
> """Returns the statistics of all the ports.
prev parent reply other threads:[~2024-09-09 15:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 7:41 Juraj Linkeš
2024-09-02 13:45 ` Luca Vizzarro
2024-09-05 16:09 ` Jeremy Spewock
2024-09-09 15:51 ` Juraj Linkeš [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=e7492914-8926-4855-9958-c18efe5f43ae@pantheon.tech \
--to=juraj.linkes@pantheon.tech \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=dmarx@iol.unh.edu \
--cc=jspewock@iol.unh.edu \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=thomas@monjalon.net \
/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).