From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F3A8606A31F for ; Sun, 6 Dec 2026 02:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=ENH2bCsq; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UWgQi5b1 Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5D0374071C; Sun, 6 Dec 2026 02:22:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id cDpL9nFrsT03; Sun, 6 Dec 2026 02:22:22 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 4CCA540729 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796523742; b=IGS23T2kjcEJgJc0KoYHTI62XLfhYe2a+RBtsY7s622BFw3d3FYp02I8dFbqWhwDLciw RTMUkMC5yHmJ5U8FDPlb6l3L4OmD4fewewo4UtEN3D517BhKNG3O281XR3wKQdCFbs+rX 2ZsLYCYRgUTQLXaDWVZORq5/trTJu9fk6FKjjygRylw8hZqlEuysyYO7SF5nbLtuvca9z AcXZAu0rAeuPyrXVsTQ/8R0W6tNZcRQL1b1U/fX77LzKReQboFTrrNI+lSs/zUDibgZ+w 5usnS6Ir83L/kL9fHuommz8VZD0LSSxPNww7UjyejOGPOHAa/Yf3uDobtdHgXakZeZw== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796523742; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Gm-Message-State:X-Received: Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From:To: Cc:Content-Type:X-BeenThere:X-Mailman-Version:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Errors-To; bh=AF3jkXs2PMZWuNmC3gQQJOJMTRkC259ui5cSmCWSwcE=; b=S6lq+WXaiB7srqA1u19EEBRwQ7EQiGjRXV7r9J1rGnmropRhT/h+cnUVqnLMNXtyXgIh NVYVQK5uSUGayxGCNTeMGDqXUEsvh8FlGxk9XPNTWAY/tbpUFGZCV6yO5N8ecpQw6w7XU XuvUVchEwUz5U/mGFBfZpM6ZTl6+syuRxx7vXt3kSjLCzlc1Z9Yy4OQvjr16V+22xUr5Z RDEtqzCT+3iBJgaeB8wh0APJhk530pY7ABOzIKcM7Fr2bbZKFcklMF4DiEYn+PZBUG/wH Xu5Uit4siPhSrLa3IPz3qfjoGHPKhPKjoJ4c5qxEwTQOQSgLDUfjGNZZ17Vjvxc+ksQ== ARC-Authentication-Results: i=1; smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796523742; bh=AF3jkXs2PMZWuNmC3gQQJOJMTRkC259ui5cSmCWSwcE=; h=Date:In-Reply-To:References:Subject:From:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ENH2bCsqdVZ79jCPVARUA/USubd+kUXReZ5GbJpQsAAfmcyNKhkkbmydYRTXHY5aJ Ptc7SIIKMi6VL4ti/8GY64BLbQQ3qAttL+FZjTygFvCmst8QBQponYtKHNoU2oyOUR G/4amIXiPtRnrE8mf9EnrmBX4o1xk+nDujdktNVJp0uM/1DXw3v+5e9NsxOPBYG+q0 pbzGmY8EU++7G5V1S/XLgbZ1FHoCN0agTQU7WR+iXUCT6XNtq+NAsNhIOtpJ/LQELs 6OUJK/7qz5wyUxsOmnuA2CVYAg+BKHPte65NCS22LbOfCyGKE9qgzcby0yS3CNbf9J qO1OwrY7co0/w== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id 4CCA540729; Sun, 6 Dec 2026 02:22:22 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id 346652C7 for ; Sun, 6 Dec 2026 02:22:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 25D8040099 for ; Sun, 6 Dec 2026 02:22:21 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0jhE4nsHWlrT for ; Sun, 6 Dec 2026 02:22:20 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org EFCD74007C Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::f48" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::f48; helo=mail-qv1-xf48.google.com; envelope-from=32syuawckdxsn9cc5d27ff7c5.3fd9ek5c-n9i54-c1ec9jkj.fjlfjc.fi7@flex--willemb.bounces.google.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UWgQi5b1 Received: from mail-qv1-xf48.google.com (mail-qv1-xf48.google.com [IPv6:2607:f8b0:4864:20::f48]) by smtp2.osuosl.org (Postfix) with ESMTPS id EFCD74007C for ; Sun, 6 Dec 2026 02:22:19 +0000 (UTC) Received: by mail-qv1-xf48.google.com with SMTP id 6a1803df08f44-921dafa1ce6so57101776d6.1 for ; Sat, 05 Dec 2026 18:22:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796523738; x=1797128538; darn=lists.osuosl.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AF3jkXs2PMZWuNmC3gQQJOJMTRkC259ui5cSmCWSwcE=; b=UWgQi5b17EcU78cSSHC4APx3LeOgqt4x4UoP2VHXrrnh8Y6OvbKUaKbmAlRBCX4aPk 3+Vj4mUEZ2gSyk+Y76naQYXKheZYSSxs1K/wBJ+r5Xru9CBmOxH9mi5V8ZCffwcNmyYi V67Ie/Dpx4THuDIj93J9I3bK5CRhUJBUoErhjeDB0/77zdYq9cl+qVoVhO1q0uSNG0aO 9a1Ci5BFm0TZEIBHdWFtFIw9wVRMtDQzYLjT/a8CF4lREoWKqdDTxFPM50xXtHy+4m33 AzpG0XLtlgD7y9AxAQRqiSx8GfUX2xoIisvuseV6/KB6xyzcLNURJXEdZwR1kzYpKqy+ TgCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796523738; x=1797128538; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AF3jkXs2PMZWuNmC3gQQJOJMTRkC259ui5cSmCWSwcE=; b=RMA7Sx8HIBQMm7ElbHMXyzjDPpvQjTFpfswmHi4dx0XAQ7jEQbtEzsKCWs0xaiXaE6 jKH1ZqlFmmiiMpvRWNFdMpykvxl2564fGMP/2KdjnsgrplQs5tMH06kz8SB0C4/uOXuf L07cpgPmYhzb4bFvzLgIee12Cd7b0okTDSa0IZuwWNLl1ehk8OSWrwLvkB0D3BTeSQRD TVC6Yu7m/q5CFKb+rOH725XNFA0QBCeKXND3ym9fOXWYyEas7mZAALmxB10kh0yPNwtt rZlvsbDtrn5PN9yLwPMdYE107i06niYK9kR/8hoscawYKmpopm2y4ZOypGx9PIhNu3UW tVXA== X-Gm-Message-State: AB4q+uGu51sPQ+Xa7boRYUKbZMFB3cqXHJqLmkHDjK9LJZASEPnEiFOx XEKfKQR6TdSy2HL963oHItQoMgADdtgVNT8J3iabIS0+X/BSctaYiHgiK6KnuaAE0NJlON4zydz qlfRCfvx9fQ== X-Received: from qvqd2.prod.google.com ([2002:ad4:50a2:0:b0:921:6405:b9a0]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:2b81:b0:921:d305:b4fa with SMTP id 6a1803df08f44-921e26878b6mr101110246d6.48.1796523738053; Sat, 05 Dec 2026 18:22:18 -0800 (PST) Date: Sat, 05 Dec 2026 21:22:17 -0500 In-Reply-To: <20261127-igb-skb-pad-v1-1-7e069eaf16d7@aweta.nl> X-Archived-By: Mime-Version: 1.0 References: <20261127-igb-skb-pad-v1-1-7e069eaf16d7@aweta.nl> Message-ID: Subject: Re: [PATCH net] igb: leave room for the Rx timestamp header in 2 KiB build_skb buffers From: willemb@google.com To: Tjerk Kusters via B4 Relay , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Sven Auhagen Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, bpf@vger.kernel.org, stable@vger.kernel.org, Tjerk Kusters Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-23.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Tjerk Kusters via B4 Relay wrote: > From: Tjerk Kusters > On 2 KiB build_skb Rx rings (PAGE_SIZE < 8192, legacy-rx off), > igb_skb_pad() places the DMA start so that exactly > IGB_MAX_FRAME_BUILD_SKB bytes (1536 on x86_64) are left before > skb_shared_info, and RLPML, or the PF pool limit in VMOLR when VFs are > allocated, is set to the same value. With Rx timestamping on, 82580 and > later MACs write a 16-byte timestamp header in front of the frame, so a > frame of more than 1520 bytes (without FCS) runs into skb_shared_info. > napi_build_skb() then zeroes the start of skb_shared_info, which holds > the last bytes of the frame, and __skb_put() moves skb->tail past > skb->end. > The MAC has checked the TCP or UDP checksum before that, so the payload > is delivered with its last bytes zeroed and without an error. Any > sender on the link can trigger this with frames of 1525 to 1536 bytes on > the wire, for example double-tagged frames or a peer with a larger MTU. > Any Rx timestamp filter is enough, as these MACs then timestamp all > packets. With XDP_TX, or XDP_REDIRECT to a device or CPU map, > xdp_update_frame_from_buff() hits the "missing reserved tailroom" WARN > for each such frame and drops it. > Before commit 9cbc948b5a20 ("igb: add XDP support"), > IGB_MAX_FRAME_BUILD_SKB left room for the header. That commit fixed the > frame size at 1536 bytes and gave the rest of the 2 KiB buffer to the > headroom. Reserve the header again in igb_skb_pad(). IGB_SKB_PAD is the > same for all build_skb rings, so the headroom goes from 192 to 176 bytes > on x86_64 for 2 KiB and for 3 KiB rings, and XDP programs have 16 bytes > less for bpf_xdp_adjust_head() and metadata. It was already below > XDP_PACKET_HEADROOM. The frame limit, the buffer size selection and the > MTU range for XDP do not change. IGB_2K_TOO_SMALL_WITH_PADDING already > counts the header, so the headroom stays at least NET_SKB_PAD. > That commit also took the header out of igb_rx_bufsz(), which is the > length of the DMA sync when a buffer goes to the hardware. Add > igb_rx_dma_len() for the two syncs. igb_rx_bufsz() itself stays as it > is, because it is also the frame size limit for XDP. > Tested on an I350 with kernel 7.3.1 (igb in net is the same apart from > the treewide kmalloc_obj conversions) at MTU 1500, with the Rx timestamp > filter set to ALL. A peer sent UDP datagrams of 0xff bytes in frames of > 1521 to 1532 bytes (without FCS). Before this patch they were delivered > with their last 1 to 12 bytes zeroed, starting 1520 bytes into the > frame, and pings with a 0xff pattern of those sizes failed. With this > patch all of them arrive intact, also with an XDP program attached. > Frames of 1533 bytes and more are dropped by the MAC, as before. With > the timestamp filter off, and at MTU 3000 (3 KiB rings), nothing > changes. Frames that a VF sends to the PF, of up to 1536 bytes, arrive > intact with and without this patch; the MAC does not put the header in > front of them. > This was found by the Sashiko AI review of another igb series. > Link: > https://lore.kernel.org/all/179551973551.3135.7270095499525377709@kernel.org/ > Fixes: 9cbc948b5a20 ("igb: add XDP support") > Cc: stable@vger.kernel.org > Signed-off-by: Tjerk Kusters > --- > The Sashiko AI review reported this on v4 to v7 of my igb Rx timestamp > series; it is older than that series. Most recently: > https://lore.kernel.org/all/179551973551.3135.7270095499525377709@kernel.org/ > This patch is independent of that series and applies on its own. > At MTU 1500, iperf3 TCP and UDP from a peer run at line rate (938 and > 950 Mbit/s) with and without this patch, with the Rx timestamp filter > off and on, and the receiver's CPU load does not change measurably > (6 runs of 10 s per case, the differences are within the spread). > The patch and its description were prepared with the help of an AI > coding assistant (Claude). I reviewed them and ran the tests described in > the commit message on my test bench. > --- > drivers/net/ethernet/intel/igb/igb.h | 21 +++++++++++++++++---- > drivers/net/ethernet/intel/igb/igb_main.c | 4 ++-- > 2 files changed, 19 insertions(+), 6 deletions(-) > diff --git a/drivers/net/ethernet/intel/igb/igb.h > b/drivers/net/ethernet/intel/igb/igb.h > index 8c9b02058cec..74e441a140c1 100644 > --- a/drivers/net/ethernet/intel/igb/igb.h > +++ b/drivers/net/ethernet/intel/igb/igb.h > @@ -153,9 +153,9 @@ struct vf_mac_filter { > /* Attempt to maximize the headroom available for incoming frames. We > * use a 2K buffer for receives and need 1536/1534 to store the data for > - * the frame. This leaves us with 512 bytes of room. From that we need > - * to deduct the space needed for the shared info and the padding needed > - * to IP align the frame. > + * the frame, plus IGB_TS_HDR_LEN for the timestamp the hardware can > place > + * in front of it. From the rest we need to deduct the space needed for > + * the shared info and the padding needed to IP align the frame. > * > * Note: For cache line sizes 256 or larger this value is going to end > * up negative. In these cases we should fall back to the 3K > @@ -190,7 +190,7 @@ static inline int igb_skb_pad(void) > if (IGB_2K_TOO_SMALL_WITH_PADDING) > rx_buf_len = IGB_RXBUFFER_3072 + SKB_DATA_ALIGN(NET_IP_ALIGN); > else > - rx_buf_len = IGB_RXBUFFER_1536; > + rx_buf_len = IGB_RXBUFFER_1536 + IGB_TS_HDR_LEN; > /* if needed make room for NET_IP_ALIGN */ > rx_buf_len -= NET_IP_ALIGN; > @@ -421,6 +421,19 @@ static inline unsigned int igb_rx_bufsz(struct > igb_ring *ring) > return IGB_RXBUFFER_2048; > } > +/* Number of bytes the hardware can write to an Rx buffer. On 2K > build_skb > + * rings the frame is limited to IGB_MAX_FRAME_BUILD_SKB, and the > timestamp > + * header comes in front of it. > + */ > +static inline unsigned int igb_rx_dma_len(struct igb_ring *ring) > +{ > +#if (PAGE_SIZE < 8192) > + if (ring_uses_build_skb(ring) && !ring_uses_large_buffer(ring)) > + return IGB_MAX_FRAME_BUILD_SKB + IGB_TS_HDR_LEN; > +#endif > + return igb_rx_bufsz(ring); > +} > + > static inline unsigned int igb_rx_pg_order(struct igb_ring *ring) > { > #if (PAGE_SIZE < 8192) > diff --git a/drivers/net/ethernet/intel/igb/igb_main.c > b/drivers/net/ethernet/intel/igb/igb_main.c > index 131df3e09ba1..67fd24d71746 100644 > --- a/drivers/net/ethernet/intel/igb/igb_main.c > +++ b/drivers/net/ethernet/intel/igb/igb_main.c > @@ -5084,7 +5084,7 @@ void igb_clean_rx_ring(struct igb_ring *rx_ring) > dma_sync_single_range_for_cpu(rx_ring->dev, > buffer_info->dma, > buffer_info->page_offset, > - igb_rx_bufsz(rx_ring), > + igb_rx_dma_len(rx_ring), > DMA_FROM_DEVICE); > /* free resources associated with mapping */ > @@ -9225,7 +9225,7 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, > u16 cleaned_count) > bi = &rx_ring->rx_buffer_info[i]; > i -= rx_ring->count; > - bufsz = igb_rx_bufsz(rx_ring); > + bufsz = igb_rx_dma_len(rx_ring); > do { > if (!igb_alloc_mapped_page(rx_ring, bi)) > --- > base-commit: cc7fe6e741730fef549e484379281736d32746f0 > change-id: 20261127-igb-skb-pad-8d96ea0a6e05 > Best regards, > -- > Tjerk Kusters This probably targets intel-wired-lan