[PATCH net-next v4 00/33] XDP extend with knowledge of frame size

Jesper Dangaard Brouer
2020-05-14T10:49:16Z

(Patchset based on net-next due to all the driver updates)

V4:
- Fixup checkpatch.pl issues
- Collected more ACKs

V3:
- Fix issue on virtio_net patch spotted by Jason Wang
- Adjust name for variable in mlx5 patch
- Collected more ACKs

V2:
- Fix bug in mlx5 for XDP_PASS case
- Collected nitpicks and ACKs from mailing list

V1:
- Fix bug in dpaa2

XDP have evolved to support several frame sizes, but xdp_buff was not
updated with this information. This have caused the side-effect that
XDP frame data hard end is unknown. This have limited the BPF-helper
bpf_xdp_adjust_tail to only shrink the packet. This patchset address
this and add packet tail extend/grow.

The purpose of the patchset is ALSO to reserve a memory area that can be
used for storing extra information, specifically for extending XDP with
multi-buffer support. One proposal is to use same layout as
skb_shared_info, which is why this area is currently 320 bytes.

When converting xdp_frame to SKB (veth and cpumap), the full tailroom
area can now be used and SKB truesize is now correct. For most
drivers this result in a much larger tailroom in SKB "head" data
area. The network stack can now take advantage of this when doing SKB
coalescing. Thus, a good driver test is to use xdp_redirect_cpu from
samples/bpf/ and do some TCP stream testing.

Use-cases for tail grow/extend:
(1) IPsec / XFRM needs a tail extend[1][2].
(2) DNS-cache responses in XDP.
(3) HAProxy ALOHA would need it to convert to XDP.
(4) Add tail info e.g. timestamp and collect via tcpdump

[1] http://vger.kernel.org/netconf2019_files/xfrm_xdp.pdf
[2] http://vger.kernel.org/netconf2019.html

Examples on howto access the tail area of an XDP packet is shown in the
XDP-tutorial example[3].

[3] https://github.com/xdp-project/xdp-tutorial/blob/master/experiment01-tailgrow/

---

Ilias Apalodimas (1):
net: netsec: Add support for XDP frame size

Jesper Dangaard Brouer (32):
xdp: add frame size to xdp_buff
bnxt: add XDP frame size to driver
sfc: add XDP frame size
mvneta: add XDP frame size to driver
net: XDP-generic determining XDP frame size
xdp: xdp_frame add member frame_sz and handle in convert_to_xdp_frame
xdp: cpumap redirect use frame_sz and increase skb_tailroom
veth: adjust hard_start offset on redirect XDP frames
veth: xdp using frame_sz in veth driver
dpaa2-eth: add XDP frame size
hv_netvsc: add XDP frame size to driver
qlogic/qede: add XDP frame size to driver
net: ethernet: ti: add XDP frame size to driver cpsw
ena: add XDP frame size to amazon NIC driver
mlx4: add XDP frame size and adjust max XDP MTU
net: thunderx: add XDP frame size
nfp: add XDP frame size to netronome driver
tun: add XDP frame size
vhost_net: also populate XDP frame size
virtio_net: add XDP frame size in two code paths
ixgbe: fix XDP redirect on archs with PAGE_SIZE above 4K
ixgbe: add XDP frame size to driver
ixgbevf: add XDP frame size to VF driver
i40e: add XDP frame size to driver
ice: add XDP frame size to driver
xdp: for Intel AF_XDP drivers add XDP frame_sz
mlx5: rx queue setup time determine frame_sz for XDP
xdp: allow bpf_xdp_adjust_tail() to grow packet size
xdp: clear grow memory in bpf_xdp_adjust_tail()
bpf: add xdp.frame_sz in bpf_prog_test_run_xdp().
selftests/bpf: adjust BPF selftest for xdp_adjust_tail
selftests/bpf: xdp_adjust_tail add grow tail tests

drivers/net/ethernet/amazon/ena/ena_netdev.c | 1
drivers/net/ethernet/amazon/ena/ena_netdev.h | 5 -
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 1
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 1
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 7 +
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 30 ++++-
drivers/net/ethernet/intel/i40e/i40e_xsk.c | 2
drivers/net/ethernet/intel/ice/ice_txrx.c | 34 ++++--
drivers/net/ethernet/intel/ice/ice_xsk.c | 2
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 33 ++++-
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 2
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 34 ++++--
drivers/net/ethernet/marvell/mvneta.c | 25 ++--
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 3
drivers/net/ethernet/mellanox/mlx4/en_rx.c | 1
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 1
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2
.../net/ethernet/netronome/nfp/nfp_net_common.c | 6 +
drivers/net/ethernet/qlogic/qede/qede_fp.c | 1
drivers/net/ethernet/qlogic/qede/qede_main.c | 2
drivers/net/ethernet/sfc/rx.c | 1
drivers/net/ethernet/socionext/netsec.c | 30 +++--
drivers/net/ethernet/ti/cpsw.c | 1
drivers/net/ethernet/ti/cpsw_new.c | 1
drivers/net/hyperv/netvsc_bpf.c | 1
drivers/net/hyperv/netvsc_drv.c | 2
drivers/net/tun.c | 2
drivers/net/veth.c | 28 +++--
drivers/net/virtio_net.c | 15 ++
drivers/vhost/net.c | 1
include/net/xdp.h | 27 ++++
include/net/xdp_sock.h | 11 ++
include/uapi/linux/bpf.h | 4 -
kernel/bpf/cpumap.c | 21 ---
net/bpf/test_run.c | 16 ++-
net/core/dev.c | 14 +-
net/core/filter.c | 15 ++
net/core/xdp.c | 8 +
.../selftests/bpf/prog_tests/xdp_adjust_tail.c | 123 +++++++++++++++++++-
.../testing/selftests/bpf/progs/test_adjust_tail.c | 30 -----
.../bpf/progs/test_xdp_adjust_tail_grow.c | 33 +++++
.../bpf/progs/test_xdp_adjust_tail_shrink.c | 30 +++++
44 files changed, 475 insertions(+), 139 deletions(-)
delete mode 100644 tools/testing/selftests/bpf/progs/test_adjust_tail.c
create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c
create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c

--