diff options
| author | Nicholas Pratte <[email protected]> | 2024-10-16 13:13:05 -0400 |
|---|---|---|
| committer | Paul Szczepanek <[email protected]> | 2024-11-15 15:00:14 +0100 |
| commit | e3b16f45cb17fe7dc4251e493fa5e9ef235bfd0d (patch) | |
| tree | cf41722eac2edf72a2a139a1822d908161ab8077 /dts/framework/remote_session/testpmd_shell.py | |
| parent | 125d85e72f9b85043fd75e4027cee76bf2c2c4ac (diff) | |
dts: add setting MAC and multicast addresses
New methods have been added to TestPMDShell in order to support the MAC
filter's individual test cases:
- set_mac_addr
- set_multicast_mac_addr
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.
Bugzilla ID: 1454
Signed-off-by: Nicholas Pratte <[email protected]>
Diffstat (limited to 'dts/framework/remote_session/testpmd_shell.py')
| -rw-r--r-- | dts/framework/remote_session/testpmd_shell.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py index 508061beac..4faf7b21c3 100644 --- a/dts/framework/remote_session/testpmd_shell.py +++ b/dts/framework/remote_session/testpmd_shell.py @@ -1665,6 +1665,65 @@ class TestPmdShell(DPDKShell): for existing_port in self._ports ] + def set_mac_addr(self, port_id: int, mac_address: str, add: bool, verify: bool = 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 to or removed from 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' operation was successful. If + :data:'False', run the command and skip this assertion. + + Raises: + InteractiveCommandExecutionError: If the set mac address operation fails. + """ + mac_cmd = "add" if add else "remove" + output = 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} on 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 = True + ) -> None: + """Add or remove multicast mac address to a specified port's allow list. + + Args: + port_id: The port ID the multicast address is set on. + multi_addr: The multicast address to be added or removed from 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 = "add" if add else "remove" + output = 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 show_port_stats_all(self) -> list[TestPmdPortStats]: """Returns the statistics of all the ports. |
