Skip to content

Commit 34e78ba

Browse files
author
Alexei Starovoitov
committed
Merge branch 'seltests/xsk: prepare for AF_XDP multi-buffer testing'
Magnus Karlsson says: ==================== Prepare the AF_XDP selftests test framework code for the upcoming multi-buffer support in AF_XDP. This so that the multi-buffer patch set does not become way too large. In that upcoming patch set, we are only including the multi-buffer tests together with any framework code that depends on the new options bit introduced in the AF_XDP multi-buffer implementation itself. Currently, the test framework is based on the premise that a packet consists of a single fragment and thus occupies a single buffer and a single descriptor. Multi-buffer breaks this assumption, as that is the whole purpose of it. Now, a packet can consist of multiple buffers and therefore consume multiple descriptors. The patch set starts with some clean-ups and simplifications followed by patches that make sure that the current code works even when a packet occupies multiple buffers. The actual code for sending and receiving multi-buffer packets will be included in the AF_XDP multi-buffer patch set as it depends on a new bit being used in the options field of the descriptor. Patch set anatomy: 1: The XDP program was unnecessarily changed many times. Fixes this. 2: There is no reason to generate a full UDP/IPv4 packet as it is never used. Simplify the code by just generating a valid Ethernet frame. 3: Introduce a more complicated payload pattern that can detect fragments out of bounds in a multi-buffer packet and other errors found in single-fragment packets. 4: As a convenience, dump the content of the faulty packet at error. 5: To simplify the code, make the usage of the packet stream for Tx and Rx more similar. 6: Store the offset of the packet in the buffer in the struct pkt definition instead of the address in the umem itself and introduce a simple buffer allocator. The address only made sense when all packets consumed a single buffer. Now, we do not know beforehand how many buffers a packet will consume, so we instead just allocate a buffer from the allocator and specify the offset within that buffer. 7: Test for huge pages only once instead of before each test that needs it. 8: Populate the fill ring based on how many frags are needed for each packet. 9: Change the data generation code so it can generate data for multi-buffer packets too. 10: Adjust the packet pacing algorithm so that it can cope with multi-buffer packets. The pacing algorithm is present so that Tx does not send too many packets/frames to Rx that it starts to drop packets. That would ruin the tests. v1 -> v2: * Fixed spelling error in patch #6 [Simon] * Fixed compilation error with llvm in patch #7 [Daniel] Thanks: Magnus ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents 0697e43 + 7cd6df4 commit 34e78ba

4 files changed

Lines changed: 379 additions & 438 deletions

File tree

tools/testing/selftests/bpf/test_xsk.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@
6868
# Run with verbose output:
6969
# sudo ./test_xsk.sh -v
7070
#
71-
# Run and dump packet contents:
72-
# sudo ./test_xsk.sh -D
73-
#
7471
# Set up veth interfaces and leave them up so xskxceiver can be launched in a debugger:
7572
# sudo ./test_xsk.sh -d
7673
#
@@ -81,11 +78,10 @@
8178

8279
ETH=""
8380

84-
while getopts "vDi:d" flag
81+
while getopts "vi:d" flag
8582
do
8683
case "${flag}" in
8784
v) verbose=1;;
88-
D) dump_pkts=1;;
8985
d) debug=1;;
9086
i) ETH=${OPTARG};;
9187
esac
@@ -157,10 +153,6 @@ if [[ $verbose -eq 1 ]]; then
157153
ARGS+="-v "
158154
fi
159155

160-
if [[ $dump_pkts -eq 1 ]]; then
161-
ARGS="-D "
162-
fi
163-
164156
retval=$?
165157
test_status $retval "${TEST_NAME}"
166158

tools/testing/selftests/bpf/xsk.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ static inline void xsk_ring_prod__submit(struct xsk_ring_prod *prod, __u32 nb)
134134
__atomic_store_n(prod->producer, *prod->producer + nb, __ATOMIC_RELEASE);
135135
}
136136

137+
static inline void xsk_ring_prod__cancel(struct xsk_ring_prod *prod, __u32 nb)
138+
{
139+
prod->cached_prod -= nb;
140+
}
141+
137142
static inline __u32 xsk_ring_cons__peek(struct xsk_ring_cons *cons, __u32 nb, __u32 *idx)
138143
{
139144
__u32 entries = xsk_cons_nb_avail(cons, nb);

0 commit comments

Comments
 (0)