Skip to content

Commit

Permalink
bnxt_en: Add support for L2 doorbell size.
Browse files Browse the repository at this point in the history
Read the L2 doorbell size from the firmware and only map the portion
of the doorbell BAR for L2 use.  This will leave the remaining doorbell
BAR available for the RoCE driver to use.  The RoCE driver can map
the remaining portion as write-combining to support the push feature.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed May 4, 2020
1 parent e93b30d commit 8ae2473
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
43 changes: 36 additions & 7 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -6364,6 +6364,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
{
struct hwrm_func_qcfg_input req = {0};
struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
u32 min_db_offset = 0;
u16 flags;
int rc;

Expand Down Expand Up @@ -6412,6 +6413,21 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
if (!bp->max_mtu)
bp->max_mtu = BNXT_MAX_MTU;

if (bp->db_size)
goto func_qcfg_exit;

if (bp->flags & BNXT_FLAG_CHIP_P5) {
if (BNXT_PF(bp))
min_db_offset = DB_PF_OFFSET_P5;
else
min_db_offset = DB_VF_OFFSET_P5;
}
bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) *
1024);
if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) ||
bp->db_size <= min_db_offset)
bp->db_size = pci_resource_len(bp->pdev, 2);

func_qcfg_exit:
mutex_unlock(&bp->hwrm_cmd_lock);
return rc;
Expand Down Expand Up @@ -10898,20 +10914,16 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
bp->dev = dev;
bp->pdev = pdev;

/* Doorbell BAR bp->bar1 is mapped after bnxt_fw_init_one_p2()
* determines the BAR size.
*/
bp->bar0 = pci_ioremap_bar(pdev, 0);
if (!bp->bar0) {
dev_err(&pdev->dev, "Cannot map device registers, aborting\n");
rc = -ENOMEM;
goto init_err_release;
}

bp->bar1 = pci_ioremap_bar(pdev, 2);
if (!bp->bar1) {
dev_err(&pdev->dev, "Cannot map doorbell registers, aborting\n");
rc = -ENOMEM;
goto init_err_release;
}

bp->bar2 = pci_ioremap_bar(pdev, 4);
if (!bp->bar2) {
dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n");
Expand Down Expand Up @@ -11833,6 +11845,16 @@ static int bnxt_pcie_dsn_get(struct bnxt *bp, u8 dsn[])
return 0;
}

static int bnxt_map_db_bar(struct bnxt *bp)
{
if (!bp->db_size)
return -ENODEV;
bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size);
if (!bp->bar1)
return -ENOMEM;
return 0;
}

static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
Expand Down Expand Up @@ -11893,6 +11915,13 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc)
goto init_err_pci_clean;

rc = bnxt_map_db_bar(bp);
if (rc) {
dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n",
rc);
goto init_err_pci_clean;
}

dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
NETIF_F_TSO | NETIF_F_TSO6 |
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,7 @@ struct bnxt {
/* ensure atomic 64-bit doorbell writes on 32-bit systems. */
spinlock_t db_lock;
#endif
int db_size;

#define BNXT_NTP_FLTR_MAX_FLTR 4096
#define BNXT_NTP_FLTR_HASH_SIZE 512
Expand Down

0 comments on commit 8ae2473

Please sign in to comment.