Skip to content

Commit 5ee0b09

Browse files
committed
RDMA/bnxt_re: Remove dynamic pkey table
Bugzilla: https://bugzilla.redhat.com/2142686 commit 0e93853 Author: Kamal Heib <kamalheib1@gmail.com> Date: Thu Nov 25 05:36:15 2021 +0200 RDMA/bnxt_re: Remove dynamic pkey table The RoCE spec requires RoCE devices to support only the default pkey. However the bnxt_re driver maintains a 0xFFFF entry pkey table and uses only the first entry. Remove the pkey table and hard code a table of length one hard wired with the default pkey. Link: https://lore.kernel.org/r/20211125033615.483750-1-kamalheib1@gmail.com Signed-off-by: Kamal Heib <kamalheib1@gmail.com> Reviewed-by: Devesh Sharma <devesh.s.sharma@oracle.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Kamal Heib <kheib@redhat.com>
1 parent b3cf5a7 commit 5ee0b09

File tree

6 files changed

+10
-175
lines changed

6 files changed

+10
-175
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,12 @@ void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str)
262262
int bnxt_re_query_pkey(struct ib_device *ibdev, u32 port_num,
263263
u16 index, u16 *pkey)
264264
{
265-
struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
265+
if (index > 0)
266+
return -EINVAL;
266267

267-
/* Ignore port_num */
268+
*pkey = IB_DEFAULT_PKEY_FULL;
268269

269-
memset(pkey, 0, sizeof(*pkey));
270-
return bnxt_qplib_get_pkey(&rdev->qplib_res,
271-
&rdev->qplib_res.pkey_tbl, index, pkey);
270+
return 0;
272271
}
273272

274273
int bnxt_re_query_gid(struct ib_device *ibdev, u32 port_num,

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <linux/delay.h>
4747
#include <linux/prefetch.h>
4848
#include <linux/if_ether.h>
49+
#include <rdma/ib_mad.h>
4950

5051
#include "roce_hsi.h"
5152

@@ -1232,7 +1233,7 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
12321233
struct bnxt_qplib_rcfw *rcfw = res->rcfw;
12331234
struct cmdq_modify_qp req;
12341235
struct creq_modify_qp_resp resp;
1235-
u16 cmd_flags = 0, pkey;
1236+
u16 cmd_flags = 0;
12361237
u32 temp32[4];
12371238
u32 bmask;
12381239
int rc;
@@ -1255,11 +1256,9 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
12551256
if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_ACCESS)
12561257
req.access = qp->access;
12571258

1258-
if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_PKEY) {
1259-
if (!bnxt_qplib_get_pkey(res, &res->pkey_tbl,
1260-
qp->pkey_index, &pkey))
1261-
req.pkey = cpu_to_le16(pkey);
1262-
}
1259+
if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_PKEY)
1260+
req.pkey = IB_DEFAULT_PKEY_FULL;
1261+
12631262
if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_QKEY)
12641263
req.qkey = cpu_to_le32(qp->qkey);
12651264

drivers/infiniband/hw/bnxt_re/qplib_res.c

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -649,31 +649,6 @@ static void bnxt_qplib_init_sgid_tbl(struct bnxt_qplib_sgid_tbl *sgid_tbl,
649649
memset(sgid_tbl->hw_id, -1, sizeof(u16) * sgid_tbl->max);
650650
}
651651

652-
static void bnxt_qplib_free_pkey_tbl(struct bnxt_qplib_res *res,
653-
struct bnxt_qplib_pkey_tbl *pkey_tbl)
654-
{
655-
if (!pkey_tbl->tbl)
656-
dev_dbg(&res->pdev->dev, "PKEY tbl not present\n");
657-
else
658-
kfree(pkey_tbl->tbl);
659-
660-
pkey_tbl->tbl = NULL;
661-
pkey_tbl->max = 0;
662-
pkey_tbl->active = 0;
663-
}
664-
665-
static int bnxt_qplib_alloc_pkey_tbl(struct bnxt_qplib_res *res,
666-
struct bnxt_qplib_pkey_tbl *pkey_tbl,
667-
u16 max)
668-
{
669-
pkey_tbl->tbl = kcalloc(max, sizeof(u16), GFP_KERNEL);
670-
if (!pkey_tbl->tbl)
671-
return -ENOMEM;
672-
673-
pkey_tbl->max = max;
674-
return 0;
675-
};
676-
677652
/* PDs */
678653
int bnxt_qplib_alloc_pd(struct bnxt_qplib_pd_tbl *pdt, struct bnxt_qplib_pd *pd)
679654
{
@@ -843,24 +818,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res,
843818
return -ENOMEM;
844819
}
845820

846-
/* PKEYs */
847-
static void bnxt_qplib_cleanup_pkey_tbl(struct bnxt_qplib_pkey_tbl *pkey_tbl)
848-
{
849-
memset(pkey_tbl->tbl, 0, sizeof(u16) * pkey_tbl->max);
850-
pkey_tbl->active = 0;
851-
}
852-
853-
static void bnxt_qplib_init_pkey_tbl(struct bnxt_qplib_res *res,
854-
struct bnxt_qplib_pkey_tbl *pkey_tbl)
855-
{
856-
u16 pkey = 0xFFFF;
857-
858-
memset(pkey_tbl->tbl, 0, sizeof(u16) * pkey_tbl->max);
859-
860-
/* pkey default = 0xFFFF */
861-
bnxt_qplib_add_pkey(res, pkey_tbl, &pkey, false);
862-
}
863-
864821
/* Stats */
865822
static void bnxt_qplib_free_stats_ctx(struct pci_dev *pdev,
866823
struct bnxt_qplib_stats *stats)
@@ -891,21 +848,18 @@ static int bnxt_qplib_alloc_stats_ctx(struct pci_dev *pdev,
891848

892849
void bnxt_qplib_cleanup_res(struct bnxt_qplib_res *res)
893850
{
894-
bnxt_qplib_cleanup_pkey_tbl(&res->pkey_tbl);
895851
bnxt_qplib_cleanup_sgid_tbl(res, &res->sgid_tbl);
896852
}
897853

898854
int bnxt_qplib_init_res(struct bnxt_qplib_res *res)
899855
{
900856
bnxt_qplib_init_sgid_tbl(&res->sgid_tbl, res->netdev);
901-
bnxt_qplib_init_pkey_tbl(res, &res->pkey_tbl);
902857

903858
return 0;
904859
}
905860

906861
void bnxt_qplib_free_res(struct bnxt_qplib_res *res)
907862
{
908-
bnxt_qplib_free_pkey_tbl(res, &res->pkey_tbl);
909863
bnxt_qplib_free_sgid_tbl(res, &res->sgid_tbl);
910864
bnxt_qplib_free_pd_tbl(&res->pd_tbl);
911865
bnxt_qplib_free_dpi_tbl(res, &res->dpi_tbl);
@@ -924,10 +878,6 @@ int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct pci_dev *pdev,
924878
if (rc)
925879
goto fail;
926880

927-
rc = bnxt_qplib_alloc_pkey_tbl(res, &res->pkey_tbl, dev_attr->max_pkey);
928-
if (rc)
929-
goto fail;
930-
931881
rc = bnxt_qplib_alloc_pd_tbl(res, &res->pd_tbl, dev_attr->max_pd);
932882
if (rc)
933883
goto fail;

drivers/infiniband/hw/bnxt_re/qplib_res.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ struct bnxt_qplib_sgid_tbl {
185185
u8 *vlan;
186186
};
187187

188-
struct bnxt_qplib_pkey_tbl {
189-
u16 *tbl;
190-
u16 max;
191-
u16 active;
192-
};
193-
194188
struct bnxt_qplib_dpi {
195189
u32 dpi;
196190
void __iomem *dbr;
@@ -258,7 +252,6 @@ struct bnxt_qplib_res {
258252
struct bnxt_qplib_rcfw *rcfw;
259253
struct bnxt_qplib_pd_tbl pd_tbl;
260254
struct bnxt_qplib_sgid_tbl sgid_tbl;
261-
struct bnxt_qplib_pkey_tbl pkey_tbl;
262255
struct bnxt_qplib_dpi_tbl dpi_tbl;
263256
bool prio;
264257
bool is_vf;

drivers/infiniband/hw/bnxt_re/qplib_sp.c

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
146146
attr->max_srq = le16_to_cpu(sb->max_srq);
147147
attr->max_srq_wqes = le32_to_cpu(sb->max_srq_wr) - 1;
148148
attr->max_srq_sges = sb->max_srq_sge;
149-
attr->max_pkey = le32_to_cpu(sb->max_pkeys);
150-
/*
151-
* Some versions of FW reports more than 0xFFFF.
152-
* Restrict it for now to 0xFFFF to avoid
153-
* reporting trucated value
154-
*/
155-
if (attr->max_pkey > 0xFFFF) {
156-
/* ib_port_attr::pkey_tbl_len is u16 */
157-
attr->max_pkey = 0xFFFF;
158-
}
159-
149+
attr->max_pkey = 1;
160150
attr->max_inline_data = le32_to_cpu(sb->max_inline_data);
161151
attr->l2_db_size = (sb->l2_db_space_size + 1) *
162152
(0x01 << RCFW_DBR_BASE_PAGE_SHIFT);
@@ -414,93 +404,6 @@ int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
414404
return rc;
415405
}
416406

417-
/* pkeys */
418-
int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
419-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index,
420-
u16 *pkey)
421-
{
422-
if (index == 0xFFFF) {
423-
*pkey = 0xFFFF;
424-
return 0;
425-
}
426-
if (index >= pkey_tbl->max) {
427-
dev_err(&res->pdev->dev,
428-
"Index %d exceeded PKEY table max (%d)\n",
429-
index, pkey_tbl->max);
430-
return -EINVAL;
431-
}
432-
memcpy(pkey, &pkey_tbl->tbl[index], sizeof(*pkey));
433-
return 0;
434-
}
435-
436-
int bnxt_qplib_del_pkey(struct bnxt_qplib_res *res,
437-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
438-
bool update)
439-
{
440-
int i, rc = 0;
441-
442-
if (!pkey_tbl) {
443-
dev_err(&res->pdev->dev, "PKEY table not allocated\n");
444-
return -EINVAL;
445-
}
446-
447-
/* Do we need a pkey_lock here? */
448-
if (!pkey_tbl->active) {
449-
dev_err(&res->pdev->dev, "PKEY table has no active entries\n");
450-
return -ENOMEM;
451-
}
452-
for (i = 0; i < pkey_tbl->max; i++) {
453-
if (!memcmp(&pkey_tbl->tbl[i], pkey, sizeof(*pkey)))
454-
break;
455-
}
456-
if (i == pkey_tbl->max) {
457-
dev_err(&res->pdev->dev,
458-
"PKEY 0x%04x not found in the pkey table\n", *pkey);
459-
return -ENOMEM;
460-
}
461-
memset(&pkey_tbl->tbl[i], 0, sizeof(*pkey));
462-
pkey_tbl->active--;
463-
464-
/* unlock */
465-
return rc;
466-
}
467-
468-
int bnxt_qplib_add_pkey(struct bnxt_qplib_res *res,
469-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
470-
bool update)
471-
{
472-
int i, free_idx, rc = 0;
473-
474-
if (!pkey_tbl) {
475-
dev_err(&res->pdev->dev, "PKEY table not allocated\n");
476-
return -EINVAL;
477-
}
478-
479-
/* Do we need a pkey_lock here? */
480-
if (pkey_tbl->active == pkey_tbl->max) {
481-
dev_err(&res->pdev->dev, "PKEY table is full\n");
482-
return -ENOMEM;
483-
}
484-
free_idx = pkey_tbl->max;
485-
for (i = 0; i < pkey_tbl->max; i++) {
486-
if (!memcmp(&pkey_tbl->tbl[i], pkey, sizeof(*pkey)))
487-
return -EALREADY;
488-
else if (!pkey_tbl->tbl[i] && free_idx == pkey_tbl->max)
489-
free_idx = i;
490-
}
491-
if (free_idx == pkey_tbl->max) {
492-
dev_err(&res->pdev->dev,
493-
"PKEY table is FULL but count is not MAX??\n");
494-
return -ENOMEM;
495-
}
496-
/* Add PKEY to the pkey_tbl */
497-
memcpy(&pkey_tbl->tbl[free_idx], pkey, sizeof(*pkey));
498-
pkey_tbl->active++;
499-
500-
/* unlock */
501-
return rc;
502-
}
503-
504407
/* AH */
505408
int bnxt_qplib_create_ah(struct bnxt_qplib_res *res, struct bnxt_qplib_ah *ah,
506409
bool block)

drivers/infiniband/hw/bnxt_re/qplib_sp.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,6 @@ int bnxt_qplib_add_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
255255
int bnxt_qplib_update_sgid(struct bnxt_qplib_sgid_tbl *sgid_tbl,
256256
struct bnxt_qplib_gid *gid, u16 gid_idx,
257257
const u8 *smac);
258-
int bnxt_qplib_get_pkey(struct bnxt_qplib_res *res,
259-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 index,
260-
u16 *pkey);
261-
int bnxt_qplib_del_pkey(struct bnxt_qplib_res *res,
262-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
263-
bool update);
264-
int bnxt_qplib_add_pkey(struct bnxt_qplib_res *res,
265-
struct bnxt_qplib_pkey_tbl *pkey_tbl, u16 *pkey,
266-
bool update);
267258
int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
268259
struct bnxt_qplib_dev_attr *attr, bool vf);
269260
int bnxt_qplib_set_func_resources(struct bnxt_qplib_res *res,

0 commit comments

Comments
 (0)