18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2020 Mellanox Technologies. All rights reserved */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _MLXSW_SPECTRUM_TRAP_H
58c2ecf20Sopenharmony_ci#define _MLXSW_SPECTRUM_TRAP_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/list.h>
88c2ecf20Sopenharmony_ci#include <net/devlink.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistruct mlxsw_sp_trap {
118c2ecf20Sopenharmony_ci	struct mlxsw_sp_trap_policer_item *policer_items_arr;
128c2ecf20Sopenharmony_ci	size_t policers_count; /* Number of registered policers */
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci	struct mlxsw_sp_trap_group_item *group_items_arr;
158c2ecf20Sopenharmony_ci	size_t groups_count; /* Number of registered groups */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	struct mlxsw_sp_trap_item *trap_items_arr;
188c2ecf20Sopenharmony_ci	size_t traps_count; /* Number of registered traps */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	u16 thin_policer_hw_id;
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci	u64 max_policers;
238c2ecf20Sopenharmony_ci	unsigned long policers_usage[]; /* Usage bitmap */
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct mlxsw_sp_trap_ops {
278c2ecf20Sopenharmony_ci	int (*groups_init)(struct mlxsw_sp *mlxsw_sp,
288c2ecf20Sopenharmony_ci			   const struct mlxsw_sp_trap_group_item **arr,
298c2ecf20Sopenharmony_ci			   size_t *p_groups_count);
308c2ecf20Sopenharmony_ci	int (*traps_init)(struct mlxsw_sp *mlxsw_sp,
318c2ecf20Sopenharmony_ci			  const struct mlxsw_sp_trap_item **arr,
328c2ecf20Sopenharmony_ci			  size_t *p_traps_count);
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_trap_ops mlxsw_sp1_trap_ops;
368c2ecf20Sopenharmony_ciextern const struct mlxsw_sp_trap_ops mlxsw_sp2_trap_ops;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#endif
39