@@ -7224,11 +7224,9 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
72247224 resp = hwrm_req_hold (bp , req );
72257225 rc = hwrm_req_send_silent (bp , req );
72267226 if (!rc ) {
7227- struct bnxt_ctx_pg_info * ctx_pg ;
72287227 struct bnxt_ctx_mem_type * ctxm ;
72297228 struct bnxt_ctx_mem_info * ctx ;
72307229 u8 init_val , init_idx = 0 ;
7231- int i , tqm_rings ;
72327230 u16 init_mask ;
72337231
72347232 ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
@@ -7311,14 +7309,6 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
73117309 ctxm = & ctx -> ctx_arr [BNXT_CTX_FTQM ];
73127310 ctxm -> instance_bmap = (1 << ctx -> tqm_fp_rings_count ) - 1 ;
73137311
7314- tqm_rings = ctx -> tqm_fp_rings_count + BNXT_MAX_TQM_SP_RINGS ;
7315- ctx_pg = kcalloc (tqm_rings , sizeof (* ctx_pg ), GFP_KERNEL );
7316- if (!ctx_pg ) {
7317- rc = - ENOMEM ;
7318- goto ctx_err ;
7319- }
7320- for (i = 0 ; i < tqm_rings ; i ++ , ctx_pg ++ )
7321- ctx -> tqm_mem [i ] = ctx_pg ;
73227312 rc = bnxt_alloc_all_ctx_pg_info (bp , BNXT_CTX_MAX );
73237313 } else {
73247314 rc = 0 ;
@@ -7380,8 +7370,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
73807370
73817371 req -> enables = cpu_to_le32 (enables );
73827372 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_QP ) {
7383- ctx_pg = & ctx -> qp_mem ;
73847373 ctxm = & ctx -> ctx_arr [BNXT_CTX_QP ];
7374+ ctx_pg = ctxm -> pg_info ;
73857375 req -> qp_num_entries = cpu_to_le32 (ctx_pg -> entries );
73867376 req -> qp_num_qp1_entries = cpu_to_le16 (ctxm -> qp_qp1_entries );
73877377 req -> qp_num_l2_entries = cpu_to_le16 (ctxm -> qp_l2_entries );
@@ -7391,8 +7381,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
73917381 & req -> qpc_page_dir );
73927382 }
73937383 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_SRQ ) {
7394- ctx_pg = & ctx -> srq_mem ;
73957384 ctxm = & ctx -> ctx_arr [BNXT_CTX_SRQ ];
7385+ ctx_pg = ctxm -> pg_info ;
73967386 req -> srq_num_entries = cpu_to_le32 (ctx_pg -> entries );
73977387 req -> srq_num_l2_entries = cpu_to_le16 (ctxm -> srq_l2_entries );
73987388 req -> srq_entry_size = cpu_to_le16 (ctxm -> entry_size );
@@ -7401,8 +7391,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74017391 & req -> srq_page_dir );
74027392 }
74037393 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_CQ ) {
7404- ctx_pg = & ctx -> cq_mem ;
74057394 ctxm = & ctx -> ctx_arr [BNXT_CTX_CQ ];
7395+ ctx_pg = ctxm -> pg_info ;
74067396 req -> cq_num_entries = cpu_to_le32 (ctx_pg -> entries );
74077397 req -> cq_num_l2_entries = cpu_to_le16 (ctxm -> cq_l2_entries );
74087398 req -> cq_entry_size = cpu_to_le16 (ctxm -> entry_size );
@@ -7411,8 +7401,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74117401 & req -> cq_page_dir );
74127402 }
74137403 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_VNIC ) {
7414- ctx_pg = & ctx -> vnic_mem ;
74157404 ctxm = & ctx -> ctx_arr [BNXT_CTX_VNIC ];
7405+ ctx_pg = ctxm -> pg_info ;
74167406 req -> vnic_num_vnic_entries = cpu_to_le16 (ctxm -> vnic_entries );
74177407 req -> vnic_num_ring_table_entries =
74187408 cpu_to_le16 (ctxm -> max_entries - ctxm -> vnic_entries );
@@ -7422,8 +7412,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74227412 & req -> vnic_page_dir );
74237413 }
74247414 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_STAT ) {
7425- ctx_pg = & ctx -> stat_mem ;
74267415 ctxm = & ctx -> ctx_arr [BNXT_CTX_STAT ];
7416+ ctx_pg = ctxm -> pg_info ;
74277417 req -> stat_num_entries = cpu_to_le32 (ctxm -> max_entries );
74287418 req -> stat_entry_size = cpu_to_le16 (ctxm -> entry_size );
74297419 bnxt_hwrm_set_pg_attr (& ctx_pg -> ring_mem ,
@@ -7433,8 +7423,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74337423 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_MRAV ) {
74347424 u32 units ;
74357425
7436- ctx_pg = & ctx -> mrav_mem ;
74377426 ctxm = & ctx -> ctx_arr [BNXT_CTX_MRAV ];
7427+ ctx_pg = ctxm -> pg_info ;
74387428 req -> mrav_num_entries = cpu_to_le32 (ctx_pg -> entries );
74397429 units = ctxm -> mrav_num_entries_units ;
74407430 if (units ) {
@@ -7452,8 +7442,8 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74527442 & req -> mrav_page_dir );
74537443 }
74547444 if (enables & FUNC_BACKING_STORE_CFG_REQ_ENABLES_TIM ) {
7455- ctx_pg = & ctx -> tim_mem ;
74567445 ctxm = & ctx -> ctx_arr [BNXT_CTX_TIM ];
7446+ ctx_pg = ctxm -> pg_info ;
74577447 req -> tim_num_entries = cpu_to_le32 (ctx_pg -> entries );
74587448 req -> tim_entry_size = cpu_to_le16 (ctxm -> entry_size );
74597449 bnxt_hwrm_set_pg_attr (& ctx_pg -> ring_mem ,
@@ -7464,14 +7454,15 @@ static int bnxt_hwrm_func_backing_store_cfg(struct bnxt *bp, u32 enables)
74647454 for (i = 0 , num_entries = & req -> tqm_sp_num_entries ,
74657455 pg_attr = & req -> tqm_sp_pg_size_tqm_sp_lvl ,
74667456 pg_dir = & req -> tqm_sp_page_dir ,
7467- ena = FUNC_BACKING_STORE_CFG_REQ_ENABLES_TQM_SP ;
7457+ ena = FUNC_BACKING_STORE_CFG_REQ_ENABLES_TQM_SP ,
7458+ ctx_pg = ctxm -> pg_info ;
74687459 i < BNXT_MAX_TQM_RINGS ;
7460+ ctx_pg = & ctx -> ctx_arr [BNXT_CTX_FTQM ].pg_info [i ],
74697461 i ++ , num_entries ++ , pg_attr ++ , pg_dir ++ , ena <<= 1 ) {
74707462 if (!(enables & ena ))
74717463 continue ;
74727464
74737465 req -> tqm_entry_size = cpu_to_le16 (ctxm -> entry_size );
7474- ctx_pg = ctx -> tqm_mem [i ];
74757466 * num_entries = cpu_to_le32 (ctx_pg -> entries );
74767467 bnxt_hwrm_set_pg_attr (& ctx_pg -> ring_mem , pg_attr , pg_dir );
74777468 }
@@ -7587,30 +7578,23 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
75877578{
75887579 struct bnxt_ctx_mem_info * ctx = bp -> ctx ;
75897580 u16 type ;
7590- int i ;
75917581
75927582 if (!ctx )
75937583 return ;
75947584
7595- if (ctx -> tqm_mem [0 ]) {
7596- for (i = 0 ; i < ctx -> tqm_fp_rings_count + 1 ; i ++ )
7597- bnxt_free_ctx_pg_tbls (bp , ctx -> tqm_mem [i ]);
7598- kfree (ctx -> tqm_mem [0 ]);
7599- ctx -> tqm_mem [0 ] = NULL ;
7600- }
7601-
7602- bnxt_free_ctx_pg_tbls (bp , & ctx -> tim_mem );
7603- bnxt_free_ctx_pg_tbls (bp , & ctx -> mrav_mem );
7604- bnxt_free_ctx_pg_tbls (bp , & ctx -> stat_mem );
7605- bnxt_free_ctx_pg_tbls (bp , & ctx -> vnic_mem );
7606- bnxt_free_ctx_pg_tbls (bp , & ctx -> cq_mem );
7607- bnxt_free_ctx_pg_tbls (bp , & ctx -> srq_mem );
7608- bnxt_free_ctx_pg_tbls (bp , & ctx -> qp_mem );
7609-
76107585 for (type = 0 ; type < BNXT_CTX_MAX ; type ++ ) {
76117586 struct bnxt_ctx_mem_type * ctxm = & ctx -> ctx_arr [type ];
7587+ struct bnxt_ctx_pg_info * ctx_pg = ctxm -> pg_info ;
7588+ int i , n = 1 ;
7589+
7590+ if (!ctx_pg )
7591+ continue ;
7592+ if (ctxm -> instance_bmap )
7593+ n = hweight32 (ctxm -> instance_bmap );
7594+ for (i = 0 ; i < n ; i ++ )
7595+ bnxt_free_ctx_pg_tbls (bp , & ctx_pg [i ]);
76127596
7613- kfree (ctxm -> pg_info );
7597+ kfree (ctx_pg );
76147598 ctxm -> pg_info = NULL ;
76157599 }
76167600
@@ -7658,7 +7642,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
76587642 }
76597643
76607644 ctxm = & ctx -> ctx_arr [BNXT_CTX_QP ];
7661- ctx_pg = & ctx -> qp_mem ;
7645+ ctx_pg = ctxm -> pg_info ;
76627646 ctx_pg -> entries = l2_qps + qp1_qps + extra_qps ;
76637647 if (ctxm -> entry_size ) {
76647648 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7668,7 +7652,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
76687652 }
76697653
76707654 ctxm = & ctx -> ctx_arr [BNXT_CTX_SRQ ];
7671- ctx_pg = & ctx -> srq_mem ;
7655+ ctx_pg = ctxm -> pg_info ;
76727656 ctx_pg -> entries = srqs + extra_srqs ;
76737657 if (ctxm -> entry_size ) {
76747658 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7678,7 +7662,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
76787662 }
76797663
76807664 ctxm = & ctx -> ctx_arr [BNXT_CTX_CQ ];
7681- ctx_pg = & ctx -> cq_mem ;
7665+ ctx_pg = ctxm -> pg_info ;
76827666 ctx_pg -> entries = ctxm -> cq_l2_entries + extra_qps * 2 ;
76837667 if (ctxm -> entry_size ) {
76847668 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7688,7 +7672,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
76887672 }
76897673
76907674 ctxm = & ctx -> ctx_arr [BNXT_CTX_VNIC ];
7691- ctx_pg = & ctx -> vnic_mem ;
7675+ ctx_pg = ctxm -> pg_info ;
76927676 ctx_pg -> entries = ctxm -> max_entries ;
76937677 if (ctxm -> entry_size ) {
76947678 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7698,7 +7682,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
76987682 }
76997683
77007684 ctxm = & ctx -> ctx_arr [BNXT_CTX_STAT ];
7701- ctx_pg = & ctx -> stat_mem ;
7685+ ctx_pg = ctxm -> pg_info ;
77027686 ctx_pg -> entries = ctxm -> max_entries ;
77037687 if (ctxm -> entry_size ) {
77047688 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7712,7 +7696,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
77127696 goto skip_rdma ;
77137697
77147698 ctxm = & ctx -> ctx_arr [BNXT_CTX_MRAV ];
7715- ctx_pg = & ctx -> mrav_mem ;
7699+ ctx_pg = ctxm -> pg_info ;
77167700 /* 128K extra is needed to accommodate static AH context
77177701 * allocation by f/w.
77187702 */
@@ -7732,7 +7716,7 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
77327716 ena = FUNC_BACKING_STORE_CFG_REQ_ENABLES_MRAV ;
77337717
77347718 ctxm = & ctx -> ctx_arr [BNXT_CTX_TIM ];
7735- ctx_pg = & ctx -> tim_mem ;
7719+ ctx_pg = ctxm -> pg_info ;
77367720 ctx_pg -> entries = l2_qps + qp1_qps + extra_qps ;
77377721 if (ctxm -> entry_size ) {
77387722 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
@@ -7751,8 +7735,8 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp)
77517735 entries = l2_qps + 2 * (extra_qps + qp1_qps );
77527736 entries = roundup (entries , ctxm -> entry_multiple );
77537737 entries = clamp_t (u32 , entries , min , ctxm -> max_entries );
7754- for (i = 0 ; i < ctx -> tqm_fp_rings_count + 1 ; i ++ ) {
7755- ctx_pg = ctx -> tqm_mem [ i ];
7738+ for (i = 0 , ctx_pg = ctxm -> pg_info ; i < ctx -> tqm_fp_rings_count + 1 ;
7739+ ctx_pg = & ctx -> ctx_arr [ BNXT_CTX_FTQM ]. pg_info [ i ], i ++ ) {
77567740 ctx_pg -> entries = i ? entries : entries_sp ;
77577741 if (ctxm -> entry_size ) {
77587742 mem_size = ctxm -> entry_size * ctx_pg -> entries ;
0 commit comments