drivers/net/ethernet/netronome/nfp/flower/offload.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/flower/offload.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/flower/offload.c- Extension
.c- Size
- 57181 bytes
- Lines
- 1979
- 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
linux/skbuff.hnet/devlink.hnet/pkt_cls.hcmsg.hmain.hconntrack.h../nfpcore/nfp_cpp.h../nfpcore/nfp_nsp.h../nfp_app.h../nfp_main.h../nfp_net.h../nfp_port.h
Detected Declarations
struct nfp_flower_merge_checkstruct nfp_flower_indr_block_cb_privfunction nfp_flower_xmit_flowfunction nfp_flower_check_higher_than_macfunction nfp_flower_check_higher_than_l3function nfp_flower_calc_opt_layerfunction nfp_flower_calc_udp_tun_layerfunction htonsfunction nfp_flower_calculate_key_layersfunction cpu_to_be16function nfp_flower_allocate_newfunction nfp_flower_update_merge_with_actionsfunction nfp_flower_populate_merge_matchfunction nfp_flower_can_mergefunction nfp_flower_copy_pre_actionsfunction nfp_fl_verify_post_tun_actsfunction nfp_fl_push_vlan_after_tunfunction nfp_flower_merge_actionfunction nfp_flower_unlink_flowfunction nfp_flower_unlink_flowsfunction list_for_each_entryfunction nfp_flower_link_flowsfunction nfp_flower_merge_offloaded_flowsfunction nfp_flower_validate_pre_tun_rulefunction offload_pre_checkfunction nfp_flower_add_offloadfunction nfp_flower_remove_merge_flowfunction nfp_flower_del_linked_merge_flowsfunction nfp_flower_del_offloadfunction __nfp_flower_update_merge_statsfunction nfp_flower_update_merge_statsfunction nfp_flower_get_statsfunction nfp_flower_repr_offloadfunction nfp_flower_setup_tc_block_cbfunction nfp_flower_setup_tc_blockfunction nfp_flower_setup_tcfunction nfp_flower_indr_block_cb_priv_lookupfunction nfp_flower_setup_indr_block_cbfunction nfp_flower_setup_indr_tc_releasefunction nfp_flower_setup_indr_tc_blockfunction nfp_setup_tc_no_devfunction nfp_flower_indr_setup_tc_cb
Annotated Snippet
struct nfp_flower_merge_check {
union {
struct {
__be16 tci;
struct nfp_flower_mac_mpls l2;
struct nfp_flower_tp_ports l4;
union {
struct nfp_flower_ipv4 ipv4;
struct nfp_flower_ipv6 ipv6;
};
};
unsigned long vals[8];
};
};
int
nfp_flower_xmit_flow(struct nfp_app *app, struct nfp_fl_payload *nfp_flow,
u8 mtype)
{
u32 meta_len, key_len, mask_len, act_len, tot_len;
struct sk_buff *skb;
unsigned char *msg;
meta_len = sizeof(struct nfp_fl_rule_metadata);
key_len = nfp_flow->meta.key_len;
mask_len = nfp_flow->meta.mask_len;
act_len = nfp_flow->meta.act_len;
tot_len = meta_len + key_len + mask_len + act_len;
/* Convert to long words as firmware expects
* lengths in units of NFP_FL_LW_SIZ.
*/
nfp_flow->meta.key_len >>= NFP_FL_LW_SIZ;
nfp_flow->meta.mask_len >>= NFP_FL_LW_SIZ;
nfp_flow->meta.act_len >>= NFP_FL_LW_SIZ;
skb = nfp_flower_cmsg_alloc(app, tot_len, mtype, GFP_KERNEL);
if (!skb)
return -ENOMEM;
msg = nfp_flower_cmsg_get_data(skb);
memcpy(msg, &nfp_flow->meta, meta_len);
memcpy(&msg[meta_len], nfp_flow->unmasked_data, key_len);
memcpy(&msg[meta_len + key_len], nfp_flow->mask_data, mask_len);
memcpy(&msg[meta_len + key_len + mask_len],
nfp_flow->action_data, act_len);
/* Convert back to bytes as software expects
* lengths in units of bytes.
*/
nfp_flow->meta.key_len <<= NFP_FL_LW_SIZ;
nfp_flow->meta.mask_len <<= NFP_FL_LW_SIZ;
nfp_flow->meta.act_len <<= NFP_FL_LW_SIZ;
nfp_ctrl_tx(app->ctrl, skb);
return 0;
}
static bool nfp_flower_check_higher_than_mac(struct flow_rule *rule)
{
return flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS) ||
flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS) ||
flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS) ||
flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP);
}
static bool nfp_flower_check_higher_than_l3(struct flow_rule *rule)
{
return flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS) ||
flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP);
}
static int
nfp_flower_calc_opt_layer(struct flow_dissector_key_enc_opts *enc_opts,
u32 *key_layer_two, int *key_size, bool ipv6,
struct netlink_ext_ack *extack)
{
if (enc_opts->len > NFP_FL_MAX_GENEVE_OPT_KEY ||
(ipv6 && enc_opts->len > NFP_FL_MAX_GENEVE_OPT_KEY_V6)) {
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: geneve options exceed maximum length");
return -EOPNOTSUPP;
}
if (enc_opts->len > 0) {
*key_layer_two |= NFP_FLOWER_LAYER2_GENEVE_OP;
*key_size += sizeof(struct nfp_flower_geneve_options);
}
Annotation
- Immediate include surface: `linux/skbuff.h`, `net/devlink.h`, `net/pkt_cls.h`, `cmsg.h`, `main.h`, `conntrack.h`, `../nfpcore/nfp_cpp.h`, `../nfpcore/nfp_nsp.h`.
- Detected declarations: `struct nfp_flower_merge_check`, `struct nfp_flower_indr_block_cb_priv`, `function nfp_flower_xmit_flow`, `function nfp_flower_check_higher_than_mac`, `function nfp_flower_check_higher_than_l3`, `function nfp_flower_calc_opt_layer`, `function nfp_flower_calc_udp_tun_layer`, `function htons`, `function nfp_flower_calculate_key_layers`, `function cpu_to_be16`.
- 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.