drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c- Extension
.c- Size
- 32883 bytes
- Lines
- 1131
- 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/kernel.hlinux/slab.hlinux/errno.hlinux/list.hlinux/string.hlinux/rhashtable.hlinux/netdevice.hlinux/mutex.hlinux/refcount.hnet/net_namespace.hnet/tc_act/tc_vlan.hreg.hcore.hresources.hspectrum.hcore_acl_flex_keys.hcore_acl_flex_actions.hspectrum_acl_tcam.h
Detected Declarations
struct mlxsw_sp_aclstruct mlxsw_sp_acl_ruleset_ht_keystruct mlxsw_sp_acl_rulesetstruct mlxsw_sp_acl_rulestruct mlxsw_sp_acl_mangle_actionfunction mlxsw_sp_acl_ruleset_is_singularfunction mlxsw_sp_acl_ruleset_bindfunction mlxsw_sp_acl_ruleset_unbindfunction mlxsw_sp_acl_ruleset_block_bindfunction mlxsw_sp_acl_ruleset_block_unbindfunction mlxsw_sp_acl_ruleset_createfunction mlxsw_sp_acl_ruleset_destroyfunction mlxsw_sp_acl_ruleset_ref_incfunction mlxsw_sp_acl_ruleset_ref_decfunction __mlxsw_sp_acl_ruleset_lookupfunction mlxsw_sp_acl_ruleset_lookupfunction mlxsw_sp_acl_ruleset_getfunction mlxsw_sp_acl_ruleset_putfunction mlxsw_sp_acl_ruleset_group_idfunction mlxsw_sp_acl_ruleset_prio_getfunction mlxsw_sp_acl_rulei_createfunction mlxsw_sp_acl_rulei_destroyfunction mlxsw_sp_acl_rulei_commitfunction mlxsw_sp_acl_rulei_priorityfunction mlxsw_sp_acl_rulei_keymask_u32function mlxsw_sp_acl_rulei_keymask_buffunction mlxsw_sp_acl_rulei_act_continuefunction mlxsw_sp_acl_rulei_act_jumpfunction mlxsw_sp_acl_rulei_act_terminatefunction mlxsw_sp_acl_rulei_act_dropfunction mlxsw_sp_acl_rulei_act_trapfunction mlxsw_sp_acl_rulei_act_fwdfunction mlxsw_sp_acl_rulei_act_mirrorfunction mlxsw_sp_acl_rulei_act_vlanfunction mlxsw_sp_acl_rulei_act_priorityfunction mlxsw_sp_acl_rulei_act_mangle_fieldfunction mlxsw_sp1_acl_rulei_act_mangle_fieldfunction mlxsw_sp2_acl_rulei_act_mangle_field_ip_oddfunction mlxsw_sp2_acl_rulei_act_mangle_fieldfunction mlxsw_sp_acl_rulei_act_manglefunction mlxsw_sp_acl_rulei_act_policefunction mlxsw_sp_acl_rulei_act_countfunction mlxsw_sp_acl_rulei_act_fid_setfunction mlxsw_sp_acl_rulei_act_ignorefunction mlxsw_sp_acl_rulei_act_samplefunction mlxsw_sp_acl_rule_createfunction mlxsw_sp_acl_rule_destroyfunction mlxsw_sp_acl_rule_add
Annotated Snippet
struct mlxsw_sp_acl {
struct mlxsw_sp *mlxsw_sp;
struct mlxsw_afk *afk;
struct mlxsw_sp_fid *dummy_fid;
struct rhashtable ruleset_ht;
struct list_head rules;
struct mutex rules_lock; /* Protects rules list */
struct {
struct delayed_work dw;
unsigned long interval; /* ms */
#define MLXSW_SP_ACL_RULE_ACTIVITY_UPDATE_PERIOD_MS 1000
} rule_activity_update;
struct mlxsw_sp_acl_tcam tcam;
};
struct mlxsw_afk *mlxsw_sp_acl_afk(struct mlxsw_sp_acl *acl)
{
return acl->afk;
}
struct mlxsw_sp_acl_tcam *mlxsw_sp_acl_to_tcam(struct mlxsw_sp_acl *acl)
{
return &acl->tcam;
}
struct mlxsw_sp_acl_ruleset_ht_key {
struct mlxsw_sp_flow_block *block;
u32 chain_index;
const struct mlxsw_sp_acl_profile_ops *ops;
};
struct mlxsw_sp_acl_ruleset {
struct rhash_head ht_node; /* Member of acl HT */
struct mlxsw_sp_acl_ruleset_ht_key ht_key;
struct rhashtable rule_ht;
refcount_t ref_count;
unsigned int min_prio;
unsigned int max_prio;
unsigned long priv[];
/* priv has to be always the last item */
};
struct mlxsw_sp_acl_rule {
struct rhash_head ht_node; /* Member of rule HT */
struct list_head list;
unsigned long cookie; /* HT key */
struct mlxsw_sp_acl_ruleset *ruleset;
struct mlxsw_sp_acl_rule_info *rulei;
u64 last_used;
u64 last_packets;
u64 last_bytes;
u64 last_drops;
unsigned long priv[];
/* priv has to be always the last item */
};
static const struct rhashtable_params mlxsw_sp_acl_ruleset_ht_params = {
.key_len = sizeof(struct mlxsw_sp_acl_ruleset_ht_key),
.key_offset = offsetof(struct mlxsw_sp_acl_ruleset, ht_key),
.head_offset = offsetof(struct mlxsw_sp_acl_ruleset, ht_node),
.automatic_shrinking = true,
};
static const struct rhashtable_params mlxsw_sp_acl_rule_ht_params = {
.key_len = sizeof(unsigned long),
.key_offset = offsetof(struct mlxsw_sp_acl_rule, cookie),
.head_offset = offsetof(struct mlxsw_sp_acl_rule, ht_node),
.automatic_shrinking = true,
};
struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp)
{
return mlxsw_sp->acl->dummy_fid;
}
static bool
mlxsw_sp_acl_ruleset_is_singular(const struct mlxsw_sp_acl_ruleset *ruleset)
{
/* We hold a reference on ruleset ourselves */
return refcount_read(&ruleset->ref_count) == 2;
}
int mlxsw_sp_acl_ruleset_bind(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_flow_block *block,
struct mlxsw_sp_flow_block_binding *binding)
{
struct mlxsw_sp_acl_ruleset *ruleset = block->ruleset_zero;
const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops;
return ops->ruleset_bind(mlxsw_sp, ruleset->priv,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/errno.h`, `linux/list.h`, `linux/string.h`, `linux/rhashtable.h`, `linux/netdevice.h`, `linux/mutex.h`.
- Detected declarations: `struct mlxsw_sp_acl`, `struct mlxsw_sp_acl_ruleset_ht_key`, `struct mlxsw_sp_acl_ruleset`, `struct mlxsw_sp_acl_rule`, `struct mlxsw_sp_acl_mangle_action`, `function mlxsw_sp_acl_ruleset_is_singular`, `function mlxsw_sp_acl_ruleset_bind`, `function mlxsw_sp_acl_ruleset_unbind`, `function mlxsw_sp_acl_ruleset_block_bind`, `function mlxsw_sp_acl_ruleset_block_unbind`.
- 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.