From: Joshua Washington <joshwash@google.com>
To: netdev@vger.kernel.org
Cc: Joshua Washington <joshwash@google.com>,
Harshitha Ramamurthy <hramamurthy@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Willem de Bruijn <willemb@google.com>,
Jordan Rhee <jordanrhee@google.com>,
Ankit Garg <nktgrg@google.com>, John Fraker <jfraker@google.com>,
Ziwei Xiao <ziweixiao@google.com>,
Matt Olson <maolson@google.com>,
Praveen Kaligineedi <pkaligineedi@google.com>,
Tim Hostetler <thostet@google.com>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: [PATCH net-next 3/4] gve: pull network headers into skb linear part
Date: Tue, 3 Mar 2026 11:55:48 -0800 [thread overview]
Message-ID: <20260303195549.2679070-4-joshwash@google.com> (raw)
In-Reply-To: <20260303195549.2679070-1-joshwash@google.com>
From: Ankit Garg <nktgrg@google.com>
Currently, in DQO mode with hw-gro enabled, entire received packet is
placed into skb fragments when header-split is disabled. This leaves
the skb linear part empty, forcing the networking stack to do multiple
small memory copies to access eth, IP and TCP headers.
This patch adds a single memcpy to put all headers into linear portion
before packet reaches the SW GRO stack; thus eliminating multiple
smaller memcpy calls.
Additionally, the criteria for calling napi_gro_frags() was updated.
Since skb->head is now populated, we instead check if the SKB is the
cached NAPI scratchpad to ensure we continue using the zero-allocation
path.
Signed-off-by: Ankit Garg <nktgrg@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
---
drivers/net/ethernet/google/gve/gve_rx_dqo.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
index 5ba893e5..ac44f50d 100644
--- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
@@ -946,6 +946,8 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
int rsc_segments, rsc_seg_len, hdr_len;
+ skb_frag_t *frag;
+ void *va;
/* HW-GRO only coalesces TCP. */
if (ptype.l4_type != GVE_L4_TYPE_TCP)
@@ -973,10 +975,20 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
/* HW-GRO packets are guaranteed to have complete TCP/IP
* headers in frag[0] when header-split is not enabled.
*/
- hdr_len = eth_get_headlen(skb->dev,
- skb_frag_address(&shinfo->frags[0]),
- skb_frag_size(&shinfo->frags[0]));
+ frag = &skb_shinfo(skb)->frags[0];
+ va = skb_frag_address(frag);
+ hdr_len =
+ eth_get_headlen(skb->dev, va, skb_frag_size(frag));
rsc_segments = DIV_ROUND_UP(skb->len - hdr_len, rsc_seg_len);
+ skb_copy_to_linear_data(skb, va, hdr_len);
+ skb_frag_size_sub(frag, hdr_len);
+ /* Verify we didn't empty the fragment completely as that could
+ * otherwise lead to page leaks.
+ */
+ DEBUG_NET_WARN_ON_ONCE(!skb_frag_size(frag));
+ skb_frag_off_add(frag, hdr_len);
+ skb->data_len -= hdr_len;
+ skb->tail += hdr_len;
}
shinfo->gso_size = rsc_seg_len;
shinfo->gso_segs = rsc_segments;
@@ -1013,7 +1025,7 @@ static int gve_rx_complete_skb(struct gve_rx_ring *rx, struct napi_struct *napi,
return err;
}
- if (skb_headlen(rx->ctx.skb_head) == 0)
+ if (rx->ctx.skb_head == napi->skb)
napi_gro_frags(napi);
else
napi_gro_receive(napi, rx->ctx.skb_head);
--
2.53.0.473.g4a7958ca14-goog
next prev parent reply other threads:[~2026-03-03 19:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 19:55 [PATCH net-next 0/4] gve: optimize and enable HW GRO for DQO Joshua Washington
2026-03-03 19:55 ` [PATCH net-next 1/4] gve: Advertise NETIF_F_GRO_HW instead of NETIF_F_LRO Joshua Washington
2026-03-03 19:55 ` [PATCH net-next 2/4] gve: fix SW coalescing when hw-GRO is used Joshua Washington
2026-03-03 19:55 ` Joshua Washington [this message]
2026-03-03 19:55 ` [PATCH net-next 4/4] gve: Enable hw-gro by default if device supported Joshua Washington
2026-03-05 15:00 ` [PATCH net-next 0/4] gve: optimize and enable HW GRO for DQO patchwork-bot+netdevbpf
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=20260303195549.2679070-4-joshwash@google.com \
--to=joshwash@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=hramamurthy@google.com \
--cc=jfraker@google.com \
--cc=john.fastabend@gmail.com \
--cc=jordanrhee@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maolson@google.com \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=pkaligineedi@google.com \
--cc=sdf@fomichev.me \
--cc=thostet@google.com \
--cc=willemb@google.com \
--cc=ziweixiao@google.com \
/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