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 28DCD45681; Mon, 22 Jul 2024 15:09:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1816240431; Mon, 22 Jul 2024 15:09:13 +0200 (CEST) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 7118F40431 for ; Mon, 22 Jul 2024 15:09:11 +0200 (CEST) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2cb5787b4a5so2179780a91.2 for ; Mon, 22 Jul 2024 06:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1721653750; x=1722258550; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=G0ZzoUw0hB6j7EMuWfcIvL9vwTw7mzJI7bSQ2c86fAA=; b=VXVaKSq5rNLguCj6REwT8W4KB4cEmmDwguVMMcQm0zpFuHTQPCl2V7rDHG3B/LSH16 9FNVJhu+QojRy61hibKnNXaPk0rq/fjg+1+08QrfjKaH9vNIW3LeXy1A+Epy61SDpeUU dywvTzzGOnjD8oVc54HUV/5g53OfCQWHfFn90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721653750; x=1722258550; h=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=G0ZzoUw0hB6j7EMuWfcIvL9vwTw7mzJI7bSQ2c86fAA=; b=QBkYf6AyJMeMFZLCa0y2yeCAxhq/fLaCvwZaX93yK78R4ILMkgKduKidepDHx+7gJJ DRi9dwQVQudjG7rf3ihgX3Efqc2oMMhM0lte9jqozgPVmBur985JA6MfO+5SWzczCh1P ACvVdb0eL9EMzHu7esQMzTguazm3fI+q2diPujKGjHTll6fUKsSxLgrSIGHEoK19oC1W 9r3je6G77EeF8rzUlWuxdgetUGmYwFU+Gmg6WgRGSS46MhDk9j2ymoTSpPKAiiqv1erb P2+vEzJLeAYcwnkaKTwet+VXvjHvxxbzdYAu7wmEXpkhmc0szIhX28RO1Fej7i2WmGP/ eRSQ== X-Forwarded-Encrypted: i=1; AJvYcCVjsqCERwrn4i1xRl2dwwt/TK1wNjh/rQL5CNVS0O1ORSG/OvE2o6x/X7Cjr9dJ5iNUtPMC9igJ038dBrk= X-Gm-Message-State: AOJu0YyjiJAg/zuFyGIuPTAzQ5Hvzdx8IbRTT7Qy49waKAfovrOWsLW1 2fI6Xeo2xlajDUr9tdG2uvCm7tV6mmcRJ280K6Yyvze7X+W0E9iJ32HkBmafURPAUwdOMkb9fSk QM8eWYROb8OzGXQ7iqU217YFy9tLXl5cXzCmAbw== X-Google-Smtp-Source: AGHT+IHb65QLC5l/eDZRE2D6nzRq9ncTvsgEAivWhMetm+zx8PWjZwGJ3X3Lwc+XaBpO52uZjygN2iLnkinvopI8uCU= X-Received: by 2002:a17:90b:4f88:b0:2c9:81a2:e8da with SMTP id 98e67ed59e1d1-2cd274adee0mr2956710a91.35.1721653750592; Mon, 22 Jul 2024 06:09:10 -0700 (PDT) MIME-Version: 1.0 References: <20240702192422.2480-2-npratte@iol.unh.edu> <20240718190509.4203-1-npratte@iol.unh.edu> <20240718190509.4203-3-npratte@iol.unh.edu> In-Reply-To: <20240718190509.4203-3-npratte@iol.unh.edu> From: Dean Marx Date: Mon, 22 Jul 2024 09:08:54 -0400 Message-ID: Subject: Re: [PATCH v3 2/3] dts: add methods for setting mac and multicast addresses To: Nicholas Pratte Cc: probb@iol.unh.edu, paul.szczepanek@arm.com, luca.vizzarro@arm.com, jspewock@iol.unh.edu, Honnappa.Nagarahalli@arm.com, yoan.picchi@foss.arm.com, juraj.linkes@pantheon.tech, dev@dpdk.org Content-Type: multipart/alternative; boundary="0000000000003b2a22061dd5c050" 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 --0000000000003b2a22061dd5c050 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I think Jeremy already mentioned this but just make sure you update vlan_set_filter_on/off to the new version that has an on boolean arg. Reviewed-by: Dean Marx On Thu, Jul 18, 2024 at 3:12=E2=80=AFPM Nicholas Pratte wrote: > Several 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 > - rx_vlan_add > - rx_vlan_rm > - vlan_filter_set_on > - vlan_filter_set_off > - set_promisc > > 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. > > The other methods listed are implemented in other respective test > suites, and their implementations have been copied, but are subject to > change; they are not the focus of this patch. > > Bugzilla ID: 1454 > Signed-off-by: Nicholas Pratte > --- > dts/framework/remote_session/testpmd_shell.py | 179 ++++++++++++++++++ > 1 file changed, 179 insertions(+) > > diff --git a/dts/framework/remote_session/testpmd_shell.py > b/dts/framework/remote_session/testpmd_shell.py > index ec22f72221..8122457ad1 100644 > --- a/dts/framework/remote_session/testpmd_shell.py > +++ b/dts/framework/remote_session/testpmd_shell.py > @@ -767,6 +767,185 @@ 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 =3D 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' operatio= n > was successful. If > + :data:'False', run the command and skip this assertion. > + > + Raises: > + InteractiveCommandExecutionError: If the set mac address > operation fails. > + """ > + mac_cmd =3D "add" if add else "remove" > + output =3D 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} o= n > 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 =3D > 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 =3D "add" if add else "remove" > + output =3D 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 rx_vlan_add(self, vlan: int, port: int, 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 > 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 scanne= d > 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 tag > + is not added. > + """ > + vlan_add_output =3D 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 {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, port: int, verify: bool =3D True) -> > None: > + """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 scanne= d > 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 tag > + is not removed. > + """ > + vlan_rm_output =3D 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 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_filter_set_on(self, port: int, verify: bool =3D True) -> No= ne: > + """Set vlan filter on. > + > + Args: > + port: The port number to enable VLAN filter on, should be > within 0-32. > + verify: If :data:`True`, the output of the command and show > port info > + 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 =3D self.send_command(f"vlan set filter on > {port}") > + if verify: > + 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, verify: bool =3D True) -> N= one: > + """Set vlan filter off. > + > + Args: > + port: The port number to disable VLAN filter on, should be > within 0-32. > + verify: If :data:`True`, the output of the command and show > port info > + 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 =3D self.send_command(f"vlan set filter off > {port}") > + if verify: > + if "Invalid port" in filter_cmd_output or "filter off" not i= n > 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 set_promisc(self, port: int, on: bool, verify: bool =3D True) -> > None: > + """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 of= f. > + verify: If :data:`True` an additional command will be sent t= o > 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. > + """ > + promisc_output =3D self.send_command(f"set promisc {port} {'on' = if > on else 'off'}") > + if verify: > + stats =3D self.show_port_info(port_id=3Dport) > + if on ^ stats.is_promiscuous_mode_enabled: > + 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 show_port_stats_all(self) -> list[TestPmdPortStats]: > """Returns the statistics of all the ports. > > -- > 2.44.0 > > --0000000000003b2a22061dd5c050 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think Jeremy already mentioned this but just make sure y= ou update vlan_set_filter_on/off to the=C2=A0new=C2=A0version that has an on boolean arg.

