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 DB9B345743; Mon, 5 Aug 2024 19:13:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8EA740658; Mon, 5 Aug 2024 19:13:16 +0200 (CEST) Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by mails.dpdk.org (Postfix) with ESMTP id 2AB8840653 for ; Mon, 5 Aug 2024 19:13:15 +0200 (CEST) Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-79f1d21d024so305085a.0 for ; Mon, 05 Aug 2024 10:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722877994; x=1723482794; 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=XeQq5yudRGPbSutyFLx+JbyWLaRJOI32TmfoSXqvL2Y=; b=Ft2Nx0/G3efUHSPOdzLrCDBmwW3El4On/Z9KfuhBwwLHlbyb8bpl7hNuuOEIBrYknT SqK9XOyXQnKPtz6gVqCjqcidJ7Wg+WU22GydOWzszM4OMbHEUI6VUSZN508oOrRbOllF dpL6uerqKQn7yN/NG/h5kPu5sFVd0HrtHS31Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722877994; x=1723482794; 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=XeQq5yudRGPbSutyFLx+JbyWLaRJOI32TmfoSXqvL2Y=; b=mwxAZJlyvZRgqZRu2xWIfgXDAUWmkMqgRKtrZ2gBEzys6FKC4kNEZ0zuM8WXotLfb9 mCsLPZDLvvKn1dPUTr6q/GobVZUsLcF3Wwkj5vDnpD+RkHuCeqELND7HPnBVRiFyB/sY 1zSHiUHr3WuWemwX1EShl9shymb1osB1AIoKdXyqIhQ9rjRTQ212AlZXCSYor617Qd4y mxElUCGuvfQ7T8/N7c6DW7Cif+QWh+kZ6Z4J+Iu19QncRJqSD3MCLCAf1oEUQ4WW0XaS MxVKob1sQ8+uKl8WpBp7dZXfOpLNxOIP0GNz0hobFuR+5QtXlscjH59mjeuXa3TIVcUG rEpQ== X-Gm-Message-State: AOJu0YzXHY+sXcVVuFlUUtwlylbhea8BoMem8b1uY7BRkefHGHvn247r Z84o0GhausSy5fHzi27O7nFn8h44n05uo/J5U8C9V6PllW9auw3p5v7yCOTPsk0= X-Google-Smtp-Source: AGHT+IHS6jQXOmJQaBXgKM4TxGgDhdsZa3FYMCm6k/hj2gL04hEjhcC+7sjuIAIHa5qlsH5umSnkiA== X-Received: by 2002:a05:622a:14d:b0:444:f51d:64e5 with SMTP id d75a77b69052e-4518923b889mr82544231cf.3.1722877994486; Mon, 05 Aug 2024 10:13:14 -0700 (PDT) Received: from localhost.unh.edu ([2606:4100:3880:1271:e2f8:4ec3:8bf3:864c]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4519ed14bf8sm19517331cf.3.2024.08.05.10.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 10:13:14 -0700 (PDT) From: Nicholas Pratte To: Honnappa.Nagarahalli@arm.com, yoan.picchi@foss.arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech, luca.vizzarro@arm.com, probb@iol.unh.edu, dmarx@iol.unh.edu, jspewock@iol.unh.edu Cc: dev@dpdk.org, Nicholas Pratte Subject: [RFC v1 1/2] dts: add additional vlan configuration to testpmd shell class Date: Mon, 5 Aug 2024 13:12:45 -0400 Message-ID: <20240805171246.18580-2-npratte@iol.unh.edu> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240805171246.18580-1-npratte@iol.unh.edu> References: <20240805171246.18580-1-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 The ethertype test suite requires many different internal runtime vlan offload options to test ethertype configuration. The following patch adds a new RxVlanOffloadOptions class that contains all the different vlan configuration options available within testpmd. Additionally, an extra method has beena added to adjust both the inner and outer tpids of ingressing and egressing packets. Bugzilla ID: 1505 Signed-off-by: Nicholas Pratte --- dts/framework/remote_session/testpmd_shell.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 288be9a085..268e34f0eb 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -70,6 +70,10 @@ class VLANOffloadFlag(Flag): #: QINQ_STRIP = auto() + def __str__(self): + """Return flag name when cast to a string.""" + return self.name + @classmethod def from_str_dict(cls, d): """Makes an instance from a dict containing the flag member names with an "on" value. @@ -915,6 +919,26 @@ def show_port_stats_all(self) -> list[TestPmdPortStats]: iter = re.finditer(r"(^ #*.+#*$[^#]+)^ #*\r$", output, re.MULTILINE) return [TestPmdPortStats.parse(block.group(1)) for block in iter] + def set_vlan_tpid(self, port_id: int, tpid: int, inner_id: bool) -> None: + """Set ethertype tpid values using the ethdev api. + + Args: + port_id: the ID of the port the tpid is being changed on. + tpid: The tpid value being changed on the port. + inner_id: If :data:`True`, set the inner tpid to the specified value. If + :data:`False`, change the outer tpid to the specified value. + + Raises: + InteractiveCommandExecutionError: If either `port_id` or `tpid` value is invalid. + """ + if tpid < 0 or tpid > 65535: + raise InteractiveCommandExecutionError("Invalid TPID value given.") + output = self.send_command( + f'vlan set {"inner" if inner_id else "outer"} tpid {tpid} {port_id}' + ) + if output.startswith("Invalid port"): + raise InteractiveCommandExecutionError(f"Invalid port ID {port_id} given.") + def show_port_stats(self, port_id: int) -> TestPmdPortStats: """Returns the given port statistics. @@ -978,6 +1002,37 @@ def rx_vlan(self, vlan: int, port: int, add: bool, verify: bool = True) -> None: f"Testpmd failed to {'add' if add else 'remove'} tag {vlan} on port {port}." ) + def set_vlan_offload_option( + self, port: int, offload_option: VLANOffloadFlag, on: bool, verify: bool = True + ) -> None: + """Enable extended vlans on the specified port. + + Args: + port: The port number to use, should be within 0-32. + on: If :data:`True`, extended vlan turn on, otherwise it turns off. + offload_options: The rx vlan offload option to be set. + verify: If :data:`True`, the output of the command and show port info + 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 stripping + fails to update. + """ + offload_output = self.send_command( + f"vlan set {str(offload_option).lower()} {'on' if on else 'off'} {port}" + ) + if verify: + if on ^ (str(offload_option) in str(self.show_port_info(port_id=port).vlan_offload)): + self._logger.debug( + f"""Failed to set {offload_option} {'on' if on else 'off'} port {port}: + \n{offload_output} + """ + ) + raise InteractiveCommandExecutionError( + f"Testpmd failed to set {offload_option} {'on' if on else 'off'} port {port}." + ) + def port_stop_all(self, verify: bool = True) -> None: """Stop all ports. -- 2.44.0