Add rx_vxlan_port add/rm method to testpmd shell for adding
or removing a vxlan id to the specified port filter list.
Port over set_verbose method from queue start/stop suite.

Signed-off-by: Dean Marx <dm...@iol.unh.edu>
---
 dts/framework/remote_session/testpmd_shell.py | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/dts/framework/remote_session/testpmd_shell.py 
b/dts/framework/remote_session/testpmd_shell.py
index 7d0b5a374c..d802338d59 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1207,6 +1207,53 @@ def extract_verbose_output(output: str) -> 
list[TestPmdVerbosePacket]:
             
out.append(TestPmdVerbosePacket.parse(f"{prev_header}\n{match.group('PACKET')}"))
         return out
 
+    def set_verbose(self, level: int, verify: bool = True) -> None:
+        """Set debug verbosity level.
+
+        Args:
+            level:
+                0: silent except for error.
+                1: fully verbose except for Tx packets.
+                2: fully verbose except for Rx packets.
+                >2: fully verbose.
+            verify: if :data:`True` an additional command will be sent to 
verify that verbose level
+                is properly set. Defaults to :data:`True`.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and 
verbose level
+            is not correctly set.
+        """
+        verbose_output = self.send_command(f"set verbose {level}")
+        if verify:
+            if "Change verbose level" not in verbose_output:
+                self._logger.debug(f"Failed to set verbose level to {level}: 
\n{verbose_output}")
+                raise InteractiveCommandExecutionError(
+                    f"Testpmd failed to set verbose level to {level}."
+                )
+
+    def rx_vxlan(self, vxlan_id: int, port_id: int, add: bool, verify: bool = 
True) -> None:
+        """Add or remove vxlan id to filter list.
+
+        Args:
+            vxlan_id: Number of VXLAN ID to add to port filter list.
+            port_id: Number of port to add VXLAN ID to.
+            add: If :data:`True`, adds specified VXLAN ID, otherwise removes 
it.
+            verify: If :data:`True`, the output of the command is checked to 
verify
+                the VXLAN ID was successfully added/removed from the port.
+
+        Raises:
+            InteractiveCommandExecutionError: If `verify` is :data:`True` and 
VXLAN ID
+                is not successfully added or removed.
+        """
+        action = "add" if add else "rm"
+        vxlan_output = self.send_command(f"rx_vxlan_port {action} {vxlan_id} 
{port_id}")
+        if verify:
+            if "udp tunneling add error" in vxlan_output:
+                self._logger.debug(f"Failed to set VXLAN:\n{vxlan_output}")
+                raise InteractiveCommandExecutionError(
+                    f"Failed to set VXLAN:\n{vxlan_output}"
+                )
+
     def _close(self) -> None:
         """Overrides :meth:`~.interactive_shell.close`."""
         self.stop()
-- 
2.44.0

Reply via email to