From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 89BF7AA92 for ; Fri, 20 Apr 2018 16:22:10 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 1CBE130C01A for ; Fri, 20 Apr 2018 07:22:06 -0700 (PDT) Received: from C02VPB22HTD6.vpn.broadcom.net (unknown [10.10.117.120]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id DDB51AC0797 for ; Fri, 20 Apr 2018 07:22:05 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Date: Fri, 20 Apr 2018 07:22:00 -0700 Message-Id: <20180420142202.95545-2-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.15.1 (Apple Git-101) In-Reply-To: <20180420142202.95545-1-ajit.khaparde@broadcom.com> References: <46189266.0ermlJLUP5@xps> <20180420142202.95545-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH v3 1/3] net/bnxt: cache address of doorbell to subsequent access X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Apr 2018 14:22:11 -0000 While creating TX, Rx, CQ rings use cached DB address instead of getting it from the PCI memory resource. Signed-off-by: Ajit Khaparde --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_cpr.c | 2 +- drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++++ drivers/net/bnxt/bnxt_ring.c | 17 +++++------------ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index bdca2622f..97b0e0853 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -208,6 +208,7 @@ struct bnxt { struct rte_eth_dev *eth_dev; struct rte_eth_rss_conf rss_conf; struct rte_pci_device *pdev; + void *doorbell_base; uint32_t flags; #define BNXT_FLAG_REGISTERED (1 << 0) diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 5ac197ea7..8dde8cc0f 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -144,7 +144,7 @@ int bnxt_alloc_def_cp_ring(struct bnxt *bp) HWRM_NA_SIGNATURE); if (rc) goto err_out; - cpr->cp_doorbell = bp->pdev->mem_resource[2].addr; + cpr->cp_doorbell = (char *)bp->doorbell_base; B_CP_DIS_DB(cpr, cpr->cp_raw_cons); if (BNXT_PF(bp)) rc = bnxt_hwrm_func_cfg_def_cp(bp); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 7632c326b..a133114a3 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -3095,11 +3095,23 @@ static int bnxt_init_board(struct rte_eth_dev *eth_dev) rc = -ENOMEM; goto init_err_release; } + + if (!pci_dev->mem_resource[2].addr) { + PMD_DRV_LOG(ERR, + "Cannot find PCI device BAR 2 address, aborting\n"); + rc = -ENODEV; + goto init_err_release; + } else { + bp->doorbell_base = (void *)pci_dev->mem_resource[2].addr; + } + return 0; init_err_release: if (bp->bar0) bp->bar0 = NULL; + if (bp->doorbell_base) + bp->doorbell_base = NULL; init_err_disable: diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c index 478eab4f3..8e822e11f 100644 --- a/drivers/net/bnxt/bnxt_ring.c +++ b/drivers/net/bnxt/bnxt_ring.c @@ -261,7 +261,6 @@ int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx, */ int bnxt_alloc_hwrm_rings(struct bnxt *bp) { - struct rte_pci_device *pci_dev = bp->pdev; unsigned int i; int rc = 0; @@ -283,8 +282,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) HWRM_NA_SIGNATURE); if (rc) goto err_out; - cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr + - idx * 0x80; + cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80; bp->grp_info[i].cp_fw_ring_id = cp_ring->fw_ring_id; B_CP_DIS_DB(cpr, cpr->cp_raw_cons); @@ -296,8 +294,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) if (rc) goto err_out; rxr->rx_prod = 0; - rxr->rx_doorbell = (char *)pci_dev->mem_resource[2].addr + - idx * 0x80; + rxr->rx_doorbell = (char *)bp->doorbell_base + idx * 0x80; bp->grp_info[i].rx_fw_ring_id = ring->fw_ring_id; B_RX_DB(rxr->rx_doorbell, rxr->rx_prod); @@ -316,9 +313,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) goto err_out; PMD_DRV_LOG(DEBUG, "Alloc AGG Done!\n"); rxr->ag_prod = 0; - rxr->ag_doorbell = - (char *)pci_dev->mem_resource[2].addr + - map_idx * 0x80; + rxr->ag_doorbell = (char *)bp->doorbell_base + map_idx * 0x80; bp->grp_info[i].ag_fw_ring_id = ring->fw_ring_id; B_RX_DB(rxr->ag_doorbell, rxr->ag_prod); @@ -350,8 +345,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) if (rc) goto err_out; - cpr->cp_doorbell = (char *)pci_dev->mem_resource[2].addr + - idx * 0x80; + cpr->cp_doorbell = (char *)bp->doorbell_base + idx * 0x80; B_CP_DIS_DB(cpr, cpr->cp_raw_cons); /* Tx ring */ @@ -362,8 +356,7 @@ int bnxt_alloc_hwrm_rings(struct bnxt *bp) if (rc) goto err_out; - txr->tx_doorbell = (char *)pci_dev->mem_resource[2].addr + - idx * 0x80; + txr->tx_doorbell = (char *)bp->doorbell_base + idx * 0x80; txq->index = idx; } -- 2.15.1 (Apple Git-101)