Blame SOURCES/0019-netdrv-bnxt_en-Refactor-bnxt_alloc_stats.patch

f95c89
From 7b521924055a466fc15021ba7c0fbd3833739abf Mon Sep 17 00:00:00 2001
f95c89
From: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Date: Wed, 2 Oct 2019 18:22:34 -0400
f95c89
Subject: [PATCH 19/96] [netdrv] bnxt_en: Refactor bnxt_alloc_stats()
f95c89
f95c89
Message-id: <0b455fb7258aebee3261769c74274ce59cd30970.1570027456.git.jtoppins@redhat.com>
f95c89
Patchwork-id: 276441
f95c89
O-Subject: [RHEL-8.2 PATCH 12/78] bnxt_en: Refactor bnxt_alloc_stats().
f95c89
Bugzilla: 1724766
f95c89
RH-Acked-by: John Linville <linville@redhat.com>
f95c89
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
f95c89
f95c89
Reverse the condition of the large "if" block and return early.  This
f95c89
will simplify the follow up patch to add PCIe statistics.
f95c89
f95c89
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
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 a220eabc8887e3c02d308a9960e92a70cbd00b52)
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 | 75 +++++++++++++++----------------
f95c89
 1 file changed, 36 insertions(+), 39 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:12.563542039 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:12.831539579 +0100
f95c89
@@ -3446,56 +3446,53 @@
f95c89
 		cpr->hw_stats_ctx_id = INVALID_STATS_CTX_ID;
f95c89
 	}
f95c89
 
f95c89
-	if (BNXT_PF(bp) && bp->chip_num != CHIP_NUM_58700) {
f95c89
-		if (bp->hw_rx_port_stats)
f95c89
-			goto alloc_ext_stats;
f95c89
-
f95c89
-		bp->hw_port_stats_size = sizeof(struct rx_port_stats) +
f95c89
-					 sizeof(struct tx_port_stats) + 1024;
f95c89
-
f95c89
-		bp->hw_rx_port_stats =
f95c89
-			dma_alloc_coherent(&pdev->dev, bp->hw_port_stats_size,
f95c89
-					   &bp->hw_rx_port_stats_map,
f95c89
-					   GFP_KERNEL);
f95c89
-		if (!bp->hw_rx_port_stats)
f95c89
-			return -ENOMEM;
f95c89
+	if (BNXT_VF(bp) || bp->chip_num == CHIP_NUM_58700)
f95c89
+		return 0;
f95c89
 
f95c89
-		bp->hw_tx_port_stats = (void *)(bp->hw_rx_port_stats + 1) +
f95c89
-				       512;
f95c89
-		bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +
f95c89
-					   sizeof(struct rx_port_stats) + 512;
f95c89
-		bp->flags |= BNXT_FLAG_PORT_STATS;
f95c89
+	if (bp->hw_rx_port_stats)
f95c89
+		goto alloc_ext_stats;
f95c89
 
f95c89
-alloc_ext_stats:
f95c89
-		/* Display extended statistics only if FW supports it */
f95c89
-		if (bp->hwrm_spec_code < 0x10804 ||
f95c89
-		    bp->hwrm_spec_code == 0x10900)
f95c89
-			return 0;
f95c89
+	bp->hw_port_stats_size = sizeof(struct rx_port_stats) +
f95c89
+				 sizeof(struct tx_port_stats) + 1024;
f95c89
 
f95c89
-		if (bp->hw_rx_port_stats_ext)
f95c89
-			goto alloc_tx_ext_stats;
f95c89
+	bp->hw_rx_port_stats =
f95c89
+		dma_alloc_coherent(&pdev->dev, bp->hw_port_stats_size,
f95c89
+				   &bp->hw_rx_port_stats_map,
f95c89
+				   GFP_KERNEL);
f95c89
+	if (!bp->hw_rx_port_stats)
f95c89
+		return -ENOMEM;
f95c89
+
f95c89
+	bp->hw_tx_port_stats = (void *)(bp->hw_rx_port_stats + 1) + 512;
f95c89
+	bp->hw_tx_port_stats_map = bp->hw_rx_port_stats_map +
f95c89
+				   sizeof(struct rx_port_stats) + 512;
f95c89
+	bp->flags |= BNXT_FLAG_PORT_STATS;
f95c89
 
f95c89
-		bp->hw_rx_port_stats_ext =
f95c89
-			dma_alloc_coherent(&pdev->dev,
f95c89
-					   sizeof(struct rx_port_stats_ext),
f95c89
-					   &bp->hw_rx_port_stats_ext_map,
f95c89
-					   GFP_KERNEL);
f95c89
-		if (!bp->hw_rx_port_stats_ext)
f95c89
-			return 0;
f95c89
+alloc_ext_stats:
f95c89
+	/* Display extended statistics only if FW supports it */
f95c89
+	if (bp->hwrm_spec_code < 0x10804 || bp->hwrm_spec_code == 0x10900)
f95c89
+		return 0;
f95c89
+
f95c89
+	if (bp->hw_rx_port_stats_ext)
f95c89
+		goto alloc_tx_ext_stats;
f95c89
+
f95c89
+	bp->hw_rx_port_stats_ext =
f95c89
+		dma_alloc_coherent(&pdev->dev, sizeof(struct rx_port_stats_ext),
f95c89
+				   &bp->hw_rx_port_stats_ext_map, GFP_KERNEL);
f95c89
+	if (!bp->hw_rx_port_stats_ext)
f95c89
+		return 0;
f95c89
 
f95c89
 alloc_tx_ext_stats:
f95c89
-		if (bp->hw_tx_port_stats_ext)
f95c89
-			return 0;
f95c89
+	if (bp->hw_tx_port_stats_ext)
f95c89
+		return 0;
f95c89
 
f95c89
-		if (bp->hwrm_spec_code >= 0x10902) {
f95c89
-			bp->hw_tx_port_stats_ext =
f95c89
-				dma_alloc_coherent(&pdev->dev,
f95c89
-						   sizeof(struct tx_port_stats_ext),
f95c89
-						   &bp->hw_tx_port_stats_ext_map,
f95c89
-						   GFP_KERNEL);
f95c89
-		}
f95c89
-		bp->flags |= BNXT_FLAG_PORT_STATS_EXT;
f95c89
+	if (bp->hwrm_spec_code >= 0x10902) {
f95c89
+		bp->hw_tx_port_stats_ext =
f95c89
+			dma_alloc_coherent(&pdev->dev,
f95c89
+					   sizeof(struct tx_port_stats_ext),
f95c89
+					   &bp->hw_tx_port_stats_ext_map,
f95c89
+					   GFP_KERNEL);
f95c89
 	}
f95c89
+	bp->flags |= BNXT_FLAG_PORT_STATS_EXT;
f95c89
 	return 0;
f95c89
 }
f95c89