OSDN Git Service

net/mlx5: DR, Enable counter on non-fwd-dest objects
authorErez Shitrit <erezsh@mellanox.com>
Wed, 8 Jan 2020 12:17:32 +0000 (14:17 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 24 Jan 2020 20:04:25 +0000 (12:04 -0800)
The current code handles only counters that attached to dest, we still
have the cases where we have counter on non-dest, like over drop etc.

Fixes: 6a48faeeca10 ("net/mlx5: Add direct rule fs_cmd implementation")
Signed-off-by: Hamdan Igbaria <hamdani@mellanox.com>
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Reviewed-by: Alex Vesker <valex@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c

index 3d587d0..1e32e24 100644 (file)
@@ -352,26 +352,16 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
        if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
                list_for_each_entry(dst, &fte->node.children, node.list) {
                        enum mlx5_flow_destination_type type = dst->dest_attr.type;
-                       u32 id;
 
                        if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
                                err = -ENOSPC;
                                goto free_actions;
                        }
 
-                       switch (type) {
-                       case MLX5_FLOW_DESTINATION_TYPE_COUNTER:
-                               id = dst->dest_attr.counter_id;
+                       if (type == MLX5_FLOW_DESTINATION_TYPE_COUNTER)
+                               continue;
 
-                               tmp_action =
-                                       mlx5dr_action_create_flow_counter(id);
-                               if (!tmp_action) {
-                                       err = -ENOMEM;
-                                       goto free_actions;
-                               }
-                               fs_dr_actions[fs_dr_num_actions++] = tmp_action;
-                               actions[num_actions++] = tmp_action;
-                               break;
+                       switch (type) {
                        case MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE:
                                tmp_action = create_ft_action(dev, dst);
                                if (!tmp_action) {
@@ -397,6 +387,32 @@ static int mlx5_cmd_dr_create_fte(struct mlx5_flow_root_namespace *ns,
                }
        }
 
+       if (fte->action.action & MLX5_FLOW_CONTEXT_ACTION_COUNT) {
+               list_for_each_entry(dst, &fte->node.children, node.list) {
+                       u32 id;
+
+                       if (dst->dest_attr.type !=
+                           MLX5_FLOW_DESTINATION_TYPE_COUNTER)
+                               continue;
+
+                       if (num_actions == MLX5_FLOW_CONTEXT_ACTION_MAX) {
+                               err = -ENOSPC;
+                               goto free_actions;
+                       }
+
+                       id = dst->dest_attr.counter_id;
+                       tmp_action =
+                               mlx5dr_action_create_flow_counter(id);
+                       if (!tmp_action) {
+                               err = -ENOMEM;
+                               goto free_actions;
+                       }
+
+                       fs_dr_actions[fs_dr_num_actions++] = tmp_action;
+                       actions[num_actions++] = tmp_action;
+               }
+       }
+
        params.match_sz = match_sz;
        params.match_buf = (u64 *)fte->val;