selftests/xsk: store offset in pkt instead of addr
authorMagnus Karlsson <magnus.karlsson@intel.com>
Tue, 16 May 2023 10:31:05 +0000 (12:31 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 May 2023 05:31:51 +0000 (22:31 -0700)
commitd9f6d9709f87236f9a33de0d42dae8402b812e19
tree8f10f3dfd92aa5e3e13c93c06dd7e1a44ea29f1c
parent69fc03d220a318a4df2c6f0612b17225e71a6069
selftests/xsk: store offset in pkt instead of addr

Store the offset in struct pkt instead of the address. This is
important since address is only meaningful in the context of a packet
that is stored in a single umem buffer and thus a single Tx
descriptor. If the packet, in contrast need to be represented by
multiple buffers in the umem, storing the address makes no sense since
the packet will consist of multiple buffers in the umem at various
addresses. This change is in preparation for the upcoming
multi-buffer support in AF_XDP and the corresponding tests.

So instead of indicating the address, we instead indicate the offset
of the packet in the first buffer. The actual address of the buffer is
allocated from the umem with a new function called
umem_alloc_buffer(). This also means we can get rid of the
use_fill_for_addr flag as the addresses fed into the fill ring will
always be the offset from the pkt specification in the packet stream
plus the address of the allocated buffer from the umem. No special
casing needed.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20230516103109.3066-7-magnus.karlsson@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/xskxceiver.c
tools/testing/selftests/bpf/xskxceiver.h