Skip to contentSkip to conversation

fix Rx split in testpmd

PATCH Applied Thomas Monjalon 1 participant 4 messages Jun 24 – Jul 2

lore
Share & tools
lore
#0 lore raw

cover fix Rx split in testpmd

Adding selective Rx in DPDK 26.07-rc1 introduced a regression when configuring Rx split at runtime with mempools defined on start.

While fixing it, a test is added in DTS, and a refactoring in DTS is added as first patch to make the second change smaller.

Thomas Monjalon (2):
dts: simplify packet check in Rx split app/testpmd: fix runtime config of Rx split

 app/test-pmd/testpmd.c          |  3 +-
 dts/tests/TestSuite_rx_split.py | 59 +++++++++++++++++++++++----------
 2 files changed, 43 insertions(+), 19 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 dts: simplify packet check in Rx split

Add shortcuts to the function verifying a received packet match its expected content.
Previous version worked with a callback function defining the expected received packet based on the sent packet. This new version allows to pass a header length,
so only the header is expected, or directly the expected bytes. If the parameter is None, the full packet is expected. This is shorter than defining a callback in many cases.

---
 dts/tests/TestSuite_rx_split.py | 35 +++++++++++++++++----------------
 1 file changed, 18 insertions(+), 17 deletions(-)
dts/tests/TestSuite_rx_split.py +18 -17
index 5f5a2e6187..633ba0bf1e 100644
@@ -56,11 +56,24 @@ def _build_packet(self) -> Packet:
         packet = Ether() / IP() / Raw(load=PAYLOAD)
         return adjust_addresses([packet])[0]
 
-    def _start_and_verify(self, testpmd: TestPmd, expected: Callable[[bytes], bytes]) -> None:
+    def _start_and_verify(
+        self,
+        testpmd: TestPmd,
+        expected: Callable[[bytes], bytes] | bytes | int | None = None,
+    ) -> None:
         """Start testpmd, send the default packet, and verify received bytes."""
         testpmd.start()
         packet = self._build_packet()
-        self._send_and_verify(testpmd, packet, expected(bytes(packet)))
+        raw = bytes(packet)
+        if expected is None:
+            raw_expected = raw
+        elif isinstance(expected, int):
+            raw_expected = raw[:expected]
+        elif isinstance(expected, bytes):
+            raw_expected = expected
+        else:
+            raw_expected = expected(raw)
+        self._send_and_verify(testpmd, packet, raw_expected)
 
     def _send_and_verify(self, testpmd: TestPmd, tg_packet: Packet, expected: bytes) -> None:
         """Clear stats, send a packet, and verify received content and stats.
@@ -128,11 +141,7 @@ def selective_rx_headers(self) -> None:
             rx_segments_length=[ETHER_IP_HDR_LEN, 0],
             mbuf_size=[256, 0],
         ) as testpmd:
-
-            def expected(packet: bytes) -> bytes:
-                return packet[:ETHER_IP_HDR_LEN]
-
-            self._start_and_verify(testpmd, expected)
+            self._start_and_verify(testpmd, ETHER_IP_HDR_LEN)
 
     @func_test
     def selective_rx_headers_discard_length(self) -> None:
@@ -151,11 +160,7 @@ def selective_rx_headers_discard_length(self) -> None:
             rx_segments_length=[ETHER_IP_HDR_LEN, len(PAYLOAD)],
             mbuf_size=[256, 0],
         ) as testpmd:
-
-            def expected(packet: bytes) -> bytes:
-                return packet[:ETHER_IP_HDR_LEN]
-
-            self._start_and_verify(testpmd, expected)
+            self._start_and_verify(testpmd, ETHER_IP_HDR_LEN)
 
     @func_test
     def selective_rx_payload_only(self) -> None:
@@ -173,11 +178,7 @@ def selective_rx_payload_only(self) -> None:
             rx_segments_length=[ETHER_IP_HDR_LEN, len(PAYLOAD)],
             mbuf_size=[0, 512],
         ) as testpmd:
-
-            def expected(_: bytes) -> bytes:
-                return PAYLOAD
-
-            self._start_and_verify(testpmd, expected)
+            self._start_and_verify(testpmd, PAYLOAD)
 
     @func_test
     def selective_rx_two_segments(self) -> None:
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 app/testpmd: fix runtime config of Rx split

In reply to Thomas Monjalon

When adding selective Rx, it was assumed that the queue configuration was set when starting testpmd via the command line options. But it should be possible to configure mempools with --mbuf-size, start Rx, stop, and configure later a split in the testpmd CLI. In such a scenario, a regression prevented to start
with more than 1 mempool without configuring a split:

Configuring Port 0 (socket 0)
ETHDEV: No Rx segmentation offload configured Fail to configure port 0 rx queues

It is fixed by considering having multiple mempools is not a condition to trigger Rx split.

A test is added in DTS to validate this use case.

Bugzilla ID: 1956

Fixes 0be0ad196b52 ("app/testpmd: support selective Rx")
---
 app/test-pmd/testpmd.c          |  3 +--
 dts/tests/TestSuite_rx_split.py | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)
app/test-pmd/testpmd.c +1 -2
index fcd8a90967..b241a7025b 100644
@@ -2750,8 +2750,7 @@ rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 	uint32_t prev_hdrs = 0;
 	int ret;
 
-	if (multi_rx_mempool == 0 &&
-	    (rx_pkt_nb_segs > 1 || mbuf_data_size_n > 1)) {
+	if (multi_rx_mempool == 0 && rx_pkt_nb_segs > 1) {
 		unsigned int nb_segs = RTE_MAX(rx_pkt_nb_segs, (uint8_t)mbuf_data_size_n);
 
 		/* multi-segment configuration */
dts/tests/TestSuite_rx_split.py +24 -0
index 633ba0bf1e..5117a569e2 100644
@@ -210,6 +210,30 @@ def expected(packet: bytes) -> bytes:
 
             self._start_and_verify(testpmd, expected)
 
+    @func_test
+    def selective_rx_runtime_config(self) -> None:
+        """Configure selective Rx at runtime after initial startup.
+
+        Steps:
+            Start testpmd with two mbuf-size pools but no rxpkts/rxhdrs.
+            Stop ports, configure buffer split offload, set rxpkts, restart ports.
+            Send an Ether/IP/payload packet.
+
+        Verify:
+            Initial startup succeeds without error.
+            Received packet has Ether + IP headers only after runtime config.
+            Port stats show expected rx_packets and rx_bytes.
+        """
+        with self._create_testpmd(
+            mbuf_size=[512, 0],
+        ) as testpmd:
+            self._start_and_verify(testpmd)
+            testpmd.stop()
+            testpmd.stop_all_ports()
+            testpmd.send_command("port config 0 rx_offload buffer_split on")
+            testpmd.send_command(f"set rxpkts {ETHER_IP_HDR_LEN},0")
+            self._start_and_verify(testpmd, ETHER_IP_HDR_LEN)
+
     @func_test
     def selective_rx_no_offload(self) -> None:
         """Configure selective Rx with buffer split disabled.
Signature · 1 line
2.54.0
author Applied
#3 lore raw
In reply to Thomas Monjalon

25/06/2026 01:03, Thomas Monjalon:

Quoted 11 lines

Adding selective Rx in DPDK 26.07-rc1 introduced a regression when configuring Rx split at runtime with mempools defined on start.

While fixing it, a test is added in DTS, and a refactoring in DTS is added as first patch to make the second change smaller.

Thomas Monjalon (2):
dts: simplify packet check in Rx split app/testpmd: fix runtime config of Rx split

I was expecting a test from the bug reporter.

Applied