Skip to content

Commit 8ae2473

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add support for L2 doorbell size.
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>
1 parent e93b30d commit 8ae2473

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6364,6 +6364,7 @@ static int bnxt_hwrm_func_qcfg(struct bnxt *bp)
63646364
{
63656365
struct hwrm_func_qcfg_input req = {0};
63666366
struct hwrm_func_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
6367+
u32 min_db_offset = 0;
63676368
u16 flags;
63686369
int rc;
63696370

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

6416+
if (bp->db_size)
6417+
goto func_qcfg_exit;
6418+
6419+
if (bp->flags & BNXT_FLAG_CHIP_P5) {
6420+
if (BNXT_PF(bp))
6421+
min_db_offset = DB_PF_OFFSET_P5;
6422+
else
6423+
min_db_offset = DB_VF_OFFSET_P5;
6424+
}
6425+
bp->db_size = PAGE_ALIGN(le16_to_cpu(resp->l2_doorbell_bar_size_kb) *
6426+
1024);
6427+
if (!bp->db_size || bp->db_size > pci_resource_len(bp->pdev, 2) ||
6428+
bp->db_size <= min_db_offset)
6429+
bp->db_size = pci_resource_len(bp->pdev, 2);
6430+
64156431
func_qcfg_exit:
64166432
mutex_unlock(&bp->hwrm_cmd_lock);
64176433
return rc;
@@ -10898,20 +10914,16 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
1089810914
bp->dev = dev;
1089910915
bp->pdev = pdev;
1090010916

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

10908-
bp->bar1 = pci_ioremap_bar(pdev, 2);
10909-
if (!bp->bar1) {
10910-
dev_err(&pdev->dev, "Cannot map doorbell registers, aborting\n");
10911-
rc = -ENOMEM;
10912-
goto init_err_release;
10913-
}
10914-
1091510927
bp->bar2 = pci_ioremap_bar(pdev, 4);
1091610928
if (!bp->bar2) {
1091710929
dev_err(&pdev->dev, "Cannot map bar4 registers, aborting\n");
@@ -11833,6 +11845,16 @@ static int bnxt_pcie_dsn_get(struct bnxt *bp, u8 dsn[])
1183311845
return 0;
1183411846
}
1183511847

11848+
static int bnxt_map_db_bar(struct bnxt *bp)
11849+
{
11850+
if (!bp->db_size)
11851+
return -ENODEV;
11852+
bp->bar1 = pci_iomap(bp->pdev, 2, bp->db_size);
11853+
if (!bp->bar1)
11854+
return -ENOMEM;
11855+
return 0;
11856+
}
11857+
1183611858
static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1183711859
{
1183811860
struct net_device *dev;
@@ -11893,6 +11915,13 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1189311915
if (rc)
1189411916
goto init_err_pci_clean;
1189511917

11918+
rc = bnxt_map_db_bar(bp);
11919+
if (rc) {
11920+
dev_err(&pdev->dev, "Cannot map doorbell BAR rc = %d, aborting\n",
11921+
rc);
11922+
goto init_err_pci_clean;
11923+
}
11924+
1189611925
dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
1189711926
NETIF_F_TSO | NETIF_F_TSO6 |
1189811927
NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,7 @@ struct bnxt {
18201820
/* ensure atomic 64-bit doorbell writes on 32-bit systems. */
18211821
spinlock_t db_lock;
18221822
#endif
1823+
int db_size;
18231824

18241825
#define BNXT_NTP_FLTR_MAX_FLTR 4096
18251826
#define BNXT_NTP_FLTR_HASH_SIZE 512

0 commit comments

Comments
 (0)