Lines Matching refs:ruleset
64 struct mlxsw_sp_acl_ruleset *ruleset; member
94 mlxsw_sp_acl_ruleset_is_singular(const struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_is_singular() argument
97 return ruleset->ref_count == 2; in mlxsw_sp_acl_ruleset_is_singular()
104 struct mlxsw_sp_acl_ruleset *ruleset = block->ruleset_zero; in mlxsw_sp_acl_ruleset_bind() local
105 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_ruleset_bind()
107 return ops->ruleset_bind(mlxsw_sp, ruleset->priv, in mlxsw_sp_acl_ruleset_bind()
115 struct mlxsw_sp_acl_ruleset *ruleset = block->ruleset_zero; in mlxsw_sp_acl_ruleset_unbind() local
116 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_ruleset_unbind()
118 ops->ruleset_unbind(mlxsw_sp, ruleset->priv, in mlxsw_sp_acl_ruleset_unbind()
124 struct mlxsw_sp_acl_ruleset *ruleset, in mlxsw_sp_acl_ruleset_block_bind() argument
130 block->ruleset_zero = ruleset; in mlxsw_sp_acl_ruleset_block_bind()
149 struct mlxsw_sp_acl_ruleset *ruleset, in mlxsw_sp_acl_ruleset_block_unbind() argument
166 struct mlxsw_sp_acl_ruleset *ruleset; in mlxsw_sp_acl_ruleset_create() local
170 alloc_size = sizeof(*ruleset) + ops->ruleset_priv_size; in mlxsw_sp_acl_ruleset_create()
171 ruleset = kzalloc(alloc_size, GFP_KERNEL); in mlxsw_sp_acl_ruleset_create()
172 if (!ruleset) in mlxsw_sp_acl_ruleset_create()
174 ruleset->ref_count = 1; in mlxsw_sp_acl_ruleset_create()
175 ruleset->ht_key.block = block; in mlxsw_sp_acl_ruleset_create()
176 ruleset->ht_key.chain_index = chain_index; in mlxsw_sp_acl_ruleset_create()
177 ruleset->ht_key.ops = ops; in mlxsw_sp_acl_ruleset_create()
179 err = rhashtable_init(&ruleset->rule_ht, &mlxsw_sp_acl_rule_ht_params); in mlxsw_sp_acl_ruleset_create()
183 err = ops->ruleset_add(mlxsw_sp, &acl->tcam, ruleset->priv, in mlxsw_sp_acl_ruleset_create()
184 tmplt_elusage, &ruleset->min_prio, in mlxsw_sp_acl_ruleset_create()
185 &ruleset->max_prio); in mlxsw_sp_acl_ruleset_create()
189 err = rhashtable_insert_fast(&acl->ruleset_ht, &ruleset->ht_node, in mlxsw_sp_acl_ruleset_create()
194 return ruleset; in mlxsw_sp_acl_ruleset_create()
197 ops->ruleset_del(mlxsw_sp, ruleset->priv); in mlxsw_sp_acl_ruleset_create()
199 rhashtable_destroy(&ruleset->rule_ht); in mlxsw_sp_acl_ruleset_create()
201 kfree(ruleset); in mlxsw_sp_acl_ruleset_create()
206 struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_destroy() argument
208 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_ruleset_destroy()
211 rhashtable_remove_fast(&acl->ruleset_ht, &ruleset->ht_node, in mlxsw_sp_acl_ruleset_destroy()
213 ops->ruleset_del(mlxsw_sp, ruleset->priv); in mlxsw_sp_acl_ruleset_destroy()
214 rhashtable_destroy(&ruleset->rule_ht); in mlxsw_sp_acl_ruleset_destroy()
215 kfree(ruleset); in mlxsw_sp_acl_ruleset_destroy()
218 static void mlxsw_sp_acl_ruleset_ref_inc(struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_ref_inc() argument
220 ruleset->ref_count++; in mlxsw_sp_acl_ruleset_ref_inc()
224 struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_ref_dec() argument
226 if (--ruleset->ref_count) in mlxsw_sp_acl_ruleset_ref_dec()
228 mlxsw_sp_acl_ruleset_destroy(mlxsw_sp, ruleset); in mlxsw_sp_acl_ruleset_ref_dec()
253 struct mlxsw_sp_acl_ruleset *ruleset; in mlxsw_sp_acl_ruleset_lookup() local
258 ruleset = __mlxsw_sp_acl_ruleset_lookup(acl, block, chain_index, ops); in mlxsw_sp_acl_ruleset_lookup()
259 if (!ruleset) in mlxsw_sp_acl_ruleset_lookup()
261 return ruleset; in mlxsw_sp_acl_ruleset_lookup()
272 struct mlxsw_sp_acl_ruleset *ruleset; in mlxsw_sp_acl_ruleset_get() local
278 ruleset = __mlxsw_sp_acl_ruleset_lookup(acl, block, chain_index, ops); in mlxsw_sp_acl_ruleset_get()
279 if (ruleset) { in mlxsw_sp_acl_ruleset_get()
280 mlxsw_sp_acl_ruleset_ref_inc(ruleset); in mlxsw_sp_acl_ruleset_get()
281 return ruleset; in mlxsw_sp_acl_ruleset_get()
288 struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_put() argument
290 mlxsw_sp_acl_ruleset_ref_dec(mlxsw_sp, ruleset); in mlxsw_sp_acl_ruleset_put()
293 u16 mlxsw_sp_acl_ruleset_group_id(struct mlxsw_sp_acl_ruleset *ruleset) in mlxsw_sp_acl_ruleset_group_id() argument
295 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_ruleset_group_id()
297 return ops->ruleset_group_id(ruleset->priv); in mlxsw_sp_acl_ruleset_group_id()
300 void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, in mlxsw_sp_acl_ruleset_prio_get() argument
304 *p_min_prio = ruleset->min_prio; in mlxsw_sp_acl_ruleset_prio_get()
305 *p_max_prio = ruleset->max_prio; in mlxsw_sp_acl_ruleset_prio_get()
693 struct mlxsw_sp_acl_ruleset *ruleset, in mlxsw_sp_acl_rule_create() argument
698 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_rule_create()
702 mlxsw_sp_acl_ruleset_ref_inc(ruleset); in mlxsw_sp_acl_rule_create()
710 rule->ruleset = ruleset; in mlxsw_sp_acl_rule_create()
723 mlxsw_sp_acl_ruleset_ref_dec(mlxsw_sp, ruleset); in mlxsw_sp_acl_rule_create()
730 struct mlxsw_sp_acl_ruleset *ruleset = rule->ruleset; in mlxsw_sp_acl_rule_destroy() local
734 mlxsw_sp_acl_ruleset_ref_dec(mlxsw_sp, ruleset); in mlxsw_sp_acl_rule_destroy()
740 struct mlxsw_sp_acl_ruleset *ruleset = rule->ruleset; in mlxsw_sp_acl_rule_add() local
741 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_rule_add()
742 struct mlxsw_sp_flow_block *block = ruleset->ht_key.block; in mlxsw_sp_acl_rule_add()
745 err = ops->rule_add(mlxsw_sp, ruleset->priv, rule->priv, rule->rulei); in mlxsw_sp_acl_rule_add()
749 err = rhashtable_insert_fast(&ruleset->rule_ht, &rule->ht_node, in mlxsw_sp_acl_rule_add()
754 if (!ruleset->ht_key.chain_index && in mlxsw_sp_acl_rule_add()
755 mlxsw_sp_acl_ruleset_is_singular(ruleset)) { in mlxsw_sp_acl_rule_add()
760 err = mlxsw_sp_acl_ruleset_block_bind(mlxsw_sp, ruleset, block); in mlxsw_sp_acl_rule_add()
774 rhashtable_remove_fast(&ruleset->rule_ht, &rule->ht_node, in mlxsw_sp_acl_rule_add()
784 struct mlxsw_sp_acl_ruleset *ruleset = rule->ruleset; in mlxsw_sp_acl_rule_del() local
785 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_rule_del()
786 struct mlxsw_sp_flow_block *block = ruleset->ht_key.block; in mlxsw_sp_acl_rule_del()
794 if (!ruleset->ht_key.chain_index && in mlxsw_sp_acl_rule_del()
795 mlxsw_sp_acl_ruleset_is_singular(ruleset)) in mlxsw_sp_acl_rule_del()
796 mlxsw_sp_acl_ruleset_block_unbind(mlxsw_sp, ruleset, block); in mlxsw_sp_acl_rule_del()
797 rhashtable_remove_fast(&ruleset->rule_ht, &rule->ht_node, in mlxsw_sp_acl_rule_del()
806 struct mlxsw_sp_acl_ruleset *ruleset = rule->ruleset; in mlxsw_sp_acl_rule_action_replace() local
807 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_rule_action_replace()
818 struct mlxsw_sp_acl_ruleset *ruleset, in mlxsw_sp_acl_rule_lookup() argument
821 return rhashtable_lookup_fast(&ruleset->rule_ht, &cookie, in mlxsw_sp_acl_rule_lookup()
834 struct mlxsw_sp_acl_ruleset *ruleset = rule->ruleset; in mlxsw_sp_acl_rule_activity_update() local
835 const struct mlxsw_sp_acl_profile_ops *ops = ruleset->ht_key.ops; in mlxsw_sp_acl_rule_activity_update()