mlxsw: spectrum_acl: Encapsulate C-TCAM region in A-TCAM region

In Spectrum-2 the C-TCAM is only used for rules that can't fit in the
A-TCAM due to a limited number of masks per A-TCAM region.

In addition, rules inserted into the C-TCAM may affect rules residing in
the A-TCAM, by clearing their C-TCAM prune bit.

The two regions are thus closely related and can be thought of as if the
C-TCAM region is encapsulated in the A-TCAM one.

Change the data structures to reflect that before introducing A-TCAM
support and make C-TCAM region initialization part of the A-TCAM region
initialization sequence.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Ido Schimmel 2018-07-25 09:24:01 +03:00 committed by David S. Miller
parent 174c0adb69
commit 57e56d3699
3 changed files with 16 additions and 11 deletions

View File

@ -45,7 +45,7 @@ struct mlxsw_sp2_acl_tcam {
}; };
struct mlxsw_sp2_acl_tcam_region { struct mlxsw_sp2_acl_tcam_region {
struct mlxsw_sp_acl_ctcam_region cregion; struct mlxsw_sp_acl_atcam_region aregion;
struct mlxsw_sp_acl_tcam_region *region; struct mlxsw_sp_acl_tcam_region *region;
}; };
@ -133,14 +133,10 @@ mlxsw_sp2_acl_tcam_region_init(struct mlxsw_sp *mlxsw_sp, void *region_priv,
struct mlxsw_sp_acl_tcam_region *_region) struct mlxsw_sp_acl_tcam_region *_region)
{ {
struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_region *region = region_priv;
int err;
region->region = _region; region->region = _region;
err = mlxsw_sp_acl_atcam_region_init(mlxsw_sp, _region); return mlxsw_sp_acl_atcam_region_init(mlxsw_sp, &region->aregion,
if (err)
return err;
return mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &region->cregion,
_region); _region);
} }
@ -149,7 +145,7 @@ mlxsw_sp2_acl_tcam_region_fini(struct mlxsw_sp *mlxsw_sp, void *region_priv)
{ {
struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_region *region = region_priv;
mlxsw_sp_acl_ctcam_region_fini(&region->cregion); mlxsw_sp_acl_atcam_region_fini(&region->aregion);
} }
static int static int
@ -165,7 +161,7 @@ static void mlxsw_sp2_acl_tcam_chunk_init(void *region_priv, void *chunk_priv,
struct mlxsw_sp2_acl_tcam_region *region = region_priv; struct mlxsw_sp2_acl_tcam_region *region = region_priv;
struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv;
mlxsw_sp_acl_ctcam_chunk_init(&region->cregion, &chunk->cchunk, mlxsw_sp_acl_ctcam_chunk_init(&region->aregion.cregion, &chunk->cchunk,
priority); priority);
} }
@ -186,7 +182,7 @@ static int mlxsw_sp2_acl_tcam_entry_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv;
entry->act_block = rulei->act_block; entry->act_block = rulei->act_block;
return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, &region->cregion, return mlxsw_sp_acl_ctcam_entry_add(mlxsw_sp, &region->aregion.cregion,
&chunk->cchunk, &entry->centry, &chunk->cchunk, &entry->centry,
rulei, true); rulei, true);
} }
@ -199,7 +195,7 @@ static void mlxsw_sp2_acl_tcam_entry_del(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv; struct mlxsw_sp2_acl_tcam_chunk *chunk = chunk_priv;
struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv; struct mlxsw_sp2_acl_tcam_entry *entry = entry_priv;
mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, &region->cregion, mlxsw_sp_acl_ctcam_entry_del(mlxsw_sp, &region->aregion.cregion,
&chunk->cchunk, &entry->centry); &chunk->cchunk, &entry->centry);
} }

View File

@ -77,6 +77,7 @@ mlxsw_sp_acl_atcam_region_erp_init(struct mlxsw_sp *mlxsw_sp,
} }
int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_atcam_region *aregion,
struct mlxsw_sp_acl_tcam_region *region) struct mlxsw_sp_acl_tcam_region *region)
{ {
int err; int err;
@ -90,8 +91,13 @@ int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp,
err = mlxsw_sp_acl_atcam_region_erp_init(mlxsw_sp, region->id); err = mlxsw_sp_acl_atcam_region_erp_init(mlxsw_sp, region->id);
if (err) if (err)
return err; return err;
return mlxsw_sp_acl_ctcam_region_init(mlxsw_sp, &aregion->cregion,
region);
}
return 0; void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion)
{
mlxsw_sp_acl_ctcam_region_fini(&aregion->cregion);
} }
int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,

View File

@ -163,6 +163,7 @@ struct mlxsw_sp_acl_atcam {
}; };
struct mlxsw_sp_acl_atcam_region { struct mlxsw_sp_acl_atcam_region {
struct mlxsw_sp_acl_ctcam_region cregion;
struct mlxsw_sp_acl_tcam_region *region; struct mlxsw_sp_acl_tcam_region *region;
struct mlxsw_sp_acl_atcam *atcam; struct mlxsw_sp_acl_atcam *atcam;
enum mlxsw_sp_acl_atcam_region_type type; enum mlxsw_sp_acl_atcam_region_type type;
@ -172,7 +173,9 @@ struct mlxsw_sp_acl_atcam_region {
int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_region_associate(struct mlxsw_sp *mlxsw_sp,
u16 region_id); u16 region_id);
int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_region_init(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_atcam_region *aregion,
struct mlxsw_sp_acl_tcam_region *region); struct mlxsw_sp_acl_tcam_region *region);
void mlxsw_sp_acl_atcam_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_atcam *atcam); struct mlxsw_sp_acl_atcam *atcam);
void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp,