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 CB7B24577B; Fri, 9 Aug 2024 19:23:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A228642E6D; Fri, 9 Aug 2024 19:23:32 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id C1B1642DE9 for ; Fri, 9 Aug 2024 19:23:31 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2cd48ad7f0dso1893809a91.0 for ; Fri, 09 Aug 2024 10:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1723224211; x=1723829011; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jHrFJ81MfYWm9OyncdsCVcjn+HviGPWI8GIBBM0ZVgQ=; b=KvXtI4lEP406WWvlFcz0Ahhz2QAnQuf02+r984UfTqWTnvXzPS4k3Nf8AXcKLO4TxH mZ4b2Y79vn3+GQCpg70TekS3hf9ERvL7ESRTrngCJm8j1gt3gHmFGmGsQus7mlYd7WNC xmLWi1eRXJBhwXM/xjliK2NhmjLJuLEFJiL1M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723224211; x=1723829011; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jHrFJ81MfYWm9OyncdsCVcjn+HviGPWI8GIBBM0ZVgQ=; b=NWdeNV7bkK1A75GPb/tLMSfSR9SeGo9U+s3AooP7HA9RxiuQgBPNBUHJc8atvceLNM EWpgWRuY3VUFJSJGdnNWAUSS8zNJtrJGn5PE0aDl/SxXm4rSD4ufusGK/t7/tXYD0ox7 4cNPAAIwQu0PDYLbANIlt6UWMnWnA/0gYcHxU48ojgAXF89d6qi+Ul+hWcjMH7lQohNd ijb7l4NrQrxUT+pA/43NzX/yaX35i9l0pHfmgAXbbnaRqWniOIHPvRf+4lMzQaDZzP/T PBCMwCmGlhdu0z8nhRx0jzGzyIm1az7j2nPqTf3e4e3V8gFCXiA65Q6t6j9x43lwLW8/ oZjw== X-Forwarded-Encrypted: i=1; AJvYcCW7njxwTaa7aWqU/Wb+mEXEu0nzaH9TKYOY2K9HwsQNc03Z/7E/j2vogmYuk+3t30nWPRqNnPZGDEFwBqQ= X-Gm-Message-State: AOJu0YxnAKuVyc9fithCJ8yjP5P9f9AY4ZXz0igfFyGvHBOCL7XxOrz7 GraxzWFHHImBBRBSAsNaY8IPC4Svj1aLDwu0pn1158wESMoiYx6xq1fMybuTO3DpQmeWw8Xht55 jNGTmSg9EMe5Ag4lpEg5nxyfQ2XpTRaaZCcXPeQ== X-Google-Smtp-Source: AGHT+IFZ73Q/cry74zaKNR6kAqCyTbl2q2dWJ0W6omUqpsWlpsFNUuhGon7OLPoou+u1W4gRDzgjkO7pKklA6gBtDKI= X-Received: by 2002:a17:90b:2390:b0:2ca:d1dc:47e2 with SMTP id 98e67ed59e1d1-2d1e804a8famr2404067a91.33.1723224210604; Fri, 09 Aug 2024 10:23:30 -0700 (PDT) MIME-Version: 1.0 References: <20240724163004.5681-1-dmarx@iol.unh.edu> <20240807194341.26102-1-dmarx@iol.unh.edu> <20240807194341.26102-2-dmarx@iol.unh.edu> In-Reply-To: <20240807194341.26102-2-dmarx@iol.unh.edu> From: Jeremy Spewock Date: Fri, 9 Aug 2024 13:23:19 -0400 Message-ID: Subject: Re: [PATCH v13 1/2] dts: add VLAN methods to testpmd shell To: Dean Marx Cc: probb@iol.unh.edu, npratte@iol.unh.edu, luca.vizzarro@arm.com, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, paul.szczepanek@arm.com, juraj.linkes@pantheon.tech, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Aug 7, 2024 at 3:43=E2=80=AFPM Dean Marx wrote: > > added the following methods to testpmd shell class: > vlan set filter on/off, rx vlan add/rm, > vlan set strip on/off, port stop/start all/port, > tx vlan set/reset, set promisc/verbose > > fixed bug in vlan_offload for > show port info, removed $ at end of regex > > Signed-off-by: Dean Marx > --- > > + def vlan_filter_set(self, port: int, on: bool, verify: bool =3D True= ) -> None: > + """Set vlan filter on. > + > + Args: > + port: The port number to enable VLAN filter on, should be wi= thin 0-32. > + on: Sets filter on if :data:`True`, otherwise turns off. > + verify: If :data:`True`, the output of the command and show = port info > + is scanned to verify that vlan filtering was enabled suc= cessfully. > + If not, it is considered an error. > + > + Raises: > + InteractiveCommandExecutionError: If `verify` is :data:`True= ` and the filter > + fails to update. > + """ > + filter_cmd_output =3D self.send_command(f"vlan set filter {'on' = if on else 'off'} {port}") > + if verify: > + if on ^ ("FILTER" in str(self.show_port_info(port_id=3Dport)= .vlan_offload)): I still think that we should avoid comparing strings here. > + self._logger.debug(f"Failed to set filter on port {port}= : \n{filter_cmd_output}") > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to set VLAN filter on port {port}." > + ) > + > + def rx_vlan(self, vlan: int, port: int, add: bool, verify: bool =3D = True) -> None: > + """Add specified vlan tag to the filter list on a port. > + > + Args: > + vlan: The vlan tag to add, should be within 1-1005, 1-4094 e= xtended. > + port: The port number to add the tag on, should be within 0-= 32. > + add: adds the tag if :data:`True`, otherwise removes tag. "adds" here should be capitalized > + verify: If :data:`True`, the output of the command is scanne= d to verify that > + the vlan tag was added to the filter list on the specifi= ed port. If not, it is > + considered an error. > + > + Raises: > + InteractiveCommandExecutionError: If `verify` is :data:`True= ` and the tag > + is not added. > + """ > + rx_output =3D self.send_command(f"rx_vlan {'add' if add else 'rm= '} {vlan} {port}") > + if verify: > + if ( > + "VLAN-filtering disabled" in rx_output > + or "Invalid vlan_id" in rx_output > + or "Bad arguments" in rx_output > + ): > + self._logger.debug( > + f"Failed to {'add' if add else 'remove'} tag {vlan} = port {port}: \n{rx_output}" > + ) > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to {'add' if add else 'remove'} tag= {vlan} on port {port}." > + ) > + > + def vlan_strip_set(self, port: int, on: bool, verify: bool =3D True)= -> None: > + """Enable vlan stripping on the specified port. > + > + Args: > + port: The port number to use, should be within 0-32. > + on: If :data:`True`, will turn strip on, otherwise will turn= off. > + 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. > + """ > + strip_output =3D self.send_command(f"vlan set strip {'on' if on = else 'off'} {port}") > + if verify: > + if on ^ ("STRIP" in str(self.show_port_info(port_id=3Dport).= vlan_offload)): Same thing here, we should probably compare the flag values rather than str= ings. > + self._logger.debug( > + f"Failed to set strip {'on' if on else 'off'} port {= port}: \n{strip_output}" > + ) > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to set strip {'on' if on else 'off'= } port {port}." > + ) > + > + def port_stop_all(self, verify: bool =3D True) -> None: > + """Stop all ports. > + > + Args: > + port: Specifies the port number to use, must be between 0-32= . This method no longer has a port parameter, so it would probably be better to remove this. > + verify: If :data:`True`, the output of the command is scanne= d > + to ensure all ports are stopped. If not, it is considere= d an error. > + > + Raises: > + InteractiveCommandExecutionError: If `verify` is :data:`True= ` and all ports > + fail to stop. > + """ > + port_output =3D 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_o= utput}") > + raise InteractiveCommandExecutionError("Testpmd failed t= o stop all ports.") > + > + > + def port_start_all(self, verify: bool =3D True) -> None: > + """Start all ports. > + > + Args: > + port: Specifies the port number to use, must be between 0-32= . This method also does not have a port parameter. > + verify: If :data:`True`, the output of the command is scanne= d > + to ensure all ports are started. If not, it is considere= d an error. > + > + Raises: > + InteractiveCommandExecutionError: If `verify` is :data:`True= ` and all ports > + fail to start. It's probably better to indent this just to make it more clear that it is a continuation line. > + """ > + port_output =3D 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 t= o start all ports.") > + > + def tx_vlan_reset(self, port: int, verify: bool =3D True) -> None: > + """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 scanne= d to verify that > + vlan insertion was disabled on the specified port. If no= t, it is > + considered an error. > + > + Raises: > + InteractiveCommandExecutionError: If `verify` is :data:`True= ` and the insertion > + tag is not reset. > + """ > + vlan_insert_output =3D self.send_command(f"tx_vlan set {port}") I think this is the incorrect command, when I tried to use this in a test suite it was throwing errors. > + 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 on port {port}: \n{= vlan_insert_output}" > + ) > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to reset vlan insertion on port {po= rt}." > + ) > + > -- > 2.44.0 >