1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2019, Mellanox Technologies */
3
4 #ifndef __MLX5_DEVLINK_H__
5 #define __MLX5_DEVLINK_H__
6
7 #include <net/devlink.h>
8
9 enum mlx5_devlink_resource_id {
10 MLX5_DL_RES_MAX_LOCAL_SFS = 1,
11 MLX5_DL_RES_MAX_EXTERNAL_SFS,
12
13 __MLX5_ID_RES_MAX,
14 MLX5_ID_RES_MAX = __MLX5_ID_RES_MAX - 1,
15 };
16
17 enum mlx5_devlink_param_id {
18 MLX5_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
19 MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE,
20 MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM,
21 MLX5_DEVLINK_PARAM_ID_ESW_PORT_METADATA,
22 MLX5_DEVLINK_PARAM_ID_ESW_MULTIPORT,
23 MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES,
24 MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE,
25 };
26
27 struct mlx5_trap_ctx {
28 int id;
29 int action;
30 };
31
32 struct mlx5_devlink_trap {
33 struct mlx5_trap_ctx trap;
34 void *item;
35 struct list_head list;
36 };
37
38 struct mlx5_devlink_trap_event_ctx {
39 struct mlx5_trap_ctx *trap;
40 int err;
41 };
42
43 struct mlx5_core_dev;
44 void mlx5_devlink_trap_report(struct mlx5_core_dev *dev, int trap_id, struct sk_buff *skb,
45 struct devlink_port *dl_port);
46 int mlx5_devlink_trap_get_num_active(struct mlx5_core_dev *dev);
47 int mlx5_devlink_traps_get_action(struct mlx5_core_dev *dev, int trap_id,
48 enum devlink_trap_action *action);
49 int mlx5_devlink_traps_register(struct devlink *devlink);
50 void mlx5_devlink_traps_unregister(struct devlink *devlink);
51
52 struct devlink *mlx5_devlink_alloc(struct device *dev);
53 void mlx5_devlink_free(struct devlink *devlink);
54 int mlx5_devlink_params_register(struct devlink *devlink);
55 void mlx5_devlink_params_unregister(struct devlink *devlink);
56
mlx5_core_is_eth_enabled(struct mlx5_core_dev * dev)57 static inline bool mlx5_core_is_eth_enabled(struct mlx5_core_dev *dev)
58 {
59 union devlink_param_value val;
60 int err;
61
62 err = devl_param_driverinit_value_get(priv_to_devlink(dev),
63 DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH,
64 &val);
65 return err ? false : val.vbool;
66 }
67
68 #endif /* __MLX5_DEVLINK_H__ */
69