Lines Matching full:family
30 int (*init)(struct mlxsw_sp_policer_family *family);
31 void (*fini)(struct mlxsw_sp_policer_family *family);
32 int (*policer_index_alloc)(struct mlxsw_sp_policer_family *family,
34 struct mlxsw_sp_policer * (*policer_index_free)(struct mlxsw_sp_policer_family *family,
36 int (*policer_init)(struct mlxsw_sp_policer_family *family,
38 int (*policer_params_check)(const struct mlxsw_sp_policer_family *family,
74 struct mlxsw_sp_policer_family *family = priv; in mlxsw_sp_policer_single_rate_occ_get() local
76 return atomic_read(&family->policers_count); in mlxsw_sp_policer_single_rate_occ_get()
80 mlxsw_sp_policer_single_rate_family_init(struct mlxsw_sp_policer_family *family) in mlxsw_sp_policer_single_rate_family_init() argument
82 struct mlxsw_core *core = family->mlxsw_sp->core; in mlxsw_sp_policer_single_rate_family_init()
92 family->start_index = MLXSW_CORE_RES_GET(core, MAX_CPU_POLICERS); in mlxsw_sp_policer_single_rate_family_init()
93 family->end_index = MLXSW_CORE_RES_GET(core, MAX_GLOBAL_POLICERS); in mlxsw_sp_policer_single_rate_family_init()
95 atomic_set(&family->policers_count, 0); in mlxsw_sp_policer_single_rate_family_init()
100 family); in mlxsw_sp_policer_single_rate_family_init()
106 mlxsw_sp_policer_single_rate_family_fini(struct mlxsw_sp_policer_family *family) in mlxsw_sp_policer_single_rate_family_fini() argument
108 struct devlink *devlink = priv_to_devlink(family->mlxsw_sp->core); in mlxsw_sp_policer_single_rate_family_fini()
112 WARN_ON(atomic_read(&family->policers_count) != 0); in mlxsw_sp_policer_single_rate_family_fini()
116 mlxsw_sp_policer_single_rate_index_alloc(struct mlxsw_sp_policer_family *family, in mlxsw_sp_policer_single_rate_index_alloc() argument
121 mutex_lock(&family->lock); in mlxsw_sp_policer_single_rate_index_alloc()
122 id = idr_alloc(&family->policer_idr, policer, family->start_index, in mlxsw_sp_policer_single_rate_index_alloc()
123 family->end_index, GFP_KERNEL); in mlxsw_sp_policer_single_rate_index_alloc()
124 mutex_unlock(&family->lock); in mlxsw_sp_policer_single_rate_index_alloc()
129 atomic_inc(&family->policers_count); in mlxsw_sp_policer_single_rate_index_alloc()
136 mlxsw_sp_policer_single_rate_index_free(struct mlxsw_sp_policer_family *family, in mlxsw_sp_policer_single_rate_index_free() argument
141 atomic_dec(&family->policers_count); in mlxsw_sp_policer_single_rate_index_free()
143 mutex_lock(&family->lock); in mlxsw_sp_policer_single_rate_index_free()
144 policer = idr_remove(&family->policer_idr, policer_index); in mlxsw_sp_policer_single_rate_index_free()
145 mutex_unlock(&family->lock); in mlxsw_sp_policer_single_rate_index_free()
153 mlxsw_sp_policer_single_rate_init(struct mlxsw_sp_policer_family *family, in mlxsw_sp_policer_single_rate_init() argument
158 struct mlxsw_sp *mlxsw_sp = family->mlxsw_sp; in mlxsw_sp_policer_single_rate_init()
169 mlxsw_sp_policer_single_rate_params_check(const struct mlxsw_sp_policer_family *family, in mlxsw_sp_policer_single_rate_params_check() argument
173 struct mlxsw_sp_policer_core *policer_core = family->mlxsw_sp->policer_core; in mlxsw_sp_policer_single_rate_params_check()
236 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policer_add() local
240 family = mlxsw_sp->policer_core->family_arr[type]; in mlxsw_sp_policer_add()
242 err = family->ops->policer_params_check(family, params, extack); in mlxsw_sp_policer_add()
251 err = family->ops->policer_index_alloc(family, policer); in mlxsw_sp_policer_add()
257 err = family->ops->policer_init(family, policer); in mlxsw_sp_policer_add()
268 family->ops->policer_index_free(family, policer->index); in mlxsw_sp_policer_add()
277 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policer_del() local
280 family = mlxsw_sp->policer_core->family_arr[type]; in mlxsw_sp_policer_del()
281 policer = family->ops->policer_index_free(family, policer_index); in mlxsw_sp_policer_del()
289 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policer_drops_counter_get() local
293 family = mlxsw_sp->policer_core->family_arr[type]; in mlxsw_sp_policer_drops_counter_get()
297 mlxsw_reg_qpcr_g_set(qpcr_pl, family->qpcr_type); in mlxsw_sp_policer_drops_counter_get()
311 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policer_family_register() local
314 family = kmemdup(tmpl, sizeof(*family), GFP_KERNEL); in mlxsw_sp_policer_family_register()
315 if (!family) in mlxsw_sp_policer_family_register()
318 family->mlxsw_sp = mlxsw_sp; in mlxsw_sp_policer_family_register()
319 idr_init(&family->policer_idr); in mlxsw_sp_policer_family_register()
320 mutex_init(&family->lock); in mlxsw_sp_policer_family_register()
322 err = family->ops->init(family); in mlxsw_sp_policer_family_register()
326 if (WARN_ON(family->start_index >= family->end_index)) { in mlxsw_sp_policer_family_register()
331 mlxsw_sp->policer_core->family_arr[tmpl->type] = family; in mlxsw_sp_policer_family_register()
336 family->ops->fini(family); in mlxsw_sp_policer_family_register()
338 mutex_destroy(&family->lock); in mlxsw_sp_policer_family_register()
339 idr_destroy(&family->policer_idr); in mlxsw_sp_policer_family_register()
340 kfree(family); in mlxsw_sp_policer_family_register()
346 struct mlxsw_sp_policer_family *family) in mlxsw_sp_policer_family_unregister() argument
348 family->ops->fini(family); in mlxsw_sp_policer_family_unregister()
349 mutex_destroy(&family->lock); in mlxsw_sp_policer_family_unregister()
350 WARN_ON(!idr_is_empty(&family->policer_idr)); in mlxsw_sp_policer_family_unregister()
351 idr_destroy(&family->policer_idr); in mlxsw_sp_policer_family_unregister()
352 kfree(family); in mlxsw_sp_policer_family_unregister()
380 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policers_init() local
382 family = mlxsw_sp->policer_core->family_arr[i]; in mlxsw_sp_policers_init()
383 mlxsw_sp_policer_family_unregister(mlxsw_sp, family); in mlxsw_sp_policers_init()
395 struct mlxsw_sp_policer_family *family; in mlxsw_sp_policers_fini() local
397 family = mlxsw_sp->policer_core->family_arr[i]; in mlxsw_sp_policers_fini()
398 mlxsw_sp_policer_family_unregister(mlxsw_sp, family); in mlxsw_sp_policers_fini()