Skip to content

Commit 0cfb329

Browse files
Devesh Sharmajgunthorpe
authored andcommitted
RDMA/bnxt_re: Replace chip context structure with pointer
The chip_ctx member in bnxt_re_dev structure is now a pointer to struct bnxt_qplib_chip_ctx. Since the member type has changed there are changes in rest of the code wherever dev->chip_ctx is used. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Naresh Kumar PBS <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Devesh Sharma <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 8dae419 commit 0cfb329

File tree

4 files changed

+36
-21
lines changed

4 files changed

+36
-21
lines changed

drivers/infiniband/hw/bnxt_re/bnxt_re.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct bnxt_re_dev {
133133
#define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29
134134
struct net_device *netdev;
135135
unsigned int version, major, minor;
136-
struct bnxt_qplib_chip_ctx chip_ctx;
136+
struct bnxt_qplib_chip_ctx *chip_ctx;
137137
struct bnxt_en_dev *en_dev;
138138
struct bnxt_msix_entry msix_entries[BNXT_RE_MAX_MSIX];
139139
int num_msix;

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
859859
bytes = (qplib_qp->sq.max_wqe * BNXT_QPLIB_MAX_SQE_ENTRY_SIZE);
860860
/* Consider mapping PSN search memory only for RC QPs. */
861861
if (qplib_qp->type == CMDQ_CREATE_QP_TYPE_RC) {
862-
psn_sz = bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx) ?
862+
psn_sz = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
863863
sizeof(struct sq_psn_search_ext) :
864864
sizeof(struct sq_psn_search);
865865
bytes += (qplib_qp->sq.max_wqe * psn_sz);
@@ -1060,6 +1060,7 @@ static void bnxt_re_adjust_gsi_rq_attr(struct bnxt_re_qp *qp)
10601060
qplqp->rq.max_sge = dev_attr->max_qp_sges;
10611061
if (qplqp->rq.max_sge > dev_attr->max_qp_sges)
10621062
qplqp->rq.max_sge = dev_attr->max_qp_sges;
1063+
qplqp->rq.max_sge = 6;
10631064
}
10641065

10651066
static void bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
@@ -1123,7 +1124,7 @@ static int bnxt_re_init_qp_type(struct bnxt_re_dev *rdev,
11231124
struct bnxt_qplib_chip_ctx *chip_ctx;
11241125
int qptype;
11251126

1126-
chip_ctx = &rdev->chip_ctx;
1127+
chip_ctx = rdev->chip_ctx;
11271128

11281129
qptype = __from_ib_qp_type(init_attr->qp_type);
11291130
if (qptype == IB_QPT_MAX) {
@@ -1343,7 +1344,7 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd,
13431344
goto fail;
13441345

13451346
if (qp_init_attr->qp_type == IB_QPT_GSI &&
1346-
!(bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx))) {
1347+
!(bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx))) {
13471348
rc = bnxt_re_create_gsi_qp(qp, pd, qp_init_attr);
13481349
if (rc == -ENODEV)
13491350
goto qp_destroy;
@@ -3820,10 +3821,10 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
38203821
spin_lock_init(&uctx->sh_lock);
38213822

38223823
resp.comp_mask = BNXT_RE_UCNTX_CMASK_HAVE_CCTX;
3823-
chip_met_rev_num = rdev->chip_ctx.chip_num;
3824-
chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_rev & 0xFF) <<
3824+
chip_met_rev_num = rdev->chip_ctx->chip_num;
3825+
chip_met_rev_num |= ((u32)rdev->chip_ctx->chip_rev & 0xFF) <<
38253826
BNXT_RE_CHIP_ID0_CHIP_REV_SFT;
3826-
chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_metal & 0xFF) <<
3827+
chip_met_rev_num |= ((u32)rdev->chip_ctx->chip_metal & 0xFF) <<
38273828
BNXT_RE_CHIP_ID0_CHIP_MET_SFT;
38283829
resp.chip_id0 = chip_met_rev_num;
38293830
/* Future extension of chip info */

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,35 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev);
8282

8383
static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
8484
{
85+
struct bnxt_qplib_chip_ctx *chip_ctx;
86+
87+
if (!rdev->chip_ctx)
88+
return;
89+
chip_ctx = rdev->chip_ctx;
90+
rdev->chip_ctx = NULL;
8591
rdev->rcfw.res = NULL;
8692
rdev->qplib_res.cctx = NULL;
93+
kfree(chip_ctx);
8794
}
8895

8996
static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev)
9097
{
98+
struct bnxt_qplib_chip_ctx *chip_ctx;
9199
struct bnxt_en_dev *en_dev;
92100
struct bnxt *bp;
93101

94102
en_dev = rdev->en_dev;
95103
bp = netdev_priv(en_dev->net);
96104

97-
rdev->chip_ctx.chip_num = bp->chip_num;
105+
chip_ctx = kzalloc(sizeof(*chip_ctx), GFP_KERNEL);
106+
if (!chip_ctx)
107+
return -ENOMEM;
108+
chip_ctx->chip_num = bp->chip_num;
109+
110+
rdev->chip_ctx = chip_ctx;
98111
/* rest members to follow eventually */
99112

100-
rdev->qplib_res.cctx = &rdev->chip_ctx;
113+
rdev->qplib_res.cctx = rdev->chip_ctx;
101114
rdev->rcfw.res = &rdev->qplib_res;
102115

103116
return 0;
@@ -136,7 +149,7 @@ static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev)
136149
ctx->srqc_count = min_t(u32, BNXT_RE_MAX_SRQC_COUNT,
137150
attr->max_srq);
138151
ctx->cq_count = min_t(u32, BNXT_RE_MAX_CQ_COUNT, attr->max_cq);
139-
if (!bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx))
152+
if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx))
140153
for (i = 0; i < MAX_TQM_ALLOC_REQ; i++)
141154
rdev->qplib_ctx.tqm_count[i] =
142155
rdev->dev_attr.tqm_alloc_reqs[i];
@@ -185,7 +198,7 @@ static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev)
185198
memset(&rdev->qplib_ctx.vf_res, 0, sizeof(struct bnxt_qplib_vf_res));
186199
bnxt_re_limit_pf_res(rdev);
187200

188-
num_vfs = bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx) ?
201+
num_vfs = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
189202
BNXT_RE_GEN_P5_MAX_VF : rdev->num_vfs;
190203
if (num_vfs)
191204
bnxt_re_limit_vf_res(&rdev->qplib_ctx, num_vfs);
@@ -208,7 +221,7 @@ static void bnxt_re_sriov_config(void *p, int num_vfs)
208221
return;
209222

210223
rdev->num_vfs = num_vfs;
211-
if (!bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx)) {
224+
if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) {
212225
bnxt_re_set_resource_limits(rdev);
213226
bnxt_qplib_set_func_resources(&rdev->qplib_res, &rdev->rcfw,
214227
&rdev->qplib_ctx);
@@ -916,7 +929,7 @@ static int bnxt_re_cqn_handler(struct bnxt_qplib_nq *nq,
916929
#define BNXT_RE_GEN_P5_VF_NQ_DB 0x4000
917930
static u32 bnxt_re_get_nqdb_offset(struct bnxt_re_dev *rdev, u16 indx)
918931
{
919-
return bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx) ?
932+
return bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
920933
(rdev->is_virtfn ? BNXT_RE_GEN_P5_VF_NQ_DB :
921934
BNXT_RE_GEN_P5_PF_NQ_DB) :
922935
rdev->msix_entries[indx].db_offset;
@@ -967,7 +980,7 @@ static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev)
967980
int i;
968981

969982
for (i = 0; i < rdev->num_msix - 1; i++) {
970-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
983+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
971984
bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type);
972985
rdev->nq[i].res = NULL;
973986
bnxt_qplib_free_nq(&rdev->nq[i]);
@@ -1025,7 +1038,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
10251038
i, rc);
10261039
goto free_nq;
10271040
}
1028-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
1041+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
10291042
pg_map = rdev->nq[i].hwq.pbl[PBL_LVL_0].pg_map_arr;
10301043
pages = rdev->nq[i].hwq.pbl[rdev->nq[i].hwq.level].pg_count;
10311044
rc = bnxt_re_net_ring_alloc(rdev, pg_map, pages, type,
@@ -1044,7 +1057,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
10441057
return 0;
10451058
free_nq:
10461059
for (i = num_vec_created; i >= 0; i--) {
1047-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
1060+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
10481061
bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type);
10491062
bnxt_qplib_free_nq(&rdev->nq[i]);
10501063
}
@@ -1324,7 +1337,7 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev)
13241337
bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
13251338
bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx);
13261339
bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
1327-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
1340+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
13281341
bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id, type);
13291342
bnxt_qplib_free_rcfw_channel(&rdev->rcfw);
13301343
}
@@ -1405,7 +1418,8 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
14051418
pr_err("Failed to allocate RCFW Channel: %#x\n", rc);
14061419
goto fail;
14071420
}
1408-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
1421+
1422+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
14091423
pg_map = rdev->rcfw.creq.pbl[PBL_LVL_0].pg_map_arr;
14101424
pages = rdev->rcfw.creq.pbl[rdev->rcfw.creq.level].pg_count;
14111425
ridx = rdev->msix_entries[BNXT_RE_AEQ_IDX].ring_idx;
@@ -1434,7 +1448,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
14341448
bnxt_re_set_resource_limits(rdev);
14351449

14361450
rc = bnxt_qplib_alloc_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx, 0,
1437-
bnxt_qplib_is_chip_gen_p5(&rdev->chip_ctx));
1451+
bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx));
14381452
if (rc) {
14391453
pr_err("Failed to allocate QPLIB context: %#x\n", rc);
14401454
goto disable_rcfw;
@@ -1504,7 +1518,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
15041518
disable_rcfw:
15051519
bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
15061520
free_ring:
1507-
type = bnxt_qplib_get_ring_type(&rdev->chip_ctx);
1521+
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
15081522
bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id, type);
15091523
free_rcfw:
15101524
bnxt_qplib_free_rcfw_channel(&rdev->rcfw);

drivers/infiniband/hw/bnxt_re/qplib_fp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ static int bnxt_qplib_cq_process_res_ud(struct bnxt_qplib_cq *cq,
24262426
}
24272427
cqe = *pcqe;
24282428
cqe->opcode = hwcqe->cqe_type_toggle & CQ_BASE_CQE_TYPE_MASK;
2429-
cqe->length = (u32)le16_to_cpu(hwcqe->length);
2429+
cqe->length = le16_to_cpu(hwcqe->length) & CQ_RES_UD_LENGTH_MASK;
24302430
cqe->cfa_meta = le16_to_cpu(hwcqe->cfa_metadata);
24312431
cqe->invrkey = le32_to_cpu(hwcqe->imm_data);
24322432
cqe->flags = le16_to_cpu(hwcqe->flags);

0 commit comments

Comments
 (0)