linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@kernel.org>
To: "Song, Yoong Siang" <yoong.siang.song@intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"KP Singh" <kpsingh@kernel.org>, "Hao Luo" <haoluo@google.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Mykola Lysenko" <mykolal@fb.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Magnus Karlsson" <magnus.karlsson@gmail.com>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Maciej Fijalkowski" <maciej.fijalkowski@intel.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH bpf-next,v3 2/2] selftests/bpf: Enhance XDP Rx metadata handling
Date: Fri, 4 Jul 2025 11:58:37 +0200	[thread overview]
Message-ID: <88a64a65-bd8c-4b73-af19-6764054d4572@kernel.org> (raw)
In-Reply-To: <IA3PR11MB92546301B67FB3A9FDCD716DD842A@IA3PR11MB9254.namprd11.prod.outlook.com>



On 04/07/2025 03.17, Song, Yoong Siang wrote:
> On Friday, July 4, 2025 1:05 AM, Jesper Dangaard Brouer <hawk@kernel.org> wrote:
>> On 02/07/2025 18.57, Song Yoong Siang wrote:
>>> Introduce the XDP_METADATA_SIZE macro as a conservative measure to
>>> accommodate any metadata areas reserved by Ethernet devices.
>>>
>>
>> This seems like a sloppy workaround :-(
>>
>> To me, the problem arise because AF_XDP is lacking the ability to
>> communicate the size of the data_meta area.  If we had this capability,
>> then we could allow the IGC driver to take some of the space, have the
>> BPF-prog expand it futher (bpf_xdp_adjust_meta) and then userspace
>> AF_XDP would simply be able to see the size of the data_meta area, and
>> apply the struct xdp_meta at right offset.
>>
> Thanks for your input.
> 
> I agree with you that the implementation will be simple if user application
> able to get the size of data_meta area. The intention of this patch set is to let
> developer aware of such limitations before we have a perfect solution.
> 
> Btw, do you got any suggestion on how to expose the metadata length?
> I not sure whether xdp_desc.options is a simple and good idea or not?

That is a question to the AF_XDP maintainers... added them to this email.

/* Rx/Tx descriptor */
struct xdp_desc {
	__u64 addr;
	__u32 len;
	__u32 options;
};

As far as I know, the xdp_desc.options field isn't used, right?


(Please AF_XDP experts, please verify below statements:)
Something else we likely want to document: The available headroom in the
AF_XDP frame.  When accessing the metadata in userspace AF_XDP we do a
negative offset from the UMEM packet pointer.  IIRC on RX the available
headroom will be either 255 or 192 bytes (depending on NIC drivers).

Slightly confusing when AF_XDP transmitting from userspace the UMEM
headroom is default zero (XSK_UMEM__DEFAULT_FRAME_HEADROOM is zero).
This is configurable via xsk_umem_config.frame_headroom, like I did in
this example[1].

Maybe I did something wrong in[1], because I see that the new method is
setting xsk_umem_config.tx_metadata_len + flag XDP_UMEM_TX_METADATA_LEN.
This is nicely documented in [2]. How does this interact with setting
xsk_umem_config.frame_headroom ?


[1] 
https://github.com/xdp-project/bpf-examples/blob/3f365af4be1fe6a0ef77e751ff9b12c912810453/AF_XDP-interaction/af_xdp_user.c#L423-L424
[2] https://www.kernel.org/doc/html/v6.12/networking/xsk-tx-metadata.html

--Jesper

  reply	other threads:[~2025-07-04  9:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-02 16:57 [PATCH bpf-next,v3 0/2] Clarify and Enhance XDP Rx Metadata Handling Song Yoong Siang
2025-07-02 16:57 ` [PATCH bpf-next,v3 1/2] doc: enhance explanation of XDP Rx metadata layout and METADATA_SIZE Song Yoong Siang
2025-07-03 15:57   ` Daniel Borkmann
2025-07-04  0:33     ` Song, Yoong Siang
2025-07-02 16:57 ` [PATCH bpf-next,v3 2/2] selftests/bpf: Enhance XDP Rx metadata handling Song Yoong Siang
2025-07-03 17:04   ` Jesper Dangaard Brouer
2025-07-04  1:17     ` Song, Yoong Siang
2025-07-04  9:58       ` Jesper Dangaard Brouer [this message]
2025-07-04 11:38         ` Daniel Borkmann
2025-07-07 15:03           ` Stanislav Fomichev
2025-07-09 14:00             ` Daniel Borkmann
2025-07-09 16:29               ` Stanislav Fomichev
2025-07-10 15:35                 ` Song, Yoong Siang
2025-07-10 17:28                   ` Jakub Kicinski
2025-07-03 15:41 ` [PATCH bpf-next,v3 0/2] Clarify and Enhance XDP Rx Metadata Handling Stanislav Fomichev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88a64a65-bd8c-4b73-af19-6764054d4572@kernel.org \
    --to=hawk@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=haoluo@google.com \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    --cc=yoong.siang.song@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).