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_param_id { 10 MLX5_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, 11 MLX5_DEVLINK_PARAM_ID_FLOW_STEERING_MODE, 12 MLX5_DEVLINK_PARAM_ID_ESW_LARGE_GROUP_NUM, 13 MLX5_DEVLINK_PARAM_ID_ESW_PORT_METADATA, 14 MLX5_DEVLINK_PARAM_ID_ESW_MULTIPORT, 15 MLX5_DEVLINK_PARAM_ID_HAIRPIN_NUM_QUEUES, 16 MLX5_DEVLINK_PARAM_ID_HAIRPIN_QUEUE_SIZE, 17 }; 18 19 struct mlx5_trap_ctx { 20 int id; 21 int action; 22 }; 23 24 struct mlx5_devlink_trap { 25 struct mlx5_trap_ctx trap; 26 void *item; 27 struct list_head list; 28 }; 29 30 struct mlx5_devlink_trap_event_ctx { 31 struct mlx5_trap_ctx *trap; 32 int err; 33 }; 34 35 struct mlx5_core_dev; 36 void mlx5_devlink_trap_report(struct mlx5_core_dev *dev, int trap_id, struct sk_buff *skb, 37 struct devlink_port *dl_port); 38 int mlx5_devlink_trap_get_num_active(struct mlx5_core_dev *dev); 39 int mlx5_devlink_traps_get_action(struct mlx5_core_dev *dev, int trap_id, 40 enum devlink_trap_action *action); 41 int mlx5_devlink_traps_register(struct devlink *devlink); 42 void mlx5_devlink_traps_unregister(struct devlink *devlink); 43 44 struct devlink *mlx5_devlink_alloc(struct device *dev); 45 void mlx5_devlink_free(struct devlink *devlink); 46 int mlx5_devlink_params_register(struct devlink *devlink); 47 void mlx5_devlink_params_unregister(struct devlink *devlink); 48 49 static inline bool mlx5_core_is_eth_enabled(struct mlx5_core_dev *dev) 50 { 51 union devlink_param_value val; 52 int err; 53 54 err = devl_param_driverinit_value_get(priv_to_devlink(dev), 55 DEVLINK_PARAM_GENERIC_ID_ENABLE_ETH, 56 &val); 57 return err ? false : val.vbool; 58 } 59 60 #endif /* __MLX5_DEVLINK_H__ */ 61