Lines Matching refs:ctx_pg

126 				  struct bnge_ctx_pg_info *ctx_pg)  in bnge_alloc_ctx_one_lvl()  argument
128 struct bnge_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnge_alloc_ctx_one_lvl()
131 rmem->pg_arr = ctx_pg->ctx_pg_arr; in bnge_alloc_ctx_one_lvl()
132 rmem->dma_arr = ctx_pg->ctx_dma_arr; in bnge_alloc_ctx_one_lvl()
140 struct bnge_ctx_pg_info *ctx_pg, u32 mem_size, in bnge_alloc_ctx_pg_tbls() argument
143 struct bnge_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnge_alloc_ctx_pg_tbls()
149 ctx_pg->nr_pages = DIV_ROUND_UP(mem_size, BNGE_PAGE_SIZE); in bnge_alloc_ctx_pg_tbls()
150 if (ctx_pg->nr_pages > MAX_CTX_TOTAL_PAGES) { in bnge_alloc_ctx_pg_tbls()
151 ctx_pg->nr_pages = 0; in bnge_alloc_ctx_pg_tbls()
154 if (ctx_pg->nr_pages > MAX_CTX_PAGES || depth > 1) { in bnge_alloc_ctx_pg_tbls()
158 ctx_pg->ctx_pg_tbl = kcalloc(MAX_CTX_PAGES, sizeof(ctx_pg), in bnge_alloc_ctx_pg_tbls()
160 if (!ctx_pg->ctx_pg_tbl) in bnge_alloc_ctx_pg_tbls()
162 nr_tbls = DIV_ROUND_UP(ctx_pg->nr_pages, MAX_CTX_PAGES); in bnge_alloc_ctx_pg_tbls()
164 rc = bnge_alloc_ctx_one_lvl(bd, ctx_pg); in bnge_alloc_ctx_pg_tbls()
173 ctx_pg->ctx_pg_tbl[i] = pg_tbl; in bnge_alloc_ctx_pg_tbls()
175 rmem->pg_tbl = ctx_pg->ctx_pg_arr[i]; in bnge_alloc_ctx_pg_tbls()
176 rmem->dma_pg_tbl = ctx_pg->ctx_dma_arr[i]; in bnge_alloc_ctx_pg_tbls()
181 int rem = ctx_pg->nr_pages % MAX_CTX_PAGES; in bnge_alloc_ctx_pg_tbls()
195 rc = bnge_alloc_ctx_one_lvl(bd, ctx_pg); in bnge_alloc_ctx_pg_tbls()
202 struct bnge_ctx_pg_info *ctx_pg) in bnge_free_ctx_pg_tbls() argument
204 struct bnge_ring_mem_info *rmem = &ctx_pg->ring_mem; in bnge_free_ctx_pg_tbls()
206 if (rmem->depth > 1 || ctx_pg->nr_pages > MAX_CTX_PAGES || in bnge_free_ctx_pg_tbls()
207 ctx_pg->ctx_pg_tbl) { in bnge_free_ctx_pg_tbls()
214 pg_tbl = ctx_pg->ctx_pg_tbl[i]; in bnge_free_ctx_pg_tbls()
219 ctx_pg->ctx_pg_arr[i] = NULL; in bnge_free_ctx_pg_tbls()
221 ctx_pg->ctx_pg_tbl[i] = NULL; in bnge_free_ctx_pg_tbls()
223 kfree(ctx_pg->ctx_pg_tbl); in bnge_free_ctx_pg_tbls()
224 ctx_pg->ctx_pg_tbl = NULL; in bnge_free_ctx_pg_tbls()
227 ctx_pg->nr_pages = 0; in bnge_free_ctx_pg_tbls()
234 struct bnge_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnge_setup_ctxm_pg_tbls() local
238 if (!ctxm->entry_size || !ctx_pg) in bnge_setup_ctxm_pg_tbls()
247 ctx_pg[i].entries = entries; in bnge_setup_ctxm_pg_tbls()
248 rc = bnge_alloc_ctx_pg_tbls(bd, &ctx_pg[i], mem_size, pg_lvl, in bnge_setup_ctxm_pg_tbls()
292 struct bnge_ctx_pg_info *ctx_pg = ctxm->pg_info; in bnge_free_ctx_mem() local
295 if (!ctx_pg) in bnge_free_ctx_mem()
300 bnge_free_ctx_pg_tbls(bd, &ctx_pg[i]); in bnge_free_ctx_mem()
302 kfree(ctx_pg); in bnge_free_ctx_mem()