Commit ae058314 authored by Mark Bloch's avatar Mark Bloch Committed by Leon Romanovsky

net/mlx5: Add option to add fwd rule with counter

Currently the code supports only drop rules to possess counters,
add that ability also for fwd rules.
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 74491de9
...@@ -374,6 +374,7 @@ static void del_rule(struct fs_node *node) ...@@ -374,6 +374,7 @@ static void del_rule(struct fs_node *node)
struct mlx5_core_dev *dev = get_dev(node); struct mlx5_core_dev *dev = get_dev(node);
int match_len = MLX5_ST_SZ_BYTES(fte_match_param); int match_len = MLX5_ST_SZ_BYTES(fte_match_param);
int err; int err;
bool update_fte = false;
match_value = mlx5_vzalloc(match_len); match_value = mlx5_vzalloc(match_len);
if (!match_value) { if (!match_value) {
...@@ -392,13 +393,23 @@ static void del_rule(struct fs_node *node) ...@@ -392,13 +393,23 @@ static void del_rule(struct fs_node *node)
list_del(&rule->next_ft); list_del(&rule->next_ft);
mutex_unlock(&rule->dest_attr.ft->lock); mutex_unlock(&rule->dest_attr.ft->lock);
} }
if (rule->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER &&
--fte->dests_size) {
modify_mask = BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
fte->action &= ~MLX5_FLOW_CONTEXT_ACTION_COUNT;
update_fte = true;
goto out;
}
if ((fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) && if ((fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) &&
--fte->dests_size) { --fte->dests_size) {
modify_mask = BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_DESTINATION_LIST), modify_mask = BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_DESTINATION_LIST),
err = mlx5_cmd_update_fte(dev, ft, update_fte = true;
fg->id, }
modify_mask, out:
fte); if (update_fte && fte->dests_size) {
err = mlx5_cmd_update_fte(dev, ft, fg->id, modify_mask, fte);
if (err) if (err)
mlx5_core_warn(dev, mlx5_core_warn(dev,
"%s can't del rule fg id=%d fte_index=%d\n", "%s can't del rule fg id=%d fte_index=%d\n",
...@@ -1287,8 +1298,9 @@ static bool counter_is_valid(struct mlx5_fc *counter, u32 action) ...@@ -1287,8 +1298,9 @@ static bool counter_is_valid(struct mlx5_fc *counter, u32 action)
if (!counter) if (!counter)
return false; return false;
/* Hardware support counter for a drop action only */ return (action & (MLX5_FLOW_CONTEXT_ACTION_DROP |
return action == (MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT); MLX5_FLOW_CONTEXT_ACTION_FWD_DEST)) &&
(action & MLX5_FLOW_CONTEXT_ACTION_COUNT);
} }
static bool dest_is_valid(struct mlx5_flow_destination *dest, static bool dest_is_valid(struct mlx5_flow_destination *dest,
......
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