From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Tianyi Gao <tianyi@cloudflare.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Jakub Kicinski <kuba@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Lorenzo Bianconi <lorenzo@kernel.org>,
Vladimir Vdovin <deliran@verdict.gg>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Donald Hunter <donald.hunter@gmail.com>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Magnus Karlsson <magnus.karlsson@intel.com>,
Tushar Vyavahare <tushar.vyavahare@intel.com>,
Jason Xing <kerneljasonxing@gmail.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Madalin Bucur <madalin.bucur@nxp.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Shuah Khan <shuah@kernel.org>,
Randy Dunlap <rdunlap@infradead.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Chris J Arges <carges@cloudflare.com>,
Jakub Sitnicki <jakub@cloudflare.com>,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
intel-wired-lan@lists.osuosl.org, llvm@lists.linux.dev,
kernel-team@cloudflare.com
Subject: Re: [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation
Date: Tue, 1 Dec 2026 10:09:04 +0100 [thread overview]
Message-ID: <b3e67ffc-5610-4598-9291-ee0264983a4a@kernel.org> (raw)
In-Reply-To: <CAG4wq-cXJtTzG2GO9KTL04b=prS+X67fRBJ=nriOO0G-24Rjzw@mail.gmail.com>
On 11/12/26 15:55, Tianyi Gao wrote:
> Hi Alexei,
>
> On Thu, 12 Nov 2026 00:34:54 +0000, Alexei Starovoitov wrote:
>> I'm with Stan on this. It looks heavy.
>>
>> How about the following idea:
>
> Thank you very much for the patch and the idea. I really appreciate it!
>
> v1 uses the skb_ext-like layout mainly because of the earlier pushback
> on a fixed struct [1][2]. This series adds only the three most commonly
> needed types of RX metadata. A 12-byte fixed struct that takes headroom
> only when any RX metadata is stored can be a reasonable middle ground.
>
> I would like to hear from Jesper and Jakub before I move to v2.
>
Short version: the RX metadata must travel with the xdp_frame, in a
format the kernel knows. Fixed struct or skb_ext-like is secondary.
Jakub, this builds on your "driver always populates" idea [1].
I like Alexei's fixed struct, and I have changed my mind. In July I
proposed the skb_ext-like layout [2]. A fixed struct is simpler and
good enough. The fields are HW offloads that map to fixed skb members
(hash, VLAN, csum). The list is short and stable: 12 bytes today, and
below 24 bytes even with RX timestamp and RX queue index. It stays
inside the cache line of the xdp_frame.
Our main use case is XDP_REDIRECT into cpumap and veth. There, core
code builds the skb from the xdp_frame on another CPU: the cpumap
kthread, or veth in threaded NAPI mode, which we run in production.
Today the RX hash and the csum status are lost on the way. GRO on the
remote CPU then puts all flows in one bucket, and veth verifies every
checksum in software.
The values could travel in data_meta, with a second XDP prog at the
target that calls a setter. We do not want that. data_meta is a
contract between BPF progs, in a format the kernel does not know. And
it needs a BPF prog at every place an skb is built, also on veths
where a service owns the XDP prog.
Jakub, I know your objection is the model, not only the layout [3].
How I see it: the RX descriptor is a HW ABI. The NIC defines and
writes it, the kernel only reads it. The xmo callbacks (xmo_rx_hash,
xmo_rx_vlan_tag, ...) read the descriptor and decode it into one
common format, which maps to the skb.
A per-driver setter must store the value in one of two places:
- Back in the descriptor, in HW format. That is device-owned memory,
and some values have no field there (e.g. csum_level).
- In driver memory, in the decoded format. Then every driver keeps
its own copy of the same struct, with the same setter.
A kernel-known area after the xdp_frame is that copy, done once.
The bigger reason is the direction. When the kernel knows the format
(fixed struct or skb_ext-like), the xdp_frame becomes a mini-SKB: it
carries what the skb needs, so core code can build the skb. The end
goal is that NIC drivers stop allocating skbs, and send the xdp_frame
into the netstack instead. ice is already close: it builds the skb
with the generic xdp_build_skb_from_buff(), and then fills the fields
from its descriptor. Later, GRO can check an xdp_frame against the
current GRO packet, and skip the skb for every packet it merges. A
per-driver setter cannot get there. Driver-local state is gone when
the frame leaves the driver, and core code cannot read it.
Jakub, I agree with you that the driver should always populate the
area [1]. The difference is when: after the XDP prog has run.
1. The prog runs first. Nothing is populated, so XDP_DROP stays as
fast as today.
2. The prog stores the values it changed, for example the csum status
after a decap [4], or a new or cleared VLAN tag.
3. On XDP_PASS and XDP_REDIRECT, the driver fills the other fields
from its descriptor.
This also fixes XDP_PASS. Today the kernel does not know what XDP
changed, so the driver applies HW info that may no longer match the
packet, and XDP cannot change a stripped VLAN tag at all. We run with
VLAN offload disabled for this reason. A return code like
XDP_PASS_MODIFIED would only say "something changed". With a store,
the BPF-prog corrects exactly the fields it changed. This is the
explicit update/invalidate plan Jakub asked for [5].
--Jesper
[1] https://lore.kernel.org/all/20250805172831.213ddd8d@kernel.org/
[2]
https://lore.kernel.org/all/1d5521eb-84fc-4417-a3f5-6366694d160a@kernel.org/
[3] https://lore.kernel.org/all/20261117161856.6f6c2ce9@kernel.org/
[4] https://lore.kernel.org/all/20260227153231.78d16b69@kernel.org/
[5] https://lore.kernel.org/all/20260722113525.34092660@kernel.org/
prev parent reply other threads:[~2026-12-01 9:09 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 3:56 [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation Tianyi Gao
2026-11-10 3:56 ` [PATCH bpf-next 01/15] xdp: reserve an skb core extension area after the xdp_frame Tianyi Gao
2026-11-10 13:10 ` Jesper Dangaard Brouer
2026-11-10 3:57 ` [PATCH bpf-next 02/15] net: dpaa, dpaa2: clear the skb core extension flag Tianyi Gao
2026-11-13 12:02 ` Loktionov, Aleksandr
2026-11-10 3:57 ` [PATCH bpf-next 03/15] xdp: add kfuncs to store RX hash and VLAN tag Tianyi Gao
2026-11-10 14:13 ` Jesper Dangaard Brouer
2026-11-10 3:57 ` [PATCH bpf-next 04/15] xdp: add a kfunc to delete skb core extension entries Tianyi Gao
2026-11-10 14:20 ` Jesper Dangaard Brouer
2026-11-13 12:04 ` Loktionov, Aleksandr
2026-11-10 3:57 ` [PATCH bpf-next 05/15] xdp: add a kfunc to store the RX checksum status Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 06/15] selftests/bpf: Test the skb core extension kfuncs Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 07/15] xdp: set skb RX metadata from the skb core extension area of xdp_frame Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 08/15] selftests/bpf: Test RX metadata on skbs built from xdp_frames Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 09/15] xdp: add the skb-ext-pass XDP feature and warn without it Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 10/15] xdp: warn on XDP_PASS with stored values when XDP runs on an skb Tianyi Gao
2026-11-10 4:53 ` bot+bpf-ci
2026-11-10 3:57 ` [PATCH bpf-next 11/15] ice: set skb RX metadata from the skb core extension area of xdp_buff Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 12/15] selftests: drv-net: xdp: test the stored RX metadata on XDP_PASS Tianyi Gao
2026-11-10 3:57 ` [PATCH bpf-next 13/15] xdp: add kfuncs to load the stored RX metadata Tianyi Gao
2026-11-13 12:05 ` Loktionov, Aleksandr
2026-11-10 3:57 ` [PATCH bpf-next 14/15] selftests/bpf: Test the load kfuncs on cpumap and veth Tianyi Gao
2026-11-13 12:06 ` Loktionov, Aleksandr
2026-11-10 3:57 ` [PATCH bpf-next 15/15] docs: net: document the skb core extension area Tianyi Gao
2026-11-10 4:53 ` bot+bpf-ci
2026-11-10 13:01 ` [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation Jesper Dangaard Brouer
2026-11-11 0:00 ` Stanislav Fomichev
2026-11-11 1:07 ` Tianyi Gao
2026-11-11 22:25 ` Stanislav Fomichev
2026-11-11 23:46 ` Tianyi Gao
2026-11-15 19:39 ` Jakub Kicinski
2026-11-15 23:36 ` Tianyi Gao
2026-11-16 22:27 ` Jakub Kicinski
2026-11-16 23:55 ` Tianyi Gao
2026-11-18 0:18 ` Jakub Kicinski
2026-11-18 0:42 ` Tianyi Gao
2026-11-18 23:35 ` Jakub Kicinski
2026-11-12 0:34 ` Alexei Starovoitov
2026-11-12 14:55 ` Tianyi Gao
2026-12-01 9:09 ` Jesper Dangaard Brouer [this message]
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=b3e67ffc-5610-4598-9291-ee0264983a4a@kernel.org \
--to=hawk@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=bpf@vger.kernel.org \
--cc=carges@cloudflare.com \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=deliran@verdict.gg \
--cc=donald.hunter@gmail.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=ioana.ciornei@nxp.com \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=kernel-team@cloudflare.com \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=lorenzo@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=madalin.bucur@nxp.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=razor@blackwall.org \
--cc=rdunlap@infradead.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=song@kernel.org \
--cc=tianyi@cloudflare.com \
--cc=tushar.vyavahare@intel.com \
--cc=yonghong.song@linux.dev \
/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