On Wed, Sep 18, 2024 at 3:41 PM Dean Marx <dm...@iol.unh.edu> wrote: > <snip> > + > + def tx_vlan_set(self, port: int, vlan: int, verify: bool = True) -> None:
One thing to note is that I think this method (unlike rx_vlan_set for some reason) requires the ports to be stopped for it to work, so we should probably decorate this with @requires_stopped_ports to make it more convenient for the developer. > + """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 insertion > + tag is not set. > + """ > + 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 tag {vlan} on port > {port}:\n{vlan_insert_output}" > + ) > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to set vlan insertion tag {vlan} on > port {port}." > + ) > + > + def tx_vlan_reset(self, port: int, verify: bool = True) -> None: I believe this method also required ports to be stopped. > + """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 insertion > + tag is not reset. > + """ > + vlan_insert_output = self.send_command(f"tx_vlan reset {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 on port {port}: > \n{vlan_insert_output}" > + ) > + raise InteractiveCommandExecutionError( > + f"Testpmd failed to reset vlan insertion on port {port}." > + ) > + <snip> > 2.44.0 >