2018-11-19 18:52:40 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
|
|
|
|
/* Copyright (c) 2018 Mellanox Technologies. */
|
|
|
|
|
|
|
|
#ifndef MLX5_CORE_EQ_H
|
|
|
|
#define MLX5_CORE_EQ_H
|
|
|
|
|
2018-11-19 18:52:41 +00:00
|
|
|
#define MLX5_NUM_CMD_EQE (32)
|
2021-10-26 15:29:39 +00:00
|
|
|
#define MLX5_NUM_ASYNC_EQE (0x1000)
|
2018-11-19 18:52:41 +00:00
|
|
|
#define MLX5_NUM_SPARE_EQE (0x80)
|
|
|
|
|
2018-11-19 18:52:40 +00:00
|
|
|
struct mlx5_eq;
|
2021-12-12 12:51:27 +00:00
|
|
|
struct mlx5_irq;
|
2018-11-20 22:12:18 +00:00
|
|
|
struct mlx5_core_dev;
|
2018-11-19 18:52:40 +00:00
|
|
|
|
|
|
|
struct mlx5_eq_param {
|
|
|
|
int nent;
|
2019-06-30 16:23:23 +00:00
|
|
|
u64 mask[4];
|
2021-12-12 12:51:27 +00:00
|
|
|
struct mlx5_irq *irq;
|
2018-11-19 18:52:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mlx5_eq *
|
2019-06-10 23:38:25 +00:00
|
|
|
mlx5_eq_create_generic(struct mlx5_core_dev *dev, struct mlx5_eq_param *param);
|
2018-11-19 18:52:40 +00:00
|
|
|
int
|
|
|
|
mlx5_eq_destroy_generic(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
|
2019-06-10 23:38:42 +00:00
|
|
|
int mlx5_eq_enable(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
|
|
|
|
struct notifier_block *nb);
|
|
|
|
void mlx5_eq_disable(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
|
|
|
|
struct notifier_block *nb);
|
2018-11-19 18:52:40 +00:00
|
|
|
|
|
|
|
struct mlx5_eqe *mlx5_eq_get_eqe(struct mlx5_eq *eq, u32 cc);
|
|
|
|
void mlx5_eq_update_ci(struct mlx5_eq *eq, u32 cc, bool arm);
|
|
|
|
|
2018-11-19 18:52:41 +00:00
|
|
|
/* The HCA will think the queue has overflowed if we
|
|
|
|
* don't tell it we've been processing events. We
|
|
|
|
* create EQs with MLX5_NUM_SPARE_EQE extra entries,
|
|
|
|
* so we must update our consumer index at
|
|
|
|
* least that often.
|
|
|
|
*
|
|
|
|
* mlx5_eq_update_cc must be called on every EQE @EQ irq handler
|
|
|
|
*/
|
|
|
|
static inline u32 mlx5_eq_update_cc(struct mlx5_eq *eq, u32 cc)
|
|
|
|
{
|
|
|
|
if (unlikely(cc >= MLX5_NUM_SPARE_EQE)) {
|
|
|
|
mlx5_eq_update_ci(eq, cc, 0);
|
|
|
|
cc = 0;
|
|
|
|
}
|
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
|
2018-11-20 22:12:18 +00:00
|
|
|
struct mlx5_nb {
|
|
|
|
struct notifier_block nb;
|
|
|
|
u8 event_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define mlx5_nb_cof(ptr, type, member) \
|
|
|
|
(container_of(container_of(ptr, struct mlx5_nb, nb), type, member))
|
|
|
|
|
|
|
|
#define MLX5_NB_INIT(name, handler, event) do { \
|
|
|
|
(name)->nb.notifier_call = handler; \
|
|
|
|
(name)->event_type = MLX5_EVENT_TYPE_##event; \
|
|
|
|
} while (0)
|
|
|
|
|
2018-11-19 18:52:40 +00:00
|
|
|
#endif /* MLX5_CORE_EQ_H */
|