]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
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)
committerPaolo Pisati <paolo.pisati@canonical.com>
Thu, 30 Jan 2020 15:28:04 +0000 (16:28 +0100)
BugLink: https://bugs.launchpad.net/bugs/1861385
commmit b850a82114df9b0ec1d191dc64eed1f20a772e0f upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c

index 3d587d0bdbbe3f9457d64c024f4403cd248ff6e4..1e32e2443f7378dd2b63b2df83052184f1895321 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;