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 90B8B44155; Tue, 4 Jun 2024 17:45:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BA3740A75; Tue, 4 Jun 2024 17:45:04 +0200 (CEST) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mails.dpdk.org (Postfix) with ESMTP id A2BF54026E for ; Tue, 4 Jun 2024 17:45:01 +0200 (CEST) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57a31d63b6bso1606915a12.0 for ; Tue, 04 Jun 2024 08:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1717515901; x=1718120701; 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=CEd0nG5LowIrT7jx0ScE1K0si46hwKHJlf8plaCBUHg=; b=Y5UhxbfzAYNRZc4Y2/JCH0mnPonZ4jKu5tEhciTO+RkrxNAtahncBumqKI0Vy6qFa8 ZNQlUIKgZhOuVX4Vw+DHATfZyrqDiInFEUhxZbTP1Z0UV3nx1PLp8pgg6jAALx1woqTd xYb5VKcThEGJLLlw1kGGJEuHwvaG77J8WoK4fq2JuJF5178A8nFkV9wVOVyUYLRxgMEI mXHVu24b2S6bJ41MzCJmGRTR9U8Z5IbhyPUQgRyGPOz+pKmC1o0R50YIzY6eCP5opIhV Aqu6M5lZsG+3tUH46ndwyASsyOUKsZTyb2X9z6oU+b6mSAnF/8Wl6c/waYfEeYGkzd+Q CmNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717515901; x=1718120701; 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=CEd0nG5LowIrT7jx0ScE1K0si46hwKHJlf8plaCBUHg=; b=DSX1uv4u6r5kOhfH2Ls0C7PAjPJcejf3LXfZqUQwxlWoU8VeteWO1tqKTOS8kZkTp4 YuZmaK+oSUwsqyyLNBlBR7ct9MsEvsJ0qgRwR3evbjX8CZX7zL/27RdG9XIsoGPJYYMj V/X2vngC4WTtlrnCK0ZuxvmLkmS8cQtVWVyGklFw/BwZT3ahENGxWDcUHDOG2cXJ5Q9H uqyCAuBsaCQENrtmriou0tUiGuvKF6r4rn4gcLqcELNLukqoKkRqjezJpoL9J0erUC00 zaNiWV9wdnN/ea3rEodVhfHDbZMMLRHM1pd7P4C8Pw0w0QKKSmh0c6F1TPNSuZ5so2jC DdSQ== X-Forwarded-Encrypted: i=1; AJvYcCVYqapffzMcqRDRDEMoIY+YI8snKk6dxA8NEM+jxsaLs7EECTkvd6yMW2iNsshjgfqV2Z1VPzO80rr1jqY= X-Gm-Message-State: AOJu0YyCb6cT8yokjWMZqYJjJ0jx66AcHC4ktGuwKmytVlVzIOJDgHB+ B2MgCwC7zxCPBCE4bDHGsU+DBgdv8zB3SqZ4dP1GqW63e5Rlg0by9nIt9kOQUas= X-Google-Smtp-Source: AGHT+IF8oD++C2PPBNgoAtT9kJfkHh5jHd7yanA8nYpJaJ7t2fzbUNJMGoO7bmGxQCs3fUxSWzg7Hw== X-Received: by 2002:a17:906:ae09:b0:a5c:db98:c2a0 with SMTP id a640c23a62f3a-a6821f4ee85mr888458766b.58.1717515901229; Tue, 04 Jun 2024 08:45:01 -0700 (PDT) Received: from [192.168.1.113] ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a689e8ecd3asm550956766b.19.2024.06.04.08.45.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jun 2024 08:45:00 -0700 (PDT) Message-ID: <6effb6eb-bd55-4047-b7d4-7a7e1ddfc119@pantheon.tech> Date: Tue, 4 Jun 2024 17:44:59 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/5] dts: add `show port stats` command to TestPmdShell To: Luca Vizzarro , dev@dpdk.org Cc: Jeremy Spewock , Paul Szczepanek References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240509112635.1170557-1-luca.vizzarro@arm.com> <20240509112635.1170557-6-luca.vizzarro@arm.com> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240509112635.1170557-6-luca.vizzarro@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 9. 5. 2024 13:26, Luca Vizzarro 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 | 68 +++++++++++++++++++ > 1 file changed, 68 insertions(+) > > diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py > index 7910e17fed..d0b6da50f0 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -531,6 +531,42 @@ class TestPmdPort(TextParser): > ) > > > +@dataclass > +class TestPmdPortStats(TextParser): > + """Port statistics.""" > + > + #: > + port_id: int = field(metadata=TextParser.find_int(r"NIC statistics for port (\d+)")) > + > + #: > + rx_packets: int = field(metadata=TextParser.find_int(r"RX-packets:\s+(\d+)")) > + #: > + rx_missed: int = field(metadata=TextParser.find_int(r"RX-missed:\s+(\d+)")) > + #: > + rx_bytes: int = field(metadata=TextParser.find_int(r"RX-bytes:\s+(\d+)")) > + #: > + rx_errors: int = field(metadata=TextParser.find_int(r"RX-errors:\s+(\d+)")) > + #: > + rx_nombuf: int = field(metadata=TextParser.find_int(r"RX-nombuf:\s+(\d+)")) > + > + #: > + tx_packets: int = field(metadata=TextParser.find_int(r"TX-packets:\s+(\d+)")) > + #: > + tx_errors: int = field(metadata=TextParser.find_int(r"TX-errors:\s+(\d+)")) > + #: > + tx_bytes: int = field(metadata=TextParser.find_int(r"TX-bytes:\s+(\d+)")) > + > + #: > + rx_pps: int = field(metadata=TextParser.find_int(r"Rx-pps:\s+(\d+)")) > + #: > + rx_bps: int = field(metadata=TextParser.find_int(r"Rx-bps:\s+(\d+)")) > + > + #: > + tx_pps: int = field(metadata=TextParser.find_int(r"Tx-pps:\s+(\d+)")) > + #: > + tx_bps: int = field(metadata=TextParser.find_int(r"Tx-bps:\s+(\d+)")) > + > + > class TestPmdShell(InteractiveShell): > """Testpmd interactive shell. > > @@ -713,6 +749,38 @@ def show_port_info(self, port_id: int) -> TestPmdPort: > > return TestPmdPort.parse(output) > > + def show_port_stats_all(self) -> list[TestPmdPortStats]: > + """Returns the statistics of all the ports.""" Missing the Returns: section. > + output = 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 = re.finditer(r"(^ #*.+#*$[^#]+)^ #*$", output, re.MULTILINE) > + 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. > + """ Missing the Returns: section. > + output = self.send_command(f"show port stats {port_id}", skip_first_line=True) > + 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", "")