Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
0002 /* Copyright (c) 2018 Mellanox Technologies. */
0003 
0004 #ifndef MLX5_CORE_EQ_H
0005 #define MLX5_CORE_EQ_H
0006 
0007 #define MLX5_NUM_CMD_EQE   (32)
0008 #define MLX5_NUM_ASYNC_EQE (0x1000)
0009 #define MLX5_NUM_SPARE_EQE (0x80)
0010 
0011 struct mlx5_eq;
0012 struct mlx5_irq;
0013 struct mlx5_core_dev;
0014 
0015 struct mlx5_eq_param {
0016     int            nent;
0017     u64            mask[4];
0018     struct mlx5_irq *irq;
0019 };
0020 
0021 struct mlx5_eq *
0022 mlx5_eq_create_generic(struct mlx5_core_dev *dev, struct mlx5_eq_param *param);
0023 int
0024 mlx5_eq_destroy_generic(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
0025 int mlx5_eq_enable(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
0026            struct notifier_block *nb);
0027 void mlx5_eq_disable(struct mlx5_core_dev *dev, struct mlx5_eq *eq,
0028              struct notifier_block *nb);
0029 
0030 struct mlx5_eqe *mlx5_eq_get_eqe(struct mlx5_eq *eq, u32 cc);
0031 void mlx5_eq_update_ci(struct mlx5_eq *eq, u32 cc, bool arm);
0032 
0033 /* The HCA will think the queue has overflowed if we
0034  * don't tell it we've been processing events.  We
0035  * create EQs with MLX5_NUM_SPARE_EQE extra entries,
0036  * so we must update our consumer index at
0037  * least that often.
0038  *
0039  * mlx5_eq_update_cc must be called on every EQE @EQ irq handler
0040  */
0041 static inline u32 mlx5_eq_update_cc(struct mlx5_eq *eq, u32 cc)
0042 {
0043     if (unlikely(cc >= MLX5_NUM_SPARE_EQE)) {
0044         mlx5_eq_update_ci(eq, cc, 0);
0045         cc = 0;
0046     }
0047     return cc;
0048 }
0049 
0050 struct mlx5_nb {
0051     struct notifier_block nb;
0052     u8 event_type;
0053 };
0054 
0055 #define mlx5_nb_cof(ptr, type, member) \
0056     (container_of(container_of(ptr, struct mlx5_nb, nb), type, member))
0057 
0058 #define MLX5_NB_INIT(name, handler, event) do {              \
0059     (name)->nb.notifier_call = handler;                  \
0060     (name)->event_type = MLX5_EVENT_TYPE_##event;        \
0061 } while (0)
0062 
0063 #endif /* MLX5_CORE_EQ_H */