Commit c71abd7d authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum: acl_erp: Convert to use objagg for tracking ERPs

Currently the ERPs are tracked internally in a hashtable. Benefit from
the newly introduced objagg library and use it to track ERPs. At this
point, there is no nesting of objects done, as the delta_create callback
always returns -EOPNOTSUPP. On the way, add "mask" into ERP mask get and
set functions and struct names.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a020d41
...@@ -80,6 +80,7 @@ config MLXSW_SPECTRUM ...@@ -80,6 +80,7 @@ config MLXSW_SPECTRUM
depends on IPV6_GRE || IPV6_GRE=n depends on IPV6_GRE || IPV6_GRE=n
select GENERIC_ALLOCATOR select GENERIC_ALLOCATOR
select PARMAN select PARMAN
select OBJAGG
select MLXFW select MLXFW
default m default m
---help--- ---help---
......
...@@ -34,15 +34,15 @@ mlxsw_sp2_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregio ...@@ -34,15 +34,15 @@ mlxsw_sp2_acl_ctcam_region_entry_insert(struct mlxsw_sp_acl_ctcam_region *cregio
{ {
struct mlxsw_sp_acl_atcam_region *aregion; struct mlxsw_sp_acl_atcam_region *aregion;
struct mlxsw_sp_acl_atcam_entry *aentry; struct mlxsw_sp_acl_atcam_entry *aentry;
struct mlxsw_sp_acl_erp *erp; struct mlxsw_sp_acl_erp_mask *erp_mask;
aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion);
aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); aentry = mlxsw_sp_acl_tcam_centry_aentry(centry);
erp = mlxsw_sp_acl_erp_get(aregion, mask, true); erp_mask = mlxsw_sp_acl_erp_mask_get(aregion, mask, true);
if (IS_ERR(erp)) if (IS_ERR(erp_mask))
return PTR_ERR(erp); return PTR_ERR(erp_mask);
aentry->erp = erp; aentry->erp_mask = erp_mask;
return 0; return 0;
} }
...@@ -57,7 +57,7 @@ mlxsw_sp2_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregio ...@@ -57,7 +57,7 @@ mlxsw_sp2_acl_ctcam_region_entry_remove(struct mlxsw_sp_acl_ctcam_region *cregio
aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion); aregion = mlxsw_sp_acl_tcam_cregion_aregion(cregion);
aentry = mlxsw_sp_acl_tcam_centry_aentry(centry); aentry = mlxsw_sp_acl_tcam_centry_aentry(centry);
mlxsw_sp_acl_erp_put(aregion, aentry->erp); mlxsw_sp_acl_erp_mask_put(aregion, aentry->erp_mask);
} }
static const struct mlxsw_sp_acl_ctcam_region_ops static const struct mlxsw_sp_acl_ctcam_region_ops
......
...@@ -64,7 +64,7 @@ static const struct rhashtable_params mlxsw_sp_acl_atcam_entries_ht_params = { ...@@ -64,7 +64,7 @@ static const struct rhashtable_params mlxsw_sp_acl_atcam_entries_ht_params = {
static bool static bool
mlxsw_sp_acl_atcam_is_centry(const struct mlxsw_sp_acl_atcam_entry *aentry) mlxsw_sp_acl_atcam_is_centry(const struct mlxsw_sp_acl_atcam_entry *aentry)
{ {
return mlxsw_sp_acl_erp_is_ctcam_erp(aentry->erp); return mlxsw_sp_acl_erp_mask_is_ctcam(aentry->erp_mask);
} }
static int static int
...@@ -379,7 +379,7 @@ mlxsw_sp_acl_atcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp, ...@@ -379,7 +379,7 @@ mlxsw_sp_acl_atcam_region_entry_insert(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei) struct mlxsw_sp_acl_rule_info *rulei)
{ {
struct mlxsw_sp_acl_tcam_region *region = aregion->region; struct mlxsw_sp_acl_tcam_region *region = aregion->region;
u8 erp_id = mlxsw_sp_acl_erp_id(aentry->erp); u8 erp_id = mlxsw_sp_acl_erp_mask_erp_id(aentry->erp_mask);
struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; struct mlxsw_sp_acl_atcam_lkey_id *lkey_id;
char ptce3_pl[MLXSW_REG_PTCE3_LEN]; char ptce3_pl[MLXSW_REG_PTCE3_LEN];
u32 kvdl_index, priority; u32 kvdl_index, priority;
...@@ -418,7 +418,7 @@ mlxsw_sp_acl_atcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp, ...@@ -418,7 +418,7 @@ mlxsw_sp_acl_atcam_region_entry_remove(struct mlxsw_sp *mlxsw_sp,
{ {
struct mlxsw_sp_acl_atcam_lkey_id *lkey_id = aentry->lkey_id; struct mlxsw_sp_acl_atcam_lkey_id *lkey_id = aentry->lkey_id;
struct mlxsw_sp_acl_tcam_region *region = aregion->region; struct mlxsw_sp_acl_tcam_region *region = aregion->region;
u8 erp_id = mlxsw_sp_acl_erp_id(aentry->erp); u8 erp_id = mlxsw_sp_acl_erp_mask_erp_id(aentry->erp_mask);
char ptce3_pl[MLXSW_REG_PTCE3_LEN]; char ptce3_pl[MLXSW_REG_PTCE3_LEN];
mlxsw_reg_ptce3_pack(ptce3_pl, false, MLXSW_REG_PTCE3_OP_WRITE_WRITE, 0, mlxsw_reg_ptce3_pack(ptce3_pl, false, MLXSW_REG_PTCE3_OP_WRITE_WRITE, 0,
...@@ -438,7 +438,7 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, ...@@ -438,7 +438,7 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_tcam_region *region = aregion->region; struct mlxsw_sp_acl_tcam_region *region = aregion->region;
char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN] = { 0 }; char mask[MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN] = { 0 };
struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl); struct mlxsw_afk *afk = mlxsw_sp_acl_afk(mlxsw_sp->acl);
struct mlxsw_sp_acl_erp *erp; struct mlxsw_sp_acl_erp_mask *erp_mask;
unsigned int blocks_count; unsigned int blocks_count;
int err; int err;
...@@ -446,11 +446,11 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, ...@@ -446,11 +446,11 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
mlxsw_afk_encode(afk, region->key_info, &rulei->values, mlxsw_afk_encode(afk, region->key_info, &rulei->values,
aentry->ht_key.enc_key, mask, 0, blocks_count - 1); aentry->ht_key.enc_key, mask, 0, blocks_count - 1);
erp = mlxsw_sp_acl_erp_get(aregion, mask, false); erp_mask = mlxsw_sp_acl_erp_mask_get(aregion, mask, false);
if (IS_ERR(erp)) if (IS_ERR(erp_mask))
return PTR_ERR(erp); return PTR_ERR(erp_mask);
aentry->erp = erp; aentry->erp_mask = erp_mask;
aentry->ht_key.erp_id = mlxsw_sp_acl_erp_id(erp); aentry->ht_key.erp_id = mlxsw_sp_acl_erp_mask_erp_id(erp_mask);
/* We can't insert identical rules into the A-TCAM, so fail and /* We can't insert identical rules into the A-TCAM, so fail and
* let the rule spill into C-TCAM * let the rule spill into C-TCAM
...@@ -472,7 +472,7 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, ...@@ -472,7 +472,7 @@ __mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node, rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node,
mlxsw_sp_acl_atcam_entries_ht_params); mlxsw_sp_acl_atcam_entries_ht_params);
err_rhashtable_insert: err_rhashtable_insert:
mlxsw_sp_acl_erp_put(aregion, erp); mlxsw_sp_acl_erp_mask_put(aregion, erp_mask);
return err; return err;
} }
...@@ -484,7 +484,7 @@ __mlxsw_sp_acl_atcam_entry_del(struct mlxsw_sp *mlxsw_sp, ...@@ -484,7 +484,7 @@ __mlxsw_sp_acl_atcam_entry_del(struct mlxsw_sp *mlxsw_sp,
mlxsw_sp_acl_atcam_region_entry_remove(mlxsw_sp, aregion, aentry); mlxsw_sp_acl_atcam_region_entry_remove(mlxsw_sp, aregion, aentry);
rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node, rhashtable_remove_fast(&aregion->entries_ht, &aentry->ht_node,
mlxsw_sp_acl_atcam_entries_ht_params); mlxsw_sp_acl_atcam_entries_ht_params);
mlxsw_sp_acl_erp_put(aregion, aentry->erp); mlxsw_sp_acl_erp_mask_put(aregion, aentry->erp_mask);
} }
int mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_atcam_entry_add(struct mlxsw_sp *mlxsw_sp,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/rhashtable.h> #include <linux/objagg.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -36,10 +36,8 @@ struct mlxsw_sp_acl_erp { ...@@ -36,10 +36,8 @@ struct mlxsw_sp_acl_erp {
struct mlxsw_sp_acl_erp_key key; struct mlxsw_sp_acl_erp_key key;
u8 id; u8 id;
u8 index; u8 index;
refcount_t refcnt;
DECLARE_BITMAP(mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN); DECLARE_BITMAP(mask_bitmap, MLXSW_SP_ACL_TCAM_MASK_LEN);
struct list_head list; struct list_head list;
struct rhash_head ht_node;
struct mlxsw_sp_acl_erp_table *erp_table; struct mlxsw_sp_acl_erp_table *erp_table;
}; };
...@@ -53,7 +51,6 @@ struct mlxsw_sp_acl_erp_table { ...@@ -53,7 +51,6 @@ struct mlxsw_sp_acl_erp_table {
DECLARE_BITMAP(erp_id_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); DECLARE_BITMAP(erp_id_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION);
DECLARE_BITMAP(erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION); DECLARE_BITMAP(erp_index_bitmap, MLXSW_SP_ACL_ERP_MAX_PER_REGION);
struct list_head atcam_erps_list; struct list_head atcam_erps_list;
struct rhashtable erp_ht;
struct mlxsw_sp_acl_erp_core *erp_core; struct mlxsw_sp_acl_erp_core *erp_core;
struct mlxsw_sp_acl_atcam_region *aregion; struct mlxsw_sp_acl_atcam_region *aregion;
const struct mlxsw_sp_acl_erp_table_ops *ops; const struct mlxsw_sp_acl_erp_table_ops *ops;
...@@ -61,12 +58,7 @@ struct mlxsw_sp_acl_erp_table { ...@@ -61,12 +58,7 @@ struct mlxsw_sp_acl_erp_table {
unsigned int num_atcam_erps; unsigned int num_atcam_erps;
unsigned int num_max_atcam_erps; unsigned int num_max_atcam_erps;
unsigned int num_ctcam_erps; unsigned int num_ctcam_erps;
}; struct objagg *objagg;
static const struct rhashtable_params mlxsw_sp_acl_erp_ht_params = {
.key_len = sizeof(struct mlxsw_sp_acl_erp_key),
.key_offset = offsetof(struct mlxsw_sp_acl_erp, key),
.head_offset = offsetof(struct mlxsw_sp_acl_erp, ht_node),
}; };
struct mlxsw_sp_acl_erp_table_ops { struct mlxsw_sp_acl_erp_table_ops {
...@@ -119,16 +111,6 @@ static const struct mlxsw_sp_acl_erp_table_ops erp_no_mask_ops = { ...@@ -119,16 +111,6 @@ static const struct mlxsw_sp_acl_erp_table_ops erp_no_mask_ops = {
.erp_destroy = mlxsw_sp_acl_erp_no_mask_destroy, .erp_destroy = mlxsw_sp_acl_erp_no_mask_destroy,
}; };
bool mlxsw_sp_acl_erp_is_ctcam_erp(const struct mlxsw_sp_acl_erp *erp)
{
return erp->key.ctcam;
}
u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp)
{
return erp->id;
}
static unsigned int static unsigned int
mlxsw_sp_acl_erp_table_entry_size(const struct mlxsw_sp_acl_erp_table *erp_table) mlxsw_sp_acl_erp_table_entry_size(const struct mlxsw_sp_acl_erp_table *erp_table)
{ {
...@@ -259,7 +241,6 @@ mlxsw_sp_acl_erp_generic_create(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -259,7 +241,6 @@ mlxsw_sp_acl_erp_generic_create(struct mlxsw_sp_acl_erp_table *erp_table,
bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask, bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask,
MLXSW_SP_ACL_TCAM_MASK_LEN); MLXSW_SP_ACL_TCAM_MASK_LEN);
list_add(&erp->list, &erp_table->atcam_erps_list); list_add(&erp->list, &erp_table->atcam_erps_list);
refcount_set(&erp->refcnt, 1);
erp_table->num_atcam_erps++; erp_table->num_atcam_erps++;
erp->erp_table = erp_table; erp->erp_table = erp_table;
...@@ -267,15 +248,8 @@ mlxsw_sp_acl_erp_generic_create(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -267,15 +248,8 @@ mlxsw_sp_acl_erp_generic_create(struct mlxsw_sp_acl_erp_table *erp_table,
if (err) if (err)
goto err_master_mask_set; goto err_master_mask_set;
err = rhashtable_insert_fast(&erp_table->erp_ht, &erp->ht_node,
mlxsw_sp_acl_erp_ht_params);
if (err)
goto err_rhashtable_insert;
return erp; return erp;
err_rhashtable_insert:
mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp);
err_master_mask_set: err_master_mask_set:
erp_table->num_atcam_erps--; erp_table->num_atcam_erps--;
list_del(&erp->list); list_del(&erp->list);
...@@ -290,8 +264,6 @@ mlxsw_sp_acl_erp_generic_destroy(struct mlxsw_sp_acl_erp *erp) ...@@ -290,8 +264,6 @@ mlxsw_sp_acl_erp_generic_destroy(struct mlxsw_sp_acl_erp *erp)
{ {
struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table;
rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node,
mlxsw_sp_acl_erp_ht_params);
mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp);
erp_table->num_atcam_erps--; erp_table->num_atcam_erps--;
list_del(&erp->list); list_del(&erp->list);
...@@ -697,7 +669,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -697,7 +669,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
memcpy(&erp->key, key, sizeof(*key)); memcpy(&erp->key, key, sizeof(*key));
bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask, bitmap_from_arr32(erp->mask_bitmap, (u32 *) key->mask,
MLXSW_SP_ACL_TCAM_MASK_LEN); MLXSW_SP_ACL_TCAM_MASK_LEN);
refcount_set(&erp->refcnt, 1);
erp_table->num_ctcam_erps++; erp_table->num_ctcam_erps++;
erp->erp_table = erp_table; erp->erp_table = erp_table;
...@@ -705,11 +676,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -705,11 +676,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
if (err) if (err)
goto err_master_mask_set; goto err_master_mask_set;
err = rhashtable_insert_fast(&erp_table->erp_ht, &erp->ht_node,
mlxsw_sp_acl_erp_ht_params);
if (err)
goto err_rhashtable_insert;
err = mlxsw_sp_acl_erp_region_ctcam_enable(erp_table); err = mlxsw_sp_acl_erp_region_ctcam_enable(erp_table);
if (err) if (err)
goto err_erp_region_ctcam_enable; goto err_erp_region_ctcam_enable;
...@@ -720,9 +686,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -720,9 +686,6 @@ __mlxsw_sp_acl_erp_ctcam_mask_create(struct mlxsw_sp_acl_erp_table *erp_table,
return erp; return erp;
err_erp_region_ctcam_enable: err_erp_region_ctcam_enable:
rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node,
mlxsw_sp_acl_erp_ht_params);
err_rhashtable_insert:
mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp);
err_master_mask_set: err_master_mask_set:
erp_table->num_ctcam_erps--; erp_table->num_ctcam_erps--;
...@@ -767,8 +730,6 @@ mlxsw_sp_acl_erp_ctcam_mask_destroy(struct mlxsw_sp_acl_erp *erp) ...@@ -767,8 +730,6 @@ mlxsw_sp_acl_erp_ctcam_mask_destroy(struct mlxsw_sp_acl_erp *erp)
struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table; struct mlxsw_sp_acl_erp_table *erp_table = erp->erp_table;
mlxsw_sp_acl_erp_region_ctcam_disable(erp_table); mlxsw_sp_acl_erp_region_ctcam_disable(erp_table);
rhashtable_remove_fast(&erp_table->erp_ht, &erp->ht_node,
mlxsw_sp_acl_erp_ht_params);
mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp); mlxsw_sp_acl_erp_master_mask_clear(erp_table, erp);
erp_table->num_ctcam_erps--; erp_table->num_ctcam_erps--;
kfree(erp); kfree(erp);
...@@ -940,13 +901,12 @@ mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table, ...@@ -940,13 +901,12 @@ mlxsw_sp_acl_erp_no_mask_destroy(struct mlxsw_sp_acl_erp_table *erp_table,
WARN_ON(1); WARN_ON(1);
} }
struct mlxsw_sp_acl_erp * struct mlxsw_sp_acl_erp_mask *
mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, mlxsw_sp_acl_erp_mask_get(struct mlxsw_sp_acl_atcam_region *aregion,
const char *mask, bool ctcam) const char *mask, bool ctcam)
{ {
struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table;
struct mlxsw_sp_acl_erp_key key; struct mlxsw_sp_acl_erp_key key;
struct mlxsw_sp_acl_erp *erp; struct objagg_obj *objagg_obj;
/* eRPs are allocated from a shared resource, but currently all /* eRPs are allocated from a shared resource, but currently all
* allocations are done under RTNL. * allocations are done under RTNL.
...@@ -955,29 +915,73 @@ mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, ...@@ -955,29 +915,73 @@ mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion,
memcpy(key.mask, mask, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN); memcpy(key.mask, mask, MLXSW_REG_PTCEX_FLEX_KEY_BLOCKS_LEN);
key.ctcam = ctcam; key.ctcam = ctcam;
erp = rhashtable_lookup_fast(&erp_table->erp_ht, &key, objagg_obj = objagg_obj_get(aregion->erp_table->objagg, &key);
mlxsw_sp_acl_erp_ht_params); if (IS_ERR(objagg_obj))
if (erp) { return ERR_CAST(objagg_obj);
refcount_inc(&erp->refcnt); return (struct mlxsw_sp_acl_erp_mask *) objagg_obj;
return erp; }
}
void mlxsw_sp_acl_erp_mask_put(struct mlxsw_sp_acl_atcam_region *aregion,
struct mlxsw_sp_acl_erp_mask *erp_mask)
{
struct objagg_obj *objagg_obj = (struct objagg_obj *) erp_mask;
ASSERT_RTNL();
objagg_obj_put(aregion->erp_table->objagg, objagg_obj);
}
bool
mlxsw_sp_acl_erp_mask_is_ctcam(const struct mlxsw_sp_acl_erp_mask *erp_mask)
{
struct objagg_obj *objagg_obj = (struct objagg_obj *) erp_mask;
const struct mlxsw_sp_acl_erp_key *key = objagg_obj_raw(objagg_obj);
return key->ctcam;
}
u8 mlxsw_sp_acl_erp_mask_erp_id(const struct mlxsw_sp_acl_erp_mask *erp_mask)
{
struct objagg_obj *objagg_obj = (struct objagg_obj *) erp_mask;
const struct mlxsw_sp_acl_erp *erp = objagg_obj_root_priv(objagg_obj);
return erp->id;
}
return erp_table->ops->erp_create(erp_table, &key); static void *mlxsw_sp_acl_erp_delta_create(void *priv, void *parent_obj,
void *obj)
{
return ERR_PTR(-EOPNOTSUPP);
} }
void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion, static void mlxsw_sp_acl_erp_delta_destroy(void *priv, void *delta_priv)
struct mlxsw_sp_acl_erp *erp)
{ {
}
static void *mlxsw_sp_acl_erp_root_create(void *priv, void *obj)
{
struct mlxsw_sp_acl_atcam_region *aregion = priv;
struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table; struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table;
struct mlxsw_sp_acl_erp_key *key = obj;
ASSERT_RTNL(); return erp_table->ops->erp_create(erp_table, key);
}
if (!refcount_dec_and_test(&erp->refcnt)) static void mlxsw_sp_acl_erp_root_destroy(void *priv, void *root_priv)
return; {
struct mlxsw_sp_acl_atcam_region *aregion = priv;
struct mlxsw_sp_acl_erp_table *erp_table = aregion->erp_table;
erp_table->ops->erp_destroy(erp_table, erp); erp_table->ops->erp_destroy(erp_table, root_priv);
} }
static const struct objagg_ops mlxsw_sp_acl_erp_objagg_ops = {
.obj_size = sizeof(struct mlxsw_sp_acl_erp_key),
.delta_create = mlxsw_sp_acl_erp_delta_create,
.delta_destroy = mlxsw_sp_acl_erp_delta_destroy,
.root_create = mlxsw_sp_acl_erp_root_create,
.root_destroy = mlxsw_sp_acl_erp_root_destroy,
};
static struct mlxsw_sp_acl_erp_table * static struct mlxsw_sp_acl_erp_table *
mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion) mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion)
{ {
...@@ -988,9 +992,12 @@ mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion) ...@@ -988,9 +992,12 @@ mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion)
if (!erp_table) if (!erp_table)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = rhashtable_init(&erp_table->erp_ht, &mlxsw_sp_acl_erp_ht_params); erp_table->objagg = objagg_create(&mlxsw_sp_acl_erp_objagg_ops,
if (err) aregion);
goto err_rhashtable_init; if (IS_ERR(erp_table->objagg)) {
err = PTR_ERR(erp_table->objagg);
goto err_objagg_create;
}
erp_table->erp_core = aregion->atcam->erp_core; erp_table->erp_core = aregion->atcam->erp_core;
erp_table->ops = &erp_no_mask_ops; erp_table->ops = &erp_no_mask_ops;
...@@ -999,7 +1006,7 @@ mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion) ...@@ -999,7 +1006,7 @@ mlxsw_sp_acl_erp_table_create(struct mlxsw_sp_acl_atcam_region *aregion)
return erp_table; return erp_table;
err_rhashtable_init: err_objagg_create:
kfree(erp_table); kfree(erp_table);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -1008,7 +1015,7 @@ static void ...@@ -1008,7 +1015,7 @@ static void
mlxsw_sp_acl_erp_table_destroy(struct mlxsw_sp_acl_erp_table *erp_table) mlxsw_sp_acl_erp_table_destroy(struct mlxsw_sp_acl_erp_table *erp_table)
{ {
WARN_ON(!list_empty(&erp_table->atcam_erps_list)); WARN_ON(!list_empty(&erp_table->atcam_erps_list));
rhashtable_destroy(&erp_table->erp_ht); objagg_destroy(erp_table->objagg);
kfree(erp_table); kfree(erp_table);
} }
......
...@@ -167,7 +167,7 @@ struct mlxsw_sp_acl_atcam_entry { ...@@ -167,7 +167,7 @@ struct mlxsw_sp_acl_atcam_entry {
struct mlxsw_sp_acl_atcam_entry_ht_key ht_key; struct mlxsw_sp_acl_atcam_entry_ht_key ht_key;
struct mlxsw_sp_acl_ctcam_entry centry; struct mlxsw_sp_acl_ctcam_entry centry;
struct mlxsw_sp_acl_atcam_lkey_id *lkey_id; struct mlxsw_sp_acl_atcam_lkey_id *lkey_id;
struct mlxsw_sp_acl_erp *erp; struct mlxsw_sp_acl_erp_mask *erp_mask;
}; };
static inline struct mlxsw_sp_acl_atcam_region * static inline struct mlxsw_sp_acl_atcam_region *
...@@ -209,15 +209,16 @@ int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp, ...@@ -209,15 +209,16 @@ int mlxsw_sp_acl_atcam_init(struct mlxsw_sp *mlxsw_sp,
void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp, void mlxsw_sp_acl_atcam_fini(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_atcam *atcam); struct mlxsw_sp_acl_atcam *atcam);
struct mlxsw_sp_acl_erp; struct mlxsw_sp_acl_erp_mask;
bool mlxsw_sp_acl_erp_is_ctcam_erp(const struct mlxsw_sp_acl_erp *erp); bool
u8 mlxsw_sp_acl_erp_id(const struct mlxsw_sp_acl_erp *erp); mlxsw_sp_acl_erp_mask_is_ctcam(const struct mlxsw_sp_acl_erp_mask *erp_mask);
struct mlxsw_sp_acl_erp * u8 mlxsw_sp_acl_erp_mask_erp_id(const struct mlxsw_sp_acl_erp_mask *erp_mask);
mlxsw_sp_acl_erp_get(struct mlxsw_sp_acl_atcam_region *aregion, struct mlxsw_sp_acl_erp_mask *
const char *mask, bool ctcam); mlxsw_sp_acl_erp_mask_get(struct mlxsw_sp_acl_atcam_region *aregion,
void mlxsw_sp_acl_erp_put(struct mlxsw_sp_acl_atcam_region *aregion, const char *mask, bool ctcam);
struct mlxsw_sp_acl_erp *erp); void mlxsw_sp_acl_erp_mask_put(struct mlxsw_sp_acl_atcam_region *aregion,
struct mlxsw_sp_acl_erp_mask *erp_mask);
int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion); int mlxsw_sp_acl_erp_region_init(struct mlxsw_sp_acl_atcam_region *aregion);
void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion); void mlxsw_sp_acl_erp_region_fini(struct mlxsw_sp_acl_atcam_region *aregion);
int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_erps_init(struct mlxsw_sp *mlxsw_sp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment