Lines Matching +full:xdp +full:- +full:rx +full:- +full:metadata

1 .. SPDX-License-Identifier: GPL-2.0
4 XDP RX Metadata
7 This document describes how an eXpress Data Path (XDP) program can access
8 hardware metadata related to a packet using a set of helper functions,
9 and how it can pass that metadata on to other consumers.
14 XDP has access to a set of kfuncs to manipulate the metadata in an XDP frame.
15 Every device driver that wishes to expose additional packet metadata can
16 implement these kfuncs. The set of kfuncs is declared in ``include/net/xdp.h``
20 metadata is supported, this set will grow:
22 .. kernel-doc:: net/core/xdp.c
25 .. kernel-doc:: net/core/xdp.c
28 .. kernel-doc:: net/core/xdp.c
31 An XDP program can use these kfuncs to read the metadata into stack
32 variables for its own consumption. Or, to pass the metadata on to other
33 consumers, an XDP program can store it into the metadata area carried
35 metadata available in which case the driver returns ``-ENODATA``.
38 implemented, the default ones that return ``-EOPNOTSUPP`` will be used
42 Within an XDP frame, the metadata layout (accessed via ``xdp_buff``) is
45 +----------+-----------------+------+
46 | headroom | custom metadata | data |
47 +----------+-----------------+------+
50 xdp_buff->data_meta xdp_buff->data
52 An XDP program can store individual metadata items into this ``data_meta``
53 area in whichever format it chooses. Later consumers of the metadata
60 :doc:`af_xdp` use-case implies that there is a contract between the BPF
61 program that redirects XDP frames into the ``AF_XDP`` socket (``XSK``) and
63 bytes out of metadata via ``bpf_xdp_adjust_meta`` and calls a subset
65 ``xsk_umem__get_data() - METADATA_SIZE`` to locate that metadata.
67 ``METADATA_SIZE`` is an application-specific constant (``AF_XDP`` receive
68 descriptor does _not_ explicitly carry the size of the metadata).
72 +----------+-----------------+------+
73 | headroom | custom metadata | data |
74 +----------+-----------------+------+
77 rx_desc->address
82 This is the path where the packets processed by the XDP program are passed
85 the descriptors and populate ``skb`` metadata when doing this ``xdp_buff->skb``
86 conversion, and the XDP metadata is not used by the kernel when building
87 ``skbs``. However, TC-BPF programs can access the XDP metadata area using
90 In the future, we'd like to support a case where an XDP program
91 can override some of the metadata used for building ``skbs``.
97 Some devices (like virtual ethernet links) support running a second XDP
100 the original metadata. The same applies to XDP programs installed
103 This means that for redirected packets only custom metadata is
104 currently supported, which has to be prepared by the initial XDP program
106 ``skb`` created from such a frame won't have any hardware metadata populated
108 that will also only have access to the custom metadata.
113 Adding programs that access metadata kfuncs to the ``BPF_MAP_TYPE_PROG_ARRAY``
120 netlink. See ``xdp-rx-metadata-features`` attribute set in
128 BPF program that handles XDP metadata.