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 B38EC45492; Tue, 18 Jun 2024 17:21:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A04D410F2; Tue, 18 Jun 2024 17:21:46 +0200 (CEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mails.dpdk.org (Postfix) with ESMTP id 432B4410E6 for ; Tue, 18 Jun 2024 17:21:45 +0200 (CEST) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52bc335e49aso6307809e87.3 for ; Tue, 18 Jun 2024 08:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1718724104; x=1719328904; 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=MHb8h8j8jgniS++dpWfLhtvv3iL0bsiwhp4kmcOK+g8=; b=ZvtMnEpuL6LJupUjA1TniH9rhxuHECVYGRwigFdxTTG+yFVNA0i5ZTWP1OPnKAeUWc SF4EN4aIWExhb8YYTbnINDYipfcz/XUjfhV7EPCtw6s7A+RD28TafVPRJQtcRiX/ijCn fu0PBeRzl6BSdUM+cVhZTYZwQAOc1QviXiDpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718724104; x=1719328904; 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=MHb8h8j8jgniS++dpWfLhtvv3iL0bsiwhp4kmcOK+g8=; b=UWEYHzlxElQODOkjzCKhpypunm4kkkQdbL3fl/lrp2rchtCvIuiJTK3O5IIblwD+y6 dz09/H8Rz1CqEGqQApw4AxhTm+v8S8lMbjW2ytew45dwwaP8f3x9KfafqLwHhqYVL+XI oqnjOxnMrty+KcX13tlNNEIuT1ElqeHnyYkNpJP+di7tHaQ4V4a8jPN8H167lj9DT8wx bqWLYqA+yDH5PmwckLz3TW0bugzyN2sXt1gg2hJNthNN/7erQGfNaHuz+XIHudmcLNll eHBwjaLAaVX46E2Zl2SgWd0gUUMOMTRYr3K0YUV+ZXdw7NklwzK45/C0pEbYzGmCckQc 14aA== X-Gm-Message-State: AOJu0YxYQFWmvndPwNIQP6tnGQbTyLkL4dHp2rTWts8yypH9VHYcjSpO DRvcUXe+lZ9qno6ZlZhk/z4/DEuPRsFJMaXelUim2pCd14e9NrrhEJUuRjPE59s= X-Google-Smtp-Source: AGHT+IHc/zglNM27TH4oQycsfXlfMl5+NhYGXMH2LkeTztr/lKCjb9mc2d+tqx0g04s/B6sFD+9B1w== X-Received: by 2002:a05:6512:3ca4:b0:52c:8339:d09b with SMTP id 2adb3069b0e04-52ca6e55096mr9851713e87.1.1718724104474; Tue, 18 Jun 2024 08:21:44 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1210:52ef:3eaf:5f1e:6f6a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3607509c9absm14348420f8f.46.2024.06.18.08.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 08:21:43 -0700 (PDT) From: Dean Marx To: Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech, probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com, jspewock@iol.unh.edu, bruce.richardson@intel.com, luca.vizzarro@arm.com Cc: dev@dpdk.org, Dean Marx Subject: [PATCH v4 2/3] dts: updated testpmd shell class Date: Tue, 18 Jun 2024 11:20:52 -0400 Message-ID: <20240618152053.30723-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240618152053.30723-1-dmarx@iol.unh.edu> References: <20240614150238.26374-1-dmarx@iol.unh.edu> <20240618152053.30723-1-dmarx@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 Ported over the promisc and verbose mode functions from v2 of the queue start/stop suite to use for the VLAN suite. Tweaked some of the verification methods to be more concise, changed some docstrings to be more specific. Signed-off-by: Dean Marx --- dts/framework/remote_session/testpmd_shell.py | 186 +++++++++++++----- 1 file changed, 141 insertions(+), 45 deletions(-) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 5bbc7d3b1c..aad3a3a448 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -225,7 +225,7 @@ def set_forward_mode(self, mode: TestPmdForwardingModes, verify: bool = True): f"Test pmd failed to set fwd mode to {mode.value}" ) - def vlan_filter_set_on(self, port: int = 0, verify: bool = True): + def vlan_filter_set_on(self, port: int, verify: bool = True): """Set vlan filter on. Args: @@ -240,11 +240,11 @@ def vlan_filter_set_on(self, port: int = 0, verify: bool = True): """ filter_cmd_output = self.send_command(f"vlan set filter on {port}") if verify: - if "Invalid port" in filter_cmd_output: - self._logger.debug(f"Failed to enable vlan filter: \n{filter_cmd_output}") - raise InteractiveCommandExecutionError("Testpmd failed to enable vlan filter.") + if "Invalid port" in filter_cmd_output or "filter: on" not in self.send_command(f"show port info {port}"): + self._logger.debug(f"Failed to enable vlan filter on port {port}: \n{filter_cmd_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to enable vlan filter on port {port}.") - def vlan_filter_set_off(self, port: int = 0, verify: bool = True): + def vlan_filter_set_off(self, port: int, verify: bool = True): """Set vlan filter off. Args: @@ -259,31 +259,31 @@ def vlan_filter_set_off(self, port: int = 0, verify: bool = True): """ filter_cmd_output = self.send_command(f"vlan set filter off {port}") if verify: - if "Invalid port" in filter_cmd_output: - self._logger.debug(f"Failed to disable vlan filter: \n{filter_cmd_output}") - raise InteractiveCommandExecutionError("Testpmd failed to disable vlan filter.") + if "Invalid port" in filter_cmd_output or "filter: off" not in self.send_command(f"show port info {port}"): + self._logger.debug(f"Failed to disable vlan filter on port {port}: \n{filter_cmd_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to disable vlan filter on port {port}.") - def rx_vlan_add(self, vlan: int = 0, port: int = 0, verify: bool = True): + def rx_vlan_add(self, vlan: int, port: int, verify: bool = True): """Add specified vlan tag to the filter list on a port. Args: - vlan: The vlan tag to add, should be within 1-4094. + vlan: The vlan tag to add, should be within 1-1005, 1-4094 extended. port: The port number to add the tag on, should be within 0-32. verify: If :data:`True`, the output of the command is scanned to verify that the vlan tag was added to the filter list on the specified port. If not, it is considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter - fails to update. + InteractiveCommandExecutionError: If `verify` is :data:`True` and the tag + is not added. """ vlan_add_output = self.send_command(f"rx_vlan add {vlan} {port}") if verify: if "VLAN-filtering disabled" in vlan_add_output or "Invalid vlan_id" in vlan_add_output: - self._logger.debug(f"Failed to add vlan tag: \n{vlan_add_output}") - raise InteractiveCommandExecutionError("Testpmd failed to add vlan tag.") + self._logger.debug(f"Failed to add vlan tag {vlan} on port {port}: \n{vlan_add_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to add vlan tag {vlan} on port {port}.") - def rx_vlan_rm(self, vlan: int = 0, port: int = 0, verify: bool = True): + def rx_vlan_rm(self, vlan: int, port: int, verify: bool = True): """Remove specified vlan tag from filter list on a port. Args: @@ -294,16 +294,16 @@ def rx_vlan_rm(self, vlan: int = 0, port: int = 0, verify: bool = True): considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter - fails to update. + InteractiveCommandExecutionError: If `verify` is :data:`True` and the tag + is not removed. """ vlan_rm_output = self.send_command(f"rx_vlan rm {vlan} {port}") if verify: if "VLAN-filtering disabled" in vlan_rm_output or "Invalid vlan_id" in vlan_rm_output: - self._logger.debug(f"Failed to add vlan tag: \n{vlan_rm_output}") - raise InteractiveCommandExecutionError("Testpmd failed to add vlan tag.") + self._logger.debug(f"Failed to remove vlan tag {vlan} on port {port}: \n{vlan_rm_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to remove vlan tag {vlan} on port {port}.") - def vlan_strip_set_on(self, port: int = 0, verify: bool = True): + def vlan_strip_set_on(self, port: int, verify: bool = True): """Enable vlan stripping on the specified port. Args: @@ -313,16 +313,16 @@ def vlan_strip_set_on(self, port: int = 0, verify: bool = True): considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + InteractiveCommandExecutionError: If `verify` is :data:`True` and stripping fails to update. """ vlan_strip_output = self.send_command(f"vlan set strip on {port}") if verify: - if "Invalid port" in vlan_strip_output: - self._logger.debug(f"Failed to add vlan tag: \n{vlan_strip_output}") - raise InteractiveCommandExecutionError("Testpmd failed to add vlan tag.") + if "strip on" not in self.send_command(f"show port info {port}"): + self._logger.debug(f"Failed to set vlan filter on for port {port}: \n{vlan_strip_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to set vlan filter on for port {port}.") - def vlan_strip_set_off(self, port: int = 0, verify: bool = True): + def vlan_strip_set_off(self, port: int, verify: bool = True): """Disable vlan stripping on the specified port. Args: @@ -332,24 +332,71 @@ def vlan_strip_set_off(self, port: int = 0, verify: bool = True): considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + InteractiveCommandExecutionError: If `verify` is :data:`True` and stripping fails to update. """ vlan_strip_output = self.send_command(f"vlan set strip off {port}") if verify: - if "Invalid port" in vlan_strip_output: - self._logger.debug(f"Failed to enable stripping: \n{vlan_strip_output}") - raise InteractiveCommandExecutionError(f"Testpmd failed to enable stripping on port {port}.") + if "strip off" not in self.send_command(f"show port info {port}"): + self._logger.debug(f"Failed to disable vlan stripping on port {port}: \n{vlan_strip_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to disable vlan stripping on port {port}.") - def port_stop_all(self): - """Stop all ports.""" - self.send_command("port stop all") + def port_stop_all(self, verify: bool = True): + """Stop all ports. - def port_start_all(self): - """Start all ports.""" - self.send_command("port start all") + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and all ports + fail to stop.""" + port_output = self.send_command("port stop all") + if verify: + if "Done" not in port_output: + self._logger.debug(f"Failed to stop all ports: \n{port_output}") + raise InteractiveCommandExecutionError("Testpmd failed to stop all ports.") + + def port_stop(self, port: int, verify: bool = True): + """Stop all ports. - def tx_vlan_set(self, port: int = 0, vlan: int = 0, verify: bool = True): + Args: + port: specifies the port number to use, must be between 0-32 + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the port + is not stopped.""" + port_output = self.send_command(f"port stop {port}") + if verify: + if "Done" not in port_output: + self._logger.debug(f"Failed to stop port {port}: \n{port_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to stop port {port}.") + + def port_start_all(self, verify: bool = True): + """Start all ports. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and all ports + fail to start.""" + port_output = self.send_command("port start all") + if verify: + if "Done" not in port_output: + self._logger.debug(f"Failed to start all ports: \n{port_output}") + raise InteractiveCommandExecutionError("Testpmd failed to start all ports.") + + def port_start(self, port: int, verify: bool = True): + """Stop all ports. + + Args: + port: specifies the port number to use, must be between 0-32 + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the port + is not started.""" + port_output = self.send_command(f"port start {port}") + if verify: + if "Done" not in port_output: + self._logger.debug(f"Failed to start port {port}: \n{port_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to start port {port}.") + + + def tx_vlan_set(self, port: int, vlan: int, verify: bool = True): """Set hardware insertion of vlan tags in packets sent on a port. Args: @@ -360,17 +407,17 @@ def tx_vlan_set(self, port: int = 0, vlan: int = 0, verify: bool = True): considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter - fails to update. + InteractiveCommandExecutionError: If `verify` is :data:`True` and the insertion + tag is not set. """ vlan_insert_output = self.send_command(f"tx_vlan set {port} {vlan}") if verify: if ("Please stop port" in vlan_insert_output or "Invalid vlan_id" in vlan_insert_output or "Invalid port" in vlan_insert_output): - self._logger.debug(f"Failed to set vlan insertion tag: \n{vlan_insert_output}") - raise InteractiveCommandExecutionError("Testpmd failed to set vlan insertion tag.") + self._logger.debug(f"Failed to set vlan insertion tag {vlan} on port {port}: \n{vlan_insert_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to set vlan insertion tag {vlan} on port {port}.") - def tx_vlan_reset(self, port: int = 0, verify: bool = True): + def tx_vlan_reset(self, port: int, verify: bool = True): """Disable hardware insertion of vlan tags in packets sent on a port. Args: @@ -380,14 +427,63 @@ def tx_vlan_reset(self, port: int = 0, verify: bool = True): considered an error. Raises: - InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter - fails to update. + InteractiveCommandExecutionError: If `verify` is :data:`True` and the insertion + tag is not reset. """ vlan_insert_output = self.send_command(f"tx_vlan set {port}") if verify: if "Please stop port" in vlan_insert_output or "Invalid port" in vlan_insert_output: - self._logger.debug(f"Failed to reset vlan insertion: \n{vlan_insert_output}") - raise InteractiveCommandExecutionError("Testpmd failed to reset vlan insertion.") + self._logger.debug(f"Failed to reset vlan insertion on port {port}: \n{vlan_insert_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to reset vlan insertion on port {port}.") + + def set_promisc(self, port: int, on: bool, verify: bool = True): + """Turns promiscuous mode on/off for the specified port + + Args: + port: port number to use, should be within 0-32. + on: if :data:`True`, turn promisc mode on, otherwise turn off. + verify: if :data:`True` an additional command will be sent to verify that promisc mode + is properly set. Defaults to :data:`True`. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and promisc mode + is not correctly set. + """ + if on: + promisc_output = self.send_command(f"set promisc {port} on") + else: + promisc_output = self.send_command(f"set promisc {port} off") + if verify: + if (on and "Promiscuous mode: enabled" not in + self.send_command(f"show port info {port}")): + self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to set promisc mode on port {port}.") + elif (not on and "Promiscuous mode: disabled" not in + self.send_command(f"show port info {port}")): + self._logger.debug(f"Failed to set promisc mode on port {port}: \n{promisc_output}") + raise InteractiveCommandExecutionError(f"Testpmd failed to set promisc mode on port {port}.") + + + def set_verbose(self, level: int, verify: bool = True): + """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`.""" -- 2.44.0