1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2/* Copyright (c) 2018 Mellanox Technologies */
3
4#ifndef __LIB_MLX5_DEVCOM_H__
5#define __LIB_MLX5_DEVCOM_H__
6
7#include <linux/mlx5/driver.h>
8
9enum mlx5_devcom_component {
10 MLX5_DEVCOM_ESW_OFFLOADS,
11 MLX5_DEVCOM_MPV,
12 MLX5_DEVCOM_HCA_PORTS,
13 MLX5_DEVCOM_SD_GROUP,
14 MLX5_DEVCOM_NUM_COMPONENTS,
15};
16
17typedef int (*mlx5_devcom_event_handler_t)(int event,
18 void *my_data,
19 void *event_data);
20
21struct mlx5_devcom_dev *mlx5_devcom_register_device(struct mlx5_core_dev *dev);
22void mlx5_devcom_unregister_device(struct mlx5_devcom_dev *devc);
23
24struct mlx5_devcom_comp_dev *
25mlx5_devcom_register_component(struct mlx5_devcom_dev *devc,
26 enum mlx5_devcom_component id,
27 u64 key,
28 mlx5_devcom_event_handler_t handler,
29 void *data);
30void mlx5_devcom_unregister_component(struct mlx5_devcom_comp_dev *devcom);
31
32int mlx5_devcom_send_event(struct mlx5_devcom_comp_dev *devcom,
33 int event, int rollback_event,
34 void *event_data);
35int mlx5_devcom_comp_get_size(struct mlx5_devcom_comp_dev *devcom);
36
37void mlx5_devcom_comp_set_ready(struct mlx5_devcom_comp_dev *devcom, bool ready);
38bool mlx5_devcom_comp_is_ready(struct mlx5_devcom_comp_dev *devcom);
39
40bool mlx5_devcom_for_each_peer_begin(struct mlx5_devcom_comp_dev *devcom);
41void mlx5_devcom_for_each_peer_end(struct mlx5_devcom_comp_dev *devcom);
42void *mlx5_devcom_get_next_peer_data(struct mlx5_devcom_comp_dev *devcom,
43 struct mlx5_devcom_comp_dev **pos);
44
45#define mlx5_devcom_for_each_peer_entry(devcom, data, pos) \
46 for (pos = NULL, data = mlx5_devcom_get_next_peer_data(devcom, &pos); \
47 data; \
48 data = mlx5_devcom_get_next_peer_data(devcom, &pos))
49
50void *mlx5_devcom_get_next_peer_data_rcu(struct mlx5_devcom_comp_dev *devcom,
51 struct mlx5_devcom_comp_dev **pos);
52
53#define mlx5_devcom_for_each_peer_entry_rcu(devcom, data, pos) \
54 for (pos = NULL, data = mlx5_devcom_get_next_peer_data_rcu(devcom, &pos); \
55 data; \
56 data = mlx5_devcom_get_next_peer_data_rcu(devcom, &pos))
57
58void mlx5_devcom_comp_lock(struct mlx5_devcom_comp_dev *devcom);
59void mlx5_devcom_comp_unlock(struct mlx5_devcom_comp_dev *devcom);
60int mlx5_devcom_comp_trylock(struct mlx5_devcom_comp_dev *devcom);
61
62#endif /* __LIB_MLX5_DEVCOM_H__ */
63

source code of linux/drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.h