drivers/net/ethernet/marvell/mvneta_bm.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/mvneta_bm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/mvneta_bm.c- Extension
.c- Size
- 13336 bytes
- Lines
- 500
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/genalloc.hlinux/io.hlinux/kernel.hlinux/mbus.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/skbuff.hnet/hwbm.hmvneta_bm.h
Detected Declarations
function Copyrightfunction mvneta_bm_readfunction mvneta_bm_pool_enablefunction mvneta_bm_pool_disablefunction mvneta_bm_config_setfunction mvneta_bm_config_clearfunction mvneta_bm_pool_target_setfunction mvneta_bm_constructfunction mvneta_bm_pool_createfunction mvneta_bm_bufs_freefunction mvneta_bm_pool_destroyfunction mvneta_bm_pools_initfunction mvneta_bm_default_setfunction mvneta_bm_initfunction mvneta_bm_get_sramfunction mvneta_bm_put_sramfunction mvneta_bm_putfunction mvneta_bm_probefunction mvneta_bm_removeexport mvneta_bm_constructexport mvneta_bm_pool_useexport mvneta_bm_bufs_freeexport mvneta_bm_pool_destroyexport mvneta_bm_getexport mvneta_bm_put
Annotated Snippet
if (err) {
dev_err(&priv->pdev->dev, "fail to create pool %d\n",
new_pool->id);
return NULL;
}
/* Allocate buffers for this pool */
num = hwbm_pool_add(hwbm_pool, hwbm_pool->size);
if (num != hwbm_pool->size) {
WARN(1, "pool %d: %d of %d allocated\n",
new_pool->id, num, hwbm_pool->size);
return NULL;
}
}
return new_pool;
}
EXPORT_SYMBOL_GPL(mvneta_bm_pool_use);
/* Free all buffers from the pool */
void mvneta_bm_bufs_free(struct mvneta_bm *priv, struct mvneta_bm_pool *bm_pool,
u8 port_map)
{
int i;
bm_pool->port_map &= ~port_map;
if (bm_pool->port_map)
return;
mvneta_bm_config_set(priv, MVNETA_BM_EMPTY_LIMIT_MASK);
for (i = 0; i < bm_pool->hwbm_pool.buf_num; i++) {
dma_addr_t buf_phys_addr;
u32 *vaddr;
/* Get buffer physical address (indirect access) */
buf_phys_addr = mvneta_bm_pool_get_bp(priv, bm_pool);
/* Work-around to the problems when destroying the pool,
* when it occurs that a read access to BPPI returns 0.
*/
if (buf_phys_addr == 0)
continue;
vaddr = phys_to_virt(buf_phys_addr);
if (!vaddr)
break;
dma_unmap_single(&priv->pdev->dev, buf_phys_addr,
bm_pool->buf_size, DMA_FROM_DEVICE);
hwbm_buf_free(&bm_pool->hwbm_pool, vaddr);
}
mvneta_bm_config_clear(priv, MVNETA_BM_EMPTY_LIMIT_MASK);
/* Update BM driver with number of buffers removed from pool */
bm_pool->hwbm_pool.buf_num -= i;
}
EXPORT_SYMBOL_GPL(mvneta_bm_bufs_free);
/* Cleanup pool */
void mvneta_bm_pool_destroy(struct mvneta_bm *priv,
struct mvneta_bm_pool *bm_pool, u8 port_map)
{
struct hwbm_pool *hwbm_pool = &bm_pool->hwbm_pool;
bm_pool->port_map &= ~port_map;
if (bm_pool->port_map)
return;
bm_pool->type = MVNETA_BM_FREE;
mvneta_bm_bufs_free(priv, bm_pool, port_map);
if (hwbm_pool->buf_num)
WARN(1, "cannot free all buffers in pool %d\n", bm_pool->id);
if (bm_pool->virt_addr) {
dma_free_coherent(&priv->pdev->dev,
sizeof(u32) * hwbm_pool->size,
bm_pool->virt_addr, bm_pool->phys_addr);
bm_pool->virt_addr = NULL;
}
mvneta_bm_pool_disable(priv, bm_pool->id);
}
EXPORT_SYMBOL_GPL(mvneta_bm_pool_destroy);
static void mvneta_bm_pools_init(struct mvneta_bm *priv)
{
struct device_node *dn = priv->pdev->dev.of_node;
struct mvneta_bm_pool *bm_pool;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/genalloc.h`, `linux/io.h`, `linux/kernel.h`, `linux/mbus.h`, `linux/module.h`, `linux/netdevice.h`, `linux/of.h`.
- Detected declarations: `function Copyright`, `function mvneta_bm_read`, `function mvneta_bm_pool_enable`, `function mvneta_bm_pool_disable`, `function mvneta_bm_config_set`, `function mvneta_bm_config_clear`, `function mvneta_bm_pool_target_set`, `function mvneta_bm_construct`, `function mvneta_bm_pool_create`, `function mvneta_bm_bufs_free`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.