HW_SW_MAX_RING_SIZE gives the RX UMEM 8k frames and 8k rings, then
sends batches of 2k and of the maximum HW TX ring size minus 8. This
only works in the single-interface mode, where the TX socket uses the
RX UMEM, and veth, which cannot change its ring sizes, skips the case.
With two interfaces, TX has its own UMEM of DEFAULT_UMEM_BUFFERS (1k)
frames and 2k rings: the in-flight limit in __send_pkts() turns
negative for a 2k batch, so TX never sends and RX times out, and the
second batch would not fit in the TX ring anyway.
The next patch removes the single-interface mode, so size the TX UMEM
like the RX one. The shared UMEM setup copies the RX UMEM over the TX
one and is not affected.
With a HW TX ring of more than 8200 descriptors, the second batch would
also outgrow the 8k XSK TX ring, and __send_pkts() would spin forever
waiting to reserve it, so cap the batch below the XSK ring size.
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
tools/testing/selftests/bpf/prog_tests/test_xsk.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
index 2a1362874092..05457f77ca52 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.c
@@ -2504,6 +2504,7 @@ int testapp_hw_sw_min_ring_size(struct test_spec *test)
int testapp_hw_sw_max_ring_size(struct test_spec *test)
{
u32 max_descs = XSK_RING_PROD__DEFAULT_NUM_DESCS * 4;
+ u32 batch_size;
int ret;
test->set_ring = true;@@ -2513,6 +2514,9 @@ int testapp_hw_sw_max_ring_size(struct test_spec *test)
test->ifobj_rx->xsk->umem->num_frames = max_descs;
test->ifobj_rx->xsk->umem->fill_size = max_descs;
test->ifobj_rx->xsk->umem->comp_size = max_descs;
+ test->ifobj_tx->xsk->umem->num_frames = max_descs;
+ test->ifobj_tx->xsk->umem->fill_size = max_descs;
+ test->ifobj_tx->xsk->umem->comp_size = max_descs;
test->ifobj_tx->xsk->batch_size = XSK_RING_PROD__DEFAULT_NUM_DESCS;
test->ifobj_rx->xsk->batch_size = XSK_RING_PROD__DEFAULT_NUM_DESCS;
@@ -2521,10 +2525,12 @@ int testapp_hw_sw_max_ring_size(struct test_spec *test)
return ret;
/* Set batch_size to 8152 for testing, as the ice HW ignores the 3 lowest bits when
- * updating the Rx HW tail register.
+ * updating the Rx HW tail register. __send_pkts() waits until a whole batch fits
+ * in the XSK TX ring, so keep it below that ring's size on NICs with larger rings.
*/
- test->ifobj_tx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8;
- test->ifobj_rx->xsk->batch_size = test->ifobj_tx->ring.tx_max_pending - 8;
+ batch_size = min(test->ifobj_tx->ring.tx_max_pending, max_descs) - 8;
+ test->ifobj_tx->xsk->batch_size = batch_size;
+ test->ifobj_rx->xsk->batch_size = batch_size;
if (pkt_stream_replace(test, max_descs, MIN_PKT_SIZE)) {
clean_sockets(test, test->ifobj_tx);
clean_sockets(test, test->ifobj_rx);--
2.43.0