[v2,1/2] dts: add ability to modify number of queues on a port to testpmd
Checks
Commit Message
From: Jeremy Spewock <jspewock@iol.unh.edu>
The ability to change the configuration of a port at runtime is a
crucial aspect of DPDK. This patch adds both the steps required to
modify the number of queues on a port at runtime and also the
verification steps to ensure that the command behaved as expected.
Depends-on: patch-143033 ("dts: add text parser for testpmd verbose
output")
Depends-on: patch-143385 ("dts: add VLAN methods to testpmd shell")
Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 36 +++++++++++++++++++
1 file changed, 36 insertions(+)
@@ -1450,6 +1450,42 @@ def set_verbose(self, level: int, verify: bool = True) -> None:
f"Testpmd failed to set verbose level to {level}."
)
+ def set_num_queues_all(self, num_queues: int, is_rx: bool, verify: bool = True) -> None:
+ """Modify the number of Rx/Tx queues configured on all ports.
+
+ Args:
+ num_queues: Number of queues to set on all ports.
+ is_rx: If :data:`True` then the number of Rx queues will be modified, otherwise the
+ number of Tx queues will be modified.
+ verify: If :data:`True` then an additional command will be sent to check the info of
+ `port_id` and verify that the number of queues is equal to `num_queues`.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and testpmd failed to
+ update the number of queues on the ports.
+ """
+ queue_type = "rxq" if is_rx else "txq"
+ self.port_stop_all(verify=verify)
+ port_config_output = self.send_command(f"port config all {queue_type} {num_queues}")
+ # ports have to be started before the output can be verified.
+ self.port_start_all(verify=verify)
+ if verify:
+ all_ports_modified = all(
+ queues == num_queues
+ for queues in map(
+ lambda info: info.rx_queues_num if is_rx else info.tx_queues_num,
+ self.show_port_info_all(),
+ )
+ )
+ if not all_ports_modified:
+ self._logger.debug(
+ f"Failed to set number of queues on all ports to "
+ f"{num_queues}:\n{port_config_output}"
+ )
+ raise InteractiveCommandExecutionError(
+ "Testpmd failed to update the number of queues on all ports."
+ )
+
def _close(self) -> None:
"""Overrides :meth:`~.interactive_shell.close`."""
self.stop()