drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c- Extension
.c- Size
- 13852 bytes
- Lines
- 533
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/errno.hlinux/types.hlinux/debugfs.hlinux/export.hlinux/list.hlinux/skbuff.hlinux/pci.hlinux/scatterlist.hlibcxgb_ppm.h
Detected Declarations
function Copyrightfunction ppm_find_unused_entriesfunction ppm_mark_entriesfunction ppm_get_cpu_entriesfunction ppm_get_entriesfunction ppm_unmark_entriesfunction cxgbi_ppm_ppod_releasefunction cxgbi_ppm_ppods_reservefunction cxgbi_ppm_make_ppod_hdrfunction ppm_freefunction ppm_destroyfunction cxgbi_ppm_releasefunction ppm_alloc_cpu_poolfunction for_each_possible_cpufunction cxgbi_ppm_initfunction cxgbi_tagmask_setexport cxgbi_ppm_ppod_releaseexport cxgbi_ppm_ppods_reserveexport cxgbi_ppm_make_ppod_hdrexport cxgbi_ppm_releaseexport cxgbi_ppm_initexport cxgbi_tagmask_set
Annotated Snippet
if (!pool) {
ppmax_pool = 0;
reserve_factor = 0;
}
pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n",
ndev->name, ppmax, ppmax_pool, pool_index_max);
}
ppod_bmap_size = BITS_TO_LONGS(ppmax - ppmax_pool);
alloc_sz = sizeof(struct cxgbi_ppm) +
ppmax * (sizeof(struct cxgbi_ppod_data)) +
ppod_bmap_size * sizeof(unsigned long);
ppm = vzalloc(alloc_sz);
if (!ppm)
goto release_ppm_pool;
ppm->ppod_bmap = (unsigned long *)(&ppm->ppod_data[ppmax]);
if ((ppod_bmap_size >> 3) > (ppmax - ppmax_pool)) {
unsigned int start = ppmax - ppmax_pool;
unsigned int end = ppod_bmap_size >> 3;
bitmap_set(ppm->ppod_bmap, ppmax, end - start);
pr_info("%s: %u - %u < %u * 8, mask extra bits %u, %u.\n",
__func__, ppmax, ppmax_pool, ppod_bmap_size, start,
end);
}
if (iscsi_edram_size) {
unsigned int first_ddr_idx =
iscsi_edram_size >> PPOD_SIZE_SHIFT;
ppm->max_index_in_edram = first_ddr_idx - 1;
bitmap_set(ppm->ppod_bmap, first_ddr_idx, 1);
pr_debug("reserved %u ppod in bitmap\n", first_ddr_idx);
}
spin_lock_init(&ppm->map_lock);
kref_init(&ppm->refcnt);
memcpy(&ppm->tformat, tformat, sizeof(struct cxgbi_tag_format));
ppm->ppm_pp = ppm_pp;
ppm->ndev = ndev;
ppm->pdev = pdev;
ppm->lldev = lldev;
ppm->ppmax = ppmax;
ppm->next = 0;
ppm->llimit = llimit;
ppm->base_idx = start > llimit ?
(start - llimit + 1) >> PPOD_SIZE_SHIFT : 0;
ppm->bmap_index_max = ppmax - ppmax_pool;
ppm->pool = pool;
ppm->pool_rsvd = ppmax_pool;
ppm->pool_index_max = pool_index_max;
/* check one more time */
if (*ppm_pp) {
ppm_free(ppm);
ppm = (struct cxgbi_ppm *)(*ppm_pp);
pr_info("ippm: %s, ppm 0x%p,0x%p already initialized, %u/%u.\n",
ndev->name, ppm_pp, *ppm_pp, ppm->ppmax, ppmax);
kref_get(&ppm->refcnt);
return 1;
}
*ppm_pp = ppm;
ppm->tformat.pgsz_idx_dflt = cxgbi_ppm_find_page_index(ppm, PAGE_SIZE);
pr_info("ippm %s: ppm 0x%p, 0x%p, base %u/%u, pg %lu,%u, rsvd %u,%u.\n",
ndev->name, ppm_pp, ppm, ppm->base_idx, ppm->ppmax, PAGE_SIZE,
ppm->tformat.pgsz_idx_dflt, ppm->pool_rsvd,
ppm->pool_index_max);
return 0;
release_ppm_pool:
free_percpu(pool);
return -ENOMEM;
}
EXPORT_SYMBOL(cxgbi_ppm_init);
unsigned int cxgbi_tagmask_set(unsigned int ppmax)
{
unsigned int bits = fls(ppmax);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/errno.h`, `linux/types.h`, `linux/debugfs.h`, `linux/export.h`, `linux/list.h`, `linux/skbuff.h`.
- Detected declarations: `function Copyright`, `function ppm_find_unused_entries`, `function ppm_mark_entries`, `function ppm_get_cpu_entries`, `function ppm_get_entries`, `function ppm_unmark_entries`, `function cxgbi_ppm_ppod_release`, `function cxgbi_ppm_ppods_reserve`, `function cxgbi_ppm_make_ppod_hdr`, `function ppm_free`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.