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 2416A456A3; Fri, 26 Jul 2024 18:39:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C72842ECB; Fri, 26 Jul 2024 18:39:47 +0200 (CEST) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) by mails.dpdk.org (Postfix) with ESMTP id C6E5242EC5 for ; Fri, 26 Jul 2024 18:39:45 +0200 (CEST) Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-44feddaa266so323651cf.2 for ; Fri, 26 Jul 2024 09:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722011985; x=1722616785; 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=V8w6/+ibXdH2s7BaShXRJMVSNI3EhOMoCEocLd6+Qfc=; b=ABEDO/fFbp/ViVbAb3sNA+rxRN7SLn/2T31LNA+CD/BUW9IKWgA07EQpSS4bIcc3TS l8JYlQAz47wMkkrV/yd+XGX3HTKTbtXDQONVyn8KP2dbrCbkgQpnbO1H9BdBcqhvK7PS pNTbk9ClUZy6Gm0pjZUvP7apOF8Q++Df45nuE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722011985; x=1722616785; 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=V8w6/+ibXdH2s7BaShXRJMVSNI3EhOMoCEocLd6+Qfc=; b=r9Oza/mr5PrGAbIJyFm2zUhP/CqWqUw+z+nu2heuVqMb/s6Rhqv1j09YTqAIn2tBNY KRa0nVBscNJsjujoViKJ4vLQHVr8nNIuyHmbEVlq+8a7bjSnT7S3X1In2Cql6gZiIbgm XN1sxeMXtihWHTI4buXywuOAMiGSadtvnkL2ZIWjE4xRuxOuxaSOnt/doIKhyMPmp1WI sKAvBJ2l9bw7J+TR3Jhpu91MfQz2KI/8N5A5WWhF1rbGMKfX+6/ntNnwDrS7p22Gaay9 AUiJqKEMMeN+4dDMlct1NdrT7LpMSnTT4m14Bd9yP3Gh/uDb5sO1z1Amzhi+GYcBvHzN B90A== X-Gm-Message-State: AOJu0Yyg6p84xBaoYSyis+4XjtYUMsR4eA+n1nah2RS1pyeJtwXycgWt K4MDUd0m0f1AoB9O9ClKakZe139Yly7s1TAv31Ql5paI7kzbcy+qrJgMVeT6N+tFBtqyyOmYg7n g X-Google-Smtp-Source: AGHT+IEJZr6ld/yRWGcYbvXCIu5Rc7eIFJYCYakae5HzR2pIZ905xndm68GewjeHxJqzrQoIET6ECA== X-Received: by 2002:a05:620a:d96:b0:79e:fbbd:6631 with SMTP id af79cd13be357-7a1d6961716mr411587585a.5.1722011985094; Fri, 26 Jul 2024 09:39:45 -0700 (PDT) Received: from localhost.unh.edu ([2606:4100:3880:1257::1003]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d7398d3asm191961685a.7.2024.07.26.09.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 09:39:44 -0700 (PDT) From: Nicholas Pratte To: probb@iol.unh.edu, dmarx@iol.unh.edu, jspewock@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech Cc: dev@dpdk.org, Nicholas Pratte Subject: [PATCH v4 1/2] dts: add methods for setting mac and multicast addresses Date: Fri, 26 Jul 2024 12:39:15 -0400 Message-ID: <20240726163915.19277-3-npratte@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240702192422.2480-2-npratte@iol.unh.edu> References: <20240702192422.2480-2-npratte@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 New methods have been added to TestPMDShell in order to produce the mac filter's individual test cases: - set_mac_addr - set_multicast_mac_addr set_mac_addr and set_multicast_addr were created for the mac filter test suite, enabling users to both add or remove mac and multicast addresses based on a boolean 'add or remove' parameter. The success or failure of each call can be verified if a user deems it necessary. Bugzilla ID: 1454 Signed-off-by: Nicholas Pratte --- dts/framework/remote_session/testpmd_shell.py | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 8e5a1c084a..64ffb23439 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -765,6 +765,65 @@ def show_port_info(self, port_id: int) -> TestPmdPort: return TestPmdPort.parse(output) + def set_mac_addr(self, port_id: int, mac_address: str, add: bool, verify: bool = True) -> None: + """Add or remove a mac address on a given port's Allowlist. + + Args: + port_id: The port ID the mac address is set on. + mac_address: The mac address to be added or removed to the specified port. + add: If :data:`True`, add the specified mac address. If :data:`False`, remove specified + mac address. + verify: If :data:'True', assert that the 'mac_addr' operation was successful. If + :data:'False', run the command and skip this assertion. + + Raises: + InteractiveCommandExecutionError: If the set mac address operation fails. + """ + mac_cmd = "add" if add else "remove" + output = self.send_command(f"mac_addr {mac_cmd} {port_id} {mac_address}") + if "Bad arguments" in output: + self._logger.debug("Invalid argument provided to mac_addr") + raise InteractiveCommandExecutionError("Invalid argument provided") + + if verify: + if "mac_addr_cmd error:" in output: + self._logger.debug(f"Failed to {mac_cmd} {mac_address} on port {port_id}") + raise InteractiveCommandExecutionError( + f"Failed to {mac_cmd} {mac_address} on port {port_id} \n{output}" + ) + + def set_multicast_mac_addr( + self, port_id: int, multi_addr: str, add: bool, verify: bool = True + ) -> None: + """Add or remove multicast mac address to a specified port's filter. + + Args: + port_id: The port ID the multicast address is set on. + multi_addr: The multicast address to be added to the filter. + add: If :data:'True', add the specified multicast address to the port filter. + If :data:'False', remove the specified multicast address from the port filter. + verify: If :data:'True', assert that the 'mcast_addr' operations was successful. + If :data:'False', execute the 'mcast_addr' operation and skip the assertion. + + Raises: + InteractiveCommandExecutionError: If either the 'add' or 'remove' operations fails. + """ + mcast_cmd = "add" if add else "remove" + output = self.send_command(f"mcast_addr {mcast_cmd} {port_id} {multi_addr}") + if "Bad arguments" in output: + self._logger.debug("Invalid arguments provided to mcast_addr") + raise InteractiveCommandExecutionError("Invalid argument provided") + + if verify: + if ( + "Invalid multicast_addr" in output + or f'multicast address {"already" if add else "not"} filtered by port' in output + ): + self._logger.debug(f"Failed to {mcast_cmd} {multi_addr} on port {port_id}") + raise InteractiveCommandExecutionError( + f"Failed to {mcast_cmd} {multi_addr} on port {port_id} \n{output}" + ) + def show_port_stats_all(self) -> list[TestPmdPortStats]: """Returns the statistics of all the ports. -- 2.44.0