xref: /linux/include/linux/mlx5/qp.h (revision e126ba97dba9edeb6fafa3665b5f8497fc9cdf8c)
1*e126ba97SEli Cohen /*
2*e126ba97SEli Cohen  * Copyright (c) 2013, Mellanox Technologies inc.  All rights reserved.
3*e126ba97SEli Cohen  *
4*e126ba97SEli Cohen  * This software is available to you under a choice of one of two
5*e126ba97SEli Cohen  * licenses.  You may choose to be licensed under the terms of the GNU
6*e126ba97SEli Cohen  * General Public License (GPL) Version 2, available from the file
7*e126ba97SEli Cohen  * COPYING in the main directory of this source tree, or the
8*e126ba97SEli Cohen  * OpenIB.org BSD license below:
9*e126ba97SEli Cohen  *
10*e126ba97SEli Cohen  *     Redistribution and use in source and binary forms, with or
11*e126ba97SEli Cohen  *     without modification, are permitted provided that the following
12*e126ba97SEli Cohen  *     conditions are met:
13*e126ba97SEli Cohen  *
14*e126ba97SEli Cohen  *      - Redistributions of source code must retain the above
15*e126ba97SEli Cohen  *        copyright notice, this list of conditions and the following
16*e126ba97SEli Cohen  *        disclaimer.
17*e126ba97SEli Cohen  *
18*e126ba97SEli Cohen  *      - Redistributions in binary form must reproduce the above
19*e126ba97SEli Cohen  *        copyright notice, this list of conditions and the following
20*e126ba97SEli Cohen  *        disclaimer in the documentation and/or other materials
21*e126ba97SEli Cohen  *        provided with the distribution.
22*e126ba97SEli Cohen  *
23*e126ba97SEli Cohen  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24*e126ba97SEli Cohen  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25*e126ba97SEli Cohen  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26*e126ba97SEli Cohen  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27*e126ba97SEli Cohen  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28*e126ba97SEli Cohen  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29*e126ba97SEli Cohen  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30*e126ba97SEli Cohen  * SOFTWARE.
31*e126ba97SEli Cohen  */
32*e126ba97SEli Cohen 
33*e126ba97SEli Cohen #ifndef MLX5_QP_H
34*e126ba97SEli Cohen #define MLX5_QP_H
35*e126ba97SEli Cohen 
36*e126ba97SEli Cohen #include <linux/mlx5/device.h>
37*e126ba97SEli Cohen #include <linux/mlx5/driver.h>
38*e126ba97SEli Cohen 
39*e126ba97SEli Cohen #define MLX5_INVALID_LKEY	0x100
40*e126ba97SEli Cohen 
41*e126ba97SEli Cohen enum mlx5_qp_optpar {
42*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_ALT_ADDR_PATH		= 1 << 0,
43*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RRE			= 1 << 1,
44*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RAE			= 1 << 2,
45*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RWE			= 1 << 3,
46*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PKEY_INDEX		= 1 << 4,
47*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_Q_KEY			= 1 << 5,
48*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RNR_TIMEOUT		= 1 << 6,
49*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH	= 1 << 7,
50*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_SRA_MAX			= 1 << 8,
51*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RRA_MAX			= 1 << 9,
52*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PM_STATE			= 1 << 10,
53*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RETRY_COUNT		= 1 << 12,
54*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RNR_RETRY		= 1 << 13,
55*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_ACK_TIMEOUT		= 1 << 14,
56*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PRI_PORT			= 1 << 16,
57*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_SRQN			= 1 << 18,
58*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_CQN_RCV			= 1 << 19,
59*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_DC_HS			= 1 << 20,
60*e126ba97SEli Cohen 	MLX5_QP_OPTPAR_DC_KEY			= 1 << 21,
61*e126ba97SEli Cohen };
62*e126ba97SEli Cohen 
63*e126ba97SEli Cohen enum mlx5_qp_state {
64*e126ba97SEli Cohen 	MLX5_QP_STATE_RST			= 0,
65*e126ba97SEli Cohen 	MLX5_QP_STATE_INIT			= 1,
66*e126ba97SEli Cohen 	MLX5_QP_STATE_RTR			= 2,
67*e126ba97SEli Cohen 	MLX5_QP_STATE_RTS			= 3,
68*e126ba97SEli Cohen 	MLX5_QP_STATE_SQER			= 4,
69*e126ba97SEli Cohen 	MLX5_QP_STATE_SQD			= 5,
70*e126ba97SEli Cohen 	MLX5_QP_STATE_ERR			= 6,
71*e126ba97SEli Cohen 	MLX5_QP_STATE_SQ_DRAINING		= 7,
72*e126ba97SEli Cohen 	MLX5_QP_STATE_SUSPENDED			= 9,
73*e126ba97SEli Cohen 	MLX5_QP_NUM_STATE
74*e126ba97SEli Cohen };
75*e126ba97SEli Cohen 
76*e126ba97SEli Cohen enum {
77*e126ba97SEli Cohen 	MLX5_QP_ST_RC				= 0x0,
78*e126ba97SEli Cohen 	MLX5_QP_ST_UC				= 0x1,
79*e126ba97SEli Cohen 	MLX5_QP_ST_UD				= 0x2,
80*e126ba97SEli Cohen 	MLX5_QP_ST_XRC				= 0x3,
81*e126ba97SEli Cohen 	MLX5_QP_ST_MLX				= 0x4,
82*e126ba97SEli Cohen 	MLX5_QP_ST_DCI				= 0x5,
83*e126ba97SEli Cohen 	MLX5_QP_ST_DCT				= 0x6,
84*e126ba97SEli Cohen 	MLX5_QP_ST_QP0				= 0x7,
85*e126ba97SEli Cohen 	MLX5_QP_ST_QP1				= 0x8,
86*e126ba97SEli Cohen 	MLX5_QP_ST_RAW_ETHERTYPE		= 0x9,
87*e126ba97SEli Cohen 	MLX5_QP_ST_RAW_IPV6			= 0xa,
88*e126ba97SEli Cohen 	MLX5_QP_ST_SNIFFER			= 0xb,
89*e126ba97SEli Cohen 	MLX5_QP_ST_SYNC_UMR			= 0xe,
90*e126ba97SEli Cohen 	MLX5_QP_ST_PTP_1588			= 0xd,
91*e126ba97SEli Cohen 	MLX5_QP_ST_REG_UMR			= 0xc,
92*e126ba97SEli Cohen 	MLX5_QP_ST_MAX
93*e126ba97SEli Cohen };
94*e126ba97SEli Cohen 
95*e126ba97SEli Cohen enum {
96*e126ba97SEli Cohen 	MLX5_QP_PM_MIGRATED			= 0x3,
97*e126ba97SEli Cohen 	MLX5_QP_PM_ARMED			= 0x0,
98*e126ba97SEli Cohen 	MLX5_QP_PM_REARM			= 0x1
99*e126ba97SEli Cohen };
100*e126ba97SEli Cohen 
101*e126ba97SEli Cohen enum {
102*e126ba97SEli Cohen 	MLX5_NON_ZERO_RQ	= 0 << 24,
103*e126ba97SEli Cohen 	MLX5_SRQ_RQ		= 1 << 24,
104*e126ba97SEli Cohen 	MLX5_CRQ_RQ		= 2 << 24,
105*e126ba97SEli Cohen 	MLX5_ZERO_LEN_RQ	= 3 << 24
106*e126ba97SEli Cohen };
107*e126ba97SEli Cohen 
108*e126ba97SEli Cohen enum {
109*e126ba97SEli Cohen 	/* params1 */
110*e126ba97SEli Cohen 	MLX5_QP_BIT_SRE				= 1 << 15,
111*e126ba97SEli Cohen 	MLX5_QP_BIT_SWE				= 1 << 14,
112*e126ba97SEli Cohen 	MLX5_QP_BIT_SAE				= 1 << 13,
113*e126ba97SEli Cohen 	/* params2 */
114*e126ba97SEli Cohen 	MLX5_QP_BIT_RRE				= 1 << 15,
115*e126ba97SEli Cohen 	MLX5_QP_BIT_RWE				= 1 << 14,
116*e126ba97SEli Cohen 	MLX5_QP_BIT_RAE				= 1 << 13,
117*e126ba97SEli Cohen 	MLX5_QP_BIT_RIC				= 1 <<	4,
118*e126ba97SEli Cohen };
119*e126ba97SEli Cohen 
120*e126ba97SEli Cohen enum {
121*e126ba97SEli Cohen 	MLX5_WQE_CTRL_CQ_UPDATE		= 2 << 2,
122*e126ba97SEli Cohen 	MLX5_WQE_CTRL_SOLICITED		= 1 << 1,
123*e126ba97SEli Cohen };
124*e126ba97SEli Cohen 
125*e126ba97SEli Cohen enum {
126*e126ba97SEli Cohen 	MLX5_SEND_WQE_BB	= 64,
127*e126ba97SEli Cohen };
128*e126ba97SEli Cohen 
129*e126ba97SEli Cohen enum {
130*e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_LOCAL_READ	= 1 << 27,
131*e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_LOCAL_WRITE	= 1 << 28,
132*e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_REMOTE_READ	= 1 << 29,
133*e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_REMOTE_WRITE	= 1 << 30,
134*e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_ATOMIC	= 1 << 31
135*e126ba97SEli Cohen };
136*e126ba97SEli Cohen 
137*e126ba97SEli Cohen enum {
138*e126ba97SEli Cohen 	MLX5_FENCE_MODE_NONE			= 0 << 5,
139*e126ba97SEli Cohen 	MLX5_FENCE_MODE_INITIATOR_SMALL		= 1 << 5,
140*e126ba97SEli Cohen 	MLX5_FENCE_MODE_STRONG_ORDERING		= 3 << 5,
141*e126ba97SEli Cohen 	MLX5_FENCE_MODE_SMALL_AND_FENCE		= 4 << 5,
142*e126ba97SEli Cohen };
143*e126ba97SEli Cohen 
144*e126ba97SEli Cohen enum {
145*e126ba97SEli Cohen 	MLX5_QP_LAT_SENSITIVE	= 1 << 28,
146*e126ba97SEli Cohen 	MLX5_QP_ENABLE_SIG	= 1 << 31,
147*e126ba97SEli Cohen };
148*e126ba97SEli Cohen 
149*e126ba97SEli Cohen enum {
150*e126ba97SEli Cohen 	MLX5_RCV_DBR	= 0,
151*e126ba97SEli Cohen 	MLX5_SND_DBR	= 1,
152*e126ba97SEli Cohen };
153*e126ba97SEli Cohen 
154*e126ba97SEli Cohen struct mlx5_wqe_fmr_seg {
155*e126ba97SEli Cohen 	__be32			flags;
156*e126ba97SEli Cohen 	__be32			mem_key;
157*e126ba97SEli Cohen 	__be64			buf_list;
158*e126ba97SEli Cohen 	__be64			start_addr;
159*e126ba97SEli Cohen 	__be64			reg_len;
160*e126ba97SEli Cohen 	__be32			offset;
161*e126ba97SEli Cohen 	__be32			page_size;
162*e126ba97SEli Cohen 	u32			reserved[2];
163*e126ba97SEli Cohen };
164*e126ba97SEli Cohen 
165*e126ba97SEli Cohen struct mlx5_wqe_ctrl_seg {
166*e126ba97SEli Cohen 	__be32			opmod_idx_opcode;
167*e126ba97SEli Cohen 	__be32			qpn_ds;
168*e126ba97SEli Cohen 	u8			signature;
169*e126ba97SEli Cohen 	u8			rsvd[2];
170*e126ba97SEli Cohen 	u8			fm_ce_se;
171*e126ba97SEli Cohen 	__be32			imm;
172*e126ba97SEli Cohen };
173*e126ba97SEli Cohen 
174*e126ba97SEli Cohen struct mlx5_wqe_xrc_seg {
175*e126ba97SEli Cohen 	__be32			xrc_srqn;
176*e126ba97SEli Cohen 	u8			rsvd[12];
177*e126ba97SEli Cohen };
178*e126ba97SEli Cohen 
179*e126ba97SEli Cohen struct mlx5_wqe_masked_atomic_seg {
180*e126ba97SEli Cohen 	__be64			swap_add;
181*e126ba97SEli Cohen 	__be64			compare;
182*e126ba97SEli Cohen 	__be64			swap_add_mask;
183*e126ba97SEli Cohen 	__be64			compare_mask;
184*e126ba97SEli Cohen };
185*e126ba97SEli Cohen 
186*e126ba97SEli Cohen struct mlx5_av {
187*e126ba97SEli Cohen 	union {
188*e126ba97SEli Cohen 		struct {
189*e126ba97SEli Cohen 			__be32	qkey;
190*e126ba97SEli Cohen 			__be32	reserved;
191*e126ba97SEli Cohen 		} qkey;
192*e126ba97SEli Cohen 		__be64	dc_key;
193*e126ba97SEli Cohen 	} key;
194*e126ba97SEli Cohen 	__be32	dqp_dct;
195*e126ba97SEli Cohen 	u8	stat_rate_sl;
196*e126ba97SEli Cohen 	u8	fl_mlid;
197*e126ba97SEli Cohen 	__be16	rlid;
198*e126ba97SEli Cohen 	u8	reserved0[10];
199*e126ba97SEli Cohen 	u8	tclass;
200*e126ba97SEli Cohen 	u8	hop_limit;
201*e126ba97SEli Cohen 	__be32	grh_gid_fl;
202*e126ba97SEli Cohen 	u8	rgid[16];
203*e126ba97SEli Cohen };
204*e126ba97SEli Cohen 
205*e126ba97SEli Cohen struct mlx5_wqe_datagram_seg {
206*e126ba97SEli Cohen 	struct mlx5_av	av;
207*e126ba97SEli Cohen };
208*e126ba97SEli Cohen 
209*e126ba97SEli Cohen struct mlx5_wqe_raddr_seg {
210*e126ba97SEli Cohen 	__be64			raddr;
211*e126ba97SEli Cohen 	__be32			rkey;
212*e126ba97SEli Cohen 	u32			reserved;
213*e126ba97SEli Cohen };
214*e126ba97SEli Cohen 
215*e126ba97SEli Cohen struct mlx5_wqe_atomic_seg {
216*e126ba97SEli Cohen 	__be64			swap_add;
217*e126ba97SEli Cohen 	__be64			compare;
218*e126ba97SEli Cohen };
219*e126ba97SEli Cohen 
220*e126ba97SEli Cohen struct mlx5_wqe_data_seg {
221*e126ba97SEli Cohen 	__be32			byte_count;
222*e126ba97SEli Cohen 	__be32			lkey;
223*e126ba97SEli Cohen 	__be64			addr;
224*e126ba97SEli Cohen };
225*e126ba97SEli Cohen 
226*e126ba97SEli Cohen struct mlx5_wqe_umr_ctrl_seg {
227*e126ba97SEli Cohen 	u8		flags;
228*e126ba97SEli Cohen 	u8		rsvd0[3];
229*e126ba97SEli Cohen 	__be16		klm_octowords;
230*e126ba97SEli Cohen 	__be16		bsf_octowords;
231*e126ba97SEli Cohen 	__be64		mkey_mask;
232*e126ba97SEli Cohen 	u8		rsvd1[32];
233*e126ba97SEli Cohen };
234*e126ba97SEli Cohen 
235*e126ba97SEli Cohen struct mlx5_seg_set_psv {
236*e126ba97SEli Cohen 	__be32		psv_num;
237*e126ba97SEli Cohen 	__be16		syndrome;
238*e126ba97SEli Cohen 	__be16		status;
239*e126ba97SEli Cohen 	__be32		transient_sig;
240*e126ba97SEli Cohen 	__be32		ref_tag;
241*e126ba97SEli Cohen };
242*e126ba97SEli Cohen 
243*e126ba97SEli Cohen struct mlx5_seg_get_psv {
244*e126ba97SEli Cohen 	u8		rsvd[19];
245*e126ba97SEli Cohen 	u8		num_psv;
246*e126ba97SEli Cohen 	__be32		l_key;
247*e126ba97SEli Cohen 	__be64		va;
248*e126ba97SEli Cohen 	__be32		psv_index[4];
249*e126ba97SEli Cohen };
250*e126ba97SEli Cohen 
251*e126ba97SEli Cohen struct mlx5_seg_check_psv {
252*e126ba97SEli Cohen 	u8		rsvd0[2];
253*e126ba97SEli Cohen 	__be16		err_coalescing_op;
254*e126ba97SEli Cohen 	u8		rsvd1[2];
255*e126ba97SEli Cohen 	__be16		xport_err_op;
256*e126ba97SEli Cohen 	u8		rsvd2[2];
257*e126ba97SEli Cohen 	__be16		xport_err_mask;
258*e126ba97SEli Cohen 	u8		rsvd3[7];
259*e126ba97SEli Cohen 	u8		num_psv;
260*e126ba97SEli Cohen 	__be32		l_key;
261*e126ba97SEli Cohen 	__be64		va;
262*e126ba97SEli Cohen 	__be32		psv_index[4];
263*e126ba97SEli Cohen };
264*e126ba97SEli Cohen 
265*e126ba97SEli Cohen struct mlx5_rwqe_sig {
266*e126ba97SEli Cohen 	u8	rsvd0[4];
267*e126ba97SEli Cohen 	u8	signature;
268*e126ba97SEli Cohen 	u8	rsvd1[11];
269*e126ba97SEli Cohen };
270*e126ba97SEli Cohen 
271*e126ba97SEli Cohen struct mlx5_wqe_signature_seg {
272*e126ba97SEli Cohen 	u8	rsvd0[4];
273*e126ba97SEli Cohen 	u8	signature;
274*e126ba97SEli Cohen 	u8	rsvd1[11];
275*e126ba97SEli Cohen };
276*e126ba97SEli Cohen 
277*e126ba97SEli Cohen struct mlx5_wqe_inline_seg {
278*e126ba97SEli Cohen 	__be32	byte_count;
279*e126ba97SEli Cohen };
280*e126ba97SEli Cohen 
281*e126ba97SEli Cohen struct mlx5_core_qp {
282*e126ba97SEli Cohen 	void (*event)		(struct mlx5_core_qp *, int);
283*e126ba97SEli Cohen 	int			qpn;
284*e126ba97SEli Cohen 	atomic_t		refcount;
285*e126ba97SEli Cohen 	struct completion	free;
286*e126ba97SEli Cohen 	struct mlx5_rsc_debug	*dbg;
287*e126ba97SEli Cohen 	int			pid;
288*e126ba97SEli Cohen };
289*e126ba97SEli Cohen 
290*e126ba97SEli Cohen struct mlx5_qp_path {
291*e126ba97SEli Cohen 	u8			fl;
292*e126ba97SEli Cohen 	u8			rsvd3;
293*e126ba97SEli Cohen 	u8			free_ar;
294*e126ba97SEli Cohen 	u8			pkey_index;
295*e126ba97SEli Cohen 	u8			rsvd0;
296*e126ba97SEli Cohen 	u8			grh_mlid;
297*e126ba97SEli Cohen 	__be16			rlid;
298*e126ba97SEli Cohen 	u8			ackto_lt;
299*e126ba97SEli Cohen 	u8			mgid_index;
300*e126ba97SEli Cohen 	u8			static_rate;
301*e126ba97SEli Cohen 	u8			hop_limit;
302*e126ba97SEli Cohen 	__be32			tclass_flowlabel;
303*e126ba97SEli Cohen 	u8			rgid[16];
304*e126ba97SEli Cohen 	u8			rsvd1[4];
305*e126ba97SEli Cohen 	u8			sl;
306*e126ba97SEli Cohen 	u8			port;
307*e126ba97SEli Cohen 	u8			rsvd2[6];
308*e126ba97SEli Cohen };
309*e126ba97SEli Cohen 
310*e126ba97SEli Cohen struct mlx5_qp_context {
311*e126ba97SEli Cohen 	__be32			flags;
312*e126ba97SEli Cohen 	__be32			flags_pd;
313*e126ba97SEli Cohen 	u8			mtu_msgmax;
314*e126ba97SEli Cohen 	u8			rq_size_stride;
315*e126ba97SEli Cohen 	__be16			sq_crq_size;
316*e126ba97SEli Cohen 	__be32			qp_counter_set_usr_page;
317*e126ba97SEli Cohen 	__be32			wire_qpn;
318*e126ba97SEli Cohen 	__be32			log_pg_sz_remote_qpn;
319*e126ba97SEli Cohen 	struct			mlx5_qp_path pri_path;
320*e126ba97SEli Cohen 	struct			mlx5_qp_path alt_path;
321*e126ba97SEli Cohen 	__be32			params1;
322*e126ba97SEli Cohen 	u8			reserved2[4];
323*e126ba97SEli Cohen 	__be32			next_send_psn;
324*e126ba97SEli Cohen 	__be32			cqn_send;
325*e126ba97SEli Cohen 	u8			reserved3[8];
326*e126ba97SEli Cohen 	__be32			last_acked_psn;
327*e126ba97SEli Cohen 	__be32			ssn;
328*e126ba97SEli Cohen 	__be32			params2;
329*e126ba97SEli Cohen 	__be32			rnr_nextrecvpsn;
330*e126ba97SEli Cohen 	__be32			xrcd;
331*e126ba97SEli Cohen 	__be32			cqn_recv;
332*e126ba97SEli Cohen 	__be64			db_rec_addr;
333*e126ba97SEli Cohen 	__be32			qkey;
334*e126ba97SEli Cohen 	__be32			rq_type_srqn;
335*e126ba97SEli Cohen 	__be32			rmsn;
336*e126ba97SEli Cohen 	__be16			hw_sq_wqe_counter;
337*e126ba97SEli Cohen 	__be16			sw_sq_wqe_counter;
338*e126ba97SEli Cohen 	__be16			hw_rcyclic_byte_counter;
339*e126ba97SEli Cohen 	__be16			hw_rq_counter;
340*e126ba97SEli Cohen 	__be16			sw_rcyclic_byte_counter;
341*e126ba97SEli Cohen 	__be16			sw_rq_counter;
342*e126ba97SEli Cohen 	u8			rsvd0[5];
343*e126ba97SEli Cohen 	u8			cgs;
344*e126ba97SEli Cohen 	u8			cs_req;
345*e126ba97SEli Cohen 	u8			cs_res;
346*e126ba97SEli Cohen 	__be64			dc_access_key;
347*e126ba97SEli Cohen 	u8			rsvd1[24];
348*e126ba97SEli Cohen };
349*e126ba97SEli Cohen 
350*e126ba97SEli Cohen struct mlx5_create_qp_mbox_in {
351*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
352*e126ba97SEli Cohen 	__be32			input_qpn;
353*e126ba97SEli Cohen 	u8			rsvd0[4];
354*e126ba97SEli Cohen 	__be32			opt_param_mask;
355*e126ba97SEli Cohen 	u8			rsvd1[4];
356*e126ba97SEli Cohen 	struct mlx5_qp_context	ctx;
357*e126ba97SEli Cohen 	u8			rsvd3[16];
358*e126ba97SEli Cohen 	__be64			pas[0];
359*e126ba97SEli Cohen };
360*e126ba97SEli Cohen 
361*e126ba97SEli Cohen struct mlx5_create_qp_mbox_out {
362*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
363*e126ba97SEli Cohen 	__be32			qpn;
364*e126ba97SEli Cohen 	u8			rsvd0[4];
365*e126ba97SEli Cohen };
366*e126ba97SEli Cohen 
367*e126ba97SEli Cohen struct mlx5_destroy_qp_mbox_in {
368*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
369*e126ba97SEli Cohen 	__be32			qpn;
370*e126ba97SEli Cohen 	u8			rsvd0[4];
371*e126ba97SEli Cohen };
372*e126ba97SEli Cohen 
373*e126ba97SEli Cohen struct mlx5_destroy_qp_mbox_out {
374*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
375*e126ba97SEli Cohen 	u8			rsvd0[8];
376*e126ba97SEli Cohen };
377*e126ba97SEli Cohen 
378*e126ba97SEli Cohen struct mlx5_modify_qp_mbox_in {
379*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
380*e126ba97SEli Cohen 	__be32			qpn;
381*e126ba97SEli Cohen 	u8			rsvd1[4];
382*e126ba97SEli Cohen 	__be32			optparam;
383*e126ba97SEli Cohen 	u8			rsvd0[4];
384*e126ba97SEli Cohen 	struct mlx5_qp_context	ctx;
385*e126ba97SEli Cohen };
386*e126ba97SEli Cohen 
387*e126ba97SEli Cohen struct mlx5_modify_qp_mbox_out {
388*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
389*e126ba97SEli Cohen 	u8			rsvd0[8];
390*e126ba97SEli Cohen };
391*e126ba97SEli Cohen 
392*e126ba97SEli Cohen struct mlx5_query_qp_mbox_in {
393*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
394*e126ba97SEli Cohen 	__be32			qpn;
395*e126ba97SEli Cohen 	u8			rsvd[4];
396*e126ba97SEli Cohen };
397*e126ba97SEli Cohen 
398*e126ba97SEli Cohen struct mlx5_query_qp_mbox_out {
399*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
400*e126ba97SEli Cohen 	u8			rsvd1[8];
401*e126ba97SEli Cohen 	__be32			optparam;
402*e126ba97SEli Cohen 	u8			rsvd0[4];
403*e126ba97SEli Cohen 	struct mlx5_qp_context	ctx;
404*e126ba97SEli Cohen 	u8			rsvd2[16];
405*e126ba97SEli Cohen 	__be64			pas[0];
406*e126ba97SEli Cohen };
407*e126ba97SEli Cohen 
408*e126ba97SEli Cohen struct mlx5_conf_sqp_mbox_in {
409*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
410*e126ba97SEli Cohen 	__be32			qpn;
411*e126ba97SEli Cohen 	u8			rsvd[3];
412*e126ba97SEli Cohen 	u8			type;
413*e126ba97SEli Cohen };
414*e126ba97SEli Cohen 
415*e126ba97SEli Cohen struct mlx5_conf_sqp_mbox_out {
416*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
417*e126ba97SEli Cohen 	u8			rsvd[8];
418*e126ba97SEli Cohen };
419*e126ba97SEli Cohen 
420*e126ba97SEli Cohen struct mlx5_alloc_xrcd_mbox_in {
421*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
422*e126ba97SEli Cohen 	u8			rsvd[8];
423*e126ba97SEli Cohen };
424*e126ba97SEli Cohen 
425*e126ba97SEli Cohen struct mlx5_alloc_xrcd_mbox_out {
426*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
427*e126ba97SEli Cohen 	__be32			xrcdn;
428*e126ba97SEli Cohen 	u8			rsvd[4];
429*e126ba97SEli Cohen };
430*e126ba97SEli Cohen 
431*e126ba97SEli Cohen struct mlx5_dealloc_xrcd_mbox_in {
432*e126ba97SEli Cohen 	struct mlx5_inbox_hdr	hdr;
433*e126ba97SEli Cohen 	__be32			xrcdn;
434*e126ba97SEli Cohen 	u8			rsvd[4];
435*e126ba97SEli Cohen };
436*e126ba97SEli Cohen 
437*e126ba97SEli Cohen struct mlx5_dealloc_xrcd_mbox_out {
438*e126ba97SEli Cohen 	struct mlx5_outbox_hdr	hdr;
439*e126ba97SEli Cohen 	u8			rsvd[8];
440*e126ba97SEli Cohen };
441*e126ba97SEli Cohen 
442*e126ba97SEli Cohen static inline struct mlx5_core_qp *__mlx5_qp_lookup(struct mlx5_core_dev *dev, u32 qpn)
443*e126ba97SEli Cohen {
444*e126ba97SEli Cohen 	return radix_tree_lookup(&dev->priv.qp_table.tree, qpn);
445*e126ba97SEli Cohen }
446*e126ba97SEli Cohen 
447*e126ba97SEli Cohen int mlx5_core_create_qp(struct mlx5_core_dev *dev,
448*e126ba97SEli Cohen 			struct mlx5_core_qp *qp,
449*e126ba97SEli Cohen 			struct mlx5_create_qp_mbox_in *in,
450*e126ba97SEli Cohen 			int inlen);
451*e126ba97SEli Cohen int mlx5_core_qp_modify(struct mlx5_core_dev *dev, enum mlx5_qp_state cur_state,
452*e126ba97SEli Cohen 			enum mlx5_qp_state new_state,
453*e126ba97SEli Cohen 			struct mlx5_modify_qp_mbox_in *in, int sqd_event,
454*e126ba97SEli Cohen 			struct mlx5_core_qp *qp);
455*e126ba97SEli Cohen int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
456*e126ba97SEli Cohen 			 struct mlx5_core_qp *qp);
457*e126ba97SEli Cohen int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
458*e126ba97SEli Cohen 		       struct mlx5_query_qp_mbox_out *out, int outlen);
459*e126ba97SEli Cohen 
460*e126ba97SEli Cohen int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn);
461*e126ba97SEli Cohen int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn);
462*e126ba97SEli Cohen void mlx5_init_qp_table(struct mlx5_core_dev *dev);
463*e126ba97SEli Cohen void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev);
464*e126ba97SEli Cohen int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
465*e126ba97SEli Cohen void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
466*e126ba97SEli Cohen 
467*e126ba97SEli Cohen #endif /* MLX5_QP_H */
468