xref: /linux/drivers/infiniband/hw/irdma/user.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
1*3ec648c6SKrzysztof Kozlowski /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2551c46edSMustafa Ismail /* Copyright (c) 2015 - 2020 Intel Corporation */
3551c46edSMustafa Ismail #ifndef IRDMA_USER_H
4551c46edSMustafa Ismail #define IRDMA_USER_H
5551c46edSMustafa Ismail 
6551c46edSMustafa Ismail #define irdma_handle void *
7551c46edSMustafa Ismail #define irdma_adapter_handle irdma_handle
8551c46edSMustafa Ismail #define irdma_qp_handle irdma_handle
9551c46edSMustafa Ismail #define irdma_cq_handle irdma_handle
10551c46edSMustafa Ismail #define irdma_pd_id irdma_handle
11551c46edSMustafa Ismail #define irdma_stag_handle irdma_handle
12551c46edSMustafa Ismail #define irdma_stag_index u32
13551c46edSMustafa Ismail #define irdma_stag u32
14551c46edSMustafa Ismail #define irdma_stag_key u8
15551c46edSMustafa Ismail #define irdma_tagged_offset u64
16551c46edSMustafa Ismail #define irdma_access_privileges u32
17551c46edSMustafa Ismail #define irdma_physical_fragment u64
18551c46edSMustafa Ismail #define irdma_address_list u64 *
19551c46edSMustafa Ismail 
20551c46edSMustafa Ismail #define	IRDMA_MAX_MR_SIZE       0x200000000000ULL
21551c46edSMustafa Ismail 
22551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_LOCALREAD		0x01
23551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_LOCALWRITE		0x02
24551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_REMOTEREAD_ONLY	0x04
25551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_REMOTEREAD		0x05
26551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_REMOTEWRITE_ONLY	0x08
27551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_REMOTEWRITE		0x0a
28551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_BIND_WINDOW		0x10
29551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_ZERO_BASED		0x20
30551c46edSMustafa Ismail #define IRDMA_ACCESS_FLAGS_ALL			0x3f
31551c46edSMustafa Ismail 
32551c46edSMustafa Ismail #define IRDMA_OP_TYPE_RDMA_WRITE		0x00
33551c46edSMustafa Ismail #define IRDMA_OP_TYPE_RDMA_READ			0x01
34551c46edSMustafa Ismail #define IRDMA_OP_TYPE_SEND			0x03
35551c46edSMustafa Ismail #define IRDMA_OP_TYPE_SEND_INV			0x04
36551c46edSMustafa Ismail #define IRDMA_OP_TYPE_SEND_SOL			0x05
37551c46edSMustafa Ismail #define IRDMA_OP_TYPE_SEND_SOL_INV		0x06
38551c46edSMustafa Ismail #define IRDMA_OP_TYPE_RDMA_WRITE_SOL		0x0d
39551c46edSMustafa Ismail #define IRDMA_OP_TYPE_BIND_MW			0x08
40551c46edSMustafa Ismail #define IRDMA_OP_TYPE_FAST_REG_NSMR		0x09
41551c46edSMustafa Ismail #define IRDMA_OP_TYPE_INV_STAG			0x0a
42551c46edSMustafa Ismail #define IRDMA_OP_TYPE_RDMA_READ_INV_STAG	0x0b
43551c46edSMustafa Ismail #define IRDMA_OP_TYPE_NOP			0x0c
44551c46edSMustafa Ismail #define IRDMA_OP_TYPE_REC	0x3e
45551c46edSMustafa Ismail #define IRDMA_OP_TYPE_REC_IMM	0x3f
46551c46edSMustafa Ismail 
47551c46edSMustafa Ismail #define IRDMA_FLUSH_MAJOR_ERR	1
48551c46edSMustafa Ismail 
49551c46edSMustafa Ismail enum irdma_device_caps_const {
50551c46edSMustafa Ismail 	IRDMA_WQE_SIZE =			4,
51551c46edSMustafa Ismail 	IRDMA_CQP_WQE_SIZE =			8,
52551c46edSMustafa Ismail 	IRDMA_CQE_SIZE =			4,
53551c46edSMustafa Ismail 	IRDMA_EXTENDED_CQE_SIZE =		8,
54551c46edSMustafa Ismail 	IRDMA_AEQE_SIZE =			2,
55551c46edSMustafa Ismail 	IRDMA_CEQE_SIZE =			1,
56551c46edSMustafa Ismail 	IRDMA_CQP_CTX_SIZE =			8,
57551c46edSMustafa Ismail 	IRDMA_SHADOW_AREA_SIZE =		8,
58551c46edSMustafa Ismail 	IRDMA_QUERY_FPM_BUF_SIZE =		176,
59551c46edSMustafa Ismail 	IRDMA_COMMIT_FPM_BUF_SIZE =		176,
60551c46edSMustafa Ismail 	IRDMA_GATHER_STATS_BUF_SIZE =		1024,
61551c46edSMustafa Ismail 	IRDMA_MIN_IW_QP_ID =			0,
62551c46edSMustafa Ismail 	IRDMA_MAX_IW_QP_ID =			262143,
63551c46edSMustafa Ismail 	IRDMA_MIN_CEQID =			0,
64551c46edSMustafa Ismail 	IRDMA_MAX_CEQID =			1023,
65551c46edSMustafa Ismail 	IRDMA_CEQ_MAX_COUNT =			IRDMA_MAX_CEQID + 1,
66551c46edSMustafa Ismail 	IRDMA_MIN_CQID =			0,
67551c46edSMustafa Ismail 	IRDMA_MAX_CQID =			524287,
68551c46edSMustafa Ismail 	IRDMA_MIN_AEQ_ENTRIES =			1,
69551c46edSMustafa Ismail 	IRDMA_MAX_AEQ_ENTRIES =			524287,
70551c46edSMustafa Ismail 	IRDMA_MIN_CEQ_ENTRIES =			1,
71551c46edSMustafa Ismail 	IRDMA_MAX_CEQ_ENTRIES =			262143,
72551c46edSMustafa Ismail 	IRDMA_MIN_CQ_SIZE =			1,
73551c46edSMustafa Ismail 	IRDMA_MAX_CQ_SIZE =			1048575,
74551c46edSMustafa Ismail 	IRDMA_DB_ID_ZERO =			0,
75551c46edSMustafa Ismail 	IRDMA_MAX_WQ_FRAGMENT_COUNT =		13,
76551c46edSMustafa Ismail 	IRDMA_MAX_SGE_RD =			13,
77551c46edSMustafa Ismail 	IRDMA_MAX_OUTBOUND_MSG_SIZE =		2147483647,
78551c46edSMustafa Ismail 	IRDMA_MAX_INBOUND_MSG_SIZE =		2147483647,
79551c46edSMustafa Ismail 	IRDMA_MAX_PUSH_PAGE_COUNT =		1024,
80551c46edSMustafa Ismail 	IRDMA_MAX_PE_ENA_VF_COUNT =		32,
81551c46edSMustafa Ismail 	IRDMA_MAX_VF_FPM_ID =			47,
82551c46edSMustafa Ismail 	IRDMA_MAX_SQ_PAYLOAD_SIZE =		2145386496,
83551c46edSMustafa Ismail 	IRDMA_MAX_INLINE_DATA_SIZE =		101,
84551c46edSMustafa Ismail 	IRDMA_MAX_WQ_ENTRIES =			32768,
85551c46edSMustafa Ismail 	IRDMA_Q2_BUF_SIZE =			256,
86551c46edSMustafa Ismail 	IRDMA_QP_CTX_SIZE =			256,
87551c46edSMustafa Ismail 	IRDMA_MAX_PDS =				262144,
8872d422c2SSindhu Devale 	IRDMA_MIN_WQ_SIZE_GEN2 =                8,
89551c46edSMustafa Ismail };
90551c46edSMustafa Ismail 
91551c46edSMustafa Ismail enum irdma_addressing_type {
92551c46edSMustafa Ismail 	IRDMA_ADDR_TYPE_ZERO_BASED = 0,
93551c46edSMustafa Ismail 	IRDMA_ADDR_TYPE_VA_BASED   = 1,
94551c46edSMustafa Ismail };
95551c46edSMustafa Ismail 
96551c46edSMustafa Ismail enum irdma_flush_opcode {
97551c46edSMustafa Ismail 	FLUSH_INVALID = 0,
98551c46edSMustafa Ismail 	FLUSH_GENERAL_ERR,
99551c46edSMustafa Ismail 	FLUSH_PROT_ERR,
100551c46edSMustafa Ismail 	FLUSH_REM_ACCESS_ERR,
101551c46edSMustafa Ismail 	FLUSH_LOC_QP_OP_ERR,
102551c46edSMustafa Ismail 	FLUSH_REM_OP_ERR,
103551c46edSMustafa Ismail 	FLUSH_LOC_LEN_ERR,
104551c46edSMustafa Ismail 	FLUSH_FATAL_ERR,
105d3bdcd59SSindhu Devale 	FLUSH_RETRY_EXC_ERR,
1069f7fa37aSSindhu Devale 	FLUSH_MW_BIND_ERR,
1077f51a961SSindhu-Devale 	FLUSH_REM_INV_REQ_ERR,
108551c46edSMustafa Ismail };
109551c46edSMustafa Ismail 
110551c46edSMustafa Ismail enum irdma_cmpl_status {
111551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_SUCCESS = 0,
112551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_FLUSHED,
113551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_WQE,
114551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_QP_CATASTROPHIC,
115551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_REMOTE_TERMINATION,
116551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_STAG,
117551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_BASE_BOUND_VIOLATION,
118551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_ACCESS_VIOLATION,
119551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_PD_ID,
120551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_WRAP_ERROR,
121551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_STAG_INVALID_PDID,
122551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_RDMA_READ_ZERO_ORD,
123551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_QP_NOT_PRIVLEDGED,
124551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_STAG_NOT_INVALID,
125551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_PHYS_BUF_SIZE,
126551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_PHYS_BUF_ENTRY,
127551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_FBO,
128551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_LEN,
129551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_ACCESS,
130551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_PHYS_BUF_LIST_TOO_LONG,
131551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_VIRT_ADDRESS,
132551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_REGION,
133551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_WINDOW,
134551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_INVALID_TOTAL_LEN,
135551c46edSMustafa Ismail 	IRDMA_COMPL_STATUS_UNKNOWN,
136551c46edSMustafa Ismail };
137551c46edSMustafa Ismail 
138551c46edSMustafa Ismail enum irdma_cmpl_notify {
139551c46edSMustafa Ismail 	IRDMA_CQ_COMPL_EVENT     = 0,
140551c46edSMustafa Ismail 	IRDMA_CQ_COMPL_SOLICITED = 1,
141551c46edSMustafa Ismail };
142551c46edSMustafa Ismail 
143551c46edSMustafa Ismail enum irdma_qp_caps {
144551c46edSMustafa Ismail 	IRDMA_WRITE_WITH_IMM = 1,
145551c46edSMustafa Ismail 	IRDMA_SEND_WITH_IMM  = 2,
146551c46edSMustafa Ismail 	IRDMA_ROCE	     = 4,
147551c46edSMustafa Ismail 	IRDMA_PUSH_MODE      = 8,
148551c46edSMustafa Ismail };
149551c46edSMustafa Ismail 
150551c46edSMustafa Ismail struct irdma_qp_uk;
151551c46edSMustafa Ismail struct irdma_cq_uk;
152551c46edSMustafa Ismail struct irdma_qp_uk_init_info;
153551c46edSMustafa Ismail struct irdma_cq_uk_init_info;
154551c46edSMustafa Ismail 
155551c46edSMustafa Ismail struct irdma_ring {
156551c46edSMustafa Ismail 	u32 head;
157551c46edSMustafa Ismail 	u32 tail;
158551c46edSMustafa Ismail 	u32 size;
159551c46edSMustafa Ismail };
160551c46edSMustafa Ismail 
161551c46edSMustafa Ismail struct irdma_cqe {
162551c46edSMustafa Ismail 	__le64 buf[IRDMA_CQE_SIZE];
163551c46edSMustafa Ismail };
164551c46edSMustafa Ismail 
165551c46edSMustafa Ismail struct irdma_extended_cqe {
166551c46edSMustafa Ismail 	__le64 buf[IRDMA_EXTENDED_CQE_SIZE];
167551c46edSMustafa Ismail };
168551c46edSMustafa Ismail 
169551c46edSMustafa Ismail struct irdma_post_send {
1709ed8110cSZhu Yanjun 	struct ib_sge *sg_list;
171551c46edSMustafa Ismail 	u32 num_sges;
172551c46edSMustafa Ismail 	u32 qkey;
173551c46edSMustafa Ismail 	u32 dest_qp;
174551c46edSMustafa Ismail 	u32 ah_id;
175551c46edSMustafa Ismail };
176551c46edSMustafa Ismail 
177551c46edSMustafa Ismail struct irdma_post_rq_info {
178551c46edSMustafa Ismail 	u64 wr_id;
1799ed8110cSZhu Yanjun 	struct ib_sge *sg_list;
180551c46edSMustafa Ismail 	u32 num_sges;
181551c46edSMustafa Ismail };
182551c46edSMustafa Ismail 
183551c46edSMustafa Ismail struct irdma_rdma_write {
1849ed8110cSZhu Yanjun 	struct ib_sge *lo_sg_list;
185551c46edSMustafa Ismail 	u32 num_lo_sges;
1869ed8110cSZhu Yanjun 	struct ib_sge rem_addr;
187551c46edSMustafa Ismail };
188551c46edSMustafa Ismail 
189551c46edSMustafa Ismail struct irdma_rdma_read {
1909ed8110cSZhu Yanjun 	struct ib_sge *lo_sg_list;
191551c46edSMustafa Ismail 	u32 num_lo_sges;
1929ed8110cSZhu Yanjun 	struct ib_sge rem_addr;
193551c46edSMustafa Ismail };
194551c46edSMustafa Ismail 
195551c46edSMustafa Ismail struct irdma_bind_window {
196551c46edSMustafa Ismail 	irdma_stag mr_stag;
197551c46edSMustafa Ismail 	u64 bind_len;
198551c46edSMustafa Ismail 	void *va;
199551c46edSMustafa Ismail 	enum irdma_addressing_type addressing_type;
200551c46edSMustafa Ismail 	bool ena_reads:1;
201551c46edSMustafa Ismail 	bool ena_writes:1;
202551c46edSMustafa Ismail 	irdma_stag mw_stag;
203551c46edSMustafa Ismail 	bool mem_window_type_1:1;
204551c46edSMustafa Ismail };
205551c46edSMustafa Ismail 
206551c46edSMustafa Ismail struct irdma_inv_local_stag {
207551c46edSMustafa Ismail 	irdma_stag target_stag;
208551c46edSMustafa Ismail };
209551c46edSMustafa Ismail 
210551c46edSMustafa Ismail struct irdma_post_sq_info {
211551c46edSMustafa Ismail 	u64 wr_id;
212551c46edSMustafa Ismail 	u8 op_type;
213551c46edSMustafa Ismail 	u8 l4len;
214551c46edSMustafa Ismail 	bool signaled:1;
215551c46edSMustafa Ismail 	bool read_fence:1;
216551c46edSMustafa Ismail 	bool local_fence:1;
217551c46edSMustafa Ismail 	bool inline_data:1;
218551c46edSMustafa Ismail 	bool imm_data_valid:1;
219551c46edSMustafa Ismail 	bool report_rtt:1;
220551c46edSMustafa Ismail 	bool udp_hdr:1;
221551c46edSMustafa Ismail 	bool defer_flag:1;
222551c46edSMustafa Ismail 	u32 imm_data;
223551c46edSMustafa Ismail 	u32 stag_to_inv;
224551c46edSMustafa Ismail 	union {
225551c46edSMustafa Ismail 		struct irdma_post_send send;
226551c46edSMustafa Ismail 		struct irdma_rdma_write rdma_write;
227551c46edSMustafa Ismail 		struct irdma_rdma_read rdma_read;
228551c46edSMustafa Ismail 		struct irdma_bind_window bind_window;
229551c46edSMustafa Ismail 		struct irdma_inv_local_stag inv_local_stag;
230551c46edSMustafa Ismail 	} op;
231551c46edSMustafa Ismail };
232551c46edSMustafa Ismail 
233551c46edSMustafa Ismail struct irdma_cq_poll_info {
234551c46edSMustafa Ismail 	u64 wr_id;
235551c46edSMustafa Ismail 	irdma_qp_handle qp_handle;
236551c46edSMustafa Ismail 	u32 bytes_xfered;
237551c46edSMustafa Ismail 	u32 tcp_seq_num_rtt;
238551c46edSMustafa Ismail 	u32 qp_id;
239551c46edSMustafa Ismail 	u32 ud_src_qpn;
240551c46edSMustafa Ismail 	u32 imm_data;
241551c46edSMustafa Ismail 	irdma_stag inv_stag; /* or L_R_Key */
242551c46edSMustafa Ismail 	enum irdma_cmpl_status comp_status;
243551c46edSMustafa Ismail 	u16 major_err;
244551c46edSMustafa Ismail 	u16 minor_err;
245551c46edSMustafa Ismail 	u16 ud_vlan;
246551c46edSMustafa Ismail 	u8 ud_smac[6];
247551c46edSMustafa Ismail 	u8 op_type;
24824419777SMustafa Ismail 	u8 q_type;
249551c46edSMustafa Ismail 	bool stag_invalid_set:1; /* or L_R_Key set */
250551c46edSMustafa Ismail 	bool error:1;
251551c46edSMustafa Ismail 	bool solicited_event:1;
252551c46edSMustafa Ismail 	bool ipv4:1;
253551c46edSMustafa Ismail 	bool ud_vlan_valid:1;
254551c46edSMustafa Ismail 	bool ud_smac_valid:1;
255551c46edSMustafa Ismail 	bool imm_valid:1;
256551c46edSMustafa Ismail };
257551c46edSMustafa Ismail 
2582c4b14eaSShiraz Saleem int irdma_uk_inline_rdma_write(struct irdma_qp_uk *qp,
2592c4b14eaSShiraz Saleem 			       struct irdma_post_sq_info *info, bool post_sq);
2602c4b14eaSShiraz Saleem int irdma_uk_inline_send(struct irdma_qp_uk *qp,
2612c4b14eaSShiraz Saleem 			 struct irdma_post_sq_info *info, bool post_sq);
2622c4b14eaSShiraz Saleem int irdma_uk_post_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled,
263551c46edSMustafa Ismail 		      bool post_sq);
2642c4b14eaSShiraz Saleem int irdma_uk_post_receive(struct irdma_qp_uk *qp,
265551c46edSMustafa Ismail 			  struct irdma_post_rq_info *info);
266551c46edSMustafa Ismail void irdma_uk_qp_post_wr(struct irdma_qp_uk *qp);
2672c4b14eaSShiraz Saleem int irdma_uk_rdma_read(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
268551c46edSMustafa Ismail 		       bool inv_stag, bool post_sq);
2692c4b14eaSShiraz Saleem int irdma_uk_rdma_write(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
270551c46edSMustafa Ismail 			bool post_sq);
2712c4b14eaSShiraz Saleem int irdma_uk_send(struct irdma_qp_uk *qp, struct irdma_post_sq_info *info,
2722c4b14eaSShiraz Saleem 		  bool post_sq);
2732c4b14eaSShiraz Saleem int irdma_uk_stag_local_invalidate(struct irdma_qp_uk *qp,
274551c46edSMustafa Ismail 				   struct irdma_post_sq_info *info,
275551c46edSMustafa Ismail 				   bool post_sq);
276551c46edSMustafa Ismail 
277551c46edSMustafa Ismail struct irdma_wqe_uk_ops {
2784f44e519SMustafa Ismail 	void (*iw_copy_inline_data)(u8 *dest, struct ib_sge *sge_list,
2794f44e519SMustafa Ismail 				    u32 num_sges, u8 polarity);
280551c46edSMustafa Ismail 	u16 (*iw_inline_data_size_to_quanta)(u32 data_size);
2819ed8110cSZhu Yanjun 	void (*iw_set_fragment)(__le64 *wqe, u32 offset, struct ib_sge *sge,
282551c46edSMustafa Ismail 				u8 valid);
283551c46edSMustafa Ismail 	void (*iw_set_mw_bind_wqe)(__le64 *wqe,
284551c46edSMustafa Ismail 				   struct irdma_bind_window *op_info);
285551c46edSMustafa Ismail };
286551c46edSMustafa Ismail 
2872c4b14eaSShiraz Saleem int irdma_uk_cq_poll_cmpl(struct irdma_cq_uk *cq,
288551c46edSMustafa Ismail 			  struct irdma_cq_poll_info *info);
289551c46edSMustafa Ismail void irdma_uk_cq_request_notification(struct irdma_cq_uk *cq,
290551c46edSMustafa Ismail 				      enum irdma_cmpl_notify cq_notify);
291551c46edSMustafa Ismail void irdma_uk_cq_resize(struct irdma_cq_uk *cq, void *cq_base, int size);
292551c46edSMustafa Ismail void irdma_uk_cq_set_resized_cnt(struct irdma_cq_uk *qp, u16 cnt);
293dede33daSZhu Yanjun void irdma_uk_cq_init(struct irdma_cq_uk *cq,
294551c46edSMustafa Ismail 		      struct irdma_cq_uk_init_info *info);
2952c4b14eaSShiraz Saleem int irdma_uk_qp_init(struct irdma_qp_uk *qp,
296551c46edSMustafa Ismail 		     struct irdma_qp_uk_init_info *info);
2973a849872SSindhu Devale void irdma_uk_calc_shift_wq(struct irdma_qp_uk_init_info *ukinfo, u8 *sq_shift,
2983a849872SSindhu Devale 			    u8 *rq_shift);
2993a849872SSindhu Devale int irdma_uk_calc_depth_shift_sq(struct irdma_qp_uk_init_info *ukinfo,
3003a849872SSindhu Devale 				 u32 *sq_depth, u8 *sq_shift);
3013a849872SSindhu Devale int irdma_uk_calc_depth_shift_rq(struct irdma_qp_uk_init_info *ukinfo,
3023a849872SSindhu Devale 				 u32 *rq_depth, u8 *rq_shift);
303551c46edSMustafa Ismail struct irdma_sq_uk_wr_trk_info {
304551c46edSMustafa Ismail 	u64 wrid;
305551c46edSMustafa Ismail 	u32 wr_len;
306551c46edSMustafa Ismail 	u16 quanta;
307551c46edSMustafa Ismail 	u8 reserved[2];
308551c46edSMustafa Ismail };
309551c46edSMustafa Ismail 
310551c46edSMustafa Ismail struct irdma_qp_quanta {
311551c46edSMustafa Ismail 	__le64 elem[IRDMA_WQE_SIZE];
312551c46edSMustafa Ismail };
313551c46edSMustafa Ismail 
314551c46edSMustafa Ismail struct irdma_qp_uk {
315551c46edSMustafa Ismail 	struct irdma_qp_quanta *sq_base;
316551c46edSMustafa Ismail 	struct irdma_qp_quanta *rq_base;
317551c46edSMustafa Ismail 	struct irdma_uk_attrs *uk_attrs;
318551c46edSMustafa Ismail 	u32 __iomem *wqe_alloc_db;
319551c46edSMustafa Ismail 	struct irdma_sq_uk_wr_trk_info *sq_wrtrk_array;
320551c46edSMustafa Ismail 	u64 *rq_wrid_array;
321551c46edSMustafa Ismail 	__le64 *shadow_area;
322551c46edSMustafa Ismail 	struct irdma_ring sq_ring;
323551c46edSMustafa Ismail 	struct irdma_ring rq_ring;
324551c46edSMustafa Ismail 	struct irdma_ring initial_ring;
325551c46edSMustafa Ismail 	u32 qp_id;
326551c46edSMustafa Ismail 	u32 qp_caps;
327551c46edSMustafa Ismail 	u32 sq_size;
328551c46edSMustafa Ismail 	u32 rq_size;
329551c46edSMustafa Ismail 	u32 max_sq_frag_cnt;
330551c46edSMustafa Ismail 	u32 max_rq_frag_cnt;
331551c46edSMustafa Ismail 	u32 max_inline_data;
332551c46edSMustafa Ismail 	struct irdma_wqe_uk_ops wqe_ops;
333551c46edSMustafa Ismail 	u16 conn_wqes;
334551c46edSMustafa Ismail 	u8 qp_type;
335551c46edSMustafa Ismail 	u8 swqe_polarity;
336551c46edSMustafa Ismail 	u8 swqe_polarity_deferred;
337551c46edSMustafa Ismail 	u8 rwqe_polarity;
338551c46edSMustafa Ismail 	u8 rq_wqe_size;
339551c46edSMustafa Ismail 	u8 rq_wqe_size_multiplier;
340551c46edSMustafa Ismail 	bool deferred_flag:1;
341551c46edSMustafa Ismail 	bool first_sq_wq:1;
342551c46edSMustafa Ismail 	bool sq_flush_complete:1; /* Indicates flush was seen and SQ was empty after the flush */
343551c46edSMustafa Ismail 	bool rq_flush_complete:1; /* Indicates flush was seen and RQ was empty after the flush */
344551c46edSMustafa Ismail 	bool destroy_pending:1; /* Indicates the QP is being destroyed */
345551c46edSMustafa Ismail 	void *back_qp;
346551c46edSMustafa Ismail 	u8 dbg_rq_flushed;
347551c46edSMustafa Ismail 	u8 sq_flush_seen;
348551c46edSMustafa Ismail 	u8 rq_flush_seen;
349551c46edSMustafa Ismail };
350551c46edSMustafa Ismail 
351551c46edSMustafa Ismail struct irdma_cq_uk {
352551c46edSMustafa Ismail 	struct irdma_cqe *cq_base;
353551c46edSMustafa Ismail 	u32 __iomem *cqe_alloc_db;
354551c46edSMustafa Ismail 	u32 __iomem *cq_ack_db;
355551c46edSMustafa Ismail 	__le64 *shadow_area;
356551c46edSMustafa Ismail 	u32 cq_id;
357551c46edSMustafa Ismail 	u32 cq_size;
358551c46edSMustafa Ismail 	struct irdma_ring cq_ring;
359551c46edSMustafa Ismail 	u8 polarity;
360551c46edSMustafa Ismail 	bool avoid_mem_cflct:1;
361551c46edSMustafa Ismail };
362551c46edSMustafa Ismail 
363551c46edSMustafa Ismail struct irdma_qp_uk_init_info {
364551c46edSMustafa Ismail 	struct irdma_qp_quanta *sq;
365551c46edSMustafa Ismail 	struct irdma_qp_quanta *rq;
366551c46edSMustafa Ismail 	struct irdma_uk_attrs *uk_attrs;
367551c46edSMustafa Ismail 	u32 __iomem *wqe_alloc_db;
368551c46edSMustafa Ismail 	__le64 *shadow_area;
369551c46edSMustafa Ismail 	struct irdma_sq_uk_wr_trk_info *sq_wrtrk_array;
370551c46edSMustafa Ismail 	u64 *rq_wrid_array;
371551c46edSMustafa Ismail 	u32 qp_id;
372551c46edSMustafa Ismail 	u32 qp_caps;
373551c46edSMustafa Ismail 	u32 sq_size;
374551c46edSMustafa Ismail 	u32 rq_size;
375551c46edSMustafa Ismail 	u32 max_sq_frag_cnt;
376551c46edSMustafa Ismail 	u32 max_rq_frag_cnt;
377551c46edSMustafa Ismail 	u32 max_inline_data;
3783a849872SSindhu Devale 	u32 sq_depth;
3793a849872SSindhu Devale 	u32 rq_depth;
380551c46edSMustafa Ismail 	u8 first_sq_wq;
381551c46edSMustafa Ismail 	u8 type;
3823a849872SSindhu Devale 	u8 sq_shift;
3833a849872SSindhu Devale 	u8 rq_shift;
384551c46edSMustafa Ismail 	int abi_ver;
385551c46edSMustafa Ismail 	bool legacy_mode;
386551c46edSMustafa Ismail };
387551c46edSMustafa Ismail 
388551c46edSMustafa Ismail struct irdma_cq_uk_init_info {
389551c46edSMustafa Ismail 	u32 __iomem *cqe_alloc_db;
390551c46edSMustafa Ismail 	u32 __iomem *cq_ack_db;
391551c46edSMustafa Ismail 	struct irdma_cqe *cq_base;
392551c46edSMustafa Ismail 	__le64 *shadow_area;
393551c46edSMustafa Ismail 	u32 cq_size;
394551c46edSMustafa Ismail 	u32 cq_id;
395551c46edSMustafa Ismail 	bool avoid_mem_cflct;
396551c46edSMustafa Ismail };
397551c46edSMustafa Ismail 
398551c46edSMustafa Ismail __le64 *irdma_qp_get_next_send_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx,
399551c46edSMustafa Ismail 				   u16 quanta, u32 total_size,
400551c46edSMustafa Ismail 				   struct irdma_post_sq_info *info);
401551c46edSMustafa Ismail __le64 *irdma_qp_get_next_recv_wqe(struct irdma_qp_uk *qp, u32 *wqe_idx);
402551c46edSMustafa Ismail void irdma_uk_clean_cq(void *q, struct irdma_cq_uk *cq);
4032c4b14eaSShiraz Saleem int irdma_nop(struct irdma_qp_uk *qp, u64 wr_id, bool signaled, bool post_sq);
4042c4b14eaSShiraz Saleem int irdma_fragcnt_to_quanta_sq(u32 frag_cnt, u16 *quanta);
4052c4b14eaSShiraz Saleem int irdma_fragcnt_to_wqesize_rq(u32 frag_cnt, u16 *wqe_size);
406551c46edSMustafa Ismail void irdma_get_wqe_shift(struct irdma_uk_attrs *uk_attrs, u32 sge,
407551c46edSMustafa Ismail 			 u32 inline_data, u8 *shift);
4082c4b14eaSShiraz Saleem int irdma_get_sqdepth(struct irdma_uk_attrs *uk_attrs, u32 sq_size, u8 shift,
4092c4b14eaSShiraz Saleem 		      u32 *wqdepth);
4102c4b14eaSShiraz Saleem int irdma_get_rqdepth(struct irdma_uk_attrs *uk_attrs, u32 rq_size, u8 shift,
4112c4b14eaSShiraz Saleem 		      u32 *wqdepth);
412551c46edSMustafa Ismail void irdma_clr_wqes(struct irdma_qp_uk *qp, u32 qp_wqe_idx);
413551c46edSMustafa Ismail #endif /* IRDMA_USER_H */
414