Skip to content

Commit 0ac20fa

Browse files
selvintxavierjgunthorpe
authored andcommitted
RDMA/bnxt_re: Reorg the bar mapping
Reorganize the code for allocation and mapping of Doorbell pages. Implements new HW command to get the BAR length used by L2 driver. These changes are used by the future patch which maps the WC Doorbell pages. Also, introduced a new lock dpi_tbl_lock for synchronize the DB page allocation from users. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 3fe9882 commit 0ac20fa

File tree

8 files changed

+213
-77
lines changed

8 files changed

+213
-77
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ int bnxt_re_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
618618
* ibv_devinfo and family of application when DPIs
619619
* are depleted.
620620
*/
621-
if (bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl,
622-
&ucntx->dpi, ucntx)) {
621+
if (bnxt_qplib_alloc_dpi(&rdev->qplib_res,
622+
&ucntx->dpi, ucntx, BNXT_QPLIB_DPI_TYPE_UC)) {
623623
rc = -ENOMEM;
624624
goto dbfail;
625625
}
@@ -4095,8 +4095,7 @@ void bnxt_re_dealloc_ucontext(struct ib_ucontext *ib_uctx)
40954095
/* Free DPI only if this is the first PD allocated by the
40964096
* application and mark the context dpi as NULL
40974097
*/
4098-
bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
4099-
&rdev->qplib_res.dpi_tbl, &uctx->dpi);
4098+
bnxt_qplib_dealloc_dpi(&rdev->qplib_res, &uctx->dpi);
41004099
uctx->dpi.dbr = NULL;
41014100
}
41024101
}

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,40 @@ static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
8585
static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev);
8686
static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
8787

88+
static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
89+
u32 *offset);
90+
static void bnxt_re_set_db_offset(struct bnxt_re_dev *rdev)
91+
{
92+
struct bnxt_qplib_chip_ctx *cctx;
93+
struct bnxt_en_dev *en_dev;
94+
struct bnxt_qplib_res *res;
95+
u32 l2db_len = 0;
96+
u32 offset = 0;
97+
u32 barlen;
98+
int rc;
99+
100+
res = &rdev->qplib_res;
101+
en_dev = rdev->en_dev;
102+
cctx = rdev->chip_ctx;
103+
104+
/* Issue qcfg */
105+
rc = bnxt_re_hwrm_qcfg(rdev, &l2db_len, &offset);
106+
if (rc)
107+
dev_info(rdev_to_dev(rdev),
108+
"Couldn't get DB bar size, Low latency framework is disabled\n");
109+
/* set register offsets for both UC and WC */
110+
res->dpi_tbl.ucreg.offset = res->is_vf ? BNXT_QPLIB_DBR_VF_DB_OFFSET :
111+
BNXT_QPLIB_DBR_PF_DB_OFFSET;
112+
res->dpi_tbl.wcreg.offset = res->dpi_tbl.ucreg.offset;
113+
114+
/* If WC mapping is disabled by L2 driver then en_dev->l2_db_size
115+
* is equal to the DB-Bar actual size. This indicates that L2
116+
* is mapping entire bar as UC-. RoCE driver can't enable WC mapping
117+
* in such cases and DB-push will be disabled.
118+
*/
119+
barlen = pci_resource_len(res->pdev, RCFW_DBR_PCI_BAR_REGION);
120+
}
121+
88122
static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
89123
{
90124
struct bnxt_qplib_chip_ctx *cctx;
@@ -116,6 +150,7 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)
116150
{
117151
struct bnxt_qplib_chip_ctx *chip_ctx;
118152
struct bnxt_en_dev *en_dev;
153+
int rc;
119154

120155
en_dev = rdev->en_dev;
121156

@@ -134,6 +169,12 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)
134169
rdev->qplib_res.is_vf = BNXT_EN_VF(en_dev);
135170

136171
bnxt_re_set_drv_mode(rdev, wqe_mode);
172+
173+
bnxt_re_set_db_offset(rdev);
174+
rc = bnxt_qplib_map_db_bar(&rdev->qplib_res);
175+
if (rc)
176+
return rc;
177+
137178
if (bnxt_qplib_determine_atomics(en_dev->pdev))
138179
ibdev_info(&rdev->ibdev,
139180
"platform doesn't support global atomics.");
@@ -343,6 +384,30 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
343384
fw_msg->timeout = timeout;
344385
}
345386

