drivers/net/ethernet/microchip/sparx5/sparx5_pool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/sparx5_pool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/sparx5_pool.c- Extension
.c- Size
- 1732 bytes
- Lines
- 82
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sparx5_main_regs.hsparx5_main.h
Detected Declarations
function Copyrightfunction sparx5_pool_idx_to_idfunction sparx5_pool_putfunction sparx5_pool_getfunction sparx5_pool_get_with_idx
Annotated Snippet
if (e_itr->ref_cnt == 0) {
*id = sparx5_pool_idx_to_id(i);
return ++e_itr->ref_cnt;
}
}
return -ENOSPC;
}
/* Get resource from pool that matches index.
* Return reference count on success, otherwise return error.
*/
int sparx5_pool_get_with_idx(struct sparx5_pool_entry *pool, int size, u32 idx,
u32 *id)
{
struct sparx5_pool_entry *e_itr;
int i, ret = -ENOSPC;
for (i = 0, e_itr = pool; i < size; i++, e_itr++) {
/* Pool index of first free entry */
if (e_itr->ref_cnt == 0 && ret == -ENOSPC)
ret = i;
/* Tc index already in use ? */
if (e_itr->idx == idx && e_itr->ref_cnt > 0) {
ret = i;
break;
}
}
/* Did we find a free entry? */
if (ret >= 0) {
*id = sparx5_pool_idx_to_id(ret);
e_itr = (pool + ret);
e_itr->idx = idx;
return ++e_itr->ref_cnt;
}
return ret;
}
Annotation
- Immediate include surface: `sparx5_main_regs.h`, `sparx5_main.h`.
- Detected declarations: `function Copyright`, `function sparx5_pool_idx_to_id`, `function sparx5_pool_put`, `function sparx5_pool_get`, `function sparx5_pool_get_with_idx`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.