Lines Matching +full:2 +full:ppm
8 * General Public License (GPL) Version 2, available from the file
65 int cxgbi_ppm_find_page_index(struct cxgbi_ppm *ppm, unsigned long pgsz) in cxgbi_ppm_find_page_index() argument
67 struct cxgbi_tag_format *tformat = &ppm->tformat; in cxgbi_ppm_find_page_index()
73 pr_debug("%s: %s ppm, pgsz %lu -> idx %d.\n", in cxgbi_ppm_find_page_index()
74 __func__, ppm->ndev->name, pgsz, i); in cxgbi_ppm_find_page_index()
104 static void ppm_mark_entries(struct cxgbi_ppm *ppm, int i, int count, in ppm_mark_entries() argument
107 struct cxgbi_ppod_data *pdata = ppm->ppod_data + i; in ppm_mark_entries()
118 static int ppm_get_cpu_entries(struct cxgbi_ppm *ppm, unsigned int count, in ppm_get_cpu_entries() argument
125 if (!ppm->pool) in ppm_get_cpu_entries()
129 pool = per_cpu_ptr(ppm->pool, cpu); in ppm_get_cpu_entries()
133 i = ppm_find_unused_entries(pool->bmap, ppm->pool_index_max, in ppm_get_cpu_entries()
142 if (pool->next >= ppm->pool_index_max) in ppm_get_cpu_entries()
148 __func__, cpu, i, count, i + cpu * ppm->pool_index_max, in ppm_get_cpu_entries()
151 i += cpu * ppm->pool_index_max; in ppm_get_cpu_entries()
152 ppm_mark_entries(ppm, i, count, caller_data); in ppm_get_cpu_entries()
157 static int ppm_get_entries(struct cxgbi_ppm *ppm, unsigned int count, in ppm_get_entries() argument
162 spin_lock_bh(&ppm->map_lock); in ppm_get_entries()
163 i = ppm_find_unused_entries(ppm->ppod_bmap, ppm->bmap_index_max, in ppm_get_entries()
164 ppm->next, count, 0); in ppm_get_entries()
166 ppm->next = 0; in ppm_get_entries()
167 spin_unlock_bh(&ppm->map_lock); in ppm_get_entries()
173 ppm->next = i + count; in ppm_get_entries()
174 if (ppm->max_index_in_edram && (ppm->next >= ppm->max_index_in_edram)) in ppm_get_entries()
175 ppm->next = 0; in ppm_get_entries()
176 else if (ppm->next >= ppm->bmap_index_max) in ppm_get_entries()
177 ppm->next = 0; in ppm_get_entries()
179 spin_unlock_bh(&ppm->map_lock); in ppm_get_entries()
182 __func__, i, count, i + ppm->pool_rsvd, ppm->next, in ppm_get_entries()
185 i += ppm->pool_rsvd; in ppm_get_entries()
186 ppm_mark_entries(ppm, i, count, caller_data); in ppm_get_entries()
191 static void ppm_unmark_entries(struct cxgbi_ppm *ppm, int i, int count) in ppm_unmark_entries() argument
195 if (i < ppm->pool_rsvd) { in ppm_unmark_entries()
199 cpu = i / ppm->pool_index_max; in ppm_unmark_entries()
200 i %= ppm->pool_index_max; in ppm_unmark_entries()
202 pool = per_cpu_ptr(ppm->pool, cpu); in ppm_unmark_entries()
213 spin_lock_bh(&ppm->map_lock); in ppm_unmark_entries()
215 i -= ppm->pool_rsvd; in ppm_unmark_entries()
216 bitmap_clear(ppm->ppod_bmap, i, count); in ppm_unmark_entries()
218 if (i < ppm->next) in ppm_unmark_entries()
219 ppm->next = i; in ppm_unmark_entries()
220 spin_unlock_bh(&ppm->map_lock); in ppm_unmark_entries()
222 pr_debug("%s: idx %d, next %u.\n", __func__, i, ppm->next); in ppm_unmark_entries()
226 void cxgbi_ppm_ppod_release(struct cxgbi_ppm *ppm, u32 idx) in cxgbi_ppm_ppod_release() argument
230 if (idx >= ppm->ppmax) { in cxgbi_ppm_ppod_release()
231 pr_warn("ippm: idx too big %u > %u.\n", idx, ppm->ppmax); in cxgbi_ppm_ppod_release()
235 pdata = ppm->ppod_data + idx; in cxgbi_ppm_ppod_release()
242 ppm_unmark_entries(ppm, idx, pdata->npods); in cxgbi_ppm_ppod_release()
246 int cxgbi_ppm_ppods_reserve(struct cxgbi_ppm *ppm, unsigned short nr_pages, in cxgbi_ppm_ppods_reserve() argument
264 idx = ppm_get_cpu_entries(ppm, npods, caller_data); in cxgbi_ppm_ppods_reserve()
267 idx = ppm_get_entries(ppm, npods, caller_data); in cxgbi_ppm_ppods_reserve()
270 nr_pages, npods, ppm->next, caller_data); in cxgbi_ppm_ppods_reserve()
274 pdata = ppm->ppod_data + idx; in cxgbi_ppm_ppods_reserve()
275 hwidx = ppm->base_idx + idx; in cxgbi_ppm_ppods_reserve()
292 void cxgbi_ppm_make_ppod_hdr(struct cxgbi_ppm *ppm, u32 tag, in cxgbi_ppm_make_ppod_hdr() argument
305 hdr->pgsz_tag_clr = htonl(tag & ppm->tformat.idx_clr_mask); in cxgbi_ppm_make_ppod_hdr()
314 static void ppm_free(struct cxgbi_ppm *ppm) in ppm_free() argument
316 vfree(ppm); in ppm_free()
321 struct cxgbi_ppm *ppm = container_of(kref, in ppm_destroy() local
324 pr_info("ippm: kref 0, destroy %s ppm 0x%p.\n", in ppm_destroy()
325 ppm->ndev->name, ppm); in ppm_destroy()
327 *ppm->ppm_pp = NULL; in ppm_destroy()
329 free_percpu(ppm->pool); in ppm_destroy()
330 ppm_free(ppm); in ppm_destroy()
333 int cxgbi_ppm_release(struct cxgbi_ppm *ppm) in cxgbi_ppm_release() argument
335 if (ppm) { in cxgbi_ppm_release()
338 rv = kref_put(&ppm->refcnt, ppm_destroy); in cxgbi_ppm_release()
394 struct cxgbi_ppm *ppm = (struct cxgbi_ppm *)(*ppm_pp); in cxgbi_ppm_init() local
420 if (ppm) { in cxgbi_ppm_init()
421 pr_info("ippm: %s, ppm 0x%p,0x%p already initialized, %u/%u.\n", in cxgbi_ppm_init()
422 ndev->name, ppm_pp, ppm, ppm->ppmax, ppmax); in cxgbi_ppm_init()
423 kref_get(&ppm->refcnt); in cxgbi_ppm_init()
444 ppm = vzalloc(alloc_sz); in cxgbi_ppm_init()
445 if (!ppm) in cxgbi_ppm_init()
448 ppm->ppod_bmap = (unsigned long *)(&ppm->ppod_data[ppmax]); in cxgbi_ppm_init()
454 bitmap_set(ppm->ppod_bmap, ppmax, end - start); in cxgbi_ppm_init()
463 ppm->max_index_in_edram = first_ddr_idx - 1; in cxgbi_ppm_init()
464 bitmap_set(ppm->ppod_bmap, first_ddr_idx, 1); in cxgbi_ppm_init()
468 spin_lock_init(&ppm->map_lock); in cxgbi_ppm_init()
469 kref_init(&ppm->refcnt); in cxgbi_ppm_init()
471 memcpy(&ppm->tformat, tformat, sizeof(struct cxgbi_tag_format)); in cxgbi_ppm_init()
473 ppm->ppm_pp = ppm_pp; in cxgbi_ppm_init()
474 ppm->ndev = ndev; in cxgbi_ppm_init()
475 ppm->pdev = pdev; in cxgbi_ppm_init()
476 ppm->lldev = lldev; in cxgbi_ppm_init()
477 ppm->ppmax = ppmax; in cxgbi_ppm_init()
478 ppm->next = 0; in cxgbi_ppm_init()
479 ppm->llimit = llimit; in cxgbi_ppm_init()
480 ppm->base_idx = start > llimit ? in cxgbi_ppm_init()
482 ppm->bmap_index_max = ppmax - ppmax_pool; in cxgbi_ppm_init()
484 ppm->pool = pool; in cxgbi_ppm_init()
485 ppm->pool_rsvd = ppmax_pool; in cxgbi_ppm_init()
486 ppm->pool_index_max = pool_index_max; in cxgbi_ppm_init()
490 ppm_free(ppm); in cxgbi_ppm_init()
491 ppm = (struct cxgbi_ppm *)(*ppm_pp); in cxgbi_ppm_init()
493 pr_info("ippm: %s, ppm 0x%p,0x%p already initialized, %u/%u.\n", in cxgbi_ppm_init()
494 ndev->name, ppm_pp, *ppm_pp, ppm->ppmax, ppmax); in cxgbi_ppm_init()
496 kref_get(&ppm->refcnt); in cxgbi_ppm_init()
499 *ppm_pp = ppm; in cxgbi_ppm_init()
501 ppm->tformat.pgsz_idx_dflt = cxgbi_ppm_find_page_index(ppm, PAGE_SIZE); in cxgbi_ppm_init()
503 pr_info("ippm %s: ppm 0x%p, 0x%p, base %u/%u, pg %lu,%u, rsvd %u,%u.\n", in cxgbi_ppm_init()
504 ndev->name, ppm_pp, ppm, ppm->base_idx, ppm->ppmax, PAGE_SIZE, in cxgbi_ppm_init()
505 ppm->tformat.pgsz_idx_dflt, ppm->pool_rsvd, in cxgbi_ppm_init()
506 ppm->pool_index_max); in cxgbi_ppm_init()