]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: HWS, support flow sampler destination
authorVlad Dogaru <vdogaru@nvidia.com>
Thu, 2 Jan 2025 18:14:13 +0000 (20:14 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 7 Jan 2025 00:33:41 +0000 (16:33 -0800)
Since sampler isn't currently supported via HWS, use a FW island
that forwards any packets to the supplied sampler.

Signed-off-by: Vlad Dogaru <vdogaru@nvidia.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20250102181415.1477316-15-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/action.c
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/action.h
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/cmd.c

index 67d4f40cbd836e4783f99f6932d86f7e35dff53e..b5332c54d4fb0fe22d7ff04d20b5e13d9b3e5164 100644 (file)
@@ -471,6 +471,7 @@ static void hws_action_fill_stc_attr(struct mlx5hws_action *action,
                break;
        case MLX5HWS_ACTION_TYP_TBL:
        case MLX5HWS_ACTION_TYP_DEST_ARRAY:
+       case MLX5HWS_ACTION_TYP_SAMPLER:
                attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_FT;
                attr->action_offset = MLX5HWS_ACTION_OFFSET_HIT;
                attr->dest_table_id = obj_id;
@@ -1873,7 +1874,50 @@ struct mlx5hws_action *
 mlx5hws_action_create_flow_sampler(struct mlx5hws_context *ctx,
                                   u32 sampler_id, u32 flags)
 {
-       mlx5hws_err(ctx, "Flow sampler action - unsupported\n");
+       struct mlx5hws_cmd_ft_create_attr ft_attr = {0};
+       struct mlx5hws_cmd_set_fte_attr fte_attr = {0};
+       struct mlx5hws_cmd_forward_tbl *fw_island;
+       struct mlx5hws_cmd_set_fte_dest dest;
+       struct mlx5hws_action *action;
+       int ret;
+
+       if (flags != (MLX5HWS_ACTION_FLAG_HWS_FDB | MLX5HWS_ACTION_FLAG_SHARED)) {
+               mlx5hws_err(ctx, "Unsupported flags for flow sampler\n");
+               return NULL;
+       }
+
+       ft_attr.type = FS_FT_FDB;
+       ft_attr.level = ctx->caps->fdb_ft.max_level - 1;
+
+       dest.destination_type = MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER;
+       dest.destination_id = sampler_id;
+
+       fte_attr.dests_num = 1;
+       fte_attr.dests = &dest;
+       fte_attr.action_flags = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
+       fte_attr.ignore_flow_level = 1;
+
+       fw_island = mlx5hws_cmd_forward_tbl_create(ctx->mdev, &ft_attr, &fte_attr);
+       if (!fw_island)
+               return NULL;
+
+       action = hws_action_create_generic(ctx, flags,
+                                          MLX5HWS_ACTION_TYP_SAMPLER);
+       if (!action)
+               goto destroy_fw_island;
+
+       ret = hws_action_create_stcs(action, fw_island->ft_id);
+       if (ret)
+               goto free_action;
+
+       action->flow_sampler.fw_island = fw_island;
+
+       return action;
+
+free_action:
+       kfree(action);
+destroy_fw_island:
+       mlx5hws_cmd_forward_tbl_destroy(ctx->mdev, fw_island);
        return NULL;
 }
 
@@ -1912,6 +1956,11 @@ static void hws_action_destroy_hws(struct mlx5hws_action *action)
                }
                kfree(action->dest_array.dest_list);
                break;
+       case MLX5HWS_ACTION_TYP_SAMPLER:
+               hws_action_destroy_stcs(action);
+               mlx5hws_cmd_forward_tbl_destroy(action->ctx->mdev,
+                                               action->flow_sampler.fw_island);
+               break;
        case MLX5HWS_ACTION_TYP_REFORMAT_TNL_L3_TO_L2:
        case MLX5HWS_ACTION_TYP_MODIFY_HDR:
                shared_arg = false;
@@ -2429,6 +2478,7 @@ int mlx5hws_action_template_process(struct mlx5hws_action_template *at)
                case MLX5HWS_ACTION_TYP_DROP:
                case MLX5HWS_ACTION_TYP_TBL:
                case MLX5HWS_ACTION_TYP_DEST_ARRAY:
+               case MLX5HWS_ACTION_TYP_SAMPLER:
                case MLX5HWS_ACTION_TYP_VPORT:
                case MLX5HWS_ACTION_TYP_MISS:
                        /* Hit action */
index 6d1592c49e0c2491ff8b2fe2cca6375668343517..64b76075f7f8fe3d5c6b45be0c36c918686de679 100644 (file)
@@ -165,6 +165,9 @@ struct mlx5hws_action {
                                        size_t num_dest;
                                        struct mlx5hws_cmd_set_fte_dest *dest_list;
                                } dest_array;
+                               struct {
+                                       struct mlx5hws_cmd_forward_tbl *fw_island;
+                               } flow_sampler;
                                struct {
                                        u8 type;
                                        u8 start_anchor;
index 9b71ff80831d76a258712ab35c1e9dba3a1e0e16..487e75476b0ab8d41235d10e55164121a5b6e659 100644 (file)
@@ -257,6 +257,12 @@ int mlx5hws_cmd_set_fte(struct mlx5_core_dev *mdev,
                                                 dest->ext_reformat_id);
                                }
                                break;
+                       case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
+                               MLX5_SET(dest_format, in_dests,
+                                        destination_type, ifc_dest_type);
+                               MLX5_SET(dest_format, in_dests, destination_id,
+                                        dest->destination_id);
+                               break;
                        default:
                                ret = -EOPNOTSUPP;
                                goto out;