[PATCH bpf-next,v2 0/2] Clarify and Enhance XDP Rx Metadata Handling

Song Yoong Siang posted 2 patches 3 months, 1 week ago
There is a newer version of this series
Documentation/networking/xdp-rx-metadata.rst  | 38 +++++++++++++++++++
.../selftests/bpf/prog_tests/xdp_metadata.c   |  2 +-
.../selftests/bpf/progs/xdp_hw_metadata.c     |  2 +-
.../selftests/bpf/progs/xdp_metadata.c        |  2 +-
tools/testing/selftests/bpf/xdp_hw_metadata.c |  2 +-
tools/testing/selftests/bpf/xdp_metadata.h    |  7 ++++
6 files changed, 49 insertions(+), 4 deletions(-)
[PATCH bpf-next,v2 0/2] Clarify and Enhance XDP Rx Metadata Handling
Posted by Song Yoong Siang 3 months, 1 week ago
This patch set improves the documentation and selftests for XDP Rx metadata
handling. The first patch clarifies the documentation around XDP metadata
layout and the use of bpf_xdp_adjust_meta. The second patch enhances the
BPF selftests to make XDP metadata handling more robust and portable across
different NICs.

Prior to this patch set, the user application retrieved the xdp_meta by
calculating backward from the data pointer, while the XDP program fill in
the xdp_meta by calculating backward from data_meta. This approach will
cause mismatch if there is device-reserved metadata.

                        |<---sizeof(xdp_meta)--|
                        |                      |
                 struct xdp_meta               rx_desc->address
                        ^                      ^
                        |                      |
+----------+----------------------+------------+------+
| headroom |    custom metadata   |  reserved  | data |
+----------+----------------------+------------+------+
           ^                      ^            ^
           |                      |            |
    struct xdp_meta     xdp_buff->data_meta    xdp_buff->data
           |                      |
           |<---sizeof(xdp_meta)--|

V2:
  - unconditionally do bpf_xdp_adjust_meta with -XDP_METADATA_SIZE (Stanislav)

V1: https://lore.kernel.org/netdev/20250701042940.3272325-1-yoong.siang.song@intel.com/

Song Yoong Siang (2):
  doc: clarify XDP Rx metadata layout and bpf_xdp_adjust_meta usage
  selftests/bpf: Enhance XDP Rx Metadata Handling

 Documentation/networking/xdp-rx-metadata.rst  | 38 +++++++++++++++++++
 .../selftests/bpf/prog_tests/xdp_metadata.c   |  2 +-
 .../selftests/bpf/progs/xdp_hw_metadata.c     |  2 +-
 .../selftests/bpf/progs/xdp_metadata.c        |  2 +-
 tools/testing/selftests/bpf/xdp_hw_metadata.c |  2 +-
 tools/testing/selftests/bpf/xdp_metadata.h    |  7 ++++
 6 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.34.1