Add packet resizing tests using the bpf_xdp_adjust_tail()function within the AF_XDP framework. Implement testapp_adjust_tail_common() to handle common logic for packet resizing tests, streamlining the testing process. Allow setting MTU to MAX_ETH_JUMBO_SIZE for specific tests. Implement testapp_adjust_tail_shrink() and testapp_adjust_tail_shrink_mb() to test shrinking packets, including multi-buffer scenarios, under AF_XDP. Implement testapp_adjust_tail_grow() and testapp_adjust_tail_grow_mb() to test growing packets within the AF_XDP context, utilizing the common logic function for consistency and efficiency. Signed-off-by: Tushar Vyavahare <tushar.vyavahare@xxxxxxxxx> --- tools/testing/selftests/bpf/xskxceiver.c | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 52ce0217d3d5..36f32b7ef31d 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -2600,6 +2600,34 @@ static int testapp_adjust_tail(struct test_spec *test, u32 value, u32 pkt_len) return 0; } +static int testapp_adjust_tail_common(struct test_spec *test, int adjust_value, u32 len, + bool set_mtu) +{ + if (set_mtu) + test->mtu = MAX_ETH_JUMBO_SIZE; + return testapp_adjust_tail(test, adjust_value, len); +} + +static int testapp_adjust_tail_shrink(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, -4, MIN_PKT_SIZE, false); +} + +static int testapp_adjust_tail_shrink_mb(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, -4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true); +} + +static int testapp_adjust_tail_grow(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, 4, MIN_PKT_SIZE, false); +} + +static int testapp_adjust_tail_grow_mb(struct test_spec *test) +{ + return testapp_adjust_tail_common(test, 4, XSK_RING_PROD__DEFAULT_NUM_DESCS * 3, true); +} + static void run_pkt_test(struct test_spec *test) { int ret; @@ -2706,6 +2734,10 @@ static const struct test_spec tests[] = { {.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags}, {.name = "HW_SW_MIN_RING_SIZE", .test_func = testapp_hw_sw_min_ring_size}, {.name = "HW_SW_MAX_RING_SIZE", .test_func = testapp_hw_sw_max_ring_size}, + {.name = "XDP_ADJUST_TAIL_SHRINK", .test_func = testapp_adjust_tail_shrink}, + {.name = "XDP_ADJUST_TAIL_SHRINK_MULTI_BUFF", .test_func = testapp_adjust_tail_shrink_mb}, + {.name = "XDP_ADJUST_TAIL_GROW", .test_func = testapp_adjust_tail_grow}, + {.name = "XDP_ADJUST_TAIL_GROW_MULTI_BUFF", .test_func = testapp_adjust_tail_grow_mb}, }; static void print_tests(void) -- 2.34.1