Commit 3fcb94e3 authored by Oz Shlomo's avatar Oz Shlomo Committed by Jakub Kicinski

net/mlx5e: TC, rename post_meter actions

Currently post meter supports only the pipe/drop conform-exceed policy.
This assumption is reflected in several variable names.
Rename the following variables as a pre-step for using the generalized
branching action platform.

Rename fwd_green_rule/drop_red_rule to green_rule/red_rule respectively.
Repurpose red_counter/green_counter to act_counter/drop_counter to allow
police conform-exceed configurations that do not drop.
Signed-off-by: default avatarOz Shlomo <ozsh@nvidia.com>
Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Link: https://lore.kernel.org/r/20221203221337.29267-10-saeed@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c84fa1ab
......@@ -257,16 +257,16 @@ __mlx5e_flow_meter_alloc(struct mlx5e_flow_meters *flow_meters)
counter = mlx5_fc_create(mdev, true);
if (IS_ERR(counter)) {
err = PTR_ERR(counter);
goto err_red_counter;
goto err_drop_counter;
}
meter->red_counter = counter;
meter->drop_counter = counter;
counter = mlx5_fc_create(mdev, true);
if (IS_ERR(counter)) {
err = PTR_ERR(counter);
goto err_green_counter;
goto err_act_counter;
}
meter->green_counter = counter;
meter->act_counter = counter;
meters_obj = list_first_entry_or_null(&flow_meters->partial_list,
struct mlx5e_flow_meter_aso_obj,
......@@ -313,10 +313,10 @@ __mlx5e_flow_meter_alloc(struct mlx5e_flow_meters *flow_meters)
err_mem:
mlx5e_flow_meter_destroy_aso_obj(mdev, id);
err_create:
mlx5_fc_destroy(mdev, meter->green_counter);
err_green_counter:
mlx5_fc_destroy(mdev, meter->red_counter);
err_red_counter:
mlx5_fc_destroy(mdev, meter->act_counter);
err_act_counter:
mlx5_fc_destroy(mdev, meter->drop_counter);
err_drop_counter:
kfree(meter);
return ERR_PTR(err);
}
......@@ -329,8 +329,8 @@ __mlx5e_flow_meter_free(struct mlx5e_flow_meter_handle *meter)
struct mlx5e_flow_meter_aso_obj *meters_obj;
int n, pos;
mlx5_fc_destroy(mdev, meter->green_counter);
mlx5_fc_destroy(mdev, meter->red_counter);
mlx5_fc_destroy(mdev, meter->act_counter);
mlx5_fc_destroy(mdev, meter->drop_counter);
meters_obj = meter->meters_obj;
pos = (meter->obj_id - meters_obj->base_id) * 2 + meter->idx;
......@@ -575,8 +575,8 @@ mlx5e_tc_meter_get_stats(struct mlx5e_flow_meter_handle *meter,
u64 bytes1, packets1, lastuse1;
u64 bytes2, packets2, lastuse2;
mlx5_fc_query_cached(meter->green_counter, &bytes1, &packets1, &lastuse1);
mlx5_fc_query_cached(meter->red_counter, &bytes2, &packets2, &lastuse2);
mlx5_fc_query_cached(meter->act_counter, &bytes1, &packets1, &lastuse1);
mlx5_fc_query_cached(meter->drop_counter, &bytes2, &packets2, &lastuse2);
*bytes = bytes1 + bytes2;
*packets = packets1 + packets2;
......
......@@ -32,8 +32,8 @@ struct mlx5e_flow_meter_handle {
struct hlist_node hlist;
struct mlx5e_flow_meter_params params;
struct mlx5_fc *green_counter;
struct mlx5_fc *red_counter;
struct mlx5_fc *act_counter;
struct mlx5_fc *drop_counter;
};
struct mlx5e_meter_attr {
......
......@@ -11,8 +11,8 @@
struct mlx5e_post_meter_priv {
struct mlx5_flow_table *ft;
struct mlx5_flow_group *fg;
struct mlx5_flow_handle *fwd_green_rule;
struct mlx5_flow_handle *drop_red_rule;
struct mlx5_flow_handle *green_rule;
struct mlx5_flow_handle *red_rule;
};
struct mlx5_flow_table *
......@@ -85,8 +85,8 @@ static int
mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
struct mlx5e_post_meter_priv *post_meter,
struct mlx5e_post_act *post_act,
struct mlx5_fc *green_counter,
struct mlx5_fc *red_counter)
struct mlx5_fc *act_counter,
struct mlx5_fc *drop_counter)
{
struct mlx5_flow_destination dest[2] = {};
struct mlx5_flow_act flow_act = {};
......@@ -104,7 +104,7 @@ mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
MLX5_FLOW_CONTEXT_ACTION_COUNT;
flow_act.flags |= FLOW_ACT_IGNORE_FLOW_LEVEL;
dest[0].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
dest[0].counter_id = mlx5_fc_id(red_counter);
dest[0].counter_id = mlx5_fc_id(drop_counter);
rule = mlx5_add_flow_rules(post_meter->ft, spec, &flow_act, dest, 1);
if (IS_ERR(rule)) {
......@@ -112,7 +112,7 @@ mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
err = PTR_ERR(rule);
goto err_red;
}
post_meter->drop_red_rule = rule;
post_meter->red_rule = rule;
mlx5e_tc_match_to_reg_match(spec, PACKET_COLOR_TO_REG,
MLX5_FLOW_METER_COLOR_GREEN, MLX5_PACKET_COLOR_MASK);
......@@ -121,7 +121,7 @@ mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
dest[0].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
dest[0].ft = mlx5e_tc_post_act_get_ft(post_act);
dest[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER;
dest[1].counter_id = mlx5_fc_id(green_counter);
dest[1].counter_id = mlx5_fc_id(act_counter);
rule = mlx5_add_flow_rules(post_meter->ft, spec, &flow_act, dest, 2);
if (IS_ERR(rule)) {
......@@ -129,13 +129,13 @@ mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
err = PTR_ERR(rule);
goto err_green;
}
post_meter->fwd_green_rule = rule;
post_meter->green_rule = rule;
kvfree(spec);
return 0;
err_green:
mlx5_del_flow_rules(post_meter->drop_red_rule);
mlx5_del_flow_rules(post_meter->red_rule);
err_red:
kvfree(spec);
return err;
......@@ -144,8 +144,8 @@ mlx5e_post_meter_rules_create(struct mlx5e_priv *priv,
static void
mlx5e_post_meter_rules_destroy(struct mlx5e_post_meter_priv *post_meter)
{
mlx5_del_flow_rules(post_meter->drop_red_rule);
mlx5_del_flow_rules(post_meter->fwd_green_rule);
mlx5_del_flow_rules(post_meter->red_rule);
mlx5_del_flow_rules(post_meter->green_rule);
}
static void
......@@ -164,8 +164,8 @@ struct mlx5e_post_meter_priv *
mlx5e_post_meter_init(struct mlx5e_priv *priv,
enum mlx5_flow_namespace_type ns_type,
struct mlx5e_post_act *post_act,
struct mlx5_fc *green_counter,
struct mlx5_fc *red_counter)
struct mlx5_fc *act_counter,
struct mlx5_fc *drop_counter)
{
struct mlx5e_post_meter_priv *post_meter;
int err;
......@@ -182,8 +182,8 @@ mlx5e_post_meter_init(struct mlx5e_priv *priv,
if (err)
goto err_fg;
err = mlx5e_post_meter_rules_create(priv, post_meter, post_act, green_counter,
red_counter);
err = mlx5e_post_meter_rules_create(priv, post_meter, post_act,
act_counter, drop_counter);
if (err)
goto err_rules;
......
......@@ -21,8 +21,8 @@ struct mlx5e_post_meter_priv *
mlx5e_post_meter_init(struct mlx5e_priv *priv,
enum mlx5_flow_namespace_type ns_type,
struct mlx5e_post_act *post_act,
struct mlx5_fc *green_counter,
struct mlx5_fc *red_counter);
struct mlx5_fc *act_counter,
struct mlx5_fc *drop_counter);
void
mlx5e_post_meter_cleanup(struct mlx5e_post_meter_priv *post_meter);
......
......@@ -422,8 +422,8 @@ mlx5e_tc_add_flow_meter(struct mlx5e_priv *priv,
}
ns_type = mlx5e_tc_meter_get_namespace(meter->flow_meters);
post_meter = mlx5e_post_meter_init(priv, ns_type, post_act, meter->green_counter,
meter->red_counter);
post_meter = mlx5e_post_meter_init(priv, ns_type, post_act, meter->act_counter,
meter->drop_counter);
if (IS_ERR(post_meter)) {
mlx5_core_err(priv->mdev, "Failed to init post meter\n");
goto err_meter_init;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment