drivers/net/dsa/mv88e6xxx/tcflower.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/mv88e6xxx/tcflower.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/mv88e6xxx/tcflower.c- Extension
.c- Size
- 4155 bytes
- Lines
- 168
- 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
chip.htcflower.htcam.h
Detected Declarations
function Copyrightfunction mv88e6xxx_cls_flower_addfunction flow_action_for_eachfunction mv88e6xxx_cls_flower_delfunction mv88e6xxx_flower_teardownfunction list_for_each_entry_safe
Annotated Snippet
BIT_ULL(FLOW_DISSECTOR_KEY_IPV4_ADDRS))) {
NL_SET_ERR_MSG_MOD(extack,
"Unsupported keys used");
return -EOPNOTSUPP;
}
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
struct flow_match_control match;
flow_rule_match_control(rule, &match);
addr_type = match.key->addr_type;
if (flow_rule_has_control_flags(match.mask->flags,
cls->common.extack))
return -EOPNOTSUPP;
}
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_match_basic match;
flow_rule_match_basic(rule, &match);
mv88e6xxx_tcam_match_set(key, MV88E6XXX_ETHTYPE_OFFSET,
match.key->n_proto,
match.mask->n_proto);
mv88e6xxx_tcam_match_set(key, MV88E6XXX_IP_PROTO_OFFSET,
match.key->ip_proto,
match.mask->ip_proto);
}
if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
struct flow_match_ipv4_addrs match;
flow_rule_match_ipv4_addrs(cls->rule, &match);
mv88e6xxx_tcam_match_set(key, MV88E6XXX_IPV4_SRC_OFFSET,
match.key->src,
match.mask->src);
mv88e6xxx_tcam_match_set(key, MV88E6XXX_IPV4_DST_OFFSET,
match.key->dst,
match.mask->dst);
}
return 0;
}
int mv88e6xxx_cls_flower_add(struct dsa_switch *ds, int port,
struct flow_cls_offload *cls, bool ingress)
{
struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
struct netlink_ext_ack *extack = cls->common.extack;
struct mv88e6xxx_chip *chip = ds->priv;
struct mv88e6xxx_tcam_key key = { 0 };
const struct flow_action_entry *act;
unsigned long cookie = cls->cookie;
struct mv88e6xxx_tcam_entry *entry;
int err, i;
if (!mv88e6xxx_has_tcam(chip)) {
NL_SET_ERR_MSG_MOD(extack, "hardware offload not supported");
return -EOPNOTSUPP;
}
err = mv88e6xxx_flower_parse_key(chip, extack, cls, &key);
if (err)
return err;
mv88e6xxx_reg_lock(chip);
entry = mv88e6xxx_tcam_entry_find(chip, cookie);
if (entry) {
err = -EEXIST;
goto err_unlock;
}
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) {
err = -ENOMEM;
goto err_unlock;
}
entry->cookie = cookie;
entry->prio = cls->common.prio;
entry->key = key;
flow_action_for_each(i, act, &rule->action) {
switch (act->id) {
case FLOW_ACTION_TRAP: {
int cpu = dsa_upstream_port(ds, port);
entry->action.dpv_mode = DPV_MODE_REPLACE;
entry->action.dpv = BIT(cpu);
break;
}
Annotation
- Immediate include surface: `chip.h`, `tcflower.h`, `tcam.h`.
- Detected declarations: `function Copyright`, `function mv88e6xxx_cls_flower_add`, `function flow_action_for_each`, `function mv88e6xxx_cls_flower_del`, `function mv88e6xxx_flower_teardown`, `function list_for_each_entry_safe`.
- 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.