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 7C4004545E; Fri, 14 Jun 2024 17:03:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5528241149; Fri, 14 Jun 2024 17:03:53 +0200 (CEST) Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by mails.dpdk.org (Postfix) with ESMTP id 8BF884042C for ; Fri, 14 Jun 2024 17:03:51 +0200 (CEST) Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7955dfce860so145993085a.2 for ; Fri, 14 Jun 2024 08:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1718377431; x=1718982231; 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=qHcylJKNYSynqsHtvyI/1F5/tr3LKfj+iFP4N3CDDo8=; b=TowryZs1K1cr/m/hoqfMqdNHMLMh0M7HVfCTR+RtrlFV9KJg1D+/65/7CUHQVRpyVJ 0FqjsYFnHWPVoFoREMLIBViWlLLacGrpk5A/zqxtcTRUszSpdJIyrXpVtCL7gRtZPMTe TaNcuupBxJbAomtkFI4s5zWYOjWEJF6a4nC8k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718377431; x=1718982231; 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=qHcylJKNYSynqsHtvyI/1F5/tr3LKfj+iFP4N3CDDo8=; b=RxYgqHiCUsPPaT4GjF3ygy8eok9bv3BDjI7B6GfhxcizFllTc5zn9saHutwdxSWxfc 6PGNQAci2f00CoW5jwIpTBV5SopNMqO2et7NtyxnRxtsJF6XuDnOZO52WR9Yw3RLgDP7 Y1vfNV5Eizbcqo/ztloNrwtlYJjPn2Ckk9OzT8q00tg9nhojF1E4Aoyi4kwNkUdnNSu5 jm5vlUpaTz+QR/iFMXdAevnTF8FqOYLN7/X1DgOppWMMTwusN0STWDn+6WiycfWmxQRb 8vCI+0fkQhCAKn3KraNSpYzagyUqiGDVMQegHAoYK5OLX+UuFv3EDKQnF/lu9ZHNqpUR q+gw== X-Gm-Message-State: AOJu0Yz3yP6xXcTj4RUD3tEXJrwX7H+u7X4PFKF3Q3XYTcC4KuJrntJ3 +L6yQa6OGMtjUO/GsJDZTL6EPTVuhacV/Kh4od8b+EYBmy4HCcq/CgBBZHMqrKZq62dgkYY3WBm t X-Google-Smtp-Source: AGHT+IEzXut1NFlIzlig+/ROb5WY3oGsL2c0yIRi4jjBFsKmKpGjrzEjAH/RImCbuDv65DpcrgyXgw== X-Received: by 2002:a05:620a:4509:b0:795:4c3c:c3be with SMTP id af79cd13be357-798d2591ffdmr294334485a.53.1718377430575; Fri, 14 Jun 2024 08:03:50 -0700 (PDT) Received: from dean-laptop.iol.unh.edu ([2606:4100:3880:1271:f9bd:24da:464d:6294]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44212efe609sm12966671cf.52.2024.06.14.08.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:03:50 -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 v3 1/3] Added VLAN commands to testpmd_shell class Date: Fri, 14 Jun 2024 11:02:36 -0400 Message-ID: <20240614150238.26374-2-dmarx@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240614150238.26374-1-dmarx@iol.unh.edu> References: <20240611161606.23881-2-dmarx@iol.unh.edu> <20240614150238.26374-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 The testpmd_shell class is intended for sending commands to a remote testpmd session within a test suite, and as of right now it is missing most commands. Added commands for vlan filtering, stripping, and insertion, as well as stopping and starting ports during testpmd runtime. Signed-off-by: Dean Marx --- dts/framework/remote_session/testpmd_shell.py | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index cb2ab6bd00..5bbc7d3b1c 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -225,6 +225,170 @@ 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): + """Set vlan filter on. + + Args: + port: The port number to use, should be within 0-32. + verify: If :data:`True`, the output of the command is scanned to verify that + vlan filtering was enabled successfully. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + fails to update. + """ + 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.") + + def vlan_filter_set_off(self, port: int = 0, verify: bool = True): + """Set vlan filter off. + + Args: + port: The port number to use, should be within 0-32. + verify: If :data:`True`, the output of the command is scanned to verify that + vlan filtering was disabled successfully. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + fails to update. + """ + 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.") + + def rx_vlan_add(self, vlan: int = 0, port: int = 0, 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. + 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. + """ + 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.") + + def rx_vlan_rm(self, vlan: int = 0, port: int = 0, verify: bool = True): + """Remove specified vlan tag from filter list on a port. + + Args: + vlan: The vlan tag to remove, should be within 1-4094. + port: The port number to remove the tag from, should be within 0-32. + verify: If :data:`True`, the output of the command is scanned to verify that + the vlan tag was removed from 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. + """ + 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.") + + def vlan_strip_set_on(self, port: int = 0, verify: bool = True): + """Enable vlan stripping on the specified port. + + Args: + port: The port number to use, should be within 0-32. + verify: If :data:`True`, the output of the command is scanned to verify that + vlan stripping was enabled on the specified port. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + 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.") + + def vlan_strip_set_off(self, port: int = 0, verify: bool = True): + """Disable vlan stripping on the specified port. + + Args: + port: The port number to use, should be within 0-32 + verify: If :data:`True`, the output of the command is scanned to verify that + vlan stripping was disabled on the specified port. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + 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}.") + + def port_stop_all(self): + """Stop all ports.""" + self.send_command("port stop all") + + def port_start_all(self): + """Start all ports.""" + self.send_command("port start all") + + def tx_vlan_set(self, port: int = 0, vlan: int = 0, verify: bool = True): + """Set hardware insertion of vlan tags in packets sent on a port. + + Args: + port: The port number to use, should be within 0-32. + vlan: The vlan tag to insert, should be within 1-4094. + verify: If :data:`True`, the output of the command is scanned to verify that + vlan insertion was enabled on the specified port. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + fails to update. + """ + 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.") + + def tx_vlan_reset(self, port: int = 0, verify: bool = True): + """Disable hardware insertion of vlan tags in packets sent on a port. + + Args: + port: The port number to use, should be within 0-32. + verify: If :data:`True`, the output of the command is scanned to verify that + vlan insertion was disabled on the specified port. If not, it is + considered an error. + + Raises: + InteractiveCommandExecutionError: If `verify` is :data:`True` and the filter + fails to update. + """ + 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.") + def close(self) -> None: """Overrides :meth:`~.interactive_shell.close`.""" self.send_command("quit", "") -- 2.44.0