Reviewed-= by: Dean Marx <dm= arx@iol.unh.edu>

On Thu, Jul 18, 2024 at 3:12=E2=80=AFPM Nicho= las Pratte <npratte@iol.unh.edu> wrote:
Se= veral new methods have been added to TestPMDShell in order to produce
the mac filter's individual test cases:
=C2=A0- set_mac_addr
=C2=A0- set_multicast_mac_addr
=C2=A0- rx_vlan_add
=C2=A0- rx_vlan_rm
=C2=A0- vlan_filter_set_on
=C2=A0- vlan_filter_set_off
=C2=A0- set_promisc

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.

The other methods listed are implemented in other respective test
suites, and their implementations have been copied, but are subject to
change; they are not the focus of this patch.

Bugzilla ID: 1454
Signed-off-by: Nicholas Pratte <
npratte@iol.unh.edu>
---
=C2=A0dts/framework/remote_session/testpmd_shell.py | 179 +++++++++++++++++= +
=C2=A01 file changed, 179 insertions(+)

diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/= remote_session/testpmd_shell.py
index ec22f72221..8122457ad1 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -767,6 +767,185 @@ def show_port_info(self, port_id: int) -> TestPmdP= ort:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return TestPmdPort.parse(output)

+=C2=A0 =C2=A0 def set_mac_addr(self, port_id: int, mac_address: str, add: = bool, verify: bool =3D True) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Add or remove a mac address = on a given port's Allowlist.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port_id: The port ID the mac add= ress is set on.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mac_address: The mac address to = be added or removed to the specified port.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 add: If :data:`True`, add the sp= ecified mac address. If :data:`False`, remove specified
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mac address.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:'True',= assert that the 'mac_addr' operation was successful. If
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :data:'False&#= 39;, run the command and skip this assertion.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If the set mac address operation fails.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 mac_cmd =3D "add" if add else "= remove"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 output =3D self.send_command(f"mac_addr {= mac_cmd} {port_id} {mac_address}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if "Bad arguments" in output:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug("Invalid= argument provided to mac_addr")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveCommandExecutio= nError("Invalid argument provided")
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "mac_addr_cmd error:&quo= t; in output:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (f"Failed to {mac_cmd} {mac_address} on port {port_id}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to {mac_cmd} {mac_address} on port {port_id} \n{output}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def set_multicast_mac_addr(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 self, port_id: int, multi_addr: str, add: bool= , verify: bool =3D True
+=C2=A0 =C2=A0 ) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Add or remove multicast mac = address to a specified port's filter.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port_id: The port ID the multica= st address is set on.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 multi_addr: The multicast addres= s to be added to the filter.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 add: If :data:'True', ad= d the specified multicast address to the port filter.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If :data:'Fals= e', remove the specified multicast address from the port filter.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:'True',= assert that the 'mcast_addr' operations was successful.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If :data:'Fals= e', execute the 'mcast_addr' operation and skip the assertion.<= br> +
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If either the 'add' or 'remove' operations fails.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 mcast_cmd =3D "add" if add else &quo= t;remove"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 output =3D self.send_command(f"mcast_addr= {mcast_cmd} {port_id} {multi_addr}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if "Bad arguments" in output:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug("Invalid= arguments provided to mcast_addr")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveCommandExecutio= nError("Invalid argument provided")
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "Invalid mult= icast_addr" in output
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 or f'multicast= address {"already" if add else "not"} filtered by port= ' in output
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (f"Failed to {mcast_cmd} {multi_addr} on port {port_id}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to {mcast_cmd} {multi_addr} on port {port_id} \n{output}" +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def rx_vlan_add(self, vlan: int, port: int, verify: bool =3D= True) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Add specified vlan tag to th= e filter list on a port.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vlan: The vlan tag to add, shoul= d be within 1-1005, 1-4094 extended.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port: The port number to add the= tag on, should be within 0-32.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:`True`, the out= put of the command is scanned to verify that
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 the vlan tag was a= dded to the filter list on the specified port. If not, it is
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 considered an erro= r.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If `verify` is :data:`True` and the tag
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is not added.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 vlan_add_output =3D self.send_command(f"r= x_vlan add {vlan} {port}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "VLAN-filtering disabled= " in vlan_add_output or "Invalid vlan_id" in vlan_add_output= :
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to add vlan tag {vlan} on port {port}: \n{vlan_add_output}"<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Testpmd failed to add vlan tag {vlan} on port {port}."
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def rx_vlan_rm(self, vlan: int, port: int, verify: bool =3D = True) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Remove specified vlan tag fr= om filter list on a port.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vlan: The vlan tag to remove, sh= ould be within 1-4094.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port: The port number to remove = the tag from, should be within 0-32.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:`True`, the out= put of the command is scanned to verify that
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 the vlan tag was r= emoved from the filter list on the specified port. If not, it is
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 considered an erro= r.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If `verify` is :data:`True` and the tag
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is not removed. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 vlan_rm_output =3D self.send_command(f"rx= _vlan rm {vlan} {port}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "VLAN-filtering disabled= " in vlan_rm_output or "Invalid vlan_id" in vlan_rm_output:<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to remove vlan tag {vlan} on port {port}: \n{vlan_rm_output}"= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Testpmd failed to remove vlan tag {vlan} on port {port}."
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def vlan_filter_set_on(self, port: int, verify: bool =3D Tru= e) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Set vlan filter on.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port: The port number to enable = VLAN filter on, should be within 0-32.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:`True`, the out= put of the command and show port info
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is scanned to veri= fy that vlan filtering was enabled successfully.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If not, it is cons= idered an error.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If `verify` is :data:`True` and the filter
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fails to update. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 filter_cmd_output =3D self.send_command(f"= ;vlan set filter on {port}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "Invalid port" in f= ilter_cmd_output or "filter on" not in self.send_command(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"show port i= nfo {port}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to enable vlan filter on port {port}: \n{filter_cmd_output}"=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Testpmd failed to enable vlan filter on port {port}."
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def vlan_filter_set_off(self, port: int, verify: bool =3D Tr= ue) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Set vlan filter off.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port: The port number to disable= VLAN filter on, should be within 0-32.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:`True`, the out= put of the command and show port info
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is scanned to veri= fy that vlan filtering was disabled successfully.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 If not, it is cons= idered an error.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If `verify` is :data:`True` and the filter
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fails to update. +=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 filter_cmd_output =3D self.send_command(f"= ;vlan set filter off {port}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if "Invalid port" in f= ilter_cmd_output or "filter off" not in self.send_command(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f"show port i= nfo {port}"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ):
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Failed to disable vlan filter on port {port}: \n{filter_cmd_output}"= ;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Testpmd failed to disable vlan filter on port {port}."
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
+=C2=A0 =C2=A0 def set_promisc(self, port: int, on: bool, verify: bool =3D = True) -> None:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Turns promiscuous mode on/of= f for the specified port.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Args:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 port: Port number to use, should= be within 0-32.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 on: If :data:`True`, turn promis= c mode on, otherwise turn off.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 verify: If :data:`True` an addit= ional command will be sent to verify that promisc mode
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is properly set. D= efaults to :data:`True`.
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 Raises:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 InteractiveCommandExecutionError= : If `verify` is :data:`True` and promisc mode
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 is not correctly s= et.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 """
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 promisc_output =3D self.send_command(f"se= t promisc {port} {'on' if on else 'off'}")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 if verify:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stats =3D self.show_port_info(po= rt_id=3Dport)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if on ^ stats.is_promiscuous_mod= e_enabled:
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self._logger.debug= (f"Failed to set promisc mode on port {port}: \n{promisc_output}"= )
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise InteractiveC= ommandExecutionError(
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f&qu= ot;Testpmd failed to set promisc mode on port {port}."
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 )
+
=C2=A0 =C2=A0 =C2=A0def show_port_stats_all(self) -> list[TestPmdPortSta= ts]:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"""Returns the statistics = of all the ports.

--
2.44.0

--0000000000003b2a22061dd5c050--