drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c- Extension
.c- Size
- 14198 bytes
- Lines
- 479
- 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.
- 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/errno.hlinux/netdevice.hnet/flow_offload.hspectrum.hspectrum_span.hreg.h
Detected Declarations
function mlxsw_sp_mall_entry_findfunction mlxsw_sp_mall_port_mirror_addfunction mlxsw_sp_mall_port_mirror_delfunction mlxsw_sp_mall_port_sample_setfunction mlxsw_sp_mall_port_sample_addfunction mlxsw_sp_mall_port_sample_delfunction mlxsw_sp_mall_port_rule_addfunction mlxsw_sp_mall_port_rule_delfunction mlxsw_sp_mall_prio_updatefunction mlxsw_sp_mall_replacefunction list_for_each_entryfunction mlxsw_sp_mall_destroyfunction mlxsw_sp_mall_port_bindfunction list_for_each_entryfunction mlxsw_sp_mall_port_unbindfunction mlxsw_sp_mall_prio_getfunction mlxsw_sp1_mall_sample_addfunction mlxsw_sp1_mall_sample_delfunction mlxsw_sp2_mall_sample_addfunction mlxsw_sp2_mall_sample_del
Annotated Snippet
if (err != -ENOENT) {
NL_SET_ERR_MSG(f->common.extack, "Failed to get flower priorities");
return err;
}
flower_prio_valid = false;
/* No flower filters are installed in specified chain. */
} else {
flower_prio_valid = true;
}
if (protocol != htons(ETH_P_ALL)) {
NL_SET_ERR_MSG(f->common.extack, "matchall rules only supported with 'all' protocol");
return -EOPNOTSUPP;
}
mall_entry = kzalloc_obj(*mall_entry);
if (!mall_entry)
return -ENOMEM;
mall_entry->cookie = f->cookie;
mall_entry->priority = f->common.prio;
mall_entry->ingress = mlxsw_sp_flow_block_is_ingress_bound(block);
if (flower_prio_valid && mall_entry->ingress &&
mall_entry->priority >= flower_min_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add behind existing flower rules");
err = -EOPNOTSUPP;
goto errout;
}
if (flower_prio_valid && !mall_entry->ingress &&
mall_entry->priority <= flower_max_prio) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add in front of existing flower rules");
err = -EOPNOTSUPP;
goto errout;
}
act = &f->rule->action.entries[0];
switch (act->id) {
case FLOW_ACTION_MIRRED:
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR;
mall_entry->mirror.to_dev = act->dev;
break;
case FLOW_ACTION_SAMPLE:
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_SAMPLE;
mall_entry->sample.params.psample_group = act->sample.psample_group;
mall_entry->sample.params.truncate = act->sample.truncate;
mall_entry->sample.params.trunc_size = act->sample.trunc_size;
mall_entry->sample.params.rate = act->sample.rate;
break;
default:
err = -EOPNOTSUPP;
goto errout;
}
list_for_each_entry(binding, &block->binding_list, list) {
err = mlxsw_sp_mall_port_rule_add(binding->mlxsw_sp_port,
mall_entry, f->common.extack);
if (err)
goto rollback;
}
block->rule_count++;
if (mall_entry->ingress)
block->egress_blocker_rule_count++;
else
block->ingress_blocker_rule_count++;
list_add_tail(&mall_entry->list, &block->mall.list);
mlxsw_sp_mall_prio_update(block);
return 0;
rollback:
list_for_each_entry_continue_reverse(binding, &block->binding_list,
list)
mlxsw_sp_mall_port_rule_del(binding->mlxsw_sp_port, mall_entry);
errout:
kfree(mall_entry);
return err;
}
void mlxsw_sp_mall_destroy(struct mlxsw_sp_flow_block *block,
struct tc_cls_matchall_offload *f)
{
struct mlxsw_sp_flow_block_binding *binding;
struct mlxsw_sp_mall_entry *mall_entry;
mall_entry = mlxsw_sp_mall_entry_find(block, f->cookie);
if (!mall_entry) {
NL_SET_ERR_MSG(f->common.extack, "Entry not found");
return;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/netdevice.h`, `net/flow_offload.h`, `spectrum.h`, `spectrum_span.h`, `reg.h`.
- Detected declarations: `function mlxsw_sp_mall_entry_find`, `function mlxsw_sp_mall_port_mirror_add`, `function mlxsw_sp_mall_port_mirror_del`, `function mlxsw_sp_mall_port_sample_set`, `function mlxsw_sp_mall_port_sample_add`, `function mlxsw_sp_mall_port_sample_del`, `function mlxsw_sp_mall_port_rule_add`, `function mlxsw_sp_mall_port_rule_del`, `function mlxsw_sp_mall_prio_update`, `function mlxsw_sp_mall_replace`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.