xref: /linux/drivers/net/ethernet/mellanox/mlx5/core/sf/vhca_event.h (revision 8f7aa3d3c7323f4ca2768a9e74ebbe359c4f8f88)
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020 Mellanox Technologies Ltd */
3 
4 #ifndef __MLX5_VHCA_EVENT_H__
5 #define __MLX5_VHCA_EVENT_H__
6 
7 #ifdef CONFIG_MLX5_SF
8 
9 struct mlx5_vhca_state_event {
10 	u16 function_id;
11 	u16 sw_function_id;
12 	u8 new_vhca_state;
13 };
14 
mlx5_vhca_event_supported(const struct mlx5_core_dev * dev)15 static inline bool mlx5_vhca_event_supported(const struct mlx5_core_dev *dev)
16 {
17 	return MLX5_CAP_GEN_MAX(dev, vhca_state);
18 }
19 
20 void mlx5_vhca_state_cap_handle(struct mlx5_core_dev *dev, void *set_hca_cap);
21 void mlx5_vhca_state_notifier_init(struct mlx5_core_dev *dev);
22 int mlx5_vhca_event_init(struct mlx5_core_dev *dev);
23 void mlx5_vhca_event_cleanup(struct mlx5_core_dev *dev);
24 void mlx5_vhca_event_start(struct mlx5_core_dev *dev);
25 void mlx5_vhca_event_stop(struct mlx5_core_dev *dev);
26 int mlx5_vhca_event_notifier_register(struct mlx5_core_dev *dev, struct notifier_block *nb);
27 void mlx5_vhca_event_notifier_unregister(struct mlx5_core_dev *dev, struct notifier_block *nb);
28 int mlx5_modify_vhca_sw_id(struct mlx5_core_dev *dev, u16 function_id, u32 sw_fn_id);
29 int mlx5_vhca_event_arm(struct mlx5_core_dev *dev, u16 function_id);
30 int mlx5_cmd_query_vhca_state(struct mlx5_core_dev *dev, u16 function_id,
31 			      u32 *out, u32 outlen);
32 void mlx5_vhca_events_work_enqueue(struct mlx5_core_dev *dev, int idx, struct work_struct *work);
33 void mlx5_vhca_event_work_queues_flush(struct mlx5_core_dev *dev);
34 
35 #else
36 
mlx5_vhca_state_cap_handle(struct mlx5_core_dev * dev,void * set_hca_cap)37 static inline void mlx5_vhca_state_cap_handle(struct mlx5_core_dev *dev, void *set_hca_cap)
38 {
39 }
40 
mlx5_vhca_state_notifier_init(struct mlx5_core_dev * dev)41 static inline void mlx5_vhca_state_notifier_init(struct mlx5_core_dev *dev)
42 {
43 }
44 
mlx5_vhca_event_init(struct mlx5_core_dev * dev)45 static inline int mlx5_vhca_event_init(struct mlx5_core_dev *dev)
46 {
47 	return 0;
48 }
49 
mlx5_vhca_event_cleanup(struct mlx5_core_dev * dev)50 static inline void mlx5_vhca_event_cleanup(struct mlx5_core_dev *dev)
51 {
52 }
53 
mlx5_vhca_event_start(struct mlx5_core_dev * dev)54 static inline void mlx5_vhca_event_start(struct mlx5_core_dev *dev)
55 {
56 }
57 
mlx5_vhca_event_stop(struct mlx5_core_dev * dev)58 static inline void mlx5_vhca_event_stop(struct mlx5_core_dev *dev)
59 {
60 }
61 
62 #endif
63 
64 #endif
65