Skip to content

Commit

Permalink
selftests/xsk: Add packet resizing tests with bpf_xdp_adjust_tail for…
Browse files Browse the repository at this point in the history
… AF_XDP

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 <[email protected]>
  • Loading branch information
tvyavaha authored and Kernel Patches Daemon committed Feb 26, 2025
1 parent 9cfd07c commit 95b4493
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tools/testing/selftests/bpf/xskxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 95b4493

Please sign in to comment.