drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_meter.c- Extension
.c- Size
- 12911 bytes
- Lines
- 461
- 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.
- 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
en/tc_priv.hpost_meter.hen/tc/post_act.h
Detected Declarations
struct mlx5e_post_meter_rate_tablestruct mlx5e_post_meter_mtu_tablestruct mlx5e_post_meter_mtu_tablesstruct mlx5e_post_meter_privfunction mlx5e_post_meter_get_ftfunction mlx5e_post_meter_get_mtu_true_ftfunction mlx5e_post_meter_get_mtu_false_ftfunction mlx5e_post_meter_table_createfunction mlx5e_post_meter_rate_fg_createfunction mlx5e_post_meter_add_rulefunction mlx5e_post_meter_rate_rules_createfunction mlx5e_post_meter_rate_rules_destroyfunction mlx5e_post_meter_rate_fg_destroyfunction mlx5e_post_meter_rate_table_destroyfunction mlx5e_post_meter_mtu_rules_destroyfunction mlx5e_post_meter_mtu_fg_destroyfunction mlx5e_post_meter_mtu_table_destroyfunction mlx5e_post_meter_rate_createfunction mlx5e_post_meter_create_mtu_tablefunction mlx5e_post_meter_mtu_createfunction mlx5e_post_meter_initfunction mlx5e_post_meter_rate_destroyfunction mlx5e_post_meter_mtu_destroyfunction mlx5e_post_meter_cleanup
Annotated Snippet
struct mlx5e_post_meter_rate_table {
struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg;
struct mlx5_flow_handle *green_rule;
struct mlx5_flow_attr *green_attr;
struct mlx5_flow_handle *red_rule;
struct mlx5_flow_attr *red_attr;
};
struct mlx5e_post_meter_mtu_table {
struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg;
struct mlx5_flow_handle *rule;
struct mlx5_flow_attr *attr;
};
struct mlx5e_post_meter_mtu_tables {
struct mlx5e_post_meter_mtu_table green_table;
struct mlx5e_post_meter_mtu_table red_table;
};
struct mlx5e_post_meter_priv {
enum mlx5e_post_meter_type type;
union {
struct mlx5e_post_meter_rate_table rate_steering_table;
struct mlx5e_post_meter_mtu_tables mtu_tables;
};
};
struct mlx5_flow_table *
mlx5e_post_meter_get_ft(struct mlx5e_post_meter_priv *post_meter)
{
return post_meter->rate_steering_table.ft;
}
struct mlx5_flow_table *
mlx5e_post_meter_get_mtu_true_ft(struct mlx5e_post_meter_priv *post_meter)
{
return post_meter->mtu_tables.green_table.ft;
}
struct mlx5_flow_table *
mlx5e_post_meter_get_mtu_false_ft(struct mlx5e_post_meter_priv *post_meter)
{
return post_meter->mtu_tables.red_table.ft;
}
static struct mlx5_flow_table *
mlx5e_post_meter_table_create(struct mlx5e_priv *priv,
enum mlx5_flow_namespace_type ns_type)
{
struct mlx5_flow_table_attr ft_attr = {};
struct mlx5_flow_namespace *root_ns;
root_ns = mlx5_get_flow_namespace(priv->mdev, ns_type);
if (!root_ns) {
mlx5_core_warn(priv->mdev, "Failed to get namespace for flow meter\n");
return ERR_PTR(-EOPNOTSUPP);
}
ft_attr.flags = MLX5_FLOW_TABLE_UNMANAGED;
ft_attr.prio = FDB_SLOW_PATH;
ft_attr.max_fte = 2;
ft_attr.level = 1;
return mlx5_create_flow_table(root_ns, &ft_attr);
}
static int
mlx5e_post_meter_rate_fg_create(struct mlx5e_priv *priv,
struct mlx5e_post_meter_priv *post_meter)
{
struct mlx5e_post_meter_rate_table *table = &post_meter->rate_steering_table;
int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in);
void *misc2, *match_criteria;
u32 *flow_group_in;
int err = 0;
flow_group_in = kvzalloc(inlen, GFP_KERNEL);
if (!flow_group_in)
return -ENOMEM;
MLX5_SET(create_flow_group_in, flow_group_in, match_criteria_enable,
MLX5_MATCH_MISC_PARAMETERS_2);
match_criteria = MLX5_ADDR_OF(create_flow_group_in, flow_group_in,
match_criteria);
misc2 = MLX5_ADDR_OF(fte_match_param, match_criteria, misc_parameters_2);
MLX5_SET(fte_match_set_misc2, misc2, metadata_reg_c_5, MLX5_PACKET_COLOR_MASK);
MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, 0);
MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, 1);
Annotation
- Immediate include surface: `en/tc_priv.h`, `post_meter.h`, `en/tc/post_act.h`.
- Detected declarations: `struct mlx5e_post_meter_rate_table`, `struct mlx5e_post_meter_mtu_table`, `struct mlx5e_post_meter_mtu_tables`, `struct mlx5e_post_meter_priv`, `function mlx5e_post_meter_get_ft`, `function mlx5e_post_meter_get_mtu_true_ft`, `function mlx5e_post_meter_get_mtu_false_ft`, `function mlx5e_post_meter_table_create`, `function mlx5e_post_meter_rate_fg_create`, `function mlx5e_post_meter_add_rule`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.