drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c- Extension
.c- Size
- 30485 bytes
- Lines
- 1150
- 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/tc_act/tc_mirred.hnet/tc_act/tc_pedit.hnet/tc_act/tc_gact.hnet/tc_act/tc_vlan.hcxgb4.hcxgb4_filter.hcxgb4_tc_flower.h
Detected Declarations
function cxgb4_action_natmode_tweakfunction cxgb4_process_flow_matchfunction cxgb4_validate_flow_matchfunction offload_peditfunction process_pedit_fieldfunction cxgb4_action_natmode_validatefunction cxgb4_process_flow_actionsfunction flow_action_for_eachfunction valid_l4_maskfunction valid_pedit_actionfunction cxgb4_validate_flow_actionsfunction flow_action_for_eachfunction for_each_portfunction cxgb4_tc_flower_hash_prio_addfunction cxgb4_tc_flower_hash_prio_delfunction cxgb4_flow_rule_replacefunction cxgb4_tc_flower_replacefunction cxgb4_flow_rule_destroyfunction cxgb4_tc_flower_destroyfunction ch_flower_stats_handlerfunction ch_flower_stats_cbfunction cxgb4_tc_flower_statsfunction cxgb4_init_tc_flowerfunction cxgb4_cleanup_tc_flower
Annotated Snippet
if (cxgb4_natmode_config_array[i].flags == natmode_flags) {
fs->nat_mode = cxgb4_natmode_config_array[i].natmode;
return;
}
}
}
static struct ch_tc_flower_entry *allocate_flower_entry(void)
{
struct ch_tc_flower_entry *new = kzalloc_obj(*new);
if (new)
spin_lock_init(&new->lock);
return new;
}
/* Must be called with either RTNL or rcu_read_lock */
static struct ch_tc_flower_entry *ch_flower_lookup(struct adapter *adap,
unsigned long flower_cookie)
{
return rhashtable_lookup_fast(&adap->flower_tbl, &flower_cookie,
adap->flower_ht_params);
}
static void cxgb4_process_flow_match(struct net_device *dev,
struct flow_rule *rule,
u16 addr_type,
struct ch_filter_specification *fs)
{
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_match_basic match;
u16 ethtype_key, ethtype_mask;
flow_rule_match_basic(rule, &match);
ethtype_key = ntohs(match.key->n_proto);
ethtype_mask = ntohs(match.mask->n_proto);
if (ethtype_key == ETH_P_ALL) {
ethtype_key = 0;
ethtype_mask = 0;
}
if (ethtype_key == ETH_P_IPV6)
fs->type = 1;
fs->val.ethtype = ethtype_key;
fs->mask.ethtype = ethtype_mask;
fs->val.proto = match.key->ip_proto;
fs->mask.proto = match.mask->ip_proto;
}
if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
struct flow_match_ipv4_addrs match;
flow_rule_match_ipv4_addrs(rule, &match);
fs->type = 0;
memcpy(&fs->val.lip[0], &match.key->dst, sizeof(match.key->dst));
memcpy(&fs->val.fip[0], &match.key->src, sizeof(match.key->src));
memcpy(&fs->mask.lip[0], &match.mask->dst, sizeof(match.mask->dst));
memcpy(&fs->mask.fip[0], &match.mask->src, sizeof(match.mask->src));
/* also initialize nat_lip/fip to same values */
memcpy(&fs->nat_lip[0], &match.key->dst, sizeof(match.key->dst));
memcpy(&fs->nat_fip[0], &match.key->src, sizeof(match.key->src));
}
if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
struct flow_match_ipv6_addrs match;
flow_rule_match_ipv6_addrs(rule, &match);
fs->type = 1;
memcpy(&fs->val.lip[0], match.key->dst.s6_addr,
sizeof(match.key->dst));
memcpy(&fs->val.fip[0], match.key->src.s6_addr,
sizeof(match.key->src));
memcpy(&fs->mask.lip[0], match.mask->dst.s6_addr,
sizeof(match.mask->dst));
memcpy(&fs->mask.fip[0], match.mask->src.s6_addr,
sizeof(match.mask->src));
/* also initialize nat_lip/fip to same values */
memcpy(&fs->nat_lip[0], match.key->dst.s6_addr,
sizeof(match.key->dst));
memcpy(&fs->nat_fip[0], match.key->src.s6_addr,
sizeof(match.key->src));
}
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
struct flow_match_ports match;
Annotation
- Immediate include surface: `net/tc_act/tc_mirred.h`, `net/tc_act/tc_pedit.h`, `net/tc_act/tc_gact.h`, `net/tc_act/tc_vlan.h`, `cxgb4.h`, `cxgb4_filter.h`, `cxgb4_tc_flower.h`.
- Detected declarations: `function cxgb4_action_natmode_tweak`, `function cxgb4_process_flow_match`, `function cxgb4_validate_flow_match`, `function offload_pedit`, `function process_pedit_field`, `function cxgb4_action_natmode_validate`, `function cxgb4_process_flow_actions`, `function flow_action_for_each`, `function valid_l4_mask`, `function valid_pedit_action`.
- 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.