]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gve: fix SW coalescing when hw-GRO is used
authorAnkit Garg <nktgrg@google.com>
Tue, 3 Mar 2026 19:55:47 +0000 (11:55 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 5 Mar 2026 14:49:51 +0000 (15:49 +0100)
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>
drivers/net/ethernet/google/gve/gve_rx_dqo.c

index 3b10139941ea163dca4d330bf58f2a3895741e9c..27885ccf52267ad5f4bc97546a4443055a5e1f3a 100644 (file)
@@ -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;
 }