drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pool.c- Extension
.c- Size
- 8811 bytes
- Lines
- 395
- 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.
- 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
internal.hbuddy.h
Detected Declarations
function hws_pool_free_one_resourcefunction hws_pool_resource_freefunction hws_pool_create_one_resourcefunction hws_pool_resource_allocfunction hws_pool_buddy_initfunction hws_pool_buddy_db_get_chunkfunction hws_pool_buddy_db_put_chunkfunction hws_pool_buddy_db_uninitfunction hws_pool_buddy_db_initfunction hws_pool_bitmap_initfunction hws_pool_bitmap_db_get_chunkfunction hws_pool_bitmap_db_put_chunkfunction hws_pool_bitmap_db_uninitfunction hws_pool_bitmap_db_initfunction hws_pool_db_initfunction hws_pool_db_unintfunction mlx5hws_pool_chunk_allocfunction mlx5hws_pool_chunk_freefunction mlx5hws_pool_createfunction mlx5hws_pool_destroy
Annotated Snippet
if (!mirror_resource) {
mlx5hws_err(pool->ctx, "Failed to allocate mirrored resource\n");
hws_pool_free_one_resource(resource);
pool->resource = NULL;
return -EINVAL;
}
pool->mirror_resource = mirror_resource;
}
return 0;
}
static int hws_pool_buddy_init(struct mlx5hws_pool *pool)
{
struct mlx5hws_buddy_mem *buddy;
buddy = mlx5hws_buddy_create(pool->alloc_log_sz);
if (!buddy) {
mlx5hws_err(pool->ctx, "Failed to create buddy order: %zu\n",
pool->alloc_log_sz);
return -ENOMEM;
}
if (hws_pool_resource_alloc(pool) != 0) {
mlx5hws_err(pool->ctx, "Failed to create resource type: %d size %zu\n",
pool->type, pool->alloc_log_sz);
mlx5hws_buddy_cleanup(buddy);
kfree(buddy);
return -ENOMEM;
}
pool->db.buddy = buddy;
return 0;
}
static int hws_pool_buddy_db_get_chunk(struct mlx5hws_pool *pool,
struct mlx5hws_pool_chunk *chunk)
{
struct mlx5hws_buddy_mem *buddy = pool->db.buddy;
if (!buddy) {
mlx5hws_err(pool->ctx, "Bad buddy state\n");
return -EINVAL;
}
chunk->offset = mlx5hws_buddy_alloc_mem(buddy, chunk->order);
if (chunk->offset >= 0)
return 0;
return -ENOMEM;
}
static void hws_pool_buddy_db_put_chunk(struct mlx5hws_pool *pool,
struct mlx5hws_pool_chunk *chunk)
{
struct mlx5hws_buddy_mem *buddy;
buddy = pool->db.buddy;
if (!buddy) {
mlx5hws_err(pool->ctx, "Bad buddy state\n");
return;
}
mlx5hws_buddy_free_mem(buddy, chunk->offset, chunk->order);
}
static void hws_pool_buddy_db_uninit(struct mlx5hws_pool *pool)
{
struct mlx5hws_buddy_mem *buddy;
buddy = pool->db.buddy;
if (buddy) {
mlx5hws_buddy_cleanup(buddy);
kfree(buddy);
pool->db.buddy = NULL;
}
}
static int hws_pool_buddy_db_init(struct mlx5hws_pool *pool)
{
int ret;
ret = hws_pool_buddy_init(pool);
if (ret)
return ret;
pool->p_db_uninit = &hws_pool_buddy_db_uninit;
pool->p_get_chunk = &hws_pool_buddy_db_get_chunk;
pool->p_put_chunk = &hws_pool_buddy_db_put_chunk;
Annotation
- Immediate include surface: `internal.h`, `buddy.h`.
- Detected declarations: `function hws_pool_free_one_resource`, `function hws_pool_resource_free`, `function hws_pool_create_one_resource`, `function hws_pool_resource_alloc`, `function hws_pool_buddy_init`, `function hws_pool_buddy_db_get_chunk`, `function hws_pool_buddy_db_put_chunk`, `function hws_pool_buddy_db_uninit`, `function hws_pool_buddy_db_init`, `function hws_pool_bitmap_init`.
- 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.