drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/lib/fs_ttc.c- Extension
.c- Size
- 28722 bytes
- Lines
- 1141
- 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/ip.hlinux/ipv6.hlinux/tcp.hlinux/mlx5/fs.hlinux/mlx5/driver.hmlx5_core.hlib/fs_ttc.h
Detected Declarations
struct mlx5_fs_ttc_groupsstruct mlx5_ttc_tablestruct mlx5_etype_protoenum TTC_GROUP_TYPEfunction mlx5_fs_ttc_table_sizefunction mlx5_cleanup_ttc_rulesfunction mlx5_ttc_get_fs_groupsfunction mlx5_ttc_has_esp_flow_groupfunction mlx5_get_proto_by_tunnel_typefunction mlx5_tunnel_proto_supported_rxfunction mlx5_tunnel_any_rx_proto_supportedfunction mlx5_tunnel_inner_ft_supportedfunction mlx5_etype_to_ipvfunction mlx5_fs_ttc_set_match_ipv_outerfunction mlx5_fs_ttc_set_match_protofunction mlx5_generate_ttc_rulefunction mlx5_generate_ttc_table_rulesfunction mlx5_create_ttc_table_ipsec_groupsfunction mlx5_create_ttc_table_groupsfunction mlx5_generate_inner_ttc_rulefunction mlx5_generate_inner_ttc_table_rulesfunction mlx5_create_inner_ttc_table_groupsfunction mlx5_destroy_ttc_tablefunction mlx5_ttc_fwd_destfunction mlx5_ttc_get_default_destfunction mlx5_ttc_fwd_default_destfunction _mlx5_ttc_destroy_ipsec_rulesfunction mlx5_ttc_destroy_ipsec_rulesfunction mlx5_ttc_get_tt_attrsfunction mlx5_ttc_create_ipsec_outer_rulefunction mlx5_ttc_create_ipsec_inner_rulefunction mlx5_ttc_create_ipsec_rules
Annotated Snippet
struct mlx5_fs_ttc_groups {
bool use_l4_type;
int num_groups;
int group_size[MLX5_TTC_MAX_NUM_GROUPS];
};
static int mlx5_fs_ttc_table_size(const struct mlx5_fs_ttc_groups *groups)
{
int i, sz = 0;
for (i = 0; i < groups->num_groups; i++)
sz += groups->group_size[i];
return sz;
}
/* L3/L4 traffic type classifier */
struct mlx5_ttc_table {
int num_groups;
const struct mlx5_fs_ttc_groups *groups;
struct mlx5_core_dev *mdev;
struct mlx5_flow_table *t;
struct mlx5_flow_group **g;
struct mlx5_ttc_rule rules[MLX5_NUM_TT];
struct mlx5_flow_handle *tunnel_rules[MLX5_NUM_TUNNEL_TT];
u32 refcnt;
struct mutex mutex; /* Protect adding rules for ipsec crypto offload */
};
struct mlx5_flow_table *mlx5_get_ttc_flow_table(struct mlx5_ttc_table *ttc)
{
return ttc->t;
}
static void mlx5_cleanup_ttc_rules(struct mlx5_ttc_table *ttc)
{
int i;
for (i = 0; i < MLX5_NUM_TT; i++) {
if (!IS_ERR_OR_NULL(ttc->rules[i].rule)) {
mlx5_del_flow_rules(ttc->rules[i].rule);
ttc->rules[i].rule = NULL;
}
}
for (i = 0; i < MLX5_NUM_TUNNEL_TT; i++) {
if (!IS_ERR_OR_NULL(ttc->tunnel_rules[i])) {
mlx5_del_flow_rules(ttc->tunnel_rules[i]);
ttc->tunnel_rules[i] = NULL;
}
}
}
static const char *mlx5_traffic_types_names[MLX5_NUM_TT] = {
[MLX5_TT_IPV4_TCP] = "TT_IPV4_TCP",
[MLX5_TT_IPV6_TCP] = "TT_IPV6_TCP",
[MLX5_TT_IPV4_UDP] = "TT_IPV4_UDP",
[MLX5_TT_IPV6_UDP] = "TT_IPV6_UDP",
[MLX5_TT_IPV4_IPSEC_AH] = "TT_IPV4_IPSEC_AH",
[MLX5_TT_IPV6_IPSEC_AH] = "TT_IPV6_IPSEC_AH",
[MLX5_TT_IPV4_IPSEC_ESP] = "TT_IPV4_IPSEC_ESP",
[MLX5_TT_IPV6_IPSEC_ESP] = "TT_IPV6_IPSEC_ESP",
[MLX5_TT_IPV4] = "TT_IPV4",
[MLX5_TT_IPV6] = "TT_IPV6",
[MLX5_TT_ANY] = "TT_ANY"
};
const char *mlx5_ttc_get_name(enum mlx5_traffic_types tt)
{
return mlx5_traffic_types_names[tt];
}
struct mlx5_etype_proto {
u16 etype;
u8 proto;
};
static struct mlx5_etype_proto ttc_rules[] = {
[MLX5_TT_IPV4_TCP] = {
.etype = ETH_P_IP,
.proto = IPPROTO_TCP,
},
[MLX5_TT_IPV6_TCP] = {
.etype = ETH_P_IPV6,
.proto = IPPROTO_TCP,
},
[MLX5_TT_IPV4_UDP] = {
.etype = ETH_P_IP,
.proto = IPPROTO_UDP,
},
Annotation
- Immediate include surface: `linux/ip.h`, `linux/ipv6.h`, `linux/tcp.h`, `linux/mlx5/fs.h`, `linux/mlx5/driver.h`, `mlx5_core.h`, `lib/fs_ttc.h`.
- Detected declarations: `struct mlx5_fs_ttc_groups`, `struct mlx5_ttc_table`, `struct mlx5_etype_proto`, `enum TTC_GROUP_TYPE`, `function mlx5_fs_ttc_table_size`, `function mlx5_cleanup_ttc_rules`, `function mlx5_ttc_get_fs_groups`, `function mlx5_ttc_has_esp_flow_group`, `function mlx5_get_proto_by_tunnel_type`, `function mlx5_tunnel_proto_supported_rx`.
- 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.