drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c- Extension
.c- Size
- 29558 bytes
- Lines
- 1290
- 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
net/pkt_cls.hnet/tc_act/tc_gact.hcommon.hdwmac4.hdwmac5.hstmmac.h
Detected Declarations
function Copyrightfunction tc_fill_actionsfunction tcf_exts_for_each_actionfunction tc_fill_entryfunction tc_unfill_entryfunction tc_config_knodefunction tc_delete_knodefunction tc_setup_cls_u32function tc_rfs_initfunction tc_initfunction tc_setup_cbsfunction tc_parse_flow_actionsfunction flow_action_for_eachfunction tc_add_basic_flowfunction tc_add_ip4_flowfunction tc_add_ports_flowfunction tc_add_flowfunction tc_del_flowfunction tc_add_vlan_flowfunction tc_del_vlan_flowfunction tc_add_ethtype_flowfunction tc_del_ethtype_flowfunction tc_add_flow_clsfunction tc_del_flow_clsfunction tc_setup_clsfunction stmmac_calc_tas_basetimefunction tc_taprio_map_maxsdu_txqfunction tc_taprio_configurefunction tc_taprio_statsfunction tc_taprio_queue_statsfunction tc_setup_tapriofunction tc_setup_taprio_without_fpefunction tc_setup_etffunction tc_query_capsfunction stmmac_reset_tc_mqpriofunction tc_setup_dwmac510_mqpriofunction tc_setup_mqprio_unimplemented
Annotated Snippet
if (is_tcf_gact_ok(act)) {
action_entry->val.af = 1;
break;
}
/* Drop */
if (is_tcf_gact_shot(act)) {
action_entry->val.rf = 1;
break;
}
/* Unsupported */
return -EINVAL;
}
return 0;
}
static int tc_fill_entry(struct stmmac_priv *priv,
struct tc_cls_u32_offload *cls)
{
struct stmmac_tc_entry *entry, *frag = NULL;
struct tc_u32_sel *sel = cls->knode.sel;
u32 off, data, mask, real_off, rem;
u32 prio = cls->common.prio << 16;
int ret;
/* Only 1 match per entry */
if (sel->nkeys <= 0 || sel->nkeys > 1)
return -EINVAL;
off = sel->keys[0].off << sel->offshift;
data = sel->keys[0].val;
mask = sel->keys[0].mask;
switch (ntohs(cls->common.protocol)) {
case ETH_P_ALL:
break;
case ETH_P_IP:
off += ETH_HLEN;
break;
default:
return -EINVAL;
}
if (off > priv->tc_off_max)
return -EINVAL;
real_off = off / 4;
rem = off % 4;
entry = tc_find_entry(priv, cls, true);
if (!entry)
return -EINVAL;
if (rem) {
frag = tc_find_entry(priv, cls, true);
if (!frag) {
ret = -EINVAL;
goto err_unuse;
}
entry->frag_ptr = frag;
entry->val.match_en = (mask << (rem * 8)) &
GENMASK(31, rem * 8);
entry->val.match_data = (data << (rem * 8)) &
GENMASK(31, rem * 8);
entry->val.frame_offset = real_off;
entry->prio = prio;
frag->val.match_en = (mask >> (rem * 8)) &
GENMASK(rem * 8 - 1, 0);
frag->val.match_data = (data >> (rem * 8)) &
GENMASK(rem * 8 - 1, 0);
frag->val.frame_offset = real_off + 1;
frag->prio = prio;
frag->is_frag = true;
} else {
entry->frag_ptr = NULL;
entry->val.match_en = mask;
entry->val.match_data = data;
entry->val.frame_offset = real_off;
entry->prio = prio;
}
ret = tc_fill_actions(entry, frag, cls);
if (ret)
goto err_unuse;
return 0;
Annotation
- Immediate include surface: `net/pkt_cls.h`, `net/tc_act/tc_gact.h`, `common.h`, `dwmac4.h`, `dwmac5.h`, `stmmac.h`.
- Detected declarations: `function Copyright`, `function tc_fill_actions`, `function tcf_exts_for_each_action`, `function tc_fill_entry`, `function tc_unfill_entry`, `function tc_config_knode`, `function tc_delete_knode`, `function tc_setup_cls_u32`, `function tc_rfs_init`, `function tc_init`.
- 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.