drivers/net/ethernet/mscc/ocelot_flower.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mscc/ocelot_flower.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mscc/ocelot_flower.c- Extension
.c- Size
- 28979 bytes
- Lines
- 1043
- 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
net/pkt_cls.hnet/tc_act/tc_gact.hsoc/mscc/ocelot_vcap.hocelot_police.hocelot_vcap.h
Detected Declarations
function Copyrightfunction ocelot_chain_to_lookupfunction ocelot_chain_to_pagfunction ocelot_is_goto_target_validfunction Groupfunction ocelot_find_vcap_filter_that_points_atfunction ocelot_flower_parse_ingress_vlan_modifyfunction ocelot_flower_parse_egress_vlan_modifyfunction ocelot_flower_parse_egress_portfunction ocelot_flower_parse_actionfunction flow_action_for_eachfunction ocelot_flower_parse_indevfunction ocelot_flower_parse_keyfunction ocelot_flower_parsefunction ocelot_vcap_dummy_filter_addfunction ocelot_vcap_dummy_filter_delfunction VLANfunction ocelot_cls_flower_replacefunction ocelot_cls_flower_destroyfunction ocelot_cls_flower_statsexport ocelot_cls_flower_replaceexport ocelot_cls_flower_destroyexport ocelot_cls_flower_stats
Annotated Snippet
if (f->common.skip_sw) {
NL_SET_ERR_MSG_FMT(extack,
"Can only %s to %s if filter also runs in software",
act_string, egress_port < 0 ?
"CPU" : "ingress of ocelot port");
return -EOPNOTSUPP;
}
egress_port = ocelot->num_phys_ports;
}
return egress_port;
}
static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
bool ingress, struct flow_cls_offload *f,
struct ocelot_vcap_filter *filter)
{
const struct flow_action *action = &f->rule->action;
struct netlink_ext_ack *extack = f->common.extack;
bool allow_missing_goto_target = false;
const struct flow_action_entry *a;
enum ocelot_tag_tpid_sel tpid;
int i, chain, egress_port;
u32 pol_ix, pol_max;
u64 rate;
int err;
if (!flow_action_basic_hw_stats_check(&f->rule->action,
f->common.extack))
return -EOPNOTSUPP;
chain = f->common.chain_index;
filter->block_id = ocelot_chain_to_block(chain, ingress);
if (filter->block_id < 0) {
NL_SET_ERR_MSG_MOD(extack, "Cannot offload to this chain");
return -EOPNOTSUPP;
}
if (filter->block_id == VCAP_IS1 || filter->block_id == VCAP_IS2)
filter->lookup = ocelot_chain_to_lookup(chain);
if (filter->block_id == VCAP_IS2)
filter->pag = ocelot_chain_to_pag(chain);
filter->goto_target = -1;
filter->type = OCELOT_VCAP_FILTER_DUMMY;
flow_action_for_each(i, a, action) {
switch (a->id) {
case FLOW_ACTION_DROP:
if (filter->block_id != VCAP_IS2) {
NL_SET_ERR_MSG_MOD(extack,
"Drop action can only be offloaded to VCAP IS2");
return -EOPNOTSUPP;
}
if (filter->goto_target != -1) {
NL_SET_ERR_MSG_MOD(extack,
"Last action must be GOTO");
return -EOPNOTSUPP;
}
filter->action.mask_mode = OCELOT_MASK_MODE_PERMIT_DENY;
filter->action.port_mask = 0;
filter->action.police_ena = true;
filter->action.pol_ix = OCELOT_POLICER_DISCARD;
filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
break;
case FLOW_ACTION_ACCEPT:
if (filter->block_id != VCAP_ES0 &&
filter->block_id != VCAP_IS1 &&
filter->block_id != VCAP_IS2) {
NL_SET_ERR_MSG_MOD(extack,
"Accept action can only be offloaded to VCAP chains");
return -EOPNOTSUPP;
}
if (filter->block_id != VCAP_ES0 &&
filter->goto_target != -1) {
NL_SET_ERR_MSG_MOD(extack,
"Last action must be GOTO");
return -EOPNOTSUPP;
}
filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
break;
case FLOW_ACTION_TRAP:
if (filter->block_id != VCAP_IS2 ||
filter->lookup != 0) {
NL_SET_ERR_MSG_MOD(extack,
"Trap action can only be offloaded to VCAP IS2 lookup 0");
return -EOPNOTSUPP;
}
if (filter->goto_target != -1) {
NL_SET_ERR_MSG_MOD(extack,
"Last action must be GOTO");
Annotation
- Immediate include surface: `net/pkt_cls.h`, `net/tc_act/tc_gact.h`, `soc/mscc/ocelot_vcap.h`, `ocelot_police.h`, `ocelot_vcap.h`.
- Detected declarations: `function Copyright`, `function ocelot_chain_to_lookup`, `function ocelot_chain_to_pag`, `function ocelot_is_goto_target_valid`, `function Group`, `function ocelot_find_vcap_filter_that_points_at`, `function ocelot_flower_parse_ingress_vlan_modify`, `function ocelot_flower_parse_egress_vlan_modify`, `function ocelot_flower_parse_egress_port`, `function ocelot_flower_parse_action`.
- 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.