387+
/* Query device config using common hwrm */
388+
static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
389+
u32 *offset)
390+
{
391+
struct bnxt_en_dev *en_dev = rdev->en_dev;
392+
struct hwrm_func_qcfg_output resp = {0};
393+
struct hwrm_func_qcfg_input req = {0};
394+
struct bnxt_fw_msg fw_msg;
395+
int rc;
396+
397+
memset(&fw_msg, 0, sizeof(fw_msg));
398+
bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
399+
HWRM_FUNC_QCFG, -1, -1);
400+
req.fid = cpu_to_le16(0xffff);
401+
bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
402+
sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
403+
rc = bnxt_send_msg(en_dev, &fw_msg);
404+
if (!rc) {
405+
*db_len = PAGE_ALIGN(le16_to_cpu(resp.l2_doorbell_bar_size_kb) * 1024);
406+
*offset = PAGE_ALIGN(le16_to_cpu(resp.legacy_l2_db_size_kb) * 1024);
407+
}
408+
return rc;
409+
}
410+
346411
/* Query function capabilities using common hwrm */
347412
int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
348413
{
@@ -847,7 +912,6 @@ static void bnxt_re_free_res(struct bnxt_re_dev *rdev)
847912

848913
if (rdev->qplib_res.dpi_tbl.max) {
849914
bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
850-
&rdev->qplib_res.dpi_tbl,
851915
&rdev->dpi_privileged);
852916
}
853917
if (rdev->qplib_res.rcfw) {
@@ -875,9 +939,9 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
875939
if (rc)
876940
goto fail;
877941

878-
rc = bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl,
942+
rc = bnxt_qplib_alloc_dpi(&rdev->qplib_res,
879943
&rdev->dpi_privileged,
880-
rdev);
944+
rdev, BNXT_QPLIB_DPI_TYPE_KERNEL);
881945
if (rc)
882946
goto dealloc_res;
883947

@@ -917,7 +981,6 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
917981
bnxt_qplib_free_nq(&rdev->nq[i]);
918982
}
919983
bnxt_qplib_dealloc_dpi(&rdev->qplib_res,
920-
&rdev->qplib_res.dpi_tbl,
921984
&rdev->dpi_privileged);
922985
dealloc_res:
923986
bnxt_qplib_free_res(&rdev->qplib_res);

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res,
668668
srq->dbinfo.xid = srq->id;
669669
srq->dbinfo.db = srq->dpi->dbr;
670670
srq->dbinfo.max_slot = 1;
671-
srq->dbinfo.priv_db = res->dpi_tbl.dbr_bar_reg_iomem;
671+
srq->dbinfo.priv_db = res->dpi_tbl.priv_db;
672672
if (srq->threshold)
673673
bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA);
674674
srq->arm_req = false;
@@ -2104,7 +2104,7 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
21042104
cq->dbinfo.hwq = &cq->hwq;
21052105
cq->dbinfo.xid = cq->id;
21062106
cq->dbinfo.db = cq->dpi->dbr;
2107-
cq->dbinfo.priv_db = res->dpi_tbl.dbr_bar_reg_iomem;
2107+
cq->dbinfo.priv_db = res->dpi_tbl.priv_db;
21082108

21092109
bnxt_qplib_armen_db(&cq->dbinfo, DBC_DBC_TYPE_CQ_ARMENA);
21102110

drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ static inline u32 bnxt_qplib_set_cmd_slots(struct cmdq_base *req)
130130
#define RCFW_MAX_COOKIE_VALUE (BNXT_QPLIB_CMDQE_MAX_CNT - 1)
131131
#define RCFW_CMD_IS_BLOCKING 0x8000
132132

133+
#define HWRM_VERSION_DEV_ATTR_MAX_DPI 0x1000A0000000DULL
134+
133135
/* Crsq buf is 1024-Byte */
134136
struct bnxt_qplib_crsbe {
135137
u8 data[1024];

0 commit comments

Comments
 (0)