drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c- Extension
.c- Size
- 15200 bytes
- Lines
- 575
- 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
dr_types.h
Detected Declarations
struct mlx5dr_icm_hot_chunkstruct mlx5dr_icm_poolstruct mlx5dr_icm_dmstruct mlx5dr_icm_mrfunction dr_icm_create_dm_mkeyfunction mlx5dr_icm_pool_get_chunk_mr_addrfunction mlx5dr_icm_pool_get_chunk_rkeyfunction mlx5dr_icm_pool_get_chunk_icm_addrfunction mlx5dr_icm_pool_get_chunk_byte_sizefunction mlx5dr_icm_pool_get_chunk_num_of_entriesfunction dr_icm_pool_mr_createfunction dr_icm_pool_mr_destroyfunction dr_icm_buddy_get_ste_sizefunction dr_icm_chunk_ste_initfunction dr_icm_buddy_init_ste_cachefunction dr_icm_buddy_cleanup_ste_cachefunction dr_icm_buddy_createfunction dr_icm_buddy_destroyfunction dr_icm_chunk_initfunction dr_icm_pool_is_sync_requiredfunction dr_icm_pool_clear_hot_chunks_arrfunction dr_icm_pool_sync_all_buddy_poolsfunction list_for_each_entry_safefunction dr_icm_handle_buddies_get_memfunction mlx5dr_icm_alloc_chunkfunction mlx5dr_icm_free_chunkfunction mlx5dr_icm_pool_free_htblfunction mlx5dr_icm_pool_destroy
Annotated Snippet
struct mlx5dr_icm_hot_chunk {
struct mlx5dr_icm_buddy_mem *buddy_mem;
unsigned int seg;
enum mlx5dr_icm_chunk_size size;
};
struct mlx5dr_icm_pool {
enum mlx5dr_icm_type icm_type;
enum mlx5dr_icm_chunk_size max_log_chunk_sz;
struct mlx5dr_domain *dmn;
struct kmem_cache *chunks_kmem_cache;
/* memory management */
struct mutex mutex; /* protect the ICM pool and ICM buddy */
struct list_head buddy_mem_list;
/* Hardware may be accessing this memory but at some future,
* undetermined time, it might cease to do so.
* sync_ste command sets them free.
*/
struct mlx5dr_icm_hot_chunk *hot_chunks_arr;
u32 hot_chunks_num;
u64 hot_memory_size;
/* hot memory size threshold for triggering sync */
u64 th;
};
struct mlx5dr_icm_dm {
u32 obj_id;
enum mlx5_sw_icm_type type;
phys_addr_t addr;
size_t length;
};
struct mlx5dr_icm_mr {
u32 mkey;
struct mlx5dr_icm_dm dm;
struct mlx5dr_domain *dmn;
size_t length;
u64 icm_start_addr;
};
static int dr_icm_create_dm_mkey(struct mlx5_core_dev *mdev,
u32 pd, u64 length, u64 start_addr, int mode,
u32 *mkey)
{
u32 inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
u32 in[MLX5_ST_SZ_DW(create_mkey_in)] = {};
void *mkc;
mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
MLX5_SET(mkc, mkc, access_mode_1_0, mode);
MLX5_SET(mkc, mkc, access_mode_4_2, (mode >> 2) & 0x7);
MLX5_SET(mkc, mkc, lw, 1);
MLX5_SET(mkc, mkc, lr, 1);
if (mode == MLX5_MKC_ACCESS_MODE_SW_ICM) {
MLX5_SET(mkc, mkc, rw, 1);
MLX5_SET(mkc, mkc, rr, 1);
}
MLX5_SET64(mkc, mkc, len, length);
MLX5_SET(mkc, mkc, pd, pd);
MLX5_SET(mkc, mkc, qpn, 0xffffff);
MLX5_SET64(mkc, mkc, start_addr, start_addr);
return mlx5_core_create_mkey(mdev, mkey, in, inlen);
}
u64 mlx5dr_icm_pool_get_chunk_mr_addr(struct mlx5dr_icm_chunk *chunk)
{
u32 offset = mlx5dr_icm_pool_dm_type_to_entry_size(chunk->buddy_mem->pool->icm_type);
return (u64)offset * chunk->seg;
}
u32 mlx5dr_icm_pool_get_chunk_rkey(struct mlx5dr_icm_chunk *chunk)
{
return chunk->buddy_mem->icm_mr->mkey;
}
u64 mlx5dr_icm_pool_get_chunk_icm_addr(struct mlx5dr_icm_chunk *chunk)
{
u32 size = mlx5dr_icm_pool_dm_type_to_entry_size(chunk->buddy_mem->pool->icm_type);
return (u64)chunk->buddy_mem->icm_mr->icm_start_addr + size * chunk->seg;
}
u32 mlx5dr_icm_pool_get_chunk_byte_size(struct mlx5dr_icm_chunk *chunk)
{
Annotation
- Immediate include surface: `dr_types.h`.
- Detected declarations: `struct mlx5dr_icm_hot_chunk`, `struct mlx5dr_icm_pool`, `struct mlx5dr_icm_dm`, `struct mlx5dr_icm_mr`, `function dr_icm_create_dm_mkey`, `function mlx5dr_icm_pool_get_chunk_mr_addr`, `function mlx5dr_icm_pool_get_chunk_rkey`, `function mlx5dr_icm_pool_get_chunk_icm_addr`, `function mlx5dr_icm_pool_get_chunk_byte_size`, `function mlx5dr_icm_pool_get_chunk_num_of_entries`.
- 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.