mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-13 22:14:20 +08:00
selftests: xsk: Add test UNALIGNED_INV_DESC_4K1_FRAME_SIZE
Add unaligned descriptor test for frame size of 4001. Using an odd frame size ensures that the end of the UMEM is not near a page boundary. This allows testing descriptors that staddle the end of the UMEM but not a page. This test used to fail without the previous commit ("xsk: Fix unaligned descriptor validation"). Signed-off-by: Kal Conley <kal.conley@dectris.com> Link: https://lore.kernel.org/r/20230405235920.7305-3-kal.conley@dectris.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
This commit is contained in:
parent
d769ccaf95
commit
c0801598e5
@ -69,6 +69,7 @@
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <assert.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
@ -1876,6 +1877,29 @@ static void run_pkt_test(struct test_spec *test, enum test_mode mode, enum test_
|
||||
test->ifobj_rx->umem->unaligned_mode = true;
|
||||
testapp_invalid_desc(test);
|
||||
break;
|
||||
case TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME: {
|
||||
u64 page_size, umem_size;
|
||||
|
||||
if (!hugepages_present(test->ifobj_tx)) {
|
||||
ksft_test_result_skip("No 2M huge pages present.\n");
|
||||
return;
|
||||
}
|
||||
test_spec_set_name(test, "UNALIGNED_INV_DESC_4K1_FRAME_SIZE");
|
||||
/* Odd frame size so the UMEM doesn't end near a page boundary. */
|
||||
test->ifobj_tx->umem->frame_size = 4001;
|
||||
test->ifobj_rx->umem->frame_size = 4001;
|
||||
test->ifobj_tx->umem->unaligned_mode = true;
|
||||
test->ifobj_rx->umem->unaligned_mode = true;
|
||||
/* This test exists to test descriptors that staddle the end of
|
||||
* the UMEM but not a page.
|
||||
*/
|
||||
page_size = sysconf(_SC_PAGESIZE);
|
||||
umem_size = test->ifobj_tx->umem->num_frames * test->ifobj_tx->umem->frame_size;
|
||||
assert(umem_size % page_size > PKT_SIZE);
|
||||
assert(umem_size % page_size < page_size - PKT_SIZE);
|
||||
testapp_invalid_desc(test);
|
||||
break;
|
||||
}
|
||||
case TEST_TYPE_UNALIGNED:
|
||||
if (!testapp_unaligned(test))
|
||||
return;
|
||||
|
@ -78,6 +78,7 @@ enum test_type {
|
||||
TEST_TYPE_ALIGNED_INV_DESC,
|
||||
TEST_TYPE_ALIGNED_INV_DESC_2K_FRAME,
|
||||
TEST_TYPE_UNALIGNED_INV_DESC,
|
||||
TEST_TYPE_UNALIGNED_INV_DESC_4K1_FRAME,
|
||||
TEST_TYPE_HEADROOM,
|
||||
TEST_TYPE_TEARDOWN,
|
||||
TEST_TYPE_BIDI,
|
||||
|
Loading…
Reference in New Issue
Block a user