drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c- Extension
.c- Size
- 5105 bytes
- Lines
- 205
- 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
sparx5_tc.hvcap_api.hvcap_api_client.hsparx5_main_regs.hsparx5_main.hsparx5_vcap_impl.h
Detected Declarations
function Copyrightfunction list_for_each_entryfunction sparx5_tc_matchall_parse_actionfunction sparx5_tc_matchall_parse_mirror_actionfunction sparx5_tc_matchall_replacefunction sparx5_tc_matchall_destroyfunction sparx5_tc_matchall_statsfunction sparx5_tc_matchall
Annotated Snippet
if (err) {
switch (err) {
case -EEXIST:
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Mirroring already exists");
break;
case -EINVAL:
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Cannot mirror a monitor port");
break;
case -ENOENT:
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"No more mirror probes available");
break;
default:
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Unknown error");
break;
}
return err;
}
/* Get baseline stats for this port */
sparx5_mirror_stats(mall_entry, &tmo->stats);
break;
case FLOW_ACTION_GOTO:
err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
tmo->common.chain_index,
action->chain_index, tmo->cookie,
true);
if (err == -EFAULT) {
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Unsupported goto chain");
return -EOPNOTSUPP;
}
if (err == -EADDRINUSE) {
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"VCAP already enabled");
return -EOPNOTSUPP;
}
if (err == -EADDRNOTAVAIL) {
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Already matching this chain");
return -EOPNOTSUPP;
}
if (err) {
NL_SET_ERR_MSG_MOD(tmo->common.extack,
"Could not enable VCAP lookups");
return err;
}
break;
default:
NL_SET_ERR_MSG_MOD(tmo->common.extack, "Unsupported action");
return -EOPNOTSUPP;
}
list_add_tail(&mall_entry->list, &sparx5->mall_entries);
return 0;
}
static int sparx5_tc_matchall_destroy(struct net_device *ndev,
struct tc_cls_matchall_offload *tmo,
bool ingress)
{
struct sparx5_port *port = netdev_priv(ndev);
struct sparx5 *sparx5 = port->sparx5;
struct sparx5_mall_entry *entry;
int err = 0;
entry = sparx5_tc_matchall_entry_find(&sparx5->mall_entries,
tmo->cookie);
if (!entry)
return -ENOENT;
if (entry->type == FLOW_ACTION_MIRRED) {
sparx5_mirror_del(entry);
} else if (entry->type == FLOW_ACTION_GOTO) {
err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev,
0, 0, tmo->cookie, false);
} else {
NL_SET_ERR_MSG_MOD(tmo->common.extack, "Unsupported action");
err = -EOPNOTSUPP;
}
list_del(&entry->list);
return err;
}
static int sparx5_tc_matchall_stats(struct net_device *ndev,
Annotation
- Immediate include surface: `sparx5_tc.h`, `vcap_api.h`, `vcap_api_client.h`, `sparx5_main_regs.h`, `sparx5_main.h`, `sparx5_vcap_impl.h`.
- Detected declarations: `function Copyright`, `function list_for_each_entry`, `function sparx5_tc_matchall_parse_action`, `function sparx5_tc_matchall_parse_mirror_action`, `function sparx5_tc_matchall_replace`, `function sparx5_tc_matchall_destroy`, `function sparx5_tc_matchall_stats`, `function sparx5_tc_matchall`.
- 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.