Blame SOURCES/0045-netdrv-bnxt_en-Refactor-tunneled-hardware-GRO-logic.patch

f95c89
From 563c6968f57f296bf0bfc06528ff603392090da2 Mon Sep 17 00:00:00 2001
f95c89
From: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Date: Wed, 2 Oct 2019 18:23:00 -0400
f95c89
Subject: [PATCH 45/96] [netdrv] bnxt_en: Refactor tunneled hardware GRO logic
f95c89
f95c89
Message-id: <7e0c61958705e069e76dbb6ad6987b3fa99093e6.1570027456.git.jtoppins@redhat.com>
f95c89
Patchwork-id: 276461
f95c89
O-Subject: [RHEL-8.2 PATCH 38/78] bnxt_en: Refactor tunneled hardware GRO logic.
f95c89
Bugzilla: 1724766
f95c89
RH-Acked-by: John Linville <linville@redhat.com>
f95c89
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
f95c89
f95c89
The 2 GRO functions to set up the hardware GRO SKB fields for 2
f95c89
different hardware chips have practically identical logic for
f95c89
tunneled packets.  Refactor the logic into a separate bnxt_gro_tunnel()
f95c89
function that can be used by both functions.
f95c89
f95c89
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
f95c89
Signed-off-by: David S. Miller <davem@davemloft.net>
f95c89
(cherry picked from commit bee5a188b71657092dc9eb1a529b4e502fe51444)
f95c89
Bugzilla: 1724766
f95c89
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532
f95c89
Tested: build, boot, basic ping
f95c89
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
f95c89
---
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 69 +++++++++++++------------------
f95c89
 1 file changed, 28 insertions(+), 41 deletions(-)
f95c89
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:16.250508195 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:16.376507039 +0100
f95c89
@@ -1209,6 +1209,31 @@
f95c89
 		bnxt_reuse_rx_agg_bufs(cpr, idx, 0, agg_bufs, true);
f95c89
 }
f95c89
 
f95c89
+#ifdef CONFIG_INET
f95c89
+static void bnxt_gro_tunnel(struct sk_buff *skb, __be16 ip_proto)
f95c89
+{
f95c89
+	struct udphdr *uh = NULL;
f95c89
+
f95c89
+	if (ip_proto == htons(ETH_P_IP)) {
f95c89
+		struct iphdr *iph = (struct iphdr *)skb->data;
f95c89
+
f95c89
+		if (iph->protocol == IPPROTO_UDP)
f95c89
+			uh = (struct udphdr *)(iph + 1);
f95c89
+	} else {
f95c89
+		struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
f95c89
+
f95c89
+		if (iph->nexthdr == IPPROTO_UDP)
f95c89
+			uh = (struct udphdr *)(iph + 1);
f95c89
+	}
f95c89
+	if (uh) {
f95c89
+		if (uh->check)
f95c89
+			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
f95c89
+		else
f95c89
+			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
f95c89
+	}
f95c89
+}
f95c89
+#endif
f95c89
+
f95c89
 static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info,
f95c89
 					   int payload_off, int tcp_ts,
f95c89
 					   struct sk_buff *skb)
f95c89
@@ -1266,28 +1291,10 @@
f95c89
 	}
f95c89
 
f95c89
 	if (inner_mac_off) { /* tunnel */
f95c89
-		struct udphdr *uh = NULL;
f95c89
 		__be16 proto = *((__be16 *)(skb->data + outer_ip_off -
f95c89
 					    ETH_HLEN - 2));
f95c89
 
f95c89
-		if (proto == htons(ETH_P_IP)) {
f95c89
-			struct iphdr *iph = (struct iphdr *)skb->data;
f95c89
-
f95c89
-			if (iph->protocol == IPPROTO_UDP)
f95c89
-				uh = (struct udphdr *)(iph + 1);
f95c89
-		} else {
f95c89
-			struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
f95c89
-
f95c89
-			if (iph->nexthdr == IPPROTO_UDP)
f95c89
-				uh = (struct udphdr *)(iph + 1);
f95c89
-		}
f95c89
-		if (uh) {
f95c89
-			if (uh->check)
f95c89
-				skb_shinfo(skb)->gso_type |=
f95c89
-					SKB_GSO_UDP_TUNNEL_CSUM;
f95c89
-			else
f95c89
-				skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
f95c89
-		}
f95c89
+		bnxt_gro_tunnel(skb, proto);
f95c89
 	}
f95c89
 #endif
f95c89
 	return skb;
f95c89
@@ -1334,28 +1341,8 @@
f95c89
 		return NULL;
f95c89
 	}
f95c89
 
f95c89
-	if (nw_off) { /* tunnel */
f95c89
-		struct udphdr *uh = NULL;
f95c89
-
f95c89
-		if (skb->protocol == htons(ETH_P_IP)) {
f95c89
-			struct iphdr *iph = (struct iphdr *)skb->data;
f95c89
-
f95c89
-			if (iph->protocol == IPPROTO_UDP)
f95c89
-				uh = (struct udphdr *)(iph + 1);
f95c89
-		} else {
f95c89
-			struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
f95c89
-
f95c89
-			if (iph->nexthdr == IPPROTO_UDP)
f95c89
-				uh = (struct udphdr *)(iph + 1);
f95c89
-		}
f95c89
-		if (uh) {
f95c89
-			if (uh->check)
f95c89
-				skb_shinfo(skb)->gso_type |=
f95c89
-					SKB_GSO_UDP_TUNNEL_CSUM;
f95c89
-			else
f95c89
-				skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
f95c89
-		}
f95c89
-	}
f95c89
+	if (nw_off) /* tunnel */
f95c89
+		bnxt_gro_tunnel(skb, skb->protocol);
f95c89
 #endif
f95c89
 	return skb;
f95c89
 }