drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c- Extension
.c- Size
- 16425 bytes
- Lines
- 561
- 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.
- 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/kernel.hlinux/slab.hlinux/list.hlinux/errno.hlinux/refcount.hitem.hcore_acl_flex_keys.h
Detected Declarations
struct mlxsw_afkstruct mlxsw_afk_key_infostruct mlxsw_afk_pickerfunction mlxsw_afk_blocks_checkfunction mlxsw_afk_destroyfunction mlxsw_afk_key_info_elements_eqfunction mlxsw_afk_key_info_findfunction list_for_each_entryfunction mlxsw_afk_picker_count_hitsfunction mlxsw_afk_picker_subtract_hitsfunction for_each_set_bitfunction mlxsw_afk_picker_most_hits_getfunction mlxsw_afk_picker_key_info_addfunction for_each_set_bitfunction mlxsw_afk_keys_fillfunction mlxsw_afk_pickerfunction mlxsw_afk_key_info_createfunction mlxsw_afk_key_info_destroyfunction mlxsw_afk_key_info_getfunction mlxsw_afk_key_info_putfunction mlxsw_afk_key_info_subsetfunction mlxsw_afk_block_elinst_getfunction mlxsw_afk_key_info_elinst_getfunction mlxsw_afk_key_info_block_encoding_getfunction mlxsw_afk_key_info_blocks_count_getfunction mlxsw_afk_values_add_u32function mlxsw_afk_values_add_buffunction mlxsw_sp_afk_encode_u32function mlxsw_sp_afk_encode_buffunction mlxsw_sp_afk_encode_onefunction mlxsw_afk_encodefunction mlxsw_afk_element_usage_for_eachfunction mlxsw_afk_clearexport mlxsw_afk_createexport mlxsw_afk_destroyexport mlxsw_afk_key_info_getexport mlxsw_afk_key_info_putexport mlxsw_afk_key_info_subsetexport mlxsw_afk_key_info_block_encoding_getexport mlxsw_afk_key_info_blocks_count_getexport mlxsw_afk_values_add_u32export mlxsw_afk_values_add_bufexport mlxsw_afk_encodeexport mlxsw_afk_clear
Annotated Snippet
struct mlxsw_afk {
struct list_head key_info_list;
unsigned int max_blocks;
const struct mlxsw_afk_ops *ops;
const struct mlxsw_afk_block *blocks;
unsigned int blocks_count;
};
static bool mlxsw_afk_blocks_check(struct mlxsw_afk *mlxsw_afk)
{
int i;
int j;
for (i = 0; i < mlxsw_afk->blocks_count; i++) {
const struct mlxsw_afk_block *block = &mlxsw_afk->blocks[i];
for (j = 0; j < block->instances_count; j++) {
const struct mlxsw_afk_element_info *elinfo;
const struct mlxsw_afk_element_inst *elinst;
elinst = &block->instances[j];
elinfo = &mlxsw_afk_element_infos[elinst->element];
if (elinst->type != elinfo->type ||
(!elinst->avoid_size_check &&
elinst->item.size.bits !=
elinfo->item.size.bits))
return false;
}
}
return true;
}
struct mlxsw_afk *mlxsw_afk_create(unsigned int max_blocks,
const struct mlxsw_afk_ops *ops)
{
struct mlxsw_afk *mlxsw_afk;
mlxsw_afk = kzalloc_obj(*mlxsw_afk);
if (!mlxsw_afk)
return NULL;
INIT_LIST_HEAD(&mlxsw_afk->key_info_list);
mlxsw_afk->max_blocks = max_blocks;
mlxsw_afk->ops = ops;
mlxsw_afk->blocks = ops->blocks;
mlxsw_afk->blocks_count = ops->blocks_count;
WARN_ON(!mlxsw_afk_blocks_check(mlxsw_afk));
return mlxsw_afk;
}
EXPORT_SYMBOL(mlxsw_afk_create);
void mlxsw_afk_destroy(struct mlxsw_afk *mlxsw_afk)
{
WARN_ON(!list_empty(&mlxsw_afk->key_info_list));
kfree(mlxsw_afk);
}
EXPORT_SYMBOL(mlxsw_afk_destroy);
struct mlxsw_afk_key_info {
struct list_head list;
refcount_t ref_count;
unsigned int blocks_count;
int element_to_block[MLXSW_AFK_ELEMENT_MAX]; /* index is element, value
* is index inside "blocks"
*/
struct mlxsw_afk_element_usage elusage;
const struct mlxsw_afk_block *blocks[];
};
static bool
mlxsw_afk_key_info_elements_eq(struct mlxsw_afk_key_info *key_info,
struct mlxsw_afk_element_usage *elusage)
{
return memcmp(&key_info->elusage, elusage, sizeof(*elusage)) == 0;
}
static struct mlxsw_afk_key_info *
mlxsw_afk_key_info_find(struct mlxsw_afk *mlxsw_afk,
struct mlxsw_afk_element_usage *elusage)
{
struct mlxsw_afk_key_info *key_info;
list_for_each_entry(key_info, &mlxsw_afk->key_info_list, list) {
if (mlxsw_afk_key_info_elements_eq(key_info, elusage))
return key_info;
}
return NULL;
}
struct mlxsw_afk_picker {
DECLARE_BITMAP(element, MLXSW_AFK_ELEMENT_MAX);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/list.h`, `linux/errno.h`, `linux/refcount.h`, `item.h`, `core_acl_flex_keys.h`.
- Detected declarations: `struct mlxsw_afk`, `struct mlxsw_afk_key_info`, `struct mlxsw_afk_picker`, `function mlxsw_afk_blocks_check`, `function mlxsw_afk_destroy`, `function mlxsw_afk_key_info_elements_eq`, `function mlxsw_afk_key_info_find`, `function list_for_each_entry`, `function mlxsw_afk_picker_count_hits`, `function mlxsw_afk_picker_subtract_hits`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration 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.