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