xref: /linux/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.h (revision e65e175b07bef5974045cc42238de99057669ca7)
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2020 Mellanox Technologies. All rights reserved */
3 
4 #ifndef _MLXSW_SPECTRUM_TRAP_H
5 #define _MLXSW_SPECTRUM_TRAP_H
6 
7 #include <linux/list.h>
8 #include <net/devlink.h>
9 
10 struct mlxsw_sp_trap {
11 	struct mlxsw_sp_trap_policer_item *policer_items_arr;
12 	size_t policers_count; /* Number of registered policers */
13 
14 	struct mlxsw_sp_trap_group_item *group_items_arr;
15 	size_t groups_count; /* Number of registered groups */
16 
17 	struct mlxsw_sp_trap_item *trap_items_arr;
18 	size_t traps_count; /* Number of registered traps */
19 
20 	u16 thin_policer_hw_id;
21 
22 	u64 max_policers;
23 	unsigned long policers_usage[]; /* Usage bitmap */
24 };
25 
26 struct mlxsw_sp_trap_ops {
27 	int (*groups_init)(struct mlxsw_sp *mlxsw_sp,
28 			   const struct mlxsw_sp_trap_group_item **arr,
29 			   size_t *p_groups_count);
30 	int (*traps_init)(struct mlxsw_sp *mlxsw_sp,
31 			  const struct mlxsw_sp_trap_item **arr,
32 			  size_t *p_traps_count);
33 };
34 
35 extern const struct mlxsw_sp_trap_ops mlxsw_sp1_trap_ops;
36 extern const struct mlxsw_sp_trap_ops mlxsw_sp2_trap_ops;
37 
38 #endif
39