drivers/net/ethernet/sfc/tc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/tc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/tc.c- Extension
.c- Size
- 95191 bytes
- Lines
- 3095
- 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/vxlan.hnet/geneve.hnet/tc_act/tc_ct.htc.htc_bindings.htc_encap_actions.htc_conntrack.hmae.hef100_rep.hefx.h
Detected Declarations
struct efx_tc_mangler_stateenum efx_tc_action_orderfunction efx_tc_indr_netdev_typefunction PFfunction efx_tc_flower_internal_mportfunction efx_tc_flower_external_mportfunction efx_tc_flower_put_macfunction efx_tc_free_action_setfunction efx_tc_free_action_set_listfunction efx_tc_flower_parse_matchfunction BIT_ULLfunction BIT_ULLfunction efx_tc_flower_release_encap_matchfunction efx_tc_flower_record_encap_matchfunction efx_tc_put_recirc_idfunction efx_tc_delete_rulefunction efx_tc_flower_action_order_okfunction efx_tc_rule_is_lhs_rulefunction flow_action_for_eachfunction efx_tc_flower_flhs_needs_arfunction efx_tc_flower_flhs_needs_arfunction efx_tc_flower_handle_lhs_actionsfunction flow_action_for_eachfunction efx_tc_flower_release_lhs_actionsfunction efx_tc_complete_mac_manglefunction efx_tc_pedit_addfunction efx_tc_manglefunction efx_tc_incomplete_manglefunction efx_tc_flower_replace_foreign_lhs_arfunction efx_tc_flower_replace_foreign_lhsfunction efx_tc_flower_replace_foreignfunction flow_action_for_eachfunction efx_tc_flower_replacefunction efx_tc_flower_replace_lhsfunction efx_tc_flower_replacefunction memsetfunction actionfunction gactfunction efx_tc_flower_destroyfunction efx_tc_flower_statsfunction efx_tc_flowerfunction efx_tc_configure_default_rulefunction efx_tc_configure_default_rule_pffunction efx_tc_configure_default_rule_wirefunction efx_tc_configure_default_rule_repfunction efx_tc_deconfigure_default_rulefunction efx_tc_configure_fallback_actsfunction efx_tc_configure_fallback_acts_pf
Annotated Snippet
struct efx_tc_mangler_state {
u8 dst_mac_32:1; /* eth->h_dest[0:3] */
u8 dst_mac_16:1; /* eth->h_dest[4:5] */
u8 src_mac_16:1; /* eth->h_source[0:1] */
u8 src_mac_32:1; /* eth->h_source[2:5] */
unsigned char dst_mac[ETH_ALEN];
unsigned char src_mac[ETH_ALEN];
};
/** efx_tc_complete_mac_mangle() - pull complete field pedits out of @mung
* @efx: NIC we're installing a flow rule on
* @act: action set (cursor) to update
* @mung: accumulated partial mangles
* @extack: netlink extended ack for reporting errors
*
* Check @mung to find any combinations of partial mangles that can be
* combined into a complete packet field edit, add that edit to @act,
* and consume the partial mangles from @mung.
*/
static int efx_tc_complete_mac_mangle(struct efx_nic *efx,
struct efx_tc_action_set *act,
struct efx_tc_mangler_state *mung,
struct netlink_ext_ack *extack)
{
struct efx_tc_mac_pedit_action *ped;
if (mung->dst_mac_32 && mung->dst_mac_16) {
ped = efx_tc_flower_get_mac(efx, mung->dst_mac, extack);
if (IS_ERR(ped))
return PTR_ERR(ped);
/* Check that we have not already populated dst_mac */
if (act->dst_mac)
efx_tc_flower_put_mac(efx, act->dst_mac);
act->dst_mac = ped;
/* consume the incomplete state */
mung->dst_mac_32 = 0;
mung->dst_mac_16 = 0;
}
if (mung->src_mac_16 && mung->src_mac_32) {
ped = efx_tc_flower_get_mac(efx, mung->src_mac, extack);
if (IS_ERR(ped))
return PTR_ERR(ped);
/* Check that we have not already populated src_mac */
if (act->src_mac)
efx_tc_flower_put_mac(efx, act->src_mac);
act->src_mac = ped;
/* consume the incomplete state */
mung->src_mac_32 = 0;
mung->src_mac_16 = 0;
}
return 0;
}
static int efx_tc_pedit_add(struct efx_nic *efx, struct efx_tc_action_set *act,
const struct flow_action_entry *fa,
struct netlink_ext_ack *extack)
{
switch (fa->mangle.htype) {
case FLOW_ACT_MANGLE_HDR_TYPE_IP4:
switch (fa->mangle.offset) {
case offsetof(struct iphdr, ttl):
/* check that pedit applies to ttl only */
if (fa->mangle.mask != ~EFX_TC_HDR_TYPE_TTL_MASK)
break;
/* Adding 0xff is equivalent to decrementing the ttl.
* Other added values are not supported.
*/
if ((fa->mangle.val & EFX_TC_HDR_TYPE_TTL_MASK) != U8_MAX)
break;
/* check that we do not decrement ttl twice */
if (!efx_tc_flower_action_order_ok(act,
EFX_TC_AO_DEC_TTL)) {
NL_SET_ERR_MSG_MOD(extack, "multiple dec ttl are not supported");
return -EOPNOTSUPP;
}
act->do_ttl_dec = 1;
return 0;
default:
break;
}
break;
Annotation
- Immediate include surface: `net/pkt_cls.h`, `net/vxlan.h`, `net/geneve.h`, `net/tc_act/tc_ct.h`, `tc.h`, `tc_bindings.h`, `tc_encap_actions.h`, `tc_conntrack.h`.
- Detected declarations: `struct efx_tc_mangler_state`, `enum efx_tc_action_order`, `function efx_tc_indr_netdev_type`, `function PF`, `function efx_tc_flower_internal_mport`, `function efx_tc_flower_external_mport`, `function efx_tc_flower_put_mac`, `function efx_tc_free_action_set`, `function efx_tc_free_action_set_list`, `function efx_tc_flower_parse_match`.
- 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.