drivers/net/ethernet/mellanox/mlx5/core/fs_pool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/fs_pool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/fs_pool.c- Extension
.c- Size
- 5263 bytes
- Lines
- 200
- 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.
- 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
mlx5_core.hfs_pool.h
Detected Declarations
function mlx5_fs_bulk_bitmap_allocfunction mlx5_fs_bulk_initfunction mlx5_fs_bulk_cleanupfunction mlx5_fs_bulk_get_free_amountfunction mlx5_fs_bulk_acquire_indexfunction mlx5_fs_bulk_release_indexfunction mlx5_fs_pool_initfunction mlx5_fs_pool_cleanupfunction mlx5_fs_pool_alloc_new_bulkfunction mlx5_fs_pool_free_bulkfunction mlx5_fs_pool_acquire_from_listfunction mlx5_fs_pool_acquire_indexfunction mlx5_fs_pool_release_index
Annotated Snippet
if (!new_bulk) {
err = -ENOENT;
goto out;
}
err = mlx5_fs_bulk_acquire_index(new_bulk, pool_index);
WARN_ON_ONCE(err);
list_add(&new_bulk->pool_list, &fs_pool->partially_used);
}
fs_pool->available_units--;
fs_pool->used_units++;
out:
mutex_unlock(&fs_pool->pool_lock);
return err;
}
int mlx5_fs_pool_release_index(struct mlx5_fs_pool *fs_pool,
struct mlx5_fs_pool_index *pool_index)
{
struct mlx5_fs_bulk *bulk = pool_index->fs_bulk;
int bulk_free_amount;
int err;
mutex_lock(&fs_pool->pool_lock);
/* TBD would rather return void if there was no warn here in original code */
err = mlx5_fs_bulk_release_index(bulk, pool_index->index);
if (err)
goto unlock;
fs_pool->available_units++;
fs_pool->used_units--;
bulk_free_amount = mlx5_fs_bulk_get_free_amount(bulk);
if (bulk_free_amount == 1)
list_move_tail(&bulk->pool_list, &fs_pool->partially_used);
if (bulk_free_amount == bulk->bulk_len) {
list_del(&bulk->pool_list);
if (fs_pool->available_units > fs_pool->threshold)
mlx5_fs_pool_free_bulk(fs_pool, bulk);
else
list_add(&bulk->pool_list, &fs_pool->unused);
}
unlock:
mutex_unlock(&fs_pool->pool_lock);
return err;
}
Annotation
- Immediate include surface: `mlx5_core.h`, `fs_pool.h`.
- Detected declarations: `function mlx5_fs_bulk_bitmap_alloc`, `function mlx5_fs_bulk_init`, `function mlx5_fs_bulk_cleanup`, `function mlx5_fs_bulk_get_free_amount`, `function mlx5_fs_bulk_acquire_index`, `function mlx5_fs_bulk_release_index`, `function mlx5_fs_pool_init`, `function mlx5_fs_pool_cleanup`, `function mlx5_fs_pool_alloc_new_bulk`, `function mlx5_fs_pool_free_bulk`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.