drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c- Extension
.c- Size
- 164157 bytes
- Lines
- 5906
- 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/flow_dissector.hnet/flow_offload.hnet/sch_generic.hnet/pkt_cls.hlinux/mlx5/fs.hlinux/mlx5/lag.hlinux/mlx5/device.hlinux/rhashtable.hlinux/refcount.hlinux/completion.hnet/arp.hnet/bareudp.hnet/bonding.hnet/dst_metadata.hdevlink.hen.hen/tc/post_act.hen/tc/act_stats.hen_rep.hen/rep/tc.hen/rep/neigh.hen_tc.heswitch.hfs_core.hen/port.hen/tc_tun.hen/mapping.hen/tc_ct.hen/mod_hdr.hen/tc_tun_encap.hen/tc/sample.hen/tc/act/act.h
Detected Declarations
struct mlx5e_tc_tablestruct mlx5e_tc_jump_statestruct mlx5e_hairpinstruct mlx5e_hairpin_entrystruct mlx5_fieldsstruct ip_ttl_wordstruct ipv6_hoplimit_wordfunction mlx5e_tc_table_freefunction mlx5e_tc_match_to_reg_matchfunction mlx5e_tc_match_to_reg_get_matchfunction mlx5e_tc_match_to_reg_set_and_get_idfunction get_act_stats_handlefunction mlx5e_get_int_port_privfunction mlx5e_get_flow_metersfunction get_ct_privfunction get_sample_privfunction get_post_actionfunction mlx5_tc_rule_insertfunction mlx5_tc_rule_deletefunction is_flow_meter_actionfunction mlx5e_tc_add_flow_meterfunction mlx5e_tc_del_flow_meterfunction mlx5e_tc_rule_offloadfunction mlx5e_tc_rule_unoffloadfunction mlx5e_tc_match_to_reg_setfunction mlx5e_tc_match_to_reg_mod_hdr_changefunction mlx5e_flow_putfunction mlx5e_is_eswitch_flowfunction mlx5e_is_ft_flowfunction mlx5e_is_offloaded_flowfunction mlx5e_get_flow_namespacefunction get_flow_counter_devfunction get_mod_hdr_tablefunction mlx5e_tc_attach_mod_hdrfunction mlx5e_tc_detach_mod_hdrfunction mlx5e_hairpin_create_transportfunction mlx5e_hairpin_destroy_transportfunction mlx5e_hairpin_create_indirect_rqtfunction mlx5e_hairpin_create_indirect_tirsfunction mlx5e_hairpin_destroy_indirect_tirsfunction mlx5e_hairpin_set_ttc_paramsfunction mlx5e_hairpin_rss_initfunction mlx5e_hairpin_rss_cleanupfunction mlx5e_hairpin_createfunction mlx5e_hairpin_destroyfunction hash_hairpin_infofunction hash_for_each_possiblefunction mlx5e_hairpin_put
Annotated Snippet
struct mlx5e_tc_table {
/* Protects the dynamic assignment of the t parameter
* which is the nic tc root table.
*/
struct mutex t_lock;
struct mlx5e_priv *priv;
struct mlx5_flow_table *t;
struct mlx5_flow_table *miss_t;
struct mlx5_fs_chains *chains;
struct mlx5e_post_act *post_act;
struct rhashtable ht;
struct mod_hdr_tbl mod_hdr;
struct mutex hairpin_tbl_lock; /* protects hairpin_tbl */
DECLARE_HASHTABLE(hairpin_tbl, 8);
struct notifier_block netdevice_nb;
struct netdev_net_notifier netdevice_nn;
struct mlx5_tc_ct_priv *ct;
struct mapping_ctx *mapping;
struct dentry *dfs_root;
/* tc action stats */
struct mlx5e_tc_act_stats_handle *action_stats_handle;
};
struct mlx5e_tc_attr_to_reg_mapping mlx5e_tc_attr_to_reg_mappings[] = {
[MAPPED_OBJ_TO_REG] = {
.mfield = MLX5_ACTION_IN_FIELD_METADATA_REG_C_0,
.moffset = 0,
.mlen = 16,
},
[VPORT_TO_REG] = {
.mfield = MLX5_ACTION_IN_FIELD_METADATA_REG_C_0,
.moffset = 16,
.mlen = 16,
},
[TUNNEL_TO_REG] = {
.mfield = MLX5_ACTION_IN_FIELD_METADATA_REG_C_1,
.moffset = 8,
.mlen = ESW_TUN_OPTS_BITS + ESW_TUN_ID_BITS,
.soffset = MLX5_BYTE_OFF(fte_match_param,
misc_parameters_2.metadata_reg_c_1),
},
[ZONE_TO_REG] = zone_to_reg_ct,
[ZONE_RESTORE_TO_REG] = zone_restore_to_reg_ct,
[CTSTATE_TO_REG] = ctstate_to_reg_ct,
[MARK_TO_REG] = mark_to_reg_ct,
[LABELS_TO_REG] = labels_to_reg_ct,
[FTEID_TO_REG] = fteid_to_reg_ct,
/* For NIC rules we store the restore metadata directly
* into reg_b that is passed to SW since we don't
* jump between steering domains.
*/
[NIC_MAPPED_OBJ_TO_REG] = {
.mfield = MLX5_ACTION_IN_FIELD_METADATA_REG_B,
.moffset = 0,
.mlen = 16,
},
[NIC_ZONE_RESTORE_TO_REG] = nic_zone_restore_to_reg_ct,
[PACKET_COLOR_TO_REG] = packet_color_to_reg,
};
struct mlx5e_tc_jump_state {
u32 jump_count;
bool jump_target;
struct mlx5_flow_attr *jumping_attr;
enum flow_action_id last_id;
u32 last_index;
};
struct mlx5e_tc_table *mlx5e_tc_table_alloc(void)
{
struct mlx5e_tc_table *tc;
tc = kvzalloc_obj(*tc);
return tc ? tc : ERR_PTR(-ENOMEM);
}
void mlx5e_tc_table_free(struct mlx5e_tc_table *tc)
{
kvfree(tc);
}
struct mlx5_fs_chains *mlx5e_nic_chains(struct mlx5e_tc_table *tc)
{
return tc->chains;
Annotation
- Immediate include surface: `net/flow_dissector.h`, `net/flow_offload.h`, `net/sch_generic.h`, `net/pkt_cls.h`, `linux/mlx5/fs.h`, `linux/mlx5/lag.h`, `linux/mlx5/device.h`, `linux/rhashtable.h`.
- Detected declarations: `struct mlx5e_tc_table`, `struct mlx5e_tc_jump_state`, `struct mlx5e_hairpin`, `struct mlx5e_hairpin_entry`, `struct mlx5_fields`, `struct ip_ttl_word`, `struct ipv6_hoplimit_word`, `function mlx5e_tc_table_free`, `function mlx5e_tc_match_to_reg_match`, `function mlx5e_tc_match_to_reg_get_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.