Commit 756aaf2a authored by Martin KaFai Lau's avatar Martin KaFai Lau

Merge branch 'selftests: xsk: Add test case for packets at end of UMEM'

Kal Conley says:

====================

This patchset fixes a minor bug in xskxceiver.c then adds a test case
for valid packets at the end of the UMEM.
====================
Signed-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parents 9af87166 ccd1b293
...@@ -1652,6 +1652,7 @@ static void testapp_single_pkt(struct test_spec *test) ...@@ -1652,6 +1652,7 @@ static void testapp_single_pkt(struct test_spec *test)
static void testapp_invalid_desc(struct test_spec *test) static void testapp_invalid_desc(struct test_spec *test)
{ {
u64 umem_size = test->ifobj_tx->umem->num_frames * test->ifobj_tx->umem->frame_size;
struct pkt pkts[] = { struct pkt pkts[] = {
/* Zero packet address allowed */ /* Zero packet address allowed */
{0, PKT_SIZE, 0, true}, {0, PKT_SIZE, 0, true},
...@@ -1661,10 +1662,12 @@ static void testapp_invalid_desc(struct test_spec *test) ...@@ -1661,10 +1662,12 @@ static void testapp_invalid_desc(struct test_spec *test)
{-2, PKT_SIZE, 0, false}, {-2, PKT_SIZE, 0, false},
/* Packet too large */ /* Packet too large */
{0x2000, XSK_UMEM__INVALID_FRAME_SIZE, 0, false}, {0x2000, XSK_UMEM__INVALID_FRAME_SIZE, 0, false},
/* Up to end of umem allowed */
{umem_size - PKT_SIZE, PKT_SIZE, 0, true},
/* After umem ends */ /* After umem ends */
{UMEM_SIZE, PKT_SIZE, 0, false}, {umem_size, PKT_SIZE, 0, false},
/* Straddle the end of umem */ /* Straddle the end of umem */
{UMEM_SIZE - PKT_SIZE / 2, PKT_SIZE, 0, false}, {umem_size - PKT_SIZE / 2, PKT_SIZE, 0, false},
/* Straddle a page boundrary */ /* Straddle a page boundrary */
{0x3000 - PKT_SIZE / 2, PKT_SIZE, 0, false}, {0x3000 - PKT_SIZE / 2, PKT_SIZE, 0, false},
/* Straddle a 2K boundrary */ /* Straddle a 2K boundrary */
...@@ -1674,16 +1677,17 @@ static void testapp_invalid_desc(struct test_spec *test) ...@@ -1674,16 +1677,17 @@ static void testapp_invalid_desc(struct test_spec *test)
if (test->ifobj_tx->umem->unaligned_mode) { if (test->ifobj_tx->umem->unaligned_mode) {
/* Crossing a page boundrary allowed */ /* Crossing a page boundrary allowed */
pkts[6].valid = true; pkts[7].valid = true;
} }
if (test->ifobj_tx->umem->frame_size == XSK_UMEM__DEFAULT_FRAME_SIZE / 2) { if (test->ifobj_tx->umem->frame_size == XSK_UMEM__DEFAULT_FRAME_SIZE / 2) {
/* Crossing a 2K frame size boundrary not allowed */ /* Crossing a 2K frame size boundrary not allowed */
pkts[7].valid = false; pkts[8].valid = false;
} }
if (test->ifobj_tx->shared_umem) { if (test->ifobj_tx->shared_umem) {
pkts[4].addr += UMEM_SIZE; pkts[4].addr += umem_size;
pkts[5].addr += UMEM_SIZE; pkts[5].addr += umem_size;
pkts[6].addr += umem_size;
} }
pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts)); pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#define THREAD_TMOUT 3 #define THREAD_TMOUT 3
#define DEFAULT_PKT_CNT (4 * 1024) #define DEFAULT_PKT_CNT (4 * 1024)
#define DEFAULT_UMEM_BUFFERS (DEFAULT_PKT_CNT / 4) #define DEFAULT_UMEM_BUFFERS (DEFAULT_PKT_CNT / 4)
#define UMEM_SIZE (DEFAULT_UMEM_BUFFERS * XSK_UMEM__DEFAULT_FRAME_SIZE)
#define RX_FULL_RXQSIZE 32 #define RX_FULL_RXQSIZE 32
#define UMEM_HEADROOM_TEST_SIZE 128 #define UMEM_HEADROOM_TEST_SIZE 128
#define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1) #define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment