summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAnkit Garg <nktgrg@google.com>2026-03-03 22:55:47 +0300
committerPaolo Abeni <pabeni@redhat.com>2026-03-05 17:49:51 +0300
commitea4c1176871fd70a06eadcbd7c828f6cb9a1b0cd (patch)
treefb30614f776aeee5874d50093da6e230664af8cf /drivers
parente637c244b954426b84340cbc551ca0e2a32058ce (diff)
downloadlinux-ea4c1176871fd70a06eadcbd7c828f6cb9a1b0cd.tar.xz
gve: fix SW coalescing when hw-GRO is used
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> Link: https://patch.msgid.link/20260303195549.2679070-3-joshwash@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/google/gve/gve_rx_dqo.c23
1 files 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 3b10139941ea..27885ccf5226 100644
--- a/drivers/net/ethernet/google/gve/gve_rx_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_rx_dqo.c
@@ -942,11 +942,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;
@@ -958,7 +963,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;
}