From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116157; b=LRLYJRTEYeW/e0a9ek/TEU/3XVFCzncKWv646tYqxSYb3cSYLy7G7P8oL0UvJzSkiBt4 Ws5Yje+iSGsbiJI6zz2L8718OjVlJFPRYx2zCyOOatQ8vFb1mz5v99x8LGycoj1NDH7/m fJe35Lys9l5qGJo6RVURkRbmJaNzJ0hmKmRH56J5X4ZKVA7DEkCfATIAQkoNyYbCpmcJi VtlaOst1ylPUyOIY5da80Knv/5SsXKtgsF0H0JGJ0NIqdEPhwEntieEzS0TTkuI/+g1O3 7JT5q6+CCzRIkv+L8t9E9aiAAkdOF+oa71IiX0XTRo3a4KdE/R3Z19Kaqac7h6mYh2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116157; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=fitoFKtcKOHFd4+ISQk35YyZpEp430ytCE+/Cena90w=; b=GrJ3c6WzrPsJHl+KFMDnt4jp9zSLClkqUCghHg2UDXGixbqonMk/82gc0OK+ANFNULe1 mNQGGOO1uHkUhaUEkBanuAEndMxzhp4kj2VZfkIHTdxhOs2n9bma+NwEn+QzKAgqgikYz WYeaZ7eVAHG1PO23upAyegxGgC71UYo4pBmgk+w3FVGgn3JDnOb2fmEWkrgL3ZX8cjHLh aXHaHO166iFKvUjk9x8aWUPHRltRWdP9ApbnQCC9JOyFKKbu9nJ60pshB74k3RydY41pz kFwXaxpOsR0D5dcZOT+pGwbsuEafCRr5AEJ0JgWfi+rTEfWBdhavjORxVPMB6sPCvWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O8RLUlSX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C325606A31A; Tue, 1 Dec 2026 09:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=O8RLUlSX Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB4ED1F0089B; Tue, 1 Dec 2026 09:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796116157; bh=fitoFKtcKOHFd4+ISQk35YyZpEp430ytCE+/Cena90w=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=O8RLUlSXH+f3UZXbFrxNLwGoELDkQJJZqCtzEIwDIOwG386h6Fk1Vxeje7CkpTRU7 Wq/pix7ngppNcOgsVzWWQ7ydAdmPnOGNe83m+p15CrsMnSsnZ0Azzow4OA16MCnaNN zH4pHzW12GqvVH57gjkUkVGDb5bCzebiEV8scrQsmvQZrRx84+/05TE532w2NLBP/p z4ibp1ueo4UzJ16YHVRqVNQWa+eZHuvlfygC9tikZHB6d3XNP5rE4qA+R1NrlLRCxv J3dog99D+F+0AN/ZByncTbEVcibGbPzscu55sntA73hfLtK6t6zoqzlSttfFhWn2ox +DvsXK+tM+Eog== Message-ID: Date: Tue, 1 Dec 2026 10:09:04 +0100 X-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH bpf-next 00/15] xdp: add SKB core extensions to keep RX metadata until skb creation To: Tianyi Gao , Alexei Starovoitov Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Jakub Kicinski , John Fastabend , Stanislav Fomichev , Lorenzo Bianconi , Vladimir Vdovin , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Andrew Lunn , Donald Hunter , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , Tony Nguyen , Przemek Kitszel , Maciej Fijalkowski , Alexander Lobakin , Magnus Karlsson , Tushar Vyavahare , Jason Xing , Nikolay Aleksandrov , Madalin Bucur , Ioana Ciornei , Jonathan Corbet , Shuah Khan , Shuah Khan , Randy Dunlap , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Chris J Arges , Jakub Sitnicki , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, intel-wired-lan@lists.osuosl.org, llvm@lists.linux.dev, kernel-team@cloudflare.com References: Content-Language: en-US From: Jesper Dangaard Brouer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/