Skip to content

Commit 1e72020

Browse files
Andrew BaileyPatrickRobbIOL
authored andcommitted
dts: add Rx Tx offload test suite
Add mbuf fast free test case. The testsuite expects mbuf fast free to be enabled by default and verifies configuration of this Tx offload capability. Signed-off-by: Andrew Bailey <[email protected]> Reviewed-by: Patrick Robb <[email protected]>
1 parent 1d20567 commit 1e72020

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. SPDX-License-Identifier: BSD-3-Clause
2+
3+
rx_tx_offload Test Suite
4+
========================
5+
6+
.. automodule:: tests.TestSuite_rx_tx_offload
7+
:members:
8+
:show-inheritance:
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright(c) 2025 University of New Hampshire
3+
4+
"""RX TX offload test suite.
5+
6+
Test the testpmd feature of configuring RX and TX offloads.
7+
"""
8+
9+
from api.capabilities import (
10+
LinkTopology,
11+
NicCapability,
12+
requires_link_topology,
13+
requires_nic_capability,
14+
)
15+
from api.test import verify
16+
from api.testpmd import TestPmd
17+
from api.testpmd.types import (
18+
OffloadConfiguration,
19+
RxTxLiteralSwitch,
20+
)
21+
from framework.test_suite import TestSuite, func_test
22+
23+
24+
@requires_link_topology(LinkTopology.ONE_LINK)
25+
class TestRxTxOffload(TestSuite):
26+
"""RX/TX offload test suite."""
27+
28+
def _check_config(
29+
self,
30+
testpmd: TestPmd,
31+
port_id: int,
32+
port_offload: str | None,
33+
rxtx: RxTxLiteralSwitch,
34+
/,
35+
queue_offload: list[str | None] | None = None,
36+
) -> bool:
37+
config: OffloadConfiguration = testpmd.get_offload_config(port_id, rxtx)
38+
if config.port_config.name != port_offload:
39+
return False
40+
41+
if queue_offload:
42+
for i, q in enumerate(config.queue_configs):
43+
if q.name != queue_offload[i]:
44+
return False
45+
return True
46+
47+
def _set_all_queues_mbuf_fast_free(
48+
self,
49+
testpmd: TestPmd,
50+
port_id: int,
51+
on: bool,
52+
num_queues: int,
53+
) -> None:
54+
for i in range(num_queues):
55+
testpmd.set_queue_mbuf_fast_free(port_id, on, i)
56+
57+
@requires_nic_capability(NicCapability.PORT_TX_OFFLOAD_MBUF_FAST_FREE)
58+
@func_test
59+
def test_mbuf_fast_free_configuration_per_port(self) -> None:
60+
"""Ensure mbuf_fast_free can be configured with testpmd per port.
61+
62+
Steps:
63+
* Start up testpmd shell.
64+
* Toggle mbuf_fast_free off per port.
65+
* Toggle mbuf_fast_free on per port.
66+
67+
Verify:
68+
* Mbuf_fast_free starts enabled.
69+
* Mbuf_fast_free can be configured off per port.
70+
* Mbuf_fast_free can be configured on per port.
71+
"""
72+
with TestPmd() as testpmd:
73+
port_id = 0
74+
testpmd.start_all_ports()
75+
76+
# Ensure MBUF_FAST_FREE is enabled by default and verify
77+
verify(
78+
self._check_config(testpmd, port_id, "MBUF_FAST_FREE", "tx"),
79+
"MBUF_FAST_FREE disabled on port start.",
80+
)
81+
# disable MBUF_FAST_FREE per port and verify
82+
testpmd.set_port_mbuf_fast_free(port_id, False)
83+
verify(
84+
self._check_config(testpmd, port_id, None, "tx"),
85+
"Failed to enable MBUF_FAST_FREE on port.",
86+
)
87+
# Enable MBUF_FAST_FREE per port and verify
88+
testpmd.set_port_mbuf_fast_free(port_id, True)
89+
verify(
90+
self._check_config(testpmd, port_id, "MBUF_FAST_FREE", "tx"),
91+
"Failed to disable MBUF_FAST_FREE on port.",
92+
)
93+
94+
@requires_nic_capability(NicCapability.QUEUE_TX_OFFLOAD_MBUF_FAST_FREE)
95+
@func_test
96+
def test_mbuf_fast_free_configuration_per_queue(self) -> None:
97+
"""Ensure mbuf_fast_free can be configured with testpmd.
98+
99+
Steps:
100+
* Start up testpmd shell.
101+
* Toggle mbuf_fast_free off per queue.
102+
* Toggle mbuf_fast_free on per queue.
103+
104+
Verify:
105+
* Mbuf_fast_free starts disabled.
106+
* Mbuf_fast_free can be configured off per queue.
107+
* Mbuf_fast_free can be configured on per queue.
108+
"""
109+
with TestPmd() as testpmd:
110+
port_id = 0
111+
num_queues = 4
112+
queue_off: list[str | None] | None = [None] * num_queues
113+
queue_on: list[str | None] | None = ["MBUF_FAST_FREE"] * num_queues
114+
115+
testpmd.set_ports_queues(num_queues)
116+
testpmd.start_all_ports()
117+
118+
# Ensure mbuf_fast_free is enabled by default on port and queues
119+
verify(
120+
self._check_config(testpmd, port_id, "MBUF_FAST_FREE", "tx", queue_on),
121+
"MBUF_FAST_FREE disabled on queue start.",
122+
)
123+
# Disable mbuf_fast_free per queue and verify
124+
self._set_all_queues_mbuf_fast_free(testpmd, port_id, False, num_queues)
125+
verify(
126+
self._check_config(testpmd, port_id, "MBUF_FAST_FREE", "tx", queue_off),
127+
"Failed to disable MBUF_FAST_FREE on all queues.",
128+
)
129+
# Disable mbuf_fast_free per queue and verify
130+
self._set_all_queues_mbuf_fast_free(testpmd, port_id, True, num_queues)
131+
verify(
132+
self._check_config(testpmd, port_id, "MBUF_FAST_FREE", "tx", queue_on),
133+
"Failed to enable MBUF_FAST_FREE on all queues.",
134+
)

0 commit comments

Comments
 (0)