Skip to content

xdp: hints via kfuncs

Stanislav Fomichev bpf llvm netdev oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 55 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11bpf: Document XDP RX metadataDocumentation/bpf/xdp-rx-metadata.rst+109 -04 replies
2/11bpf: Introduce bpf_patchinclude/linux/bpf_patch.h kernel/bpf/Makefile kernel/bpf/bpf_patch.c+107 -10 replies
3/11bpf: Support inlined/unrolled kfuncs for xdp metadataDocumentation/bpf/kfuncs.rst include/linux/bpf.h include/linux/btf.h +9 more+191 -14 replies
4/11bpf: Implement hidden BPF_PUSH64 and BPF_POP64 instructionsarch/arm64/net/bpf_jit_comp.c arch/x86/net/bpf_jit_comp.c include/linux/filter.h +1 more+45 -00 replies
5/11veth: Support rx timestamp metadata for xdpdrivers/net/veth.c+14 -027 replies
6/11xdp: Carry over xdp metadata into skb contextdrivers/net/veth.c include/linux/skbuff.h include/net/xdp.h +6 more+255 -1015 replies
7/11selftests/bpf: Verify xdp_metadata xdp->af_xdp pathtools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/prog_tests/xdp_metadata.c tools/testing/selftests/bpf/progs/xdp_metadata.c+410 -10 replies
8/11selftests/bpf: Verify xdp_metadata xdp->skb pathtools/testing/selftests/bpf/DENYLIST.s390x tools/testing/selftests/bpf/prog_tests/xdp_metadata.c tools/testing/selftests/bpf/progs/xdp_metadata.c+146 -00 replies
9/11mlx4: Introduce mlx4_xdp_buff wrapper for xdp_buffdrivers/net/ethernet/mellanox/mlx4/en_rx.c+15 -110 replies
10/11mxl4: Support rx timestamp metadata for xdpdrivers/net/ethernet/mellanox/mlx4/en_netdev.c drivers/net/ethernet/mellanox/mlx4/en_rx.c include/linux/mlx4/device.h+50 -10 replies
11/11selftests/bpf: Simple program to dump XDP RX metadatatools/testing/selftests/bpf/.gitignore tools/testing/selftests/bpf/Makefile tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +2 more+515 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 00/11] xdp: hints via kfuncs

Please see the first patch in the series for the overall design and use-cases.

Changes since last RFC:

- drop ice/bnxt example implementation (Alexander)

-ENOHARDWARE to test

- fix/test mlx4 implementation

Confirmed that I get reasonable looking timestamp. The last patch in the series is the small xsk program that can be used to dump incoming metadata.

- bpf_push64/bpf_pop64 (Alexei)

x86_64+arm64(untested)+disassembler

- struct xdp_to_skb_metadata -> struct xdp_skb_metadata (Toke)

s/xdp_to_skb/xdp_skb/

- Documentation/bpf/xdp-rx-metadata.rst

Documents functionality, assumptions and limitations.

- bpf_xdp_metadata_export_to_skb returns true/false (Martin)

Plus xdp_md->skb_metadata field to access it.

- BPF_F_XDP_HAS_METADATA flag (Toke/Martin)

Drop magic, use the flag instead.

- drop __randomize_layout

Not sure it's possible to sanely expose it via UAPI. Because every .o potentially gets its own randomized layout, test_progs refuses to link.

- remove __net_timestamp in veth driver (John/Jesper)

Instead, calling ktime_get from the kfunc; enough for the selftests.

Future work on RX side:

- Support more devices besides veth and mlx4
- Support more metadata besides RX timestamp.
- Convert skb_metadata_set() callers to xdp_convert_skb_metadata() which handles extra xdp_skb_metadata

Prior art (to record pros/cons for different approaches):

