Skip to content

Commit 22b4a63

Browse files
dmarxIOLPatrickRobbIOL
authored andcommitted
dts: add start Tx first method to testpmd shell
Add start tx_first method to testpmd shell, which sends a specified number of burst packets prior to starting packet forwarding. Signed-off-by: Dean Marx <[email protected]> Reviewed-by: Luca Vizzarro <[email protected]> Reviewed-by: Patrick Robb <[email protected]>
1 parent 2c88256 commit 22b4a63

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

dts/api/testpmd/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,27 @@ def start(self, verify: bool = True) -> None:
214214
self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
215215
raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
216216

217+
@_requires_started_ports
218+
def start_tx_first(self, burst_num: int, verify: bool = True) -> None:
219+
"""Start packet forwarding after sending specified number of bursts of packets.
220+
221+
Args:
222+
burst_num: Number of packets to send before stopping transmission.
223+
verify: If :data:`True` , a second start command will be sent in an attempt to verify
224+
packet forwarding started as expected.
225+
226+
Raises:
227+
InteractiveCommandExecutionError: If `verify` is :data:`True` and forwarding fails to
228+
start or ports fail to come up.
229+
"""
230+
self.send_command(f"start tx_first {burst_num if burst_num is not None else ""}")
231+
if verify:
232+
# If forwarding was already started, sending "start" again should tell us
233+
start_cmd_output = self.send_command("start")
234+
if "Packet forwarding already started" not in start_cmd_output:
235+
self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
236+
raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
237+
217238
def stop(self, verify: bool = True) -> str:
218239
"""Stop packet forwarding.
219240

0 commit comments

Comments
 (0)