xref: /openbmc/linux/drivers/infiniband/hw/mlx5/srq.h (revision ccb01374)
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /*
3  * Copyright (c) 2013-2018, Mellanox Technologies. All rights reserved.
4  */
5 
6 #ifndef MLX5_IB_SRQ_H
7 #define MLX5_IB_SRQ_H
8 
9 enum {
10 	MLX5_SRQ_FLAG_ERR    = (1 << 0),
11 	MLX5_SRQ_FLAG_WQ_SIG = (1 << 1),
12 	MLX5_SRQ_FLAG_RNDV   = (1 << 2),
13 };
14 
15 struct mlx5_srq_attr {
16 	u32 type;
17 	u32 flags;
18 	u32 log_size;
19 	u32 wqe_shift;
20 	u32 log_page_size;
21 	u32 wqe_cnt;
22 	u32 srqn;
23 	u32 xrcd;
24 	u32 page_offset;
25 	u32 cqn;
26 	u32 pd;
27 	u32 lwm;
28 	u32 user_index;
29 	u64 db_record;
30 	__be64 *pas;
31 	u32 tm_log_list_size;
32 	u32 tm_next_tag;
33 	u32 tm_hw_phase_cnt;
34 	u32 tm_sw_phase_cnt;
35 	u16 uid;
36 };
37 
38 struct mlx5_ib_dev;
39 
40 struct mlx5_core_srq {
41 	struct mlx5_core_rsc_common common; /* must be first */
42 	u32 srqn;
43 	int max;
44 	size_t max_gs;
45 	size_t max_avail_gather;
46 	int wqe_shift;
47 	void (*event)(struct mlx5_core_srq *srq, enum mlx5_event e);
48 
49 	atomic_t refcount;
50 	struct completion free;
51 	u16 uid;
52 };
53 
54 struct mlx5_srq_table {
55 	struct notifier_block nb;
56 	/* protect radix tree
57 	 */
58 	spinlock_t lock;
59 	struct radix_tree_root tree;
60 };
61 
62 int mlx5_cmd_create_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
63 			struct mlx5_srq_attr *in);
64 int mlx5_cmd_destroy_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq);
65 int mlx5_cmd_query_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
66 		       struct mlx5_srq_attr *out);
67 int mlx5_cmd_arm_srq(struct mlx5_ib_dev *dev, struct mlx5_core_srq *srq,
68 		     u16 lwm, int is_srq);
69 struct mlx5_core_srq *mlx5_cmd_get_srq(struct mlx5_ib_dev *dev, u32 srqn);
70 
71 int mlx5_init_srq_table(struct mlx5_ib_dev *dev);
72 void mlx5_cleanup_srq_table(struct mlx5_ib_dev *dev);
73 #endif /* MLX5_IB_SRQ_H */
74