mlxsw: spectrum_acl_tcam: Reorder functions to avoid forward declarations
[ Upstream commit 194ab9476089bbfc021073214e071a404e375ee6 ] 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> Stable-dep-of: 483ae90d8f97 ("mlxsw: spectrum_acl_tcam: Fix stack corruption") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
fd3fe73dbc
commit
541ffa885a
1 changed files with 65 additions and 65 deletions
|
@ -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_INTRVL_MIN 3000 /* ms */
|
||||||
#define MLXSW_SP_ACL_TCAM_VREGION_REHASH_CREDITS 100 /* number of entries */
|
#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,
|
int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp,
|
||||||
struct mlxsw_sp_acl_rule_info *rulei,
|
struct mlxsw_sp_acl_rule_info *rulei,
|
||||||
u32 *priority, bool fillup_priority)
|
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);
|
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[] = {
|
static const enum mlxsw_afk_element mlxsw_sp_acl_tcam_pattern_ipv4[] = {
|
||||||
MLXSW_AFK_ELEMENT_SRC_SYS_PORT,
|
MLXSW_AFK_ELEMENT_SRC_SYS_PORT,
|
||||||
MLXSW_AFK_ELEMENT_DMAC_32_47,
|
MLXSW_AFK_ELEMENT_DMAC_32_47,
|
||||||
|
|
Loading…
Add table
Reference in a new issue