drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c- Extension
.c- Size
- 41638 bytes
- Lines
- 1592
- 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
net/tc_act/tc_gate.hnet/tcp.hsparx5_tc.hvcap_api.hvcap_api_client.hvcap_tc.hsparx5_main.hsparx5_vcap_impl.h
Detected Declarations
struct sparx5_wildcard_rulestruct sparx5_multiple_rulesstruct sparx5_tc_flower_templatefunction sparx5_tc_flower_es0_tpidfunction sparx5_tc_flower_handler_basic_usagefunction sparx5_tc_flower_handler_control_usagefunction sparx5_tc_flower_handler_cvlan_usagefunction sparx5_tc_flower_handler_vlan_usagefunction sparx5_tc_use_dissectorsfunction sparx5_tc_flower_action_checkfunction flow_action_for_eachfunction sparx5_tc_add_rule_counterfunction sparx5_tc_select_protocol_keysetfunction sparx5_tc_add_rule_copyfunction sparx5_tc_add_remaining_rulesfunction sparx5_tc_set_actionsetfunction sparx5_tc_add_rule_link_targetfunction sparx5_tc_add_rule_linkfunction sparx5_tc_flower_parse_act_gatefunction sparx5_tc_flower_parse_act_policefunction sparx5_tc_flower_psfp_setupfunction sparx5_tc_action_trapfunction sparx5_tc_action_vlan_popfunction sparx5_tc_action_vlan_modifyfunction sparx5_tc_action_vlan_pushfunction sparx5_tc_flower_set_port_maskfunction sparx5_tc_action_mirredfunction sparx5_tc_action_redirectfunction sparx5_tc_flower_simplify_rulefunction sparx5_tc_flower_use_templatefunction list_for_each_entryfunction sparx5_tc_flower_replacefunction sparx5_tc_free_psfp_resourcesfunction sparx5_tc_free_rule_resourcesfunction sparx5_tc_flower_destroyfunction sparx5_tc_flower_statsfunction sparx5_tc_flower_template_createfunction sparx5_tc_flower_template_destroyfunction sparx5_tc_flower
Annotated Snippet
struct sparx5_wildcard_rule {
bool selected;
u8 value;
u8 mask;
enum vcap_keyfield_set keyset;
};
struct sparx5_multiple_rules {
struct sparx5_wildcard_rule rule[SPX5_MAX_RULE_SIZE];
};
struct sparx5_tc_flower_template {
struct list_head list; /* for insertion in the list of templates */
int cid; /* chain id */
enum vcap_keyfield_set orig; /* keyset used before the template */
enum vcap_keyfield_set keyset; /* new keyset used by template */
u16 l3_proto; /* protocol specified in the template */
};
/* SparX-5 VCAP fragment types:
* 0 = no fragment, 1 = initial fragment,
* 2 = suspicious fragment, 3 = valid follow-up fragment
*/
enum { /* key / mask */
FRAG_NOT = 0x03, /* 0 / 3 */
FRAG_SOME = 0x11, /* 1 / 1 */
FRAG_FIRST = 0x13, /* 1 / 3 */
FRAG_LATER = 0x33, /* 3 / 3 */
FRAG_INVAL = 0xff, /* invalid */
};
/* Flower fragment flag to VCAP fragment type mapping */
static const u8 sparx5_vcap_frag_map[4][4] = { /* is_frag */
{ FRAG_INVAL, FRAG_INVAL, FRAG_INVAL, FRAG_FIRST }, /* 0/0 */
{ FRAG_NOT, FRAG_NOT, FRAG_INVAL, FRAG_INVAL }, /* 0/1 */
{ FRAG_INVAL, FRAG_INVAL, FRAG_INVAL, FRAG_INVAL }, /* 1/0 */
{ FRAG_SOME, FRAG_LATER, FRAG_INVAL, FRAG_FIRST } /* 1/1 */
/* 0/0 0/1 1/0 1/1 <-- first_frag */
};
static int
sparx5_tc_flower_es0_tpid(struct vcap_tc_flower_parse_usage *st)
{
int err = 0;
switch (st->tpid) {
case ETH_P_8021Q:
err = vcap_rule_add_key_u32(st->vrule,
VCAP_KF_8021Q_TPID,
SPX5_TPID_SEL_8100, ~0);
break;
case ETH_P_8021AD:
err = vcap_rule_add_key_u32(st->vrule,
VCAP_KF_8021Q_TPID,
SPX5_TPID_SEL_88A8, ~0);
break;
default:
NL_SET_ERR_MSG_MOD(st->fco->common.extack,
"Invalid vlan proto");
err = -EINVAL;
break;
}
return err;
}
static int
sparx5_tc_flower_handler_basic_usage(struct vcap_tc_flower_parse_usage *st)
{
struct flow_match_basic mt;
int err = 0;
flow_rule_match_basic(st->frule, &mt);
if (mt.mask->n_proto) {
st->l3_proto = be16_to_cpu(mt.key->n_proto);
if (!sparx5_vcap_is_known_etype(st->admin, st->l3_proto)) {
err = vcap_rule_add_key_u32(st->vrule, VCAP_KF_ETYPE,
st->l3_proto, ~0);
if (err)
goto out;
} else if (st->l3_proto == ETH_P_IP) {
err = vcap_rule_add_key_bit(st->vrule, VCAP_KF_IP4_IS,
VCAP_BIT_1);
if (err)
goto out;
} else if (st->l3_proto == ETH_P_IPV6) {
err = vcap_rule_add_key_bit(st->vrule, VCAP_KF_IP4_IS,
VCAP_BIT_0);
if (err)
goto out;
Annotation
- Immediate include surface: `net/tc_act/tc_gate.h`, `net/tcp.h`, `sparx5_tc.h`, `vcap_api.h`, `vcap_api_client.h`, `vcap_tc.h`, `sparx5_main.h`, `sparx5_vcap_impl.h`.
- Detected declarations: `struct sparx5_wildcard_rule`, `struct sparx5_multiple_rules`, `struct sparx5_tc_flower_template`, `function sparx5_tc_flower_es0_tpid`, `function sparx5_tc_flower_handler_basic_usage`, `function sparx5_tc_flower_handler_control_usage`, `function sparx5_tc_flower_handler_cvlan_usage`, `function sparx5_tc_flower_handler_vlan_usage`, `function sparx5_tc_use_dissectors`, `function sparx5_tc_flower_action_check`.
- 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.