Skip to contentSkip to conversation

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

PATCH Applied Kal Conley 4 participants 9 messages Apr 3, 2023 – Apr 5, 2023

Subsystems (6)
lore
Share & tools
lore

Kal Conley

author
#0 lore raw

cover selftests: xsk: Add test case for packets at end of UMEM

This patchset fixes a minor bug in xskxceiver.c then adds a test case for valid packets at the end of the UMEM.

Kal Conley (2):
selftests: xsk: Use correct UMEM size in testapp_invalid_desc
selftests: xsk: Add test case for packets at end of UMEM

 tools/testing/selftests/bpf/xskxceiver.c | 16 ++++++++++------
 tools/testing/selftests/bpf/xskxceiver.h |  1 -
 2 files changed, 10 insertions(+), 7 deletions(-)
Signature · 1 line
2.39.2
author
#1 lore raw

PATCH 1/2 selftests: xsk: Use correct UMEM size in testapp_invalid_desc

Avoid UMEM_SIZE macro in testapp_invalid_desc which is incorrect when the frame size is not XSK_UMEM__DEFAULT_FRAME_SIZE. Also remove the macro since it's no longer being used.

Fixes 909f0e28207c ("selftests: xsk: Add tests for 2K frame size")
---
 tools/testing/selftests/bpf/xskxceiver.c | 9 +++++----
 tools/testing/selftests/bpf/xskxceiver.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +5 -4
index b65e0645b0cd..3956f5db84f3 100644
@@ -1652,6 +1652,7 @@ static void testapp_single_pkt(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[] = {
 		/* Zero packet address allowed */
 		{0, PKT_SIZE, 0, true},
@@ -1662,9 +1663,9 @@ static void testapp_invalid_desc(struct test_spec *test)
 		/* Packet too large */
 		{0x2000, XSK_UMEM__INVALID_FRAME_SIZE, 0, false},
 		/* After umem ends */
-		{UMEM_SIZE, PKT_SIZE, 0, false},
+		{umem_size, PKT_SIZE, 0, false},
 		/* 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 */
 		{0x3000 - PKT_SIZE / 2, PKT_SIZE, 0, false},
 		/* Straddle a 2K boundrary */
@@ -1682,8 +1683,8 @@ static void testapp_invalid_desc(struct test_spec *test)
 	}
 
 	if (test->ifobj_tx->shared_umem) {
-		pkts[4].addr += UMEM_SIZE;
-		pkts[5].addr += UMEM_SIZE;
+		pkts[4].addr += umem_size;
+		pkts[5].addr += umem_size;
 	}
 
 	pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
tools/testing/selftests/bpf/xskxceiver.h +0 -1
index bdb4efedf3a9..cc24ab72f3ff 100644
@@ -53,7 +53,6 @@
 #define THREAD_TMOUT 3
 #define DEFAULT_PKT_CNT (4 * 1024)
 #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 UMEM_HEADROOM_TEST_SIZE 128
 #define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1)
Signature · 1 line
2.39.2
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH bpf-next 1/2] selftests: xsk: Use correct UMEM size in testapp_invalid_desc

Quoted 4 lines · Kal Conley

Avoid UMEM_SIZE macro in testapp_invalid_desc which is incorrect when the frame size is not XSK_UMEM__DEFAULT_FRAME_SIZE. Also remove the macro since it's no longer being used.

Quoted 57 lines
Fixes 909f0e28207c ("selftests: xsk: Add tests for 2K frame size")
---
 tools/testing/selftests/bpf/xskxceiver.c | 9 +++++----
 tools/testing/selftests/bpf/xskxceiver.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +5 -4
index b65e0645b0cd..3956f5db84f3 100644
@@ -1652,6 +1652,7 @@ static void testapp_single_pkt(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[] = {
                /* Zero packet address allowed */
                {0, PKT_SIZE, 0, true},
@@ -1662,9 +1663,9 @@ static void testapp_invalid_desc(struct test_spec *test)
                /* Packet too large */
                {0x2000, XSK_UMEM__INVALID_FRAME_SIZE, 0, false},
                /* After umem ends */
-               {UMEM_SIZE, PKT_SIZE, 0, false},
+               {umem_size, PKT_SIZE, 0, false},
                /* 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 */
                {0x3000 - PKT_SIZE / 2, PKT_SIZE, 0, false},
                /* Straddle a 2K boundrary */
@@ -1682,8 +1683,8 @@ static void testapp_invalid_desc(struct test_spec *test)
        }
 
        if (test->ifobj_tx->shared_umem) {
-               pkts[4].addr += UMEM_SIZE;
-               pkts[5].addr += UMEM_SIZE;
+               pkts[4].addr += umem_size;
+               pkts[5].addr += umem_size;
        }
 
        pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
tools/testing/selftests/bpf/xskxceiver.h +0 -2
index bdb4efedf3a9..cc24ab72f3ff 100644
@@ -53,7 +53,6 @@
 #define THREAD_TMOUT 3
 #define DEFAULT_PKT_CNT (4 * 1024)
 #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 UMEM_HEADROOM_TEST_SIZE 128
 #define XSK_UMEM__INVALID_FRAME_SIZE (XSK_UMEM__DEFAULT_FRAME_SIZE + 1)
--

2.39.2

author
#3 lore raw

PATCH 2/2 selftests: xsk: Add test case for packets at end of UMEM

In reply to Kal Conley

Add test case to testapp_invalid_desc for valid packets at the end of the UMEM.

---
 tools/testing/selftests/bpf/xskxceiver.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +5 -2
index 3956f5db84f3..34a1f32fe752 100644
@@ -1662,6 +1662,8 @@ static void testapp_invalid_desc(struct test_spec *test)
 		{-2, PKT_SIZE, 0, false},
 		/* Packet too large */
 		{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 */
 		{umem_size, PKT_SIZE, 0, false},
 		/* Straddle the end of umem */
@@ -1675,16 +1677,17 @@ static void testapp_invalid_desc(struct test_spec *test)
 
 	if (test->ifobj_tx->umem->unaligned_mode) {
 		/* 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) {
 		/* Crossing a 2K frame size boundrary not allowed */
-		pkts[7].valid = false;
+		pkts[8].valid = false;
 	}
 
 	if (test->ifobj_tx->shared_umem) {
 		pkts[4].addr += umem_size;
 		pkts[5].addr += umem_size;
+		pkts[6].addr += umem_size;
 	}
 
 	pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
Signature · 1 line
2.39.2
Acked-by on v1 2/2
#4 lore raw
Quoted 3 lines · Kal Conley

Add test case to testapp_invalid_desc for valid packets at the end of the UMEM.

Thanks.

Quoted 41 lines
---
 tools/testing/selftests/bpf/xskxceiver.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/xskxceiver.c +5 -3
index 3956f5db84f3..34a1f32fe752 100644
@@ -1662,6 +1662,8 @@ static void testapp_invalid_desc(struct test_spec *test)
                {-2, PKT_SIZE, 0, false},
                /* Packet too large */
                {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 */
                {umem_size, PKT_SIZE, 0, false},
                /* Straddle the end of umem */
@@ -1675,16 +1677,17 @@ static void testapp_invalid_desc(struct test_spec *test)
 
        if (test->ifobj_tx->umem->unaligned_mode) {
                /* 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) {
                /* Crossing a 2K frame size boundrary not allowed */
-               pkts[7].valid = false;
+               pkts[8].valid = false;
        }
 
        if (test->ifobj_tx->shared_umem) {
                pkts[4].addr += umem_size;
                pkts[5].addr += umem_size;
+               pkts[6].addr += umem_size;
        }
 
        pkt_stream_generate_custom(test, pkts, ARRAY_SIZE(pkts));
--

2.39.2

#5 lore raw
In reply to Kal Conley
Quoted 2 lines · Kal Conley

This patchset fixes a minor bug in xskxceiver.c then adds a test case for valid packets at the end of the UMEM.

I tried test_xsk.sh. The changed subtest runs ok, so applied.

I got failures from test_xsk.sh (even before this set) though. Are these expected or something missing in the environment like kconfig?

./test_xsk.sh
PREREQUISITES: [ PASS ]
1..42
ok 1 PASS: SKB RUN_TO_COMPLETION
ok 2 PASS: SKB RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 3 PASS: SKB RUN_TO_COMPLETION_SINGLE_PKT
ok 4 PASS: SKB POLL_RX
ok 5 PASS: SKB POLL_TX
ok 6 PASS: SKB POLL_RXQ_EMPTY
ok 7 PASS: SKB POLL_TXQ_FULL
ok 8 # SKIP No 2M huge pages present.
ok 9 PASS: SKB ALIGNED_INV_DESC
ok 10 PASS: SKB ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 11 # SKIP No 2M huge pages present.
ok 12 PASS: SKB UMEM_HEADROOM
ok 13 PASS: SKB TEARDOWN
ok 14 PASS: SKB BIDIRECTIONAL
not ok 15 FAIL: SKB STAT_RX_DROPPED
ok 16 PASS: SKB STAT_TX_INVALID
ok 17 PASS: SKB STAT_RX_FULL
ok 18 PASS: SKB STAT_RX_FILL_EMPTY
ok 19 PASS: SKB BPF_RES
ok 20 PASS: SKB XDP_DROP_HALF
ok 21 PASS: SKB XDP_METADATA_COUNT
ok 22 PASS: DRV RUN_TO_COMPLETION
ok 23 PASS: DRV RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 24 PASS: DRV RUN_TO_COMPLETION_SINGLE_PKT
ok 25 PASS: DRV POLL_RX
ok 26 PASS: DRV POLL_TX
ok 27 PASS: DRV POLL_RXQ_EMPTY
ok 28 PASS: DRV POLL_TXQ_FULL
ok 29 # SKIP No 2M huge pages present.
ok 30 PASS: DRV ALIGNED_INV_DESC
ok 31 PASS: DRV ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 32 # SKIP No 2M huge pages present.
ok 33 PASS: DRV UMEM_HEADROOM
ok 34 PASS: DRV TEARDOWN
ok 35 PASS: DRV BIDIRECTIONAL
not ok 36 FAIL: DRV STAT_RX_DROPPED
ok 37 PASS: DRV STAT_TX_INVALID
ok 38 PASS: DRV STAT_RX_FULL
ok 39 PASS: DRV STAT_RX_FILL_EMPTY
ok 40 PASS: DRV BPF_RES
ok 41 PASS: DRV XDP_DROP_HALF
ok 42 PASS: DRV XDP_METADATA_COUNT
# Totals: pass:36 fail:2 xfail:0 xpass:0 skip:4 error:0 XSK_SELFTESTS_ve4206_SOFTIRQ: [ FAIL ]
1..42
ok 1 PASS: SKB BUSY-POLL RUN_TO_COMPLETION
ok 2 PASS: SKB BUSY-POLL RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 3 PASS: SKB BUSY-POLL RUN_TO_COMPLETION_SINGLE_PKT
ok 4 PASS: SKB BUSY-POLL POLL_RX
ok 5 PASS: SKB BUSY-POLL POLL_TX
ok 6 PASS: SKB BUSY-POLL POLL_RXQ_EMPTY
ok 7 PASS: SKB BUSY-POLL POLL_TXQ_FULL
ok 8 # SKIP No 2M huge pages present.
ok 9 PASS: SKB BUSY-POLL ALIGNED_INV_DESC
ok 10 PASS: SKB BUSY-POLL ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 11 # SKIP No 2M huge pages present.
ok 12 PASS: SKB BUSY-POLL UMEM_HEADROOM
ok 13 PASS: SKB BUSY-POLL TEARDOWN
ok 14 PASS: SKB BUSY-POLL BIDIRECTIONAL
not ok 15 FAIL: SKB BUSY-POLL STAT_RX_DROPPED
ok 16 PASS: SKB BUSY-POLL STAT_TX_INVALID
ok 17 PASS: SKB BUSY-POLL STAT_RX_FULL
ok 18 PASS: SKB BUSY-POLL STAT_RX_FILL_EMPTY
ok 19 PASS: SKB BUSY-POLL BPF_RES
ok 20 PASS: SKB BUSY-POLL XDP_DROP_HALF
ok 21 PASS: SKB BUSY-POLL XDP_METADATA_COUNT
ok 22 PASS: DRV BUSY-POLL RUN_TO_COMPLETION
ok 23 PASS: DRV BUSY-POLL RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 24 PASS: DRV BUSY-POLL RUN_TO_COMPLETION_SINGLE_PKT
ok 25 PASS: DRV BUSY-POLL POLL_RX
# [is_pkt_valid] expected seqnum [671], got seqnum [673]
not ok 26 FAIL: DRV BUSY-POLL POLL_TX
ok 27 PASS: DRV BUSY-POLL POLL_RXQ_EMPTY
ok 28 PASS: DRV BUSY-POLL POLL_TXQ_FULL
ok 29 # SKIP No 2M huge pages present.
not ok 30 [xskxceiver.c:xsk_configure_socket:1230]: ERROR: 16/"Device or resource busy" # Planned tests != run tests (42 != 30)
# Totals: pass:24 fail:3 xfail:0 xpass:0 skip:3 error:0

Summary:
XSK_SELFTESTS_ve4206_SOFTIRQ: [ FAIL ]

#6 lore raw
Quoted 4 lines

I tried test_xsk.sh. The changed subtest runs ok, so applied.

I got failures from test_xsk.sh (even before this set) though. Are these expected or something missing in the environment like kconfig?

I fixed the other errors here and here (please apply those):
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

One is against bpf and one is against bpf-next (because someone told me to move it). I guess they should both be applied to the same branch, probably bpf?

#7 lore raw
Quoted 5 lines · Kal Cutter Conley
Quoted 4 lines

I tried test_xsk.sh. The changed subtest runs ok, so applied.

I got failures from test_xsk.sh (even before this set) though. Are these expected or something missing in the environment like kconfig?

Quoted 7 lines

I fixed the other errors here and here (please apply those):
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

One is against bpf and one is against bpf-next (because someone told me to move it). I guess they should both be applied to the same branch, probably bpf?

They are all fixing a selftests, so applied both to bpf-next also. better but still has errors. The errors are down to 'fail:2' now:

./test_xsk.sh
PREREQUISITES: [ PASS ]
1..42
ok 1 PASS: SKB RUN_TO_COMPLETION
ok 2 PASS: SKB RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 3 PASS: SKB RUN_TO_COMPLETION_SINGLE_PKT
ok 4 PASS: SKB POLL_RX
ok 5 PASS: SKB POLL_TX
ok 6 PASS: SKB POLL_RXQ_EMPTY
ok 7 PASS: SKB POLL_TXQ_FULL
ok 8 # SKIP No 2M huge pages present.
ok 9 PASS: SKB ALIGNED_INV_DESC
ok 10 PASS: SKB ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 11 # SKIP No 2M huge pages present.
ok 12 PASS: SKB UMEM_HEADROOM
ok 13 PASS: SKB TEARDOWN
ok 14 PASS: SKB BIDIRECTIONAL
ok 15 PASS: SKB STAT_RX_DROPPED
ok 16 PASS: SKB STAT_TX_INVALID
ok 17 PASS: SKB STAT_RX_FULL
ok 18 PASS: SKB STAT_RX_FILL_EMPTY
ok 19 PASS: SKB BPF_RES
ok 20 PASS: SKB XDP_DROP_HALF
ok 21 PASS: SKB XDP_METADATA_COUNT
ok 22 PASS: DRV RUN_TO_COMPLETION
ok 23 PASS: DRV RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 24 PASS: DRV RUN_TO_COMPLETION_SINGLE_PKT
ok 25 PASS: DRV POLL_RX
ok 26 PASS: DRV POLL_TX
ok 27 PASS: DRV POLL_RXQ_EMPTY
ok 28 PASS: DRV POLL_TXQ_FULL
ok 29 # SKIP No 2M huge pages present.
ok 30 PASS: DRV ALIGNED_INV_DESC
ok 31 PASS: DRV ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 32 # SKIP No 2M huge pages present.
ok 33 PASS: DRV UMEM_HEADROOM
ok 34 PASS: DRV TEARDOWN
ok 35 PASS: DRV BIDIRECTIONAL
ok 36 PASS: DRV STAT_RX_DROPPED
ok 37 PASS: DRV STAT_TX_INVALID
ok 38 PASS: DRV STAT_RX_FULL
ok 39 PASS: DRV STAT_RX_FILL_EMPTY
ok 40 PASS: DRV BPF_RES
ok 41 PASS: DRV XDP_DROP_HALF
ok 42 PASS: DRV XDP_METADATA_COUNT
# Totals: pass:38 fail:0 xfail:0 xpass:0 skip:4 error:0 XSK_SELFTESTS_ve5350_SOFTIRQ: [ PASS ]
1..42
ok 1 PASS: SKB BUSY-POLL RUN_TO_COMPLETION
ok 2 PASS: SKB BUSY-POLL RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 3 PASS: SKB BUSY-POLL RUN_TO_COMPLETION_SINGLE_PKT
ok 4 PASS: SKB BUSY-POLL POLL_RX
ok 5 PASS: SKB BUSY-POLL POLL_TX
ok 6 PASS: SKB BUSY-POLL POLL_RXQ_EMPTY
ok 7 PASS: SKB BUSY-POLL POLL_TXQ_FULL
ok 8 # SKIP No 2M huge pages present.
ok 9 PASS: SKB BUSY-POLL ALIGNED_INV_DESC
ok 10 PASS: SKB BUSY-POLL ALIGNED_INV_DESC_2K_FRAME_SIZE
ok 11 # SKIP No 2M huge pages present.
ok 12 PASS: SKB BUSY-POLL UMEM_HEADROOM
ok 13 PASS: SKB BUSY-POLL TEARDOWN
ok 14 PASS: SKB BUSY-POLL BIDIRECTIONAL
ok 15 PASS: SKB BUSY-POLL STAT_RX_DROPPED
ok 16 PASS: SKB BUSY-POLL STAT_TX_INVALID
ok 17 PASS: SKB BUSY-POLL STAT_RX_FULL
ok 18 PASS: SKB BUSY-POLL STAT_RX_FILL_EMPTY
ok 19 PASS: SKB BUSY-POLL BPF_RES
ok 20 PASS: SKB BUSY-POLL XDP_DROP_HALF
ok 21 PASS: SKB BUSY-POLL XDP_METADATA_COUNT
ok 22 PASS: DRV BUSY-POLL RUN_TO_COMPLETION
ok 23 PASS: DRV BUSY-POLL RUN_TO_COMPLETION_2K_FRAME_SIZE
ok 24 PASS: DRV BUSY-POLL RUN_TO_COMPLETION_SINGLE_PKT
ok 25 PASS: DRV BUSY-POLL POLL_RX
# [is_pkt_valid] expected seqnum [703], got seqnum [704]
not ok 26 FAIL: DRV BUSY-POLL POLL_TX
ok 27 PASS: DRV BUSY-POLL POLL_RXQ_EMPTY
ok 28 PASS: DRV BUSY-POLL POLL_TXQ_FULL
ok 29 # SKIP No 2M huge pages present.
not ok 30 [xskxceiver.c:xsk_configure_socket:1236]: ERROR: 16/"Device or resource busy" # Planned tests != run tests (42 != 30)
# Totals: pass:25 fail:2 xfail:0 xpass:0 skip:3 error:0

#8 lore raw
In reply to Kal Conley
This series was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This series was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 8 lines · On Mon, 3 Apr 2023 16:50:45 +0200 you wrote:

This patchset fixes a minor bug in xskxceiver.c then adds a test case for valid packets at the end of the UMEM.

Kal Conley (2):
selftests: xsk: Use correct UMEM size in testapp_invalid_desc
selftests: xsk: Add test case for packets at end of UMEM

[...]

Here is the summary with links:
- [bpf-next,1/2] selftests: xsk: Use correct UMEM size in testapp_invalid_desc

    https://git.kernel.org/bpf/bpf-next/c/7a2050df244e
  - [bpf-next,2/2] selftests: xsk: Add test case for packets at end of UMEM
    https://git.kernel.org/bpf/bpf-next/c/ccd1b2933f8c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html