From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796523739; b=vmymfedH51aKvbdl0jCJIMiCahHT11O+k411H/UJGAxWLE9lsc2jyn8aJSYdiABMmh6N kddzw+PUG4ezefjMJ6VGh7U5qp4JTX/QObBhoz0zKIx3PJIZQWPKjfN6K/ynxinv7jRfT hfCwyMqLbnYzy64DxkWgB8JtojzzXW76TgS5qQ57koeXVc56Ov5ULyzBaA4LOJAWmq3XV CmtUWDSJZkEdhXJn3UWkf0WClfwXr4OdFJ9F83NmG1/YMdsANF9GUhKt2cwGaJVkK8lQp iMziOGtjIs+pxbhGX8Hkg53C44ypEjZr7/C1/JnKMdl48OeKQ3JZ3Tvfca4soJnPfYg== 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=g8SzeUOSMqVBUdgbH2FILr1/fh3TiWuQBeKeEQzuCizPrFQC79tSIUzA/mBbSurQ+GCh XCcWrDH+5mkZuVZOIry/0823Dz7jBpuvwGpkLM7aXztpaQtHu5mqzJHuMV4ku1PIMVnmf mXQXeqX8Xi3Mzxd7yiK6OK15vXaOVHpOEubjqfTW6MLEpIEiA3YJEnFoLlzp+TAgehKEI 7MIg0NKbmDIx0v3/AKlgwf8cZWLHGZldQWZqWx7/npgwx9hZUQTqHXvqhijF+fUelYNXZ IG9s4tAQeQ9Jcj/+oBFntRlsckEeTGHtaU9Xm/TUU6mQFw3SWX+SS+aQ5z3gjpQvgfg== 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.72 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (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 76FE5606A322 for ; Sun, 6 Dec 2026 02:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 76FE5606A322 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) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=WZQ0nnuo Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-921dafa1ce6so57101766d6.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=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=EgARM5y6uTmZ6m6Cunyl9ZM3ecrFlV2dGFP4K8J4Da24qLOu0ge1r5QEif2C35Ueq/ vf4Z1rCa8siM6oZE9PFHpwmzB3NibhnAOA/RNFHd30alKo+4k904sEMAVjg/+aq3x/hJ 7FiTlmbjDuGDqqRtd8/FFOoZeCDCqoOmj54VahNUIS8gQjAcMPcPxXXO5DUuQ7+uOziU B5wYUS3xYJZ/7zrIUZqNX1BygkPF15TTCJhT6afVa3SVW9/WyxKECv4GCkOny38VkJZA fQlEqqh1MluV+IjJbI9yMPjAF2EzQ7wL5F06DSwrQGApflpKDLjIB4oYYvEBJvoNeteM SjTA== X-Forwarded-Encrypted: i=1; AL+hErENvUqufUPwntUBC2aeruTa6bRd7I2FoXNG+ojmYgpjDIgOSGX4pPNdMAS+Kx8XnePUYWw=@vger.kernel.org X-Gm-Message-State: AB4q+uH3bLZeV6DECSfWlvhX+fM4taywHBVruhgHzTRVT2dqHQfhU8r3 RZ/nki9aeMYR+tF2N09QVdlwG5+8WoFnQ3l9HYcQ7fxMEjGNAgaOMm6YHr89/1Z3NCBD7zsDvGf ugJwcQmel0Q== 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: bpf@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