#sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget./translations/zh_CN/networking/xdp-rx-metadatamodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/zh_TW/networking/xdp-rx-metadatamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/it_IT/networking/xdp-rx-metadatamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/ja_JP/networking/xdp-rx-metadatamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/ko_KR/networking/xdp-rx-metadatamodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget./translations/sp_SP/networking/xdp-rx-metadatamodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhH/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata.rsthKubhsection)}(hhh](htitle)}(hXDP RX Metadatah]hXDP RX Metadata}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThis document describes how an eXpress Data Path (XDP) program can access hardware metadata related to a packet using a set of helper functions, and how it can pass that metadata on to other consumers.h]hThis document describes how an eXpress Data Path (XDP) program can access hardware metadata related to a packet using a set of helper functions, and how it can pass that metadata on to other consumers.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hGeneral Designh]hGeneral Design}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(hXXDP has access to a set of kfuncs to manipulate the metadata in an XDP frame. Every device driver that wishes to expose additional packet metadata can implement these kfuncs. The set of kfuncs is declared in ``include/net/xdp.h`` via ``XDP_METADATA_KFUNC_xxx``.h](hXDP has access to a set of kfuncs to manipulate the metadata in an XDP frame. Every device driver that wishes to expose additional packet metadata can implement these kfuncs. The set of kfuncs is declared in }(hhhhhNhNubhliteral)}(h``include/net/xdp.h``h]hinclude/net/xdp.h}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh via }(hhhhhNhNubh)}(h``XDP_METADATA_KFUNC_xxx``h]hXDP_METADATA_KFUNC_xxx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hpCurrently, the following kfuncs are supported. In the future, as more metadata is supported, this set will grow:h]hpCurrently, the following kfuncs are supported. In the future, as more metadata is supported, this set will grow:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubhindex)}(hhh]h}(h]h ]h"]h$]h&]entries](single*bpf_xdp_metadata_rx_timestamp (C function)c.bpf_xdp_metadata_rx_timestamphNtauh1j,hhhhhNhNubhdesc)}(hhh](hdesc_signature)}(hX__bpf_kfunc int bpf_xdp_metadata_rx_timestamp (const struct xdp_md *ctx, u64 *timestamp)h]hdesc_signature_line)}(hW__bpf_kfunc int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, u64 *timestamp)h](h __bpf_kfunc}(hjJhhhNhNubhdesc_sig_space)}(h h]h }(hjThhhNhNubah}(h]h ]wah"]h$]h&]uh1jRhjJhhhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chMubhdesc_sig_keyword_type)}(hinth]hint}(hjfhhhNhNubah}(h]h ]ktah"]h$]h&]uh1jdhjJhhhjchMubjS)}(h h]h }(hjuhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjJhhhjchMubh desc_name)}(hbpf_xdp_metadata_rx_timestamph]h desc_sig_name)}(hbpf_xdp_metadata_rx_timestamph]hbpf_xdp_metadata_rx_timestamp}(hjhhhNhNubah}(h]h ]nah"]h$]h&]uh1jhjubah}(h]h ](sig-namedescnameeh"]h$]h&]hhuh1jhjJhhhjchMubhdesc_parameterlist)}(h*(const struct xdp_md *ctx, u64 *timestamp)h](hdesc_parameter)}(hconst struct xdp_md *ctxh](hdesc_sig_keyword)}(hconsth]hconst}(hjhhhNhNubah}(h]h ]kah"]h$]h&]uh1jhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubj)}(hstructh]hstruct}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubh)}(hhh]j)}(hxdp_mdh]hxdp_md}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomaincreftype identifier reftargetjmodnameN classnameN c:parent_keysphinx.domains.c LookupKey)}data]j ASTIdentifier)}jjsbc.bpf_xdp_metadata_rx_timestampasbuh1hhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubhdesc_sig_punctuation)}(h*h]h*}(hj%hhhNhNubah}(h]h ]pah"]h$]h&]uh1j#hjubj)}(hctxh]hctx}(hj4hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjubj)}(hu64 *timestamph](h)}(hhh]j)}(hu64h]hu64}(hjPhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjMubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjRmodnameN classnameNjj )}j ]jc.bpf_xdp_metadata_rx_timestampasbuh1hhjIubjS)}(h h]h }(hjnhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjIubj$)}(hj'h]h*}(hj|hhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hjIubj)}(h timestamph]h timestamp}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjIubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjubeh}(h]h ]h"]h$]h&]hhuh1jhjJhhhjchMubeh}(h]h ]h"]h$]h&]hh add_permalinkuh1jHsphinx_line_type declaratorhjDhhhjchMubah}(h]j;ah ](sig sig-objecteh"]h$]h&] is_multiline _toc_parts) _toc_namehuh1jBhjchMhj?hhubh desc_content)}(hhh]h)}(hRead XDP frame RX timestamp.h]hRead XDP frame RX timestamp.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chMyhjhhubah}(h]h ]h"]h$]h&]uh1jhj?hhhjchMubeh}(h]h ](jfunctioneh"]h$]h&]domainjobjtypejdesctypejnoindex noindexentrynocontentsentryuh1j=hhhhhNhNubh container)}(hX/**Parameters** ``const struct xdp_md *ctx`` XDP context pointer. ``u64 *timestamp`` Return value pointer. **Return** * Returns 0 on success or ``-errno`` on error. * ``-EOPNOTSUPP`` : means device driver does not implement kfunc * ``-ENODATA`` : means no RX-timestamp available for this frameh](h)}(h**Parameters**h]hstrong)}(hjh]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chM}hjubhdefinition_list)}(hhh](hdefinition_list_item)}(h2``const struct xdp_md *ctx`` XDP context pointer. h](hterm)}(h``const struct xdp_md *ctx``h]h)}(hjh]hconst struct xdp_md *ctx}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chMzhjubh definition)}(hhh]h)}(hXDP context pointer.h]hXDP context pointer.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj#hMzhj&ubah}(h]h ]h"]h$]h&]uh1j$hjubeh}(h]h ]h"]h$]h&]uh1jhj#hMzhjubj)}(h)``u64 *timestamp`` Return value pointer. h](j )}(h``u64 *timestamp``h]h)}(hjIh]hu64 *timestamp}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjGubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chM{hjCubj%)}(hhh]h)}(hReturn value pointer.h]hReturn value pointer.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj^hM{hj_ubah}(h]h ]h"]h$]h&]uh1j$hjCubeh}(h]h ]h"]h$]h&]uh1jhj^hM{hjubeh}(h]h ]h"]h$]h&]uh1jhjubh)}(h **Return**h]j)}(hjh]hReturn}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chM}hjubh bullet_list)}(hhh](h list_item)}(h,Returns 0 on success or ``-errno`` on error.h]h)}(hjh](hReturns 0 on success or }(hjhhhNhNubh)}(h ``-errno``h]h-errno}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh on error.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chM}hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h>``-EOPNOTSUPP`` : means device driver does not implement kfunch]h)}(hjh](h)}(h``-EOPNOTSUPP``h]h -EOPNOTSUPP}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh/ : means device driver does not implement kfunc}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chM~hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h@``-ENODATA`` : means no RX-timestamp available for this frameh]h)}(hjh](h)}(h ``-ENODATA``h]h-ENODATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh4 : means no RX-timestamp available for this frame}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:22: ./net/core/xdp.chMhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]bulletj'uh1jhjhM}hjubeh}(h]h ] kernelindentah"]h$]h&]uh1jhhhhhNhNubj-)}(hhh]h}(h]h ]h"]h$]h&]entries](j9%bpf_xdp_metadata_rx_hash (C function)c.bpf_xdp_metadata_rx_hashhNtauh1j,hhhhhNhNubj>)}(hhh](jC)}(hp__bpf_kfunc int bpf_xdp_metadata_rx_hash (const struct xdp_md *ctx, u32 *hash, enum xdp_rss_hash_type *rss_type)h]jI)}(ho__bpf_kfunc int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, u32 *hash, enum xdp_rss_hash_type *rss_type)h](h __bpf_kfunc}(hj:hhhNhNubjS)}(h h]h }(hjBhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj:hhhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMubje)}(hinth]hint}(hjQhhhNhNubah}(h]h ]jqah"]h$]h&]uh1jdhj:hhhjPhMubjS)}(h h]h }(hj_hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj:hhhjPhMubj)}(hbpf_xdp_metadata_rx_hashh]j)}(hbpf_xdp_metadata_rx_hashh]hbpf_xdp_metadata_rx_hash}(hjqhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjmubah}(h]h ](jjeh"]h$]h&]hhuh1jhj:hhhjPhMubj)}(hG(const struct xdp_md *ctx, u32 *hash, enum xdp_rss_hash_type *rss_type)h](j)}(hconst struct xdp_md *ctxh](j)}(hjh]hconst}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubj)}(hjh]hstruct}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubh)}(hhh]j)}(hxdp_mdh]hxdp_md}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjmodnameN classnameNjj )}j ]j)}jjssbc.bpf_xdp_metadata_rx_hashasbuh1hhjubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubj$)}(hj'h]h*}(hjhhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hjubj)}(hctxh]hctx}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjubj)}(h u32 *hashh](h)}(hhh]j)}(hu32h]hu32}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjmodnameN classnameNjj )}j ]jc.bpf_xdp_metadata_rx_hashasbuh1hhjubjS)}(h h]h }(hj;hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjubj$)}(hj'h]h*}(hjIhhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hjubj)}(hhashh]hhash}(hjVhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjubj)}(h enum xdp_rss_hash_type *rss_typeh](j)}(henumh]henum}(hjohhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjkubjS)}(h h]h }(hj}hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjkubh)}(hhh]j)}(hxdp_rss_hash_typeh]hxdp_rss_hash_type}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjmodnameN classnameNjj )}j ]jc.bpf_xdp_metadata_rx_hashasbuh1hhjkubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjkubj$)}(hj'h]h*}(hjhhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hjkubj)}(hrss_typeh]hrss_type}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjkubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjubeh}(h]h ]h"]h$]h&]hhuh1jhj:hhhjPhMubeh}(h]h ]h"]h$]h&]hhjuh1jHjjhj6hhhjPhMubah}(h]j1ah ](jjeh"]h$]h&]jj)jhuh1jBhjPhMhj3hhubj)}(hhh]h)}(hRead XDP frame RX hash.h]hRead XDP frame RX hash.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjhhubah}(h]h ]h"]h$]h&]uh1jhj3hhhjPhMubeh}(h]h ](jfunctioneh"]h$]h&]jjjj jj jjjuh1j=hhhhhNhNubj)}(hX**Parameters** ``const struct xdp_md *ctx`` XDP context pointer. ``u32 *hash`` Return value pointer. ``enum xdp_rss_hash_type *rss_type`` Return value pointer for RSS type. **Description** The RSS hash type (**rss_type**) specifies what portion of packet headers NIC hardware used when calculating RSS hash value. The RSS type can be decoded via :c:type:`enum xdp_rss_hash_type ` either matching on individual L3/L4 bits ``XDP_RSS_L*`` or by combined traditional *RSS Hashing Types* ``XDP_RSS_TYPE_L*``. **Return** * Returns 0 on success or ``-errno`` on error. * ``-EOPNOTSUPP`` : means device driver doesn't implement kfunc * ``-ENODATA`` : means no RX-hash available for this frameh](h)}(h**Parameters**h]j)}(hjh]h Parameters}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhj ubj)}(hhh](j)}(h2``const struct xdp_md *ctx`` XDP context pointer. h](j )}(h``const struct xdp_md *ctx``h]h)}(hj2h]hconst struct xdp_md *ctx}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj0ubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhj,ubj%)}(hhh]h)}(hXDP context pointer.h]hXDP context pointer.}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjGhMhjHubah}(h]h ]h"]h$]h&]uh1j$hj,ubeh}(h]h ]h"]h$]h&]uh1jhjGhMhj)ubj)}(h$``u32 *hash`` Return value pointer. h](j )}(h ``u32 *hash``h]h)}(hjkh]h u32 *hash}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjiubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjeubj%)}(hhh]h)}(hReturn value pointer.h]hReturn value pointer.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhMhjubah}(h]h ]h"]h$]h&]uh1j$hjeubeh}(h]h ]h"]h$]h&]uh1jhjhMhj)ubj)}(hH``enum xdp_rss_hash_type *rss_type`` Return value pointer for RSS type. h](j )}(h$``enum xdp_rss_hash_type *rss_type``h]h)}(hjh]h enum xdp_rss_hash_type *rss_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjubj%)}(hhh]h)}(h"Return value pointer for RSS type.h]h"Return value pointer for RSS type.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhMhjubah}(h]h ]h"]h$]h&]uh1j$hjubeh}(h]h ]h"]h$]h&]uh1jhjhMhj)ubeh}(h]h ]h"]h$]h&]uh1jhj ubh)}(h**Description**h]j)}(hjh]h Description}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhj ubh)}(hXNThe RSS hash type (**rss_type**) specifies what portion of packet headers NIC hardware used when calculating RSS hash value. The RSS type can be decoded via :c:type:`enum xdp_rss_hash_type ` either matching on individual L3/L4 bits ``XDP_RSS_L*`` or by combined traditional *RSS Hashing Types* ``XDP_RSS_TYPE_L*``.h](hThe RSS hash type (}(hjhhhNhNubj)}(h **rss_type**h]hrss_type}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh) specifies what portion of packet headers NIC hardware used when calculating RSS hash value. The RSS type can be decoded via }(hjhhhNhNubh)}(h4:c:type:`enum xdp_rss_hash_type `h]h)}(hjh]henum xdp_rss_hash_type}(hjhhhNhNubah}(h]h ](xrefjc-typeeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocnetworking/xdp-rx-metadata refdomainjreftypetype refexplicitrefwarnjj )}j ]sb reftargetxdp_rss_hash_typeuh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjubh* either matching on individual L3/L4 bits }(hjhhhNhNubh)}(h``XDP_RSS_L*``h]h XDP_RSS_L*}(hj9hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh or by combined traditional }(hjhhhNhNubhemphasis)}(h*RSS Hashing Types*h]hRSS Hashing Types}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1jKhjubh }(hjhhhNhNubh)}(h``XDP_RSS_TYPE_L*``h]hXDP_RSS_TYPE_L*}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhj4hMhj ubh)}(h **Return**h]j)}(hjyh]hReturn}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1jhjwubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhj ubj)}(hhh](j)}(h,Returns 0 on success or ``-errno`` on error.h]h)}(hjh](hReturns 0 on success or }(hjhhhNhNubh)}(h ``-errno``h]h-errno}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh on error.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h=``-EOPNOTSUPP`` : means device driver doesn't implement kfunch]h)}(hjh](h)}(h``-EOPNOTSUPP``h]h -EOPNOTSUPP}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh0 : means device driver doesn’t implement kfunc}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h;``-ENODATA`` : means no RX-hash available for this frameh]h)}(hjh](h)}(h ``-ENODATA``h]h-ENODATA}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh/ : means no RX-hash available for this frame}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:25: ./net/core/xdp.chMhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]jj'uh1jhjhMhj ubeh}(h]h ] kernelindentah"]h$]h&]uh1jhhhhhNhNubj-)}(hhh]h}(h]h ]h"]h$]h&]entries](j9)bpf_xdp_metadata_rx_vlan_tag (C function)c.bpf_xdp_metadata_rx_vlan_taghNtauh1j,hhhhhNhNubj>)}(hhh](jC)}(hj__bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag (const struct xdp_md *ctx, __be16 *vlan_proto, u16 *vlan_tci)h]jI)}(hi__bpf_kfunc int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto, u16 *vlan_tci)h](h __bpf_kfunc}(hj*hhhNhNubjS)}(h h]h }(hj2hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj*hhhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:28: ./net/core/xdp.chMubje)}(hinth]hint}(hjAhhhNhNubah}(h]h ]jqah"]h$]h&]uh1jdhj*hhhj@hMubjS)}(h h]h }(hjOhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj*hhhj@hMubj)}(hbpf_xdp_metadata_rx_vlan_tagh]j)}(hbpf_xdp_metadata_rx_vlan_tagh]hbpf_xdp_metadata_rx_vlan_tag}(hjahhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj]ubah}(h]h ](jjeh"]h$]h&]hhuh1jhj*hhhj@hMubj)}(h=(const struct xdp_md *ctx, __be16 *vlan_proto, u16 *vlan_tci)h](j)}(hconst struct xdp_md *ctxh](j)}(hjh]hconst}(hj}hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjyubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjyubj)}(hjh]hstruct}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjyubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjyubh)}(hhh]j)}(hxdp_mdh]hxdp_md}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjmodnameN classnameNjj )}j ]j)}jjcsbc.bpf_xdp_metadata_rx_vlan_tagasbuh1hhjyubjS)}(h h]h }(hjhhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhjyubj$)}(hj'h]h*}(hjhhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hjyubj)}(hctxh]hctx}(hjhhhNhNubah}(h]h ]jah"]h$]h&]uh1jhjyubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjuubj)}(h__be16 *vlan_protoh](h)}(hhh]j)}(h__be16h]h__be16}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetj modnameN classnameNjj )}j ]jc.bpf_xdp_metadata_rx_vlan_tagasbuh1hhj ubjS)}(h h]h }(hj+ hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj ubj$)}(hj'h]h*}(hj9 hhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hj ubj)}(h vlan_protoh]h vlan_proto}(hjF hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjuubj)}(h u16 *vlan_tcih](h)}(hhh]j)}(hu16h]hu16}(hjb hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj_ ubah}(h]h ]h"]h$]h&] refdomainjreftypej reftargetjd modnameN classnameNjj )}j ]jc.bpf_xdp_metadata_rx_vlan_tagasbuh1hhj[ ubjS)}(h h]h }(hj hhhNhNubah}(h]h ]j_ah"]h$]h&]uh1jRhj[ ubj$)}(hj'h]h*}(hj hhhNhNubah}(h]h ]j0ah"]h$]h&]uh1j#hj[ ubj)}(hvlan_tcih]hvlan_tci}(hj hhhNhNubah}(h]h ]jah"]h$]h&]uh1jhj[ ubeh}(h]h ]h"]h$]h&]noemphhhuh1jhjuubeh}(h]h ]h"]h$]h&]hhuh1jhj*hhhj@hMubeh}(h]h ]h"]h$]h&]hhjuh1jHjjhj&hhhj@hMubah}(h]j!ah ](jjeh"]h$]h&]jj)jhuh1jBhj@hMhj#hhubj)}(hhh]h)}(h!Get XDP packet outermost VLAN tagh]h!Get XDP packet outermost VLAN tag}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:28: ./net/core/xdp.chMhj hhubah}(h]h ]h"]h$]h&]uh1jhj#hhhj@hMubeh}(h]h ](jfunctioneh"]h$]h&]jjjj jj jjjuh1j=hhhhhNhNubj)}(hX**Parameters** ``const struct xdp_md *ctx`` XDP context pointer. ``__be16 *vlan_proto`` Destination pointer for VLAN Tag protocol identifier (TPID). ``u16 *vlan_tci`` Destination pointer for VLAN TCI (VID + DEI + PCP) **Description** In case of success, ``vlan_proto`` contains *Tag protocol identifier (TPID)*, usually ``ETH_P_8021Q`` or ``ETH_P_8021AD``, but some networks can use custom TPIDs. ``vlan_proto`` is stored in **network byte order (BE)** and should be used as follows: ``if (vlan_proto == bpf_htons(ETH_P_8021Q)) do_something();`` ``vlan_tci`` contains the remaining 16 bits of a VLAN tag. Driver is expected to provide those in **host byte order (usually LE)**, so the bpf program should not perform byte conversion. According to 802.1Q standard, *VLAN TCI (Tag control information)* is a bit field that contains: *VLAN identifier (VID)* that can be read with ``vlan_tci & 0xfff``, *Drop eligible indicator (DEI)* - 1 bit, *Priority code point (PCP)* - 3 bits. For detailed meaning of DEI and PCP, please refer to other sources. **Return** * Returns 0 on success or ``-errno`` on error. * ``-EOPNOTSUPP`` : device driver doesn't implement kfunc * ``-ENODATA`` : VLAN tag was not stripped or is not availableh](h)}(h**Parameters**h]j)}(hj h]h Parameters}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhj ubah}(h]h ]h"]h$]h&]uh1hhY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:28: ./net/core/xdp.chMhj ubj)}(hhh](j)}(h2``const struct xdp_md *ctx`` XDP context pointer. h](j )}(h``const struct xdp_md *ctx``h]h)}(hj h]hconst struct xdp_md *ctx}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:28: ./net/core/xdp.chMhj ubj%)}(hhh]h)}(hXDP context pointer.h]hXDP context pointer.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hMhj ubah}(h]h ]h"]h$]h&]uh1j$hj ubeh}(h]h ]h"]h$]h&]uh1jhj hMhj ubj)}(hT``__be16 *vlan_proto`` Destination pointer for VLAN Tag protocol identifier (TPID). h](j )}(h``__be16 *vlan_proto``h]h)}(hj? h]h__be16 *vlan_proto}(hjA hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj= ubah}(h]h ]h"]h$]h&]uh1j hY/var/lib/git/docbuild/linux/Documentation/networking/xdp-rx-metadata:28: ./net/core/xdp.chMhj9 ubj%)}(hhh]h)}(hdata_meta xdp_buff->datah]h+----------+-----------------+------+ | headroom | custom metadata | data | +----------+-----------------+------+ ^ ^ | | xdp_buff->data_meta xdp_buff->data}hj sbah}(h]h ]h"]h$]h&]hhuh1j hhhK-hhhhubh)}(hAn XDP program can store individual metadata items into this ``data_meta`` area in whichever format it chooses. Later consumers of the metadata will have to agree on the format by some out of band contract (like for the AF_XDP use case, see below).h](h=An XDP program can store individual metadata items into this }(hj hhhNhNubh)}(h ``data_meta``h]h data_meta}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj ubh area in whichever format it chooses. Later consumers of the metadata will have to agree on the format by some out of band contract (like for the AF_XDP use case, see below).}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK4hhhhubeh}(h]general-designah ]h"]general designah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(hAF_XDPh]hAF_XDP}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhK:ubh)}(hXo:doc:`af_xdp` use-case implies that there is a contract between the BPF program that redirects XDP frames into the ``AF_XDP`` socket (``XSK``) and the final consumer. Thus the BPF program manually allocates a fixed number of bytes out of metadata via ``bpf_xdp_adjust_meta`` and calls a subset of kfuncs to populate it. The userspace ``XSK`` consumer computes ``xsk_umem__get_data() - METADATA_SIZE`` to locate that metadata. Note, ``xsk_umem__get_data`` is defined in ``libxdp`` and ``METADATA_SIZE`` is an application-specific constant (``AF_XDP`` receive descriptor does _not_ explicitly carry the size of the metadata).h](h)}(h :doc:`af_xdp`h]hinline)}(hj( h]haf_xdp}(hj, hhhNhNubah}(h]h ](jstdstd-doceh"]h$]h&]uh1j* hj& ubah}(h]h ]h"]h$]h&]refdocj) refdomainj6 reftypedoc refexplicitrefwarnj2af_xdpuh1hhhhKaddressh]h+----------+-----------------+------+ | headroom | custom metadata | data | +----------+-----------------+------+ ^ | rx_desc->address}hj&sbah}(h]h ]h"]h$]h&]hhuh1j hhhKHhj hhubeh}(h]af-xdpah ]h"]af_xdpah$]h&]uh1hhhhhhhhK:ubh)}(hhh](h)}(hXDP_PASSh]hXDP_PASS}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj<hhhhhKPubh)}(hXThis is the path where the packets processed by the XDP program are passed into the kernel. The kernel creates the ``skb`` out of the ``xdp_buff`` contents. Currently, every driver has custom kernel code to parse the descriptors and populate ``skb`` metadata when doing this ``xdp_buff->skb`` conversion, and the XDP metadata is not used by the kernel when building ``skbs``. However, TC-BPF programs can access the XDP metadata area using the ``data_meta`` pointer.h](hsThis is the path where the packets processed by the XDP program are passed into the kernel. The kernel creates the }(hjMhhhNhNubh)}(h``skb``h]hskb}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubh out of the }(hjMhhhNhNubh)}(h ``xdp_buff``h]hxdp_buff}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubh` contents. Currently, every driver has custom kernel code to parse the descriptors and populate }(hjMhhhNhNubh)}(h``skb``h]hskb}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubh metadata when doing this }(hjMhhhNhNubh)}(h``xdp_buff->skb``h]h xdp_buff->skb}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubhJ conversion, and the XDP metadata is not used by the kernel when building }(hjMhhhNhNubh)}(h``skbs``h]hskbs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubhF. However, TC-BPF programs can access the XDP metadata area using the }(hjMhhhNhNubh)}(h ``data_meta``h]h data_meta}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMubh pointer.}(hjMhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKRhj<hhubh)}(h}In the future, we'd like to support a case where an XDP program can override some of the metadata used for building ``skbs``.h](hvIn the future, we’d like to support a case where an XDP program can override some of the metadata used for building }(hjhhhNhNubh)}(h``skbs``h]hskbs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKZhj<hhubeh}(h]xdp-passah ]h"]xdp_passah$]h&]uh1hhhhhhhhKPubh)}(hhh](h)}(hbpf_redirect_maph]hbpf_redirect_map}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK^ubh)}(hXn``bpf_redirect_map`` can redirect the frame to a different device. Some devices (like virtual ethernet links) support running a second XDP program after the redirect. However, the final consumer doesn't have access to the original hardware descriptor and can't access any of the original metadata. The same applies to XDP programs installed into devmaps and cpumaps.h](h)}(h``bpf_redirect_map``h]hbpf_redirect_map}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhX^ can redirect the frame to a different device. Some devices (like virtual ethernet links) support running a second XDP program after the redirect. However, the final consumer doesn’t have access to the original hardware descriptor and can’t access any of the original metadata. The same applies to XDP programs installed into devmaps and cpumaps.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK`hjhhubh)}(hXThis means that for redirected packets only custom metadata is currently supported, which has to be prepared by the initial XDP program before redirect. If the frame is eventually passed to the kernel, the ``skb`` created from such a frame won't have any hardware metadata populated in its ``skb``. If such a packet is later redirected into an ``XSK``, that will also only have access to the custom metadata.h](hThis means that for redirected packets only custom metadata is currently supported, which has to be prepared by the initial XDP program before redirect. If the frame is eventually passed to the kernel, the }(hjhhhNhNubh)}(h``skb``h]hskb}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubhO created from such a frame won’t have any hardware metadata populated in its }(hjhhhNhNubh)}(h``skb``h]hskb}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh/. If such a packet is later redirected into an }(hjhhhNhNubh)}(h``XSK``h]hXSK}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh9, that will also only have access to the custom metadata.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKghjhhubeh}(h]bpf-redirect-mapah ]h"]bpf_redirect_mapah$]h&]uh1hhhhhhhhK^ubh)}(hhh](h)}(h bpf_tail_callh]h bpf_tail_call}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhhKoubh)}(hjAdding programs that access metadata kfuncs to the ``BPF_MAP_TYPE_PROG_ARRAY`` is currently not supported.h](h3Adding programs that access metadata kfuncs to the }(hjyhhhNhNubh)}(h``BPF_MAP_TYPE_PROG_ARRAY``h]hBPF_MAP_TYPE_PROG_ARRAY}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjyubh is currently not supported.}(hjyhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKqhjhhhubeh}(h] bpf-tail-callah ]h"] bpf_tail_callah$]h&]uh1hhhhhhhhKoubh)}(hhh](h)}(hSupported Devicesh]hSupported Devices}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKuubh)}(hIt is possible to query which kfunc the particular netdev implements via netlink. See ``xdp-rx-metadata-features`` attribute set in ``Documentation/netlink/specs/netdev.yaml``.h](hVIt is possible to query which kfunc the particular netdev implements via netlink. See }(hjhhhNhNubh)}(h``xdp-rx-metadata-features``h]hxdp-rx-metadata-features}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh attribute set in }(hjhhhNhNubh)}(h+``Documentation/netlink/specs/netdev.yaml``h]h'Documentation/netlink/specs/netdev.yaml}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKwhjhhubeh}(h]supported-devicesah ]h"]supported devicesah$]h&]uh1hhhhhhhhKuubh)}(hhh](h)}(hExampleh]hExample}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK|ubh)}(hSee ``tools/testing/selftests/bpf/progs/xdp_metadata.c`` and ``tools/testing/selftests/bpf/prog_tests/xdp_metadata.c`` for an example of BPF program that handles XDP metadata.h](hSee }(hjhhhNhNubh)}(h4``tools/testing/selftests/bpf/progs/xdp_metadata.c``h]h0tools/testing/selftests/bpf/progs/xdp_metadata.c}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh and }(hjhhhNhNubh)}(h9``tools/testing/selftests/bpf/prog_tests/xdp_metadata.c``h]h5tools/testing/selftests/bpf/prog_tests/xdp_metadata.c}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh9 for an example of BPF program that handles XDP metadata.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK~hjhhubeh}(h]exampleah ]h"]exampleah$]h&]uh1hhhhhhhhK|ubeh}(h]xdp-rx-metadataah ]h"]xdp rx metadataah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjberror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j<j9j j j9j6jjjejbjjjjj4j1u nametypes}(j<j j9jjejjj4uh}(j9hj hj;jDj1j6j!j&j6j jj<jbjjjhjjj1ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.