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 C3C174545F; Fri, 14 Jun 2024 19:34:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F47E40B9A; Fri, 14 Jun 2024 19:34:29 +0200 (CEST) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mails.dpdk.org (Postfix) with ESMTP id 232CC40B95 for ; Fri, 14 Jun 2024 19:34:28 +0200 (CEST) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ebd94b626cso2657291fa.3 for ; Fri, 14 Jun 2024 10:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1718386467; x=1718991267; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iaIajUGeSUIaqtkNPzyI3W77JtWCwbJN2/r9FA5xHh0=; b=TQ085ISI24IbI7jeP1gwF0qvTJgc719k0Bgmyiknr+ksUx1JXq3fHmM8i9eD3PCsAg GZDd8n0sRHF7hw75Cr0SxNGrayFMI0mTTey1kbIGPIUiZgpHwNWS4nBGzvws41wCcByR Jb/R/lSeAN4Ukk5+lRogshFNTJ/Lj1j6u7mls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718386467; x=1718991267; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iaIajUGeSUIaqtkNPzyI3W77JtWCwbJN2/r9FA5xHh0=; b=nN6fbcaf01XMUZIr7Ud8nPJ/6+A9izCZMJGuhKimzUxLR4FhRVKJu1boWP2jvCO2VN r9iz+3dEo/warjzG+UpdX7HZRD8UC7X2EMffOIw152N8xac9A4J/yOOe5Ei9yedd90+C 58nU3LPQlH4QSlMXB/e/+fPmtt7ShcNaIyZ7WOe6GaQNyMDJ65U9w2+9T/qNnqU2H994 yn2Po0CYjjjA5NQpLrHkAtjdVJzD7wBn51c6+6fvs2HcrS3E9hDx3Ft5eADEE88HnEUh Nf+J7p2p0nUvLJwpTDOELGCSS6RAAxM+U76Ecu5r02D74Qi/eOgcG61eN1oPaDiMxT2C QFOg== X-Gm-Message-State: AOJu0YxXR30DZIYQglE3/TtzbHhOKHV1KIA+Jev3fvEMgRWiqylhx2cn xurDNOSoSX+QEs2Q+GF5Ae96h4vssJOBTK7e8BtOS9mE1EOrgCKTT7HI9v9IBnj8cnLVCAU1X6a 63FSbFKQCz3tM+/7IQUL1WyYh8blVl6Bj97qBdw== X-Google-Smtp-Source: AGHT+IHOpkJ6v0dxxoYWyqQkwWhGITX5X2eY7aPtyMi9YFz7M3oSapNBLoAr5wd6vEiQv7y9kpWwez+bFdfFZAq041I= X-Received: by 2002:a2e:3a04:0:b0:2ec:170e:5b24 with SMTP id 38308e7fff4ca-2ec170e5bdemr13241021fa.4.1718386467532; Fri, 14 Jun 2024 10:34:27 -0700 (PDT) MIME-Version: 1.0 References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240606213420.254260-1-luca.vizzarro@arm.com> <20240606213420.254260-6-luca.vizzarro@arm.com> In-Reply-To: <20240606213420.254260-6-luca.vizzarro@arm.com> From: Nicholas Pratte Date: Fri, 14 Jun 2024 13:34:16 -0400 Message-ID: Subject: Re: [PATCH v5 5/5] dts: add `show port stats` command to TestPmdShell To: Luca Vizzarro Cc: dev@dpdk.org, Jeremy Spewock , =?UTF-8?Q?Juraj_Linke=C5=A1?= , Paul Szczepanek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Tested-by: Nicholas Pratte Reviewed-by: Nicholas Pratte wrote: > > Add a new TestPmdPortStats data structure to represent the output > returned by `show port stats`, which is implemented as part of > TestPmdShell. > > Bugzilla ID: 1407 > > Signed-off-by: Luca Vizzarro > Reviewed-by: Paul Szczepanek > --- > dts/framework/remote_session/testpmd_shell.py | 75 +++++++++++++++++++ > 1 file changed, 75 insertions(+) > > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framewor= k/remote_session/testpmd_shell.py > index ab9a1f86a9..d413bf2cc7 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -571,6 +571,42 @@ class TestPmdPort(TextParser): > ) > > > +@dataclass > +class TestPmdPortStats(TextParser): > + """Port statistics.""" > + > + #: > + port_id: int =3D field(metadata=3DTextParser.find_int(r"NIC statisti= cs for port (\d+)")) > + > + #: > + rx_packets: int =3D field(metadata=3DTextParser.find_int(r"RX-packet= s:\s+(\d+)")) > + #: > + rx_missed: int =3D field(metadata=3DTextParser.find_int(r"RX-missed:= \s+(\d+)")) > + #: > + rx_bytes: int =3D field(metadata=3DTextParser.find_int(r"RX-bytes:\s= +(\d+)")) > + #: > + rx_errors: int =3D field(metadata=3DTextParser.find_int(r"RX-errors:= \s+(\d+)")) > + #: > + rx_nombuf: int =3D field(metadata=3DTextParser.find_int(r"RX-nombuf:= \s+(\d+)")) > + > + #: > + tx_packets: int =3D field(metadata=3DTextParser.find_int(r"TX-packet= s:\s+(\d+)")) > + #: > + tx_errors: int =3D field(metadata=3DTextParser.find_int(r"TX-errors:= \s+(\d+)")) > + #: > + tx_bytes: int =3D field(metadata=3DTextParser.find_int(r"TX-bytes:\s= +(\d+)")) > + > + #: > + rx_pps: int =3D field(metadata=3DTextParser.find_int(r"Rx-pps:\s+(\d= +)")) > + #: > + rx_bps: int =3D field(metadata=3DTextParser.find_int(r"Rx-bps:\s+(\d= +)")) > + > + #: > + tx_pps: int =3D field(metadata=3DTextParser.find_int(r"Tx-pps:\s+(\d= +)")) > + #: > + tx_bps: int =3D field(metadata=3DTextParser.find_int(r"Tx-bps:\s+(\d= +)")) > + > + > class TestPmdShell(InteractiveShell): > """Testpmd interactive shell. > > @@ -760,6 +796,45 @@ def show_port_info(self, port_id: int) -> TestPmdPor= t: > > return TestPmdPort.parse(output) > > + def show_port_stats_all(self) -> list[TestPmdPortStats]: > + """Returns the statistics of all the ports. > + > + Returns: > + list[TestPmdPortStats]: A list containing all the ports stat= s as `TestPmdPortStats`. > + """ > + output =3D self.send_command("show port stats all") > + > + # Sample output of the "all" command looks like: > + # > + # ########### NIC statistics for port 0 ########### > + # values... > + # ################################################# > + # > + # ########### NIC statistics for port 1 ########### > + # values... > + # ################################################# > + # > + iter =3D re.finditer(r"(^ #*.+#*$[^#]+)^ #*\r$", output, re.MU= LTILINE) > + return [TestPmdPortStats.parse(block.group(1)) for block in iter= ] > + > + def show_port_stats(self, port_id: int) -> TestPmdPortStats: > + """Returns the given port statistics. > + > + Args: > + port_id: The port ID to gather information for. > + > + Raises: > + InteractiveCommandExecutionError: If `port_id` is invalid. > + > + Returns: > + TestPmdPortStats: An instance of `TestPmdPortStats` containi= ng the given port's stats. > + """ > + output =3D self.send_command(f"show port stats {port_id}", skip_= first_line=3DTrue) > + if output.startswith("Invalid port"): > + raise InteractiveCommandExecutionError("invalid port given") > + > + return TestPmdPortStats.parse(output) > + > def close(self) -> None: > """Overrides :meth:`~.interactive_shell.close`.""" > self.send_command("quit", "") > -- > 2.34.1 >