drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c- Extension
.c- Size
- 45041 bytes
- Lines
- 1589
- 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
linux/bitmap.hlinux/errno.hlinux/genalloc.hlinux/gfp.hlinux/kernel.hlinux/list.hlinux/mutex.hlinux/objagg.hlinux/rtnetlink.hlinux/slab.hcore.hreg.hspectrum.hspectrum_acl_tcam.h
Detected Declarations
struct mlxsw_sp_acl_erp_corestruct mlxsw_sp_acl_erp_keystruct mlxsw_sp_acl_erpstruct mlxsw_sp_acl_erp_master_maskstruct mlxsw_sp_acl_erp_tablestruct mlxsw_sp_acl_erp_table_opsstruct mlxsw_sp_acl_erp_deltafunction mlxsw_sp_acl_erp_table_is_usedfunction mlxsw_sp_acl_erp_bank_getfunction mlxsw_sp_acl_erp_table_entry_sizefunction mlxsw_sp_acl_erp_id_getfunction mlxsw_sp_acl_erp_id_putfunction mlxsw_sp_acl_erp_master_mask_bit_setfunction mlxsw_sp_acl_erp_master_mask_bit_clearfunction mlxsw_sp_acl_erp_master_mask_updatefunction mlxsw_sp_acl_erp_master_mask_setfunction mlxsw_sp_acl_erp_master_mask_clearfunction mlxsw_sp_acl_erp_generic_createfunction mlxsw_sp_acl_erp_generic_destroyfunction mlxsw_sp_acl_erp_table_allocfunction mlxsw_sp_acl_erp_table_freefunction mlxsw_sp_acl_erp_table_master_rpfunction mlxsw_sp_acl_erp_index_getfunction mlxsw_sp_acl_erp_index_putfunction mlxsw_sp_acl_erp_table_locatefunction mlxsw_sp_acl_erp_table_erp_addfunction mlxsw_sp_acl_erp_table_erp_delfunction mlxsw_sp_acl_erp_table_enablefunction mlxsw_sp_acl_erp_table_disablefunction mlxsw_sp_acl_erp_table_relocatefunction list_for_each_entryfunction mlxsw_sp_acl_erp_table_expandfunction mlxsw_acl_erp_table_bf_addfunction list_for_each_entryfunction mlxsw_acl_erp_table_bf_delfunction mlxsw_sp_acl_erp_region_table_transfunction mlxsw_sp_acl_erp_region_master_mask_transfunction mlxsw_sp_acl_erp_region_erp_addfunction mlxsw_sp_acl_erp_region_erp_delfunction mlxsw_sp_acl_erp_region_ctcam_enablefunction mlxsw_sp_acl_erp_region_ctcam_disablefunction __mlxsw_sp_acl_erp_table_other_incfunction mlxsw_sp_acl_erp_ctcam_incfunction mlxsw_sp_acl_erp_delta_incfunction __mlxsw_sp_acl_erp_table_other_decfunction mlxsw_sp_acl_erp_ctcam_decfunction mlxsw_sp_acl_erp_delta_decfunction mlxsw_sp_acl_erp_ctcam_mask_create
Annotated Snippet
struct mlxsw_sp_acl_erp_core {
unsigned int erpt_entries_size[MLXSW_SP_ACL_ATCAM_REGION_TYPE_MAX + 1];
struct gen_pool *erp_tables;
struct mlxsw_sp *mlxsw_sp;
struct mlxsw_sp_acl_bf *bf;
unsigned int num_erp_banks;
};
struct mlxsw_sp_acl_erp_key {
char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN];
#define __MASK_LEN 0x38
#define __MASK_IDX(i) (__MASK_LEN - (i) - 1)
bool ctcam;
};
struct mlxsw_sp_acl_erp {
struct mlxsw_sp_acl_erp_key key;
u8 id;
u8 index;
DECLARE_BITMAP(mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN);
struct list_head list;
struct mlxsw_sp_acl_erp_table *erp_table;
};
struct mlxsw_sp_acl_erp_master_mask {
DECLARE_BITMAP(bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN);
unsigned int count[MLXSW_SP_ACL_TCAM_MASK_LEN];
};
struct mlxsw_sp_acl_erp_table {
struct mlxsw_sp_acl_erp_master_mask master_mask;
DECLARE_BITMAP(erp_id_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION);
DECLARE_BITMAP(erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION);
struct list_head atcam_erps_list;
struct mlxsw_sp_acl_erp_core *erp_core;
struct mlxsw_sp_acl_atcam_region *aregion;
const struct mlxsw_sp_acl_erp_table_ops *ops;
unsigned long base_index;
unsigned int num_atcam_erps;
unsigned int num_max_atcam_erps;
unsigned int num_ctcam_erps;
unsigned int num_deltas;
struct objagg *objagg;
struct mutex objagg_lock; /* guards objagg manipulation */
};
struct mlxsw_sp_acl_erp_table_ops {
struct mlxsw_sp_acl_erp *
(*erp_create)(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp_key *key);
void (*erp_destroy)(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp *erp);
};
static struct mlxsw_sp_acl_erp *
mlxsw_sp_acl_erp_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp_key *key);
static void
mlxsw_sp_acl_erp_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp *erp);
static struct mlxsw_sp_acl_erp *
mlxsw_sp_acl_erp_second_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp_key *key);
static void
mlxsw_sp_acl_erp_second_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp *erp);
static struct mlxsw_sp_acl_erp *
mlxsw_sp_acl_erp_first_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp_key *key);
static void
mlxsw_sp_acl_erp_first_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp *erp);
static void
mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table,
struct mlxsw_sp_acl_erp *erp);
static const struct mlxsw_sp_acl_erp_table_ops erp_multiple_masks_ops = {
.erp_create = mlxsw_sp_acl_erp_mask_create,
.erp_destroy = mlxsw_sp_acl_erp_mask_destroy,
};
static const struct mlxsw_sp_acl_erp_table_ops erp_two_masks_ops = {
.erp_create = mlxsw_sp_acl_erp_mask_create,
.erp_destroy = mlxsw_sp_acl_erp_second_mask_destroy,
};
static const struct mlxsw_sp_acl_erp_table_ops erp_single_mask_ops = {
.erp_create = mlxsw_sp_acl_erp_second_mask_create,
.erp_destroy = mlxsw_sp_acl_erp_first_mask_destroy,
};
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/errno.h`, `linux/genalloc.h`, `linux/gfp.h`, `linux/kernel.h`, `linux/list.h`, `linux/mutex.h`, `linux/objagg.h`.
- Detected declarations: `struct mlxsw_sp_acl_erp_core`, `struct mlxsw_sp_acl_erp_key`, `struct mlxsw_sp_acl_erp`, `struct mlxsw_sp_acl_erp_master_mask`, `struct mlxsw_sp_acl_erp_table`, `struct mlxsw_sp_acl_erp_table_ops`, `struct mlxsw_sp_acl_erp_delta`, `function mlxsw_sp_acl_erp_table_is_used`, `function mlxsw_sp_acl_erp_bank_get`, `function mlxsw_sp_acl_erp_table_entry_size`.
- 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.