Netdev List
 help / color / mirror / Atom feed
From: Michael Chan <michael.chan@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next 06/16] bnxt_en: Refactor tunneled hardware GRO logic.
Date: Mon, 29 Jul 2019 06:10:23 -0400	[thread overview]
Message-ID: <1564395033-19511-7-git-send-email-michael.chan@broadcom.com> (raw)
In-Reply-To: <1564395033-19511-1-git-send-email-michael.chan@broadcom.com>

The 2 GRO functions to set up the hardware GRO SKB fields for 2
different hardware chips have practically identical logic for
tunneled packets.  Refactor the logic into a separate bnxt_gro_tunnel()
function that can be used by both functions.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 69 +++++++++++++------------------
 1 file changed, 28 insertions(+), 41 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 810eea2..4856fd7 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1207,6 +1207,31 @@ static void bnxt_abort_tpa(struct bnxt_cp_ring_info *cpr, u16 idx, u32 agg_bufs)
 		bnxt_reuse_rx_agg_bufs(cpr, idx, 0, agg_bufs, true);
 }
 
+#ifdef CONFIG_INET
+static void bnxt_gro_tunnel(struct sk_buff *skb, __be16 ip_proto)
+{
+	struct udphdr *uh = NULL;
+
+	if (ip_proto == htons(ETH_P_IP)) {
+		struct iphdr *iph = (struct iphdr *)skb->data;
+
+		if (iph->protocol == IPPROTO_UDP)
+			uh = (struct udphdr *)(iph + 1);
+	} else {
+		struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
+
+		if (iph->nexthdr == IPPROTO_UDP)
+			uh = (struct udphdr *)(iph + 1);
+	}
+	if (uh) {
+		if (uh->check)
+			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL_CSUM;
+		else
+			skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
+	}
+}
+#endif
+
 static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info,
 					   int payload_off, int tcp_ts,
 					   struct sk_buff *skb)
@@ -1264,28 +1289,10 @@ static struct sk_buff *bnxt_gro_func_5731x(struct bnxt_tpa_info *tpa_info,
 	}
 
 	if (inner_mac_off) { /* tunnel */
-		struct udphdr *uh = NULL;
 		__be16 proto = *((__be16 *)(skb->data + outer_ip_off -
 					    ETH_HLEN - 2));
 
-		if (proto == htons(ETH_P_IP)) {
-			struct iphdr *iph = (struct iphdr *)skb->data;
-
-			if (iph->protocol == IPPROTO_UDP)
-				uh = (struct udphdr *)(iph + 1);
-		} else {
-			struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
-
-			if (iph->nexthdr == IPPROTO_UDP)
-				uh = (struct udphdr *)(iph + 1);
-		}
-		if (uh) {
-			if (uh->check)
-				skb_shinfo(skb)->gso_type |=
-					SKB_GSO_UDP_TUNNEL_CSUM;
-			else
-				skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
-		}
+		bnxt_gro_tunnel(skb, proto);
 	}
 #endif
 	return skb;
@@ -1332,28 +1339,8 @@ static struct sk_buff *bnxt_gro_func_5730x(struct bnxt_tpa_info *tpa_info,
 		return NULL;
 	}
 
-	if (nw_off) { /* tunnel */
-		struct udphdr *uh = NULL;
-
-		if (skb->protocol == htons(ETH_P_IP)) {
-			struct iphdr *iph = (struct iphdr *)skb->data;
-
-			if (iph->protocol == IPPROTO_UDP)
-				uh = (struct udphdr *)(iph + 1);
-		} else {
-			struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
-
-			if (iph->nexthdr == IPPROTO_UDP)
-				uh = (struct udphdr *)(iph + 1);
-		}
-		if (uh) {
-			if (uh->check)
-				skb_shinfo(skb)->gso_type |=
-					SKB_GSO_UDP_TUNNEL_CSUM;
-			else
-				skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_TUNNEL;
-		}
-	}
+	if (nw_off) /* tunnel */
+		bnxt_gro_tunnel(skb, skb->protocol);
 #endif
 	return skb;
 }
-- 
2.5.1


  parent reply	other threads:[~2019-07-29 10:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 10:10 [PATCH net-next 00/16] bnxt_en: Add TPA (GRO_HW and LRO) on 57500 chips Michael Chan
2019-07-29 10:10 ` [PATCH net-next 01/16] bnxt_en: Update firmware interface spec. to 1.10.0.89 Michael Chan
2019-07-29 10:10 ` [PATCH net-next 02/16] bnxt_en: Add TPA structure definitions for BCM57500 chips Michael Chan
2019-07-29 10:10 ` [PATCH net-next 03/16] bnxt_en: Refactor TPA logic Michael Chan
2019-07-29 10:10 ` [PATCH net-next 04/16] bnxt_en: Expand bnxt_tpa_info struct to support 57500 chips Michael Chan
2019-07-29 10:10 ` [PATCH net-next 05/16] bnxt_en: Handle standalone RX_AGG completions Michael Chan
2019-07-29 10:10 ` Michael Chan [this message]
2019-07-29 10:10 ` [PATCH net-next 07/16] bnxt_en: Set TPA GRO mode flags on 57500 chips properly Michael Chan
2019-07-29 10:10 ` [PATCH net-next 08/16] bnxt_en: Add fast path logic for TPA on 57500 chips Michael Chan
2019-07-29 10:10 ` [PATCH net-next 09/16] bnxt_en: Add TPA ID mapping logic for " Michael Chan
2019-07-29 10:10 ` [PATCH net-next 10/16] bnxt_en: Add hardware GRO setup function " Michael Chan
2019-07-29 10:10 ` [PATCH net-next 11/16] bnxt_en: Refactor ethtool ring statistics logic Michael Chan
2019-07-29 10:10 ` [PATCH net-next 12/16] bnxt_en: Allocate the larger per-ring statistics block for 57500 chips Michael Chan
2019-07-29 10:10 ` [PATCH net-next 13/16] bnxt_en: Support TPA counters on " Michael Chan
2019-07-29 10:10 ` [PATCH net-next 14/16] bnxt_en: Refactor bnxt_init_one() and turn on TPA support " Michael Chan
2019-07-29 10:10 ` [PATCH net-next 15/16] bnxt_en: Support all variants of the 5750X chip family Michael Chan
2019-07-29 10:10 ` [PATCH net-next 16/16] bnxt_en: Add PCI IDs for 57500 series NPAR devices Michael Chan
2019-07-29 21:24 ` [PATCH net-next 00/16] bnxt_en: Add TPA (GRO_HW and LRO) on 57500 chips David Miller
2019-07-29 22:00   ` Michael Chan

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=1564395033-19511-7-git-send-email-michael.chan@broadcom.com \
    --to=michael.chan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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