From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796523739; b=qDGC/Y5yOgHF732knGQfUBSj/DHPOM08NAZnHarch86A3C7ALQwI+WcCFOXuUJSLfLfN ZxlQpee4TxF8/ic3VWRI2nJfdD1Ct35TH7HDCF0w2dwlPvQuqmfM/QxBHJvyze7eZ30vr JLn8+XKIubDGZII6tn6ek19VFTzh+P2G8GzwezkSFjr1dnA13ZBWGUounsF81QvHtskbq ZdV+zByJpjG9zgZ+TcDXNPRnikcE0Wp865c8CXGSTj3jTgcmFIPgASNLbWxCHEAVr209B aWjO+vKDtAcs00h32AMzg8K2Jr2uUUhjqdxq5ovcX61uRGbob2llu9eIqGtsj+HYnmA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796523739; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=AF3jkXs2PMZWuNmC3gQQJOJMTRkC259ui5cSmCWSwcE=; b=qMLYUHUFs0S9be+iVyMDyf07twtXRwqD5p5MGCaMZhR+pZspnvP+M3QyhFvsrXuf7WcU HnPyK04iOPXYKOw6BYSzxMT8vekT9I0EkbkTeZ/Bj7Z2X7P2drhyNzEE3Nrv+tyDHdBbM SE0v46Si/04OrcbQXvnF2fwSW2bXSr+yf7sTe9UWfPbL5dyWYrR+eKYIBRyltD+vuAEwG ZGFuy6CbunDRCSj7DdAEHFTayQl3dy7D0wdAmTBBSy+z+XKlLuMmjRUHIjztFGyX2mpgT IEmrR8dcpSyYwZV4CPRPt9U/8fnsCRNkcN9V7GQ/Rs755UHacQ9fHY92TxrN3tJ3+3A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WZQ0nnuo; arc=none smtp.remote-ip=209.85.219.70 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F58D606A321 for ; Sun, 6 Dec 2026 02:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6F58D606A321 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WZQ0nnuo Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-9210bbc04abso49313486d6.2 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=vger.kernel.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=WZQ0nnuo1nEhcPN4noGoelRJcwf2HiuSOgaJ4Hda4jIlkwStw+Qp5guMWad2tdOCTd OQEscwAwKzMEaJG8wDfn8RCNw7aRZ6I2oB4H7BZ5cca6VdGmdALLHA6KZ6UJtqpnH1e4 YnP1gxOCegwn0X7cLBEbhN6FiOzLXM0859dLMXF1McFUXhoH/JPlhOnwAgst1ThRGISr ZEs3ksmhv0xthvbeB//z+vsmwtmlPEMaiEcg/gsJ2wUA0nl+JwpDLvD5VS9ugwb7OSKj l4X8YqThn3cK67jLCIRRNHIJLO3yscofFIE8aoweKE/cEriqL/vLbgsp5zpYIwOHuO18 Th7A== 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=LL9cPlJErB81rZswRiZyMiieuf3XRNODlsHODsBvwLuHZZU7M7/jSKCSOUfsa1YzS/ WwLwylwlEOeSlIDLR2IIDMCAwbn4nmGOQbabMN7tr9DM3WmB/eavttwkLe1B+l8ppdWe V5fg6uA6A0UJenjQSW4R2q1r7i9IfsWpH8xSxxyf0rtB1yhOHSKX/JeJOXiiMie8m6g2 /MlNeXAN2ExRLeYc7LLYG6V09FNWZ1yVTOTgDAY9fqVBVhMNowDWs1JrQpIP20D+Y1T/ ixnttHtpJvR6he1QOqolm4eE6nl06wrE62ZB1iT/bgOvT93ZrOn1FE7jP261ISPofh8W NATw== X-Forwarded-Encrypted: i=1; AL+hErHSuBrxzLCRZynKV1AYLSM9jvMHwO5F09E1drxqGA3TRdrvalaSRYV+vsX0gzgZSpU+6wWEiNk=@vger.kernel.org X-Gm-Message-State: AB4q+uETBMP/mjr0f2e/1qyV7/UBxtLCwq2gZd4aMpDh/g4UwQM6TwKf Ve/IjYZR/kho9syvk/N2XoHvEvhS4Q9My5myT8G6NrdmVZ2W/sV4nCKZf6fpbQg2GSYtamOk3c3 J+SFjnVjsVg== 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-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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