Skip to content

Commit ae05831

Browse files
mark-blochrleon
authored andcommitted
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: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 74491de commit ae05831

File tree

1 file changed

+18
-6
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+18
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static void del_rule(struct fs_node *node)
374374
struct mlx5_core_dev *dev = get_dev(node);
375375
int match_len = MLX5_ST_SZ_BYTES(fte_match_param);
376376
int err;
377+
bool update_fte = false;
377378

378379
match_value = mlx5_vzalloc(match_len);
379380
if (!match_value) {
@@ -392,13 +393,23 @@ static void del_rule(struct fs_node *node)
392393
list_del(&rule->next_ft);
393394
mutex_unlock(&rule->dest_attr.ft->lock);
394395
}
396+
397+
if (rule->dest_attr.type == MLX5_FLOW_DESTINATION_TYPE_COUNTER &&
398+
--fte->dests_size) {
399+
modify_mask = BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_ACTION);
400+
fte->action &= ~MLX5_FLOW_CONTEXT_ACTION_COUNT;
401+
update_fte = true;
402+
goto out;
403+
}
404+
395405
if ((fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) &&
396406
--fte->dests_size) {
397407
modify_mask = BIT(MLX5_SET_FTE_MODIFY_ENABLE_MASK_DESTINATION_LIST),
398-
err = mlx5_cmd_update_fte(dev, ft,
399-
fg->id,
400-
modify_mask,
401-
fte);
408+
update_fte = true;
409+
}
410+
out:
411+
if (update_fte && fte->dests_size) {
412+
err = mlx5_cmd_update_fte(dev, ft, fg->id, modify_mask, fte);
402413
if (err)
403414
mlx5_core_warn(dev,
404415
"%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)
12871298
if (!counter)
12881299
return false;
12891300

1290-
/* Hardware support counter for a drop action only */
1291-
return action == (MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT);
1301+
return (action & (MLX5_FLOW_CONTEXT_ACTION_DROP |
1302+
MLX5_FLOW_CONTEXT_ACTION_FWD_DEST)) &&
1303+
(action & MLX5_FLOW_CONTEXT_ACTION_COUNT);
12921304
}
12931305

12941306
static bool dest_is_valid(struct mlx5_flow_destination *dest,

0 commit comments

Comments
 (0)