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 2/4] gve: fix SW coalescing when hw-GRO is used
Date: Tue, 3 Mar 2026 11:55:47 -0800 [thread overview]
Message-ID: <20260303195549.2679070-3-joshwash@google.com> (raw)
In-Reply-To: <20260303195549.2679070-1-joshwash@google.com>
From: Ankit Garg <nktgrg@google.com>
Leaving gso_segs unpopulated on hardware GRO packet prevents further
coalescing by software stack because the kernel's GRO logic marks the
SKB for flush because the expected length of all segments doesn't match
actual payload length.
Setting gso_segs correctly results in significantly more segments being
coalesced as measured by the result of dev_gro_receive().
gso_segs are derived from payload length. When header-split is enabled,
payload is in the non-linear portion of skb. And when header-split is
disabled, we have to parse the headers to determine payload length.
Signed-off-by: Ankit Garg <nktgrg@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@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 | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve_rx_dqo.c b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
index 63a96106..5ba893e5 100644
--- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
@@ -945,11 +945,16 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
struct gve_ptype ptype)
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
+ int rsc_segments, rsc_seg_len, hdr_len;
- /* Only TCP is supported right now. */
+ /* HW-GRO only coalesces TCP. */
if (ptype.l4_type != GVE_L4_TYPE_TCP)
return -EINVAL;
+ rsc_seg_len = le16_to_cpu(desc->rsc_seg_len);
+ if (!rsc_seg_len)
+ return 0;
+
switch (ptype.l3_type) {
case GVE_L3_TYPE_IPV4:
shinfo->gso_type = SKB_GSO_TCPV4;
@@ -961,7 +966,21 @@ static int gve_rx_complete_rsc(struct sk_buff *skb,
return -EINVAL;
}
- shinfo->gso_size = le16_to_cpu(desc->rsc_seg_len);
+ if (skb_headlen(skb)) {
+ /* With header-split, payload is in the non-linear part */
+ rsc_segments = DIV_ROUND_UP(skb->data_len, rsc_seg_len);
+ } else {
+ /* 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]));
+ rsc_segments = DIV_ROUND_UP(skb->len - hdr_len, rsc_seg_len);
+ }
+ shinfo->gso_size = rsc_seg_len;
+ shinfo->gso_segs = rsc_segments;
+
return 0;
}
--
2.53.0.473.g4a7958ca14-goog
next prev parent reply other threads:[~2026-03-03 19:55 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 ` Joshua Washington [this message]
2026-03-03 19:55 ` [PATCH net-next 3/4] gve: pull network headers into skb linear part Joshua Washington
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-3-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