selftests/xsk: Test AF_XDP functionality under minimal ring configurations
authorTushar Vyavahare <tushar.vyavahare@intel.com>
Tue, 2 Apr 2024 11:45:28 +0000 (11:45 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 3 Apr 2024 14:04:05 +0000 (16:04 +0200)
Add a new test case that stresses AF_XDP and the driver by configuring
small hardware and software ring sizes. This verifies that AF_XDP continues
to function properly even with insufficient ring space that could lead
to frequent producer/consumer throttling. The test procedure involves:

1. Set the minimum possible ring configuration(tx 64 and rx 128).
2. Run tests with various batch sizes(1 and 63) to validate the system's
   behavior under different configurations.

Update Makefile to include network_helpers.o in the build process for
xskxceiver.

Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20240402114529.545475-7-tushar.vyavahare@intel.com
tools/testing/selftests/bpf/xskxceiver.c

index 8c26868e17cfdf2af5ebc63660fb6e8c7d8159bb..dac2dcf39bb8ff5732793d77be3ca023d34973e5 100644 (file)
@@ -2419,6 +2419,26 @@ static int testapp_xdp_metadata_mb(struct test_spec *test)
        return testapp_xdp_metadata_copy(test);
 }
 
+static int testapp_hw_sw_min_ring_size(struct test_spec *test)
+{
+       int ret;
+
+       test->set_ring = true;
+       test->total_steps = 2;
+       test->ifobj_tx->ring.tx_pending = DEFAULT_BATCH_SIZE;
+       test->ifobj_tx->ring.rx_pending = DEFAULT_BATCH_SIZE * 2;
+       test->ifobj_tx->xsk->batch_size = 1;
+       test->ifobj_rx->xsk->batch_size = 1;
+       ret = testapp_validate_traffic(test);
+       if (ret)
+               return ret;
+
+       /* Set batch size to hw_ring_size - 1 */
+       test->ifobj_tx->xsk->batch_size = DEFAULT_BATCH_SIZE - 1;
+       test->ifobj_rx->xsk->batch_size = DEFAULT_BATCH_SIZE - 1;
+       return testapp_validate_traffic(test);
+}
+
 static void run_pkt_test(struct test_spec *test)
 {
        int ret;
@@ -2523,6 +2543,7 @@ static const struct test_spec tests[] = {
        {.name = "ALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_aligned_inv_desc_mb},
        {.name = "UNALIGNED_INV_DESC_MULTI_BUFF", .test_func = testapp_unaligned_inv_desc_mb},
        {.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags},
+       {.name = "HW_SW_MIN_RING_SIZE", .test_func = testapp_hw_sw_min_ring_size},
        };
 
 static void print_tests(void)