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 BF1C84571D; Fri, 2 Aug 2024 19:29:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A79B41611; Fri, 2 Aug 2024 19:29:49 +0200 (CEST) Received: from mail-il1-f225.google.com (mail-il1-f225.google.com [209.85.166.225]) by mails.dpdk.org (Postfix) with ESMTP id 4D6E741140 for ; Fri, 2 Aug 2024 19:29:47 +0200 (CEST) Received: by mail-il1-f225.google.com with SMTP id e9e14a558f8ab-39641271f2aso31668145ab.3 for ; Fri, 02 Aug 2024 10:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722619786; x=1723224586; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TziWeXgDqztnVyfy/Ciy40+koID74k2N+8xT70K8mLo=; b=YgYJBbPGIoTMMPTwuCrYjOqFVBXkamgrb2ExHaTCQj8iZXEGjAFiCOaTBAEfdPbvuM xhpdJHESo9lFblwYf4q9aTXt+lm46zkM+DcNApqXz41CvI3Fzp4HnodP1kfFTiN4IJcF anNbb1mF5Ab5OJTqYI9GMhWVQhZduQhb2hHJk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722619786; x=1723224586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TziWeXgDqztnVyfy/Ciy40+koID74k2N+8xT70K8mLo=; b=XbMjPIBk824tIxwypd8bD1yBcIzysPHFfsB6khS3xf+GwYQ4G6WilaglZUc07aF+57 Fhu+/DBoi+TSxgvJiDVz1o+77KOybXTx8WkLvQ6bijQlhDwQEAOvFe4vM1BfHSE0adfV ZmADiKyBuwf9HKSX5BE4ehvCELwqHyV7tnNVZAUuu8ZkImAjyWb4AthEf+zyvcU08TYS 9dQSmF+c8APaSCEQgmJZIxKhjGYZ01IMBxiw8xYfr5Pp2aF6NiAJ06x3iPGT0d0NHIKT 6B4UuH84qjOYBCF6s2S8z9ov7TsBiFzE2r6B9eLF4ppsUK5tIVWEO58Eu62kvaHv7pKM eb0A== X-Gm-Message-State: AOJu0YwtwJLXA1bxkp28W1pw3txZx6b/06pOmiIfGZ7HWMhyJHxOnP/s PbKtnq/YnKUXF1NPcre9UP2qKBsQzd2U24aTEDFbuCkuhWDWVqEisoVM7lil9e/VyGbCDL4veqO r6Sf5rfroU0n2vxET8O842i69+vxXumm01GlBtDBWmyR/lIB1 X-Google-Smtp-Source: AGHT+IHJ8wlyL/dYDMIvcsgu9ihp6JlhldWEDedC7DRHCExDfwcPXlsNkIoEekUijEkZT60Ly16Lv4gaYFdf X-Received: by 2002:a92:d245:0:b0:374:9916:92 with SMTP id e9e14a558f8ab-39b1fbf93dcmr50160775ab.22.1722619786388; Fri, 02 Aug 2024 10:29:46 -0700 (PDT) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [2606:4100:3880:1234::84]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-39b20a97820sm1119925ab.44.2024.08.02.10.29.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Aug 2024 10:29:46 -0700 (PDT) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::1083]) by postal.iol.unh.edu (Postfix) with ESMTP id 86C7A605C351; Fri, 2 Aug 2024 13:29:45 -0400 (EDT) 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 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 Message-ID: <20240802172928.212277-2-jspewock@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802172928.212277-1-jspewock@iol.unh.edu> References: <20240802172928.212277-1-jspewock@iol.unh.edu> MIME-Version: 1.0 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 From: Jeremy Spewock 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 --- 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