- Stable UAPI approach:
https://lore.kernel.org/bpf/[email protected]/
- Metadata+BTF_ID appoach:
https://lore.kernel.org/bpf/166256538687.1434226.15760041133601409770.stgit@firesoul/
- kfuncs v2 RFC:
https://lore.kernel.org/bpf/[email protected]/
- kfuncs v1 RFC:
https://lore.kernel.org/bpf/[email protected]/

Cc John Fastabend <[email protected]>
Cc David Ahern <[email protected]>
Cc Martin KaFai Lau <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>
Cc Anatoly Burakov <[email protected]>
Cc Alexander Lobakin <[email protected]>
Cc Magnus Karlsson <[email protected]>
Cc Maryam Tahhan <[email protected]>

Stanislav Fomichev (11):
bpf: Document XDP RX metadata
bpf: Introduce bpf_patch
bpf: Support inlined/unrolled kfuncs for xdp metadata
bpf: Implement hidden BPF_PUSH64 and BPF_POP64 instructions
veth: Support rx timestamp metadata for xdp
xdp: Carry over xdp metadata into skb context selftests/bpf: Verify xdp_metadata xdp->af_xdp path selftests/bpf: Verify xdp_metadata xdp->skb path
mlx4: Introduce mlx4_xdp_buff wrapper for xdp_buff
mxl4: Support rx timestamp metadata for xdp selftests/bpf: Simple program to dump XDP RX metadata

 Documentation/bpf/kfuncs.rst                  |   8 +
 Documentation/bpf/xdp-rx-metadata.rst         | 109 +++++
 arch/arm64/net/bpf_jit_comp.c                 |   8 +
 arch/x86/net/bpf_jit_comp.c                   |   8 +
 .../net/ethernet/mellanox/mlx4/en_netdev.c    |   2 +
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  68 ++-
 drivers/net/veth.c                            |  22 +-
 include/linux/bpf.h                           |   1 +
 include/linux/bpf_patch.h                     |  29 ++
 include/linux/btf.h                           |   1 +
 include/linux/btf_ids.h                       |   4 +
 include/linux/filter.h                        |  23 +
 include/linux/mlx4/device.h                   |   7 +
 include/linux/netdevice.h                     |   5 +
 include/linux/skbuff.h                        |   4 +
 include/net/xdp.h                             |  41 ++
 include/uapi/linux/bpf.h                      |  12 +
 kernel/bpf/Makefile                           |   2 +-
 kernel/bpf/bpf_patch.c                        |  77 +++
 kernel/bpf/disasm.c                           |   6 +
 kernel/bpf/syscall.c                          |  28 +-
 kernel/bpf/verifier.c                         |  80 ++++
 net/core/dev.c                                |   7 +
 net/core/filter.c                             |  40 ++
 net/core/skbuff.c                             |  20 +
 net/core/xdp.c                                | 184 +++++++-
 tools/include/uapi/linux/bpf.h                |  12 +
 tools/testing/selftests/bpf/.gitignore        |   1 +
 tools/testing/selftests/bpf/DENYLIST.s390x    |   1 +
 tools/testing/selftests/bpf/Makefile          |   8 +-
 .../selftests/bpf/prog_tests/xdp_metadata.c   | 440 ++++++++++++++++++
 .../selftests/bpf/progs/xdp_hw_metadata.c     |  99 ++++
 .../selftests/bpf/progs/xdp_metadata.c        | 114 +++++
 tools/testing/selftests/bpf/xdp_hw_metadata.c | 404 ++++++++++++++++
 tools/testing/selftests/bpf/xdp_hw_metadata.h |   6 +
 35 files changed, 1856 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/bpf/xdp-rx-metadata.rst
 create mode 100644 include/linux/bpf_patch.h
 create mode 100644 kernel/bpf/bpf_patch.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
 create mode 100644 tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
 create mode 100644 tools/testing/selftests/bpf/progs/xdp_metadata.c
 create mode 100644 tools/testing/selftests/bpf/xdp_hw_metadata.c
 create mode 100644 tools/testing/selftests/bpf/xdp_hw_metadata.h
Signature · 1 line
2.38.1.431.g37b22c650d-goog