Skip to content

Commit 035c576

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Add page info to struct bnxt_ctx_mem_type
This will further improve the organization of the bnxt_ctx_mem_info structure by moving the standalone page info structures into the bnxt_ctx_mem_type array. Add the allocation and free logic first and the next patch will migrate to use the new infrastructure. Reviewed-by: Somnath Kotur <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 76087d9 commit 035c576

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7187,6 +7187,27 @@ static void bnxt_init_ctx_initializer(struct bnxt_ctx_mem_type *ctxm,
71877187
ctxm->init_value = 0;
71887188
}
71897189

7190+
static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp, int ctx_max)
7191+
{
7192+
struct bnxt_ctx_mem_info *ctx = bp->ctx;
7193+
u16 type;
7194+
7195+
for (type = 0; type < ctx_max; type++) {
7196+
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
7197+
int n = 1;
7198+
7199+
if (!ctxm->max_entries)
7200+
continue;
7201+
7202+
if (ctxm->instance_bmap)
7203+
n = hweight32(ctxm->instance_bmap);
7204+
ctxm->pg_info = kcalloc(n, sizeof(*ctxm->pg_info), GFP_KERNEL);
7205+
if (!ctxm->pg_info)
7206+
return -ENOMEM;
7207+
}
7208+
return 0;
7209+
}
7210+
71907211
static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
71917212
{
71927213
struct hwrm_func_backing_store_qcaps_output *resp;
@@ -7298,6 +7319,7 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
72987319
}
72997320
for (i = 0; i < tqm_rings; i++, ctx_pg++)
73007321
ctx->tqm_mem[i] = ctx_pg;
7322+
rc = bnxt_alloc_all_ctx_pg_info(bp, BNXT_CTX_MAX);
73017323
} else {
73027324
rc = 0;
73037325
}
@@ -7564,6 +7586,7 @@ static void bnxt_free_ctx_pg_tbls(struct bnxt *bp,
75647586
void bnxt_free_ctx_mem(struct bnxt *bp)
75657587
{
75667588
struct bnxt_ctx_mem_info *ctx = bp->ctx;
7589+
u16 type;
75677590
int i;
75687591

75697592
if (!ctx)
@@ -7583,6 +7606,14 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
75837606
bnxt_free_ctx_pg_tbls(bp, &ctx->cq_mem);
75847607
bnxt_free_ctx_pg_tbls(bp, &ctx->srq_mem);
75857608
bnxt_free_ctx_pg_tbls(bp, &ctx->qp_mem);
7609+
7610+
for (type = 0; type < BNXT_CTX_MAX; type++) {
7611+
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
7612+
7613+
kfree(ctxm->pg_info);
7614+
ctxm->pg_info = NULL;
7615+
}
7616+
75867617
ctx->flags &= ~BNXT_CTX_FLAG_INITED;
75877618
kfree(ctx);
75887619
bp->ctx = NULL;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ struct bnxt_ctx_mem_type {
15731573
};
15741574
u32 split[BNXT_MAX_SPLIT_ENTRY];
15751575
};
1576+
struct bnxt_ctx_pg_info *pg_info;
15761577
};
15771578

15781579
#define BNXT_CTX_MRAV_AV_SPLIT_ENTRY 0

0 commit comments

Comments
 (0)