From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4ACC345945; Mon, 9 Sep 2024 17:51:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C7F040ED8; Mon, 9 Sep 2024 17:51:44 +0200 (CEST) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mails.dpdk.org (Postfix) with ESMTP id 3E11740ED8 for ; Mon, 9 Sep 2024 17:51:43 +0200 (CEST) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5c3c3b63135so4794098a12.3 for ; Mon, 09 Sep 2024 08:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1725897103; x=1726501903; darn=dpdk.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6RI8iLYmAlXYOx1mkuoIgccaBknk46VF0Ni6m4kuFpc=; b=DRCxJ1dEb0PviEXUZnGOqaoLIXgowWHF1HUwYEtMZHFcLHQwalm/m01pcPhIau1IOi FflaV9p3tVrhIPg83VMqgqPW9uhmcsGA2HotDRhqbGl46+yZ52jWnxnKHFb1o83nOecy RHViG1eeO5kbhbsvEvSC0V7duVqm4lFDp8f9bGoUPjTHoEnDC9oPKA0hQhHifUrayEme QAMw9VT5oL0J2e7RkerjPz9fYlvW59SjTy9r8UCFEBukVR7snUOa59aNRn+hMYylJpNE IkUZQdK4T+h2cbGo9Bpq5sPHsktqZcAPvxMP4EPQQifXeEP5IMVJnSOUnscAp3DEg+PD zwvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725897103; x=1726501903; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6RI8iLYmAlXYOx1mkuoIgccaBknk46VF0Ni6m4kuFpc=; b=X8tDbIlDMEKbbZEu5tr7gLjn7FKJXgmshAX5EqGcT8vwUO++/rovzNqJNYaHDOqiGL p5IvfS+QAwCBwrQPJoSSQs7hlVt5CFZ/0/nue+wK+wDdSUApHdHcT2xVfFjMJJoSnWZH KIqQ6pujLvJDXUUfwg9VWBus0502qsvWtEx6UVMq7laEur1pKzW5gQbmayj11CtGAl+L 4LIKORsqP5X9evaLpXlEAU5exjLiTSrua7OrqKz4NpWt1R3zEUPbDV0nHe6ty8F1Y0s/ OgQoOY9dZnSBH5iR2KjmHsVDKNToPah9+lFZ4CBUNJz/ZzK2+zfK9aRLH/vVZvK5htJt /NlQ== X-Gm-Message-State: AOJu0Yyyz0zMCjyt+kJJJfAjBHwD14+tH0zS7yjUvjYGiXUhLP8VEIB7 4tNgMiGzOjJFRGxFvOqdsueXMhO8vtH7LdMeJP7/UFiJ4C2+1Uv2/gfJB5waaIk= X-Google-Smtp-Source: AGHT+IH1zyxE2YOGMzHtF0bNxUVU1Vb61GX/ndgoul180w39OA/r7N7ks9Cqe1dwyDnRpxbnNj2CYQ== X-Received: by 2002:a17:907:7f14:b0:a8d:4243:2365 with SMTP id a640c23a62f3a-a8d42433fd0mr657642866b.41.1725897102687; Mon, 09 Sep 2024 08:51:42 -0700 (PDT) Received: from [192.168.200.22] ([84.245.121.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cf3ad6sm358079566b.148.2024.09.09.08.51.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Sep 2024 08:51:42 -0700 (PDT) Message-ID: Date: Mon, 9 Sep 2024 17:51:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] dts: add testpmd port information caching 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 References: <20240823074137.13989-1-juraj.linkes@pantheon.tech> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240823074137.13989-1-juraj.linkes@pantheon.tech> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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š > --- > 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.