Blame SOURCES/bnxt-dpdk-0001-net-bnxt-cache-address-of-doorbell-to-subsequent-acc.patch

c7ffa4
From 02bd8182658600ebf2cbe61168e80c19ce4cdaa5 Mon Sep 17 00:00:00 2001
c7ffa4
Message-Id: <02bd8182658600ebf2cbe61168e80c19ce4cdaa5.1524241750.git.dcaratti@redhat.com>
c7ffa4
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
c7ffa4
Date: Fri, 20 Apr 2018 07:22:00 -0700
c7ffa4
Subject: [PATCH 1/3] net/bnxt: cache address of doorbell to subsequent access
c7ffa4
c7ffa4
While creating TX, Rx, CQ rings use cached DB address instead of
c7ffa4
getting it from the PCI memory resource.
c7ffa4
c7ffa4
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
c7ffa4
---
c7ffa4
 drivers/net/bnxt/bnxt.h        |  1 +
c7ffa4
 drivers/net/bnxt/bnxt_cpr.c    |  2 +-
c7ffa4
 drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++++
c7ffa4
 drivers/net/bnxt/bnxt_ring.c   | 17 +++++------------
c7ffa4
 4 files changed, 19 insertions(+), 13 deletions(-)
c7ffa4
c7ffa4
backport notes:
c7ffa4
 - use RTE_LOG in place of PMD_DRV_LOG (missing upstream commit
c7ffa4
   3e92fd4e4ec0 ("net/bnxt: use dynamic log type")
c7ffa4
c7ffa4
--- a/drivers/net/bnxt/bnxt.h
c7ffa4
+++ b/drivers/net/bnxt/bnxt.h
c7ffa4
@@ -188,6 +188,7 @@ struct bnxt {
c7ffa4
 	struct rte_eth_dev		*eth_dev;
c7ffa4
 	struct rte_eth_rss_conf		rss_conf;
c7ffa4
 	struct rte_pci_device		*pdev;
c7ffa4
+	void				*doorbell_base;
c7ffa4
 
c7ffa4
 	uint32_t		flags;
c7ffa4
 #define BNXT_FLAG_REGISTERED	(1 << 0)
c7ffa4
--- a/drivers/net/bnxt/bnxt_cpr.c
c7ffa4
+++ b/drivers/net/bnxt/bnxt_cpr.c
c7ffa4
@@ -163,7 +163,7 @@ int bnxt_alloc_def_cp_ring(struct bnxt *
c7ffa4
 				  HWRM_NA_SIGNATURE);
c7ffa4
 	if (rc)
c7ffa4
 		goto err_out;
c7ffa4
-	cpr->cp_doorbell = bp->pdev->mem_resource[2].addr;
c7ffa4
+	cpr->cp_doorbell = (char *)bp->doorbell_base;
c7ffa4
 	B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
c7ffa4
 	bp->grp_info[0].cp_fw_ring_id = cp_ring->fw_ring_id;
c7ffa4
 	if (BNXT_PF(bp))
c7ffa4
--- a/drivers/net/bnxt/bnxt_ethdev.c
c7ffa4
+++ b/drivers/net/bnxt/bnxt_ethdev.c
c7ffa4
@@ -2769,11 +2769,23 @@ static int bnxt_init_board(struct rte_et
c7ffa4
 		rc = -ENOMEM;
c7ffa4
 		goto init_err_release;
c7ffa4
 	}
c7ffa4
+
c7ffa4
+	if (!pci_dev->mem_resource[2].addr) {
c7ffa4
+		RTE_LOG(ERR, PMD,
c7ffa4
+			"Cannot find PCI device BAR 2 address, aborting\n");
c7ffa4
+		rc = -ENODEV;
c7ffa4
+		goto init_err_release;
c7ffa4
+	} else {
c7ffa4
+		bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr;
c7ffa4
+	}
c7ffa4
+
c7ffa4
 	return 0;
c7ffa4
 
c7ffa4
 init_err_release:
c7ffa4
 	if (bp->bar0)
c7ffa4
 		bp->bar0 = NULL;
c7ffa4
+	if (bp->doorbell_base)
c7ffa4
+		bp->doorbell_base = NULL;
c7ffa4
 
c7ffa4
 init_err_disable:
c7ffa4
 
c7ffa4
--- a/drivers/net/bnxt/bnxt_ring.c
c7ffa4
+++ b/drivers/net/bnxt/bnxt_ring.c
c7ffa4
@@ -281,7 +281,6 @@ int bnxt_alloc_rings(struct bnxt *bp, ui
c7ffa4
  */
c7ffa4
 int bnxt_alloc_hwrm_rings(struct bnxt *bp)
c7ffa4
 {
c7ffa4
-	struct rte_pci_device *pci_dev = bp->pdev;
c7ffa4
 	unsigned int i;
c7ffa4
 	int rc = 0;
c7ffa4
 
c7ffa4
@@ -303,8 +302,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *b
c7ffa4
 					HWRM_NA_SIGNATURE);
c7ffa4
 		if (rc)
c7ffa4
 			goto err_out;
c7ffa4
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
c7ffa4
-		    idx * 0x80;
c7ffa4
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
c7ffa4
 		bp->grp_info[i].cp_fw_ring_id = cp_ring->fw_ring_id;
c7ffa4
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
c7ffa4
 
c7ffa4
@@ -316,8 +314,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *b
c7ffa4
 		if (rc)
c7ffa4
 			goto err_out;
c7ffa4
 		rxr->rx_prod = 0;
c7ffa4
-		rxr->rx_doorbell = (char *)pci_dev->mem_resource[2].addr +
c7ffa4
-		    idx * 0x80;
c7ffa4
+		rxr->rx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
c7ffa4
 		bp->grp_info[i].rx_fw_ring_id = ring->fw_ring_id;
c7ffa4
 		B_RX_DB(rxr->rx_doorbell, rxr->rx_prod);
c7ffa4
 
c7ffa4
@@ -336,9 +333,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *b
c7ffa4
 			goto err_out;
c7ffa4
 		RTE_LOG(DEBUG, PMD, "Alloc AGG Done!\n");
c7ffa4
 		rxr->ag_prod = 0;
c7ffa4
-		rxr->ag_doorbell =
c7ffa4
-		    (char *)pci_dev->mem_resource[2].addr +
c7ffa4
-		    map_idx * 0x80;
c7ffa4
+		rxr->ag_doorbell = (char *)bp->doorbell_base + map_idx * 0x80;
c7ffa4
 		bp->grp_info[i].ag_fw_ring_id = ring->fw_ring_id;
c7ffa4
 		B_RX_DB(rxr->ag_doorbell, rxr->ag_prod);
c7ffa4
 
c7ffa4
@@ -373,8 +368,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *b
c7ffa4
 		if (rc)
c7ffa4
 			goto err_out;
c7ffa4
 
c7ffa4
-		cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr +
c7ffa4
-		    idx * 0x80;
c7ffa4
+		cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80;
c7ffa4
 		B_CP_DIS_DB(cpr, cpr->cp_raw_cons);
c7ffa4
 
c7ffa4
 		/* Tx ring */
c7ffa4
@@ -385,8 +379,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *b
c7ffa4
 		if (rc)
c7ffa4
 			goto err_out;
c7ffa4
 
c7ffa4
-		txr->tx_doorbell = (char *)pci_dev->mem_resource[2].addr +
c7ffa4
-		    idx * 0x80;
c7ffa4
+		txr->tx_doorbell = (char *)bp->doorbell_base + idx * 0x80;
c7ffa4
 		txq->index = idx;
c7ffa4
 	}
c7ffa4