drivers/net/ethernet/netronome/nfp/flower/conntrack.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/flower/conntrack.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/flower/conntrack.c- Extension
.c- Size
- 66144 bytes
- Lines
- 2301
- 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_csum.hnet/tc_act/tc_ct.hconntrack.h../nfp_port.h
Detected Declarations
function get_hashentryfunction is_pre_ct_flowfunction flow_action_for_eachfunction is_post_ct_flowfunction flow_action_for_eachfunction get_mangled_keyfunction flow_action_for_eachfunction nfp_ct_merge_check_cannot_skipfunction nfp_ct_merge_checkfunction nfp_ct_merge_check_cannot_skipfunction nfp_ct_merge_check_cannot_skipfunction nfp_ct_merge_check_cannot_skipfunction nfp_ct_check_vlan_mergefunction nfp_ct_merge_extra_checkfunction nfp_ct_merge_act_checkfunction nfp_ct_check_metafunction nfp_fl_calc_key_layers_szfunction nfp_fl_get_csum_flagfunction nfp_fl_merge_actions_offloadfunction nfp_fl_ct_add_offloadfunction valuefunction nfp_fl_ct_del_offloadfunction nfp_ct_do_nft_mergefunction nfp_ct_do_tc_mergefunction nfp_nft_ct_translate_mangle_actionfunction nfp_nft_ct_set_flow_flagfunction cleanup_nft_merge_entryfunction nfp_free_nft_merge_childrenfunction list_for_each_entry_safefunction list_for_each_entry_safefunction nfp_del_tc_merge_entryfunction nfp_free_tc_merge_childrenfunction list_for_each_entry_safefunction nfp_fl_ct_clean_flow_entryfunction flow_action_for_eachfunction nfp_ct_merge_tc_entriesfunction list_for_each_entry_safefunction nfp_ct_merge_nft_with_tcfunction nfp_fl_ct_handle_pre_ctfunction nfp_fl_ct_handle_post_ctfunction flow_action_for_eachfunction nfp_fl_create_new_pre_ctfunction nfp_fl_ct_sub_statsfunction nfp_fl_ct_statsfunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safe
Annotated Snippet
if (act->id == FLOW_ACTION_CT) {
/* The pre_ct rule only have the ct or ct nat action, cannot
* contains other ct action e.g ct commit and so on.
*/
if ((!act->ct.action || act->ct.action == TCA_CT_ACT_NAT))
return true;
else
return false;
}
}
return false;
}
bool is_post_ct_flow(struct flow_cls_offload *flow)
{
struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
struct flow_dissector *dissector = rule->match.dissector;
struct flow_action_entry *act;
bool exist_ct_clear = false;
struct flow_match_ct ct;
int i;
if (dissector->used_keys & BIT_ULL(FLOW_DISSECTOR_KEY_CT)) {
flow_rule_match_ct(rule, &ct);
if (ct.key->ct_state & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED)
return true;
} else {
/* post ct entry cannot contains any ct action except ct_clear. */
flow_action_for_each(i, act, &flow->rule->action) {
if (act->id == FLOW_ACTION_CT) {
/* ignore ct clear action. */
if (act->ct.action == TCA_CT_ACT_CLEAR) {
exist_ct_clear = true;
continue;
}
return false;
}
}
/* when do nat with ct, the post ct entry ignore the ct status,
* will match the nat field(sip/dip) instead. In this situation,
* the flow chain index is not zero and contains ct clear action.
*/
if (flow->common.chain_index && exist_ct_clear)
return true;
}
return false;
}
/**
* get_mangled_key() - Mangle the key if mangle act exists
* @rule: rule that carries the actions
* @buf: pointer to key to be mangled
* @offset: used to adjust mangled offset in L2/L3/L4 header
* @key_sz: key size
* @htype: mangling type
*
* Returns buf where the mangled key stores.
*/
static void *get_mangled_key(struct flow_rule *rule, void *buf,
u32 offset, size_t key_sz,
enum flow_action_mangle_base htype)
{
struct flow_action_entry *act;
u32 *val = (u32 *)buf;
u32 off, msk, key;
int i;
flow_action_for_each(i, act, &rule->action) {
if (act->id == FLOW_ACTION_MANGLE &&
act->mangle.htype == htype) {
off = act->mangle.offset - offset;
msk = act->mangle.mask;
key = act->mangle.val;
/* Mangling is supposed to be u32 aligned */
if (off % 4 || off >= key_sz)
continue;
val[off >> 2] &= msk;
val[off >> 2] |= key;
}
}
return buf;
}
/* Only tos and ttl are involved in flow_match_ip structure, which
Annotation
- Immediate include surface: `net/tc_act/tc_csum.h`, `net/tc_act/tc_ct.h`, `conntrack.h`, `../nfp_port.h`.
- Detected declarations: `function get_hashentry`, `function is_pre_ct_flow`, `function flow_action_for_each`, `function is_post_ct_flow`, `function flow_action_for_each`, `function get_mangled_key`, `function flow_action_for_each`, `function nfp_ct_merge_check_cannot_skip`, `function nfp_ct_merge_check`, `function nfp_ct_merge_check_cannot_skip`.
- 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.