mlxsw: spectrum_acl_tcam: Reorder functions to avoid forward declarations
authorIdo Schimmel <idosch@nvidia.com>
Mon, 6 Feb 2023 15:39:21 +0000 (16:39 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Feb 2023 04:18:49 +0000 (20:18 -0800)
Move the initialization and de-initialization code further below in
order to avoid forward declarations in the next patch. No functional
changes.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c

index 2445957355cd93f6b76d63396c00b59c2672a6b6..dbc2f834f85922943915e80caaf7d9b31e6ba3a5 100644 (file)
@@ -29,71 +29,6 @@ size_t mlxsw_sp_acl_tcam_priv_size(struct mlxsw_sp *mlxsw_sp)
 #define MLXSW_SP_ACL_TCAM_VREGION_REHASH_INTRVL_MIN 3000 /* ms */
 #define MLXSW_SP_ACL_TCAM_VREGION_REHASH_CREDITS 100 /* number of entries */
 
-int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp,
-                          struct mlxsw_sp_acl_tcam *tcam)
-{
-       const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops;
-       u64 max_tcam_regions;
-       u64 max_regions;
-       u64 max_groups;
-       int err;
-
-       mutex_init(&tcam->lock);
-       tcam->vregion_rehash_intrvl =
-                       MLXSW_SP_ACL_TCAM_VREGION_REHASH_INTRVL_DFLT;
-       INIT_LIST_HEAD(&tcam->vregion_list);
-
-       max_tcam_regions = MLXSW_CORE_RES_GET(mlxsw_sp->core,
-                                             ACL_MAX_TCAM_REGIONS);
-       max_regions = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_REGIONS);
-
-       /* Use 1:1 mapping between ACL region and TCAM region */
-       if (max_tcam_regions < max_regions)
-               max_regions = max_tcam_regions;
-
-       tcam->used_regions = bitmap_zalloc(max_regions, GFP_KERNEL);
-       if (!tcam->used_regions) {
-               err = -ENOMEM;
-               goto err_alloc_used_regions;
-       }
-       tcam->max_regions = max_regions;
-
-       max_groups = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_GROUPS);
-       tcam->used_groups = bitmap_zalloc(max_groups, GFP_KERNEL);
-       if (!tcam->used_groups) {
-               err = -ENOMEM;
-               goto err_alloc_used_groups;
-       }
-       tcam->max_groups = max_groups;
-       tcam->max_group_size = MLXSW_CORE_RES_GET(mlxsw_sp->core,
-                                                ACL_MAX_GROUP_SIZE);
-
-       err = ops->init(mlxsw_sp, tcam->priv, tcam);
-       if (err)
-               goto err_tcam_init;
-
-       return 0;
-
-err_tcam_init:
-       bitmap_free(tcam->used_groups);
-err_alloc_used_groups:
-       bitmap_free(tcam->used_regions);
-err_alloc_used_regions:
-       mutex_destroy(&tcam->lock);
-       return err;
-}
-
-void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp,
-                           struct mlxsw_sp_acl_tcam *tcam)
-{
-       const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops;
-
-       ops->fini(mlxsw_sp, tcam->priv);
-       bitmap_free(tcam->used_groups);
-       bitmap_free(tcam->used_regions);
-       mutex_destroy(&tcam->lock);
-}
-
 int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
                                   struct mlxsw_sp_acl_rule_info *rulei,
                                   u32 *priority, bool fillup_priority)
@@ -1546,6 +1481,71 @@ mlxsw_sp_acl_tcam_vregion_rehash(struct mlxsw_sp *mlxsw_sp,
                mlxsw_sp_acl_tcam_vregion_rehash_end(mlxsw_sp, vregion, ctx);
 }
 
+int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp,
+                          struct mlxsw_sp_acl_tcam *tcam)
+{
+       const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops;
+       u64 max_tcam_regions;
+       u64 max_regions;
+       u64 max_groups;
+       int err;
+
+       mutex_init(&tcam->lock);
+       tcam->vregion_rehash_intrvl =
+                       MLXSW_SP_ACL_TCAM_VREGION_REHASH_INTRVL_DFLT;
+       INIT_LIST_HEAD(&tcam->vregion_list);
+
+       max_tcam_regions = MLXSW_CORE_RES_GET(mlxsw_sp->core,
+                                             ACL_MAX_TCAM_REGIONS);
+       max_regions = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_REGIONS);
+
+       /* Use 1:1 mapping between ACL region and TCAM region */
+       if (max_tcam_regions < max_regions)
+               max_regions = max_tcam_regions;
+
+       tcam->used_regions = bitmap_zalloc(max_regions, GFP_KERNEL);
+       if (!tcam->used_regions) {
+               err = -ENOMEM;
+               goto err_alloc_used_regions;
+       }
+       tcam->max_regions = max_regions;
+
+       max_groups = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_GROUPS);
+       tcam->used_groups = bitmap_zalloc(max_groups, GFP_KERNEL);
+       if (!tcam->used_groups) {
+               err = -ENOMEM;
+               goto err_alloc_used_groups;
+       }
+       tcam->max_groups = max_groups;
+       tcam->max_group_size = MLXSW_CORE_RES_GET(mlxsw_sp->core,
+                                                 ACL_MAX_GROUP_SIZE);
+
+       err = ops->init(mlxsw_sp, tcam->priv, tcam);
+       if (err)
+               goto err_tcam_init;
+
+       return 0;
+
+err_tcam_init:
+       bitmap_free(tcam->used_groups);
+err_alloc_used_groups:
+       bitmap_free(tcam->used_regions);
+err_alloc_used_regions:
+       mutex_destroy(&tcam->lock);
+       return err;
+}
+
+void mlxsw_sp_acl_tcam_fini(struct mlxsw_sp *mlxsw_sp,
+                           struct mlxsw_sp_acl_tcam *tcam)
+{
+       const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops;
+
+       ops->fini(mlxsw_sp, tcam->priv);
+       bitmap_free(tcam->used_groups);
+       bitmap_free(tcam->used_regions);
+       mutex_destroy(&tcam->lock);
+}
+
 static const enum mlxsw_afk_element mlxsw_sp_acl_tcam_pattern_ipv4[] = {
        MLXSW_AFK_ELEMENT_SRC_SYS_PORT,
        MLXSW_AFK_ELEMENT_DMAC_32_47,