xref: /linux/include/linux/mlx5/qp.h (revision 38ca87c6f1e514686d4a385246d1afe1e1f2e482)
1e126ba97SEli Cohen /*
2302bdf68SSaeed Mahameed  * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
3e126ba97SEli Cohen  *
4e126ba97SEli Cohen  * This software is available to you under a choice of one of two
5e126ba97SEli Cohen  * licenses.  You may choose to be licensed under the terms of the GNU
6e126ba97SEli Cohen  * General Public License (GPL) Version 2, available from the file
7e126ba97SEli Cohen  * COPYING in the main directory of this source tree, or the
8e126ba97SEli Cohen  * OpenIB.org BSD license below:
9e126ba97SEli Cohen  *
10e126ba97SEli Cohen  *     Redistribution and use in source and binary forms, with or
11e126ba97SEli Cohen  *     without modification, are permitted provided that the following
12e126ba97SEli Cohen  *     conditions are met:
13e126ba97SEli Cohen  *
14e126ba97SEli Cohen  *      - Redistributions of source code must retain the above
15e126ba97SEli Cohen  *        copyright notice, this list of conditions and the following
16e126ba97SEli Cohen  *        disclaimer.
17e126ba97SEli Cohen  *
18e126ba97SEli Cohen  *      - Redistributions in binary form must reproduce the above
19e126ba97SEli Cohen  *        copyright notice, this list of conditions and the following
20e126ba97SEli Cohen  *        disclaimer in the documentation and/or other materials
21e126ba97SEli Cohen  *        provided with the distribution.
22e126ba97SEli Cohen  *
23e126ba97SEli Cohen  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24e126ba97SEli Cohen  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25e126ba97SEli Cohen  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26e126ba97SEli Cohen  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27e126ba97SEli Cohen  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28e126ba97SEli Cohen  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29e126ba97SEli Cohen  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30e126ba97SEli Cohen  * SOFTWARE.
31e126ba97SEli Cohen  */
32e126ba97SEli Cohen 
33e126ba97SEli Cohen #ifndef MLX5_QP_H
34e126ba97SEli Cohen #define MLX5_QP_H
35e126ba97SEli Cohen 
36e126ba97SEli Cohen #include <linux/mlx5/device.h>
37e126ba97SEli Cohen #include <linux/mlx5/driver.h>
38e126ba97SEli Cohen 
39e126ba97SEli Cohen #define MLX5_INVALID_LKEY	0x100
40*38ca87c6SMax Gurtovoy /* UMR (3 WQE_BB's) + SIG (3 WQE_BB's) + PSV (mem) + PSV (wire) */
41*38ca87c6SMax Gurtovoy #define MLX5_SIG_WQE_SIZE	(MLX5_SEND_WQE_BB * 8)
42e6631814SSagi Grimberg #define MLX5_DIF_SIZE		8
43e6631814SSagi Grimberg #define MLX5_STRIDE_BLOCK_OP	0x400
44fd22f78cSSagi Grimberg #define MLX5_CPY_GRD_MASK	0xc0
45fd22f78cSSagi Grimberg #define MLX5_CPY_APP_MASK	0x30
46fd22f78cSSagi Grimberg #define MLX5_CPY_REF_MASK	0x0f
47142537f4SSagi Grimberg #define MLX5_BSF_INC_REFTAG	(1 << 6)
48142537f4SSagi Grimberg #define MLX5_BSF_INL_VALID	(1 << 15)
49142537f4SSagi Grimberg #define MLX5_BSF_REFRESH_DIF	(1 << 14)
50142537f4SSagi Grimberg #define MLX5_BSF_REPEAT_BLOCK	(1 << 7)
51142537f4SSagi Grimberg #define MLX5_BSF_APPTAG_ESCAPE	0x1
52142537f4SSagi Grimberg #define MLX5_BSF_APPREF_ESCAPE	0x2
53e126ba97SEli Cohen 
54e126ba97SEli Cohen enum mlx5_qp_optpar {
55e126ba97SEli Cohen 	MLX5_QP_OPTPAR_ALT_ADDR_PATH		= 1 << 0,
56e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RRE			= 1 << 1,
57e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RAE			= 1 << 2,
58e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RWE			= 1 << 3,
59e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PKEY_INDEX		= 1 << 4,
60e126ba97SEli Cohen 	MLX5_QP_OPTPAR_Q_KEY			= 1 << 5,
61e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RNR_TIMEOUT		= 1 << 6,
62e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PRIMARY_ADDR_PATH	= 1 << 7,
63e126ba97SEli Cohen 	MLX5_QP_OPTPAR_SRA_MAX			= 1 << 8,
64e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RRA_MAX			= 1 << 9,
65e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PM_STATE			= 1 << 10,
66e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RETRY_COUNT		= 1 << 12,
67e126ba97SEli Cohen 	MLX5_QP_OPTPAR_RNR_RETRY		= 1 << 13,
68e126ba97SEli Cohen 	MLX5_QP_OPTPAR_ACK_TIMEOUT		= 1 << 14,
69e126ba97SEli Cohen 	MLX5_QP_OPTPAR_PRI_PORT			= 1 << 16,
70e126ba97SEli Cohen 	MLX5_QP_OPTPAR_SRQN			= 1 << 18,
71e126ba97SEli Cohen 	MLX5_QP_OPTPAR_CQN_RCV			= 1 << 19,
72e126ba97SEli Cohen 	MLX5_QP_OPTPAR_DC_HS			= 1 << 20,
73e126ba97SEli Cohen 	MLX5_QP_OPTPAR_DC_KEY			= 1 << 21,
74e126ba97SEli Cohen };
75e126ba97SEli Cohen 
76e126ba97SEli Cohen enum mlx5_qp_state {
77e126ba97SEli Cohen 	MLX5_QP_STATE_RST			= 0,
78e126ba97SEli Cohen 	MLX5_QP_STATE_INIT			= 1,
79e126ba97SEli Cohen 	MLX5_QP_STATE_RTR			= 2,
80e126ba97SEli Cohen 	MLX5_QP_STATE_RTS			= 3,
81e126ba97SEli Cohen 	MLX5_QP_STATE_SQER			= 4,
82e126ba97SEli Cohen 	MLX5_QP_STATE_SQD			= 5,
83e126ba97SEli Cohen 	MLX5_QP_STATE_ERR			= 6,
84e126ba97SEli Cohen 	MLX5_QP_STATE_SQ_DRAINING		= 7,
85e126ba97SEli Cohen 	MLX5_QP_STATE_SUSPENDED			= 9,
866d2f89dfSmajd@mellanox.com 	MLX5_QP_NUM_STATE,
876d2f89dfSmajd@mellanox.com 	MLX5_QP_STATE,
886d2f89dfSmajd@mellanox.com 	MLX5_QP_STATE_BAD,
896d2f89dfSmajd@mellanox.com };
906d2f89dfSmajd@mellanox.com 
916d2f89dfSmajd@mellanox.com enum {
926d2f89dfSmajd@mellanox.com 	MLX5_SQ_STATE_NA	= MLX5_SQC_STATE_ERR + 1,
936d2f89dfSmajd@mellanox.com 	MLX5_SQ_NUM_STATE	= MLX5_SQ_STATE_NA + 1,
946d2f89dfSmajd@mellanox.com 	MLX5_RQ_STATE_NA	= MLX5_RQC_STATE_ERR + 1,
956d2f89dfSmajd@mellanox.com 	MLX5_RQ_NUM_STATE	= MLX5_RQ_STATE_NA + 1,
96e126ba97SEli Cohen };
97e126ba97SEli Cohen 
98e126ba97SEli Cohen enum {
99e126ba97SEli Cohen 	MLX5_QP_ST_RC				= 0x0,
100e126ba97SEli Cohen 	MLX5_QP_ST_UC				= 0x1,
101e126ba97SEli Cohen 	MLX5_QP_ST_UD				= 0x2,
102e126ba97SEli Cohen 	MLX5_QP_ST_XRC				= 0x3,
103e126ba97SEli Cohen 	MLX5_QP_ST_MLX				= 0x4,
104e126ba97SEli Cohen 	MLX5_QP_ST_DCI				= 0x5,
105e126ba97SEli Cohen 	MLX5_QP_ST_DCT				= 0x6,
106e126ba97SEli Cohen 	MLX5_QP_ST_QP0				= 0x7,
107e126ba97SEli Cohen 	MLX5_QP_ST_QP1				= 0x8,
108e126ba97SEli Cohen 	MLX5_QP_ST_RAW_ETHERTYPE		= 0x9,
109e126ba97SEli Cohen 	MLX5_QP_ST_RAW_IPV6			= 0xa,
110e126ba97SEli Cohen 	MLX5_QP_ST_SNIFFER			= 0xb,
111e126ba97SEli Cohen 	MLX5_QP_ST_SYNC_UMR			= 0xe,
112e126ba97SEli Cohen 	MLX5_QP_ST_PTP_1588			= 0xd,
113e126ba97SEli Cohen 	MLX5_QP_ST_REG_UMR			= 0xc,
114e126ba97SEli Cohen 	MLX5_QP_ST_MAX
115e126ba97SEli Cohen };
116e126ba97SEli Cohen 
117e126ba97SEli Cohen enum {
118e126ba97SEli Cohen 	MLX5_QP_PM_MIGRATED			= 0x3,
119e126ba97SEli Cohen 	MLX5_QP_PM_ARMED			= 0x0,
120e126ba97SEli Cohen 	MLX5_QP_PM_REARM			= 0x1
121e126ba97SEli Cohen };
122e126ba97SEli Cohen 
123e126ba97SEli Cohen enum {
12409a7d9ecSSaeed Mahameed 	MLX5_NON_ZERO_RQ	= 0x0,
12509a7d9ecSSaeed Mahameed 	MLX5_SRQ_RQ		= 0x1,
12609a7d9ecSSaeed Mahameed 	MLX5_CRQ_RQ		= 0x2,
12709a7d9ecSSaeed Mahameed 	MLX5_ZERO_LEN_RQ	= 0x3
128e126ba97SEli Cohen };
129e126ba97SEli Cohen 
13009a7d9ecSSaeed Mahameed /* TODO REM */
131e126ba97SEli Cohen enum {
132e126ba97SEli Cohen 	/* params1 */
133e126ba97SEli Cohen 	MLX5_QP_BIT_SRE				= 1 << 15,
134e126ba97SEli Cohen 	MLX5_QP_BIT_SWE				= 1 << 14,
135e126ba97SEli Cohen 	MLX5_QP_BIT_SAE				= 1 << 13,
136e126ba97SEli Cohen 	/* params2 */
137e126ba97SEli Cohen 	MLX5_QP_BIT_RRE				= 1 << 15,
138e126ba97SEli Cohen 	MLX5_QP_BIT_RWE				= 1 << 14,
139e126ba97SEli Cohen 	MLX5_QP_BIT_RAE				= 1 << 13,
140e126ba97SEli Cohen 	MLX5_QP_BIT_RIC				= 1 <<	4,
141051f2630SLeon Romanovsky 	MLX5_QP_BIT_CC_SLAVE_RECV		= 1 <<  2,
142051f2630SLeon Romanovsky 	MLX5_QP_BIT_CC_SLAVE_SEND		= 1 <<  1,
143051f2630SLeon Romanovsky 	MLX5_QP_BIT_CC_MASTER			= 1 <<  0
144e126ba97SEli Cohen };
145e126ba97SEli Cohen 
146e126ba97SEli Cohen enum {
147e126ba97SEli Cohen 	MLX5_WQE_CTRL_CQ_UPDATE		= 2 << 2,
148e281682bSSaeed Mahameed 	MLX5_WQE_CTRL_CQ_UPDATE_AND_EQE	= 3 << 2,
149e126ba97SEli Cohen 	MLX5_WQE_CTRL_SOLICITED		= 1 << 1,
150e126ba97SEli Cohen };
151e126ba97SEli Cohen 
152e126ba97SEli Cohen enum {
153e281682bSSaeed Mahameed 	MLX5_SEND_WQE_DS	= 16,
154e126ba97SEli Cohen 	MLX5_SEND_WQE_BB	= 64,
155e126ba97SEli Cohen };
156e126ba97SEli Cohen 
157e281682bSSaeed Mahameed #define MLX5_SEND_WQEBB_NUM_DS	(MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS)
158e281682bSSaeed Mahameed 
159e281682bSSaeed Mahameed enum {
160e281682bSSaeed Mahameed 	MLX5_SEND_WQE_MAX_WQEBBS	= 16,
161e281682bSSaeed Mahameed };
162e281682bSSaeed Mahameed 
163e126ba97SEli Cohen enum {
164e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_LOCAL_READ	= 1 << 27,
165e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_LOCAL_WRITE	= 1 << 28,
166e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_REMOTE_READ	= 1 << 29,
167e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_REMOTE_WRITE	= 1 << 30,
168e126ba97SEli Cohen 	MLX5_WQE_FMR_PERM_ATOMIC	= 1 << 31
169e126ba97SEli Cohen };
170e126ba97SEli Cohen 
171e126ba97SEli Cohen enum {
172e126ba97SEli Cohen 	MLX5_FENCE_MODE_NONE			= 0 << 5,
173e126ba97SEli Cohen 	MLX5_FENCE_MODE_INITIATOR_SMALL		= 1 << 5,
174c9b25495SEli Cohen 	MLX5_FENCE_MODE_FENCE			= 2 << 5,
175e126ba97SEli Cohen 	MLX5_FENCE_MODE_STRONG_ORDERING		= 3 << 5,
176e126ba97SEli Cohen 	MLX5_FENCE_MODE_SMALL_AND_FENCE		= 4 << 5,
177e126ba97SEli Cohen };
178e126ba97SEli Cohen 
179e126ba97SEli Cohen enum {
180e126ba97SEli Cohen 	MLX5_RCV_DBR	= 0,
181e126ba97SEli Cohen 	MLX5_SND_DBR	= 1,
182e126ba97SEli Cohen };
183e126ba97SEli Cohen 
184e6631814SSagi Grimberg enum {
185e6631814SSagi Grimberg 	MLX5_FLAGS_INLINE	= 1<<7,
186e6631814SSagi Grimberg 	MLX5_FLAGS_CHECK_FREE   = 1<<5,
187e6631814SSagi Grimberg };
188e6631814SSagi Grimberg 
189e126ba97SEli Cohen struct mlx5_wqe_fmr_seg {
190e126ba97SEli Cohen 	__be32			flags;
191e126ba97SEli Cohen 	__be32			mem_key;
192e126ba97SEli Cohen 	__be64			buf_list;
193e126ba97SEli Cohen 	__be64			start_addr;
194e126ba97SEli Cohen 	__be64			reg_len;
195e126ba97SEli Cohen 	__be32			offset;
196e126ba97SEli Cohen 	__be32			page_size;
197e126ba97SEli Cohen 	u32			reserved[2];
198e126ba97SEli Cohen };
199e126ba97SEli Cohen 
200e126ba97SEli Cohen struct mlx5_wqe_ctrl_seg {
201e126ba97SEli Cohen 	__be32			opmod_idx_opcode;
202e126ba97SEli Cohen 	__be32			qpn_ds;
203e126ba97SEli Cohen 	u8			signature;
204e126ba97SEli Cohen 	u8			rsvd[2];
205e126ba97SEli Cohen 	u8			fm_ce_se;
206e126ba97SEli Cohen 	__be32			imm;
207e126ba97SEli Cohen };
208e126ba97SEli Cohen 
209c1395a2aSHaggai Eran #define MLX5_WQE_CTRL_DS_MASK 0x3f
2107bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_MASK 0xffffff00
2117bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_QPN_SHIFT 8
212c1395a2aSHaggai Eran #define MLX5_WQE_DS_UNITS 16
2137bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_OPCODE_MASK 0xff
2147bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_MASK 0x00ffff00
2157bdf65d4SHaggai Eran #define MLX5_WQE_CTRL_WQE_INDEX_SHIFT 8
216c1395a2aSHaggai Eran 
217e281682bSSaeed Mahameed enum {
218e281682bSSaeed Mahameed 	MLX5_ETH_WQE_L3_INNER_CSUM      = 1 << 4,
219e281682bSSaeed Mahameed 	MLX5_ETH_WQE_L4_INNER_CSUM      = 1 << 5,
220e281682bSSaeed Mahameed 	MLX5_ETH_WQE_L3_CSUM            = 1 << 6,
221e281682bSSaeed Mahameed 	MLX5_ETH_WQE_L4_CSUM            = 1 << 7,
222e281682bSSaeed Mahameed };
223e281682bSSaeed Mahameed 
2242b31f7aeSSaeed Mahameed enum {
2254382c7b9SGal Pressman 	MLX5_ETH_WQE_SVLAN              = 1 << 0,
2262b31f7aeSSaeed Mahameed 	MLX5_ETH_WQE_INSERT_VLAN        = 1 << 15,
2272b31f7aeSSaeed Mahameed };
2282b31f7aeSSaeed Mahameed 
229547eede0SIlan Tayari enum {
230547eede0SIlan Tayari 	MLX5_ETH_WQE_SWP_INNER_L3_IPV6  = 1 << 0,
231547eede0SIlan Tayari 	MLX5_ETH_WQE_SWP_INNER_L4_UDP   = 1 << 1,
232547eede0SIlan Tayari 	MLX5_ETH_WQE_SWP_OUTER_L3_IPV6  = 1 << 4,
233547eede0SIlan Tayari 	MLX5_ETH_WQE_SWP_OUTER_L4_UDP   = 1 << 5,
234547eede0SIlan Tayari };
235547eede0SIlan Tayari 
236e281682bSSaeed Mahameed struct mlx5_wqe_eth_seg {
237547eede0SIlan Tayari 	u8              swp_outer_l4_offset;
238547eede0SIlan Tayari 	u8              swp_outer_l3_offset;
239547eede0SIlan Tayari 	u8              swp_inner_l4_offset;
240547eede0SIlan Tayari 	u8              swp_inner_l3_offset;
241e281682bSSaeed Mahameed 	u8              cs_flags;
242547eede0SIlan Tayari 	u8              swp_flags;
243e281682bSSaeed Mahameed 	__be16          mss;
244e281682bSSaeed Mahameed 	__be32          rsvd2;
2452b31f7aeSSaeed Mahameed 	union {
2462b31f7aeSSaeed Mahameed 		struct {
2472b31f7aeSSaeed Mahameed 			__be16 sz;
2482b31f7aeSSaeed Mahameed 			u8     start[2];
2492b31f7aeSSaeed Mahameed 		} inline_hdr;
2502b31f7aeSSaeed Mahameed 		struct {
2512b31f7aeSSaeed Mahameed 			__be16 type;
2522b31f7aeSSaeed Mahameed 			__be16 vlan_tci;
2532b31f7aeSSaeed Mahameed 		} insert;
2542b31f7aeSSaeed Mahameed 	};
255e281682bSSaeed Mahameed };
256e281682bSSaeed Mahameed 
257e126ba97SEli Cohen struct mlx5_wqe_xrc_seg {
258e126ba97SEli Cohen 	__be32			xrc_srqn;
259e126ba97SEli Cohen 	u8			rsvd[12];
260e126ba97SEli Cohen };
261e126ba97SEli Cohen 
262e126ba97SEli Cohen struct mlx5_wqe_masked_atomic_seg {
263e126ba97SEli Cohen 	__be64			swap_add;
264e126ba97SEli Cohen 	__be64			compare;
265e126ba97SEli Cohen 	__be64			swap_add_mask;
266e126ba97SEli Cohen 	__be64			compare_mask;
267e126ba97SEli Cohen };
268e126ba97SEli Cohen 
26917d2f88fSArtemy Kovalyov struct mlx5_base_av {
27017d2f88fSArtemy Kovalyov 	union {
27117d2f88fSArtemy Kovalyov 		struct {
27217d2f88fSArtemy Kovalyov 			__be32	qkey;
27317d2f88fSArtemy Kovalyov 			__be32	reserved;
27417d2f88fSArtemy Kovalyov 		} qkey;
27517d2f88fSArtemy Kovalyov 		__be64	dc_key;
27617d2f88fSArtemy Kovalyov 	} key;
27717d2f88fSArtemy Kovalyov 	__be32	dqp_dct;
27817d2f88fSArtemy Kovalyov 	u8	stat_rate_sl;
27917d2f88fSArtemy Kovalyov 	u8	fl_mlid;
28017d2f88fSArtemy Kovalyov 	union {
28117d2f88fSArtemy Kovalyov 		__be16	rlid;
28217d2f88fSArtemy Kovalyov 		__be16  udp_sport;
28317d2f88fSArtemy Kovalyov 	};
28417d2f88fSArtemy Kovalyov };
28517d2f88fSArtemy Kovalyov 
286e126ba97SEli Cohen struct mlx5_av {
287e126ba97SEli Cohen 	union {
288e126ba97SEli Cohen 		struct {
289e126ba97SEli Cohen 			__be32	qkey;
290e126ba97SEli Cohen 			__be32	reserved;
291e126ba97SEli Cohen 		} qkey;
292e126ba97SEli Cohen 		__be64	dc_key;
293e126ba97SEli Cohen 	} key;
294e126ba97SEli Cohen 	__be32	dqp_dct;
295e126ba97SEli Cohen 	u8	stat_rate_sl;
296e126ba97SEli Cohen 	u8	fl_mlid;
2972811ba51SAchiad Shochat 	union {
298e126ba97SEli Cohen 		__be16	rlid;
2992811ba51SAchiad Shochat 		__be16  udp_sport;
3002811ba51SAchiad Shochat 	};
3012811ba51SAchiad Shochat 	u8	reserved0[4];
3022811ba51SAchiad Shochat 	u8	rmac[6];
303e126ba97SEli Cohen 	u8	tclass;
304e126ba97SEli Cohen 	u8	hop_limit;
305e126ba97SEli Cohen 	__be32	grh_gid_fl;
306e126ba97SEli Cohen 	u8	rgid[16];
307e126ba97SEli Cohen };
308e126ba97SEli Cohen 
30925854544SSaeed Mahameed struct mlx5_ib_ah {
31025854544SSaeed Mahameed 	struct ib_ah		ibah;
31125854544SSaeed Mahameed 	struct mlx5_av		av;
31225854544SSaeed Mahameed };
31325854544SSaeed Mahameed 
31425854544SSaeed Mahameed static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
31525854544SSaeed Mahameed {
31625854544SSaeed Mahameed 	return container_of(ibah, struct mlx5_ib_ah, ibah);
31725854544SSaeed Mahameed }
31825854544SSaeed Mahameed 
319e126ba97SEli Cohen struct mlx5_wqe_datagram_seg {
320e126ba97SEli Cohen 	struct mlx5_av	av;
321e126ba97SEli Cohen };
322e126ba97SEli Cohen 
323e126ba97SEli Cohen struct mlx5_wqe_raddr_seg {
324e126ba97SEli Cohen 	__be64			raddr;
325e126ba97SEli Cohen 	__be32			rkey;
326e126ba97SEli Cohen 	u32			reserved;
327e126ba97SEli Cohen };
328e126ba97SEli Cohen 
329e126ba97SEli Cohen struct mlx5_wqe_atomic_seg {
330e126ba97SEli Cohen 	__be64			swap_add;
331e126ba97SEli Cohen 	__be64			compare;
332e126ba97SEli Cohen };
333e126ba97SEli Cohen 
334e126ba97SEli Cohen struct mlx5_wqe_data_seg {
335e126ba97SEli Cohen 	__be32			byte_count;
336e126ba97SEli Cohen 	__be32			lkey;
337e126ba97SEli Cohen 	__be64			addr;
338e126ba97SEli Cohen };
339e126ba97SEli Cohen 
340e126ba97SEli Cohen struct mlx5_wqe_umr_ctrl_seg {
341e126ba97SEli Cohen 	u8		flags;
342e126ba97SEli Cohen 	u8		rsvd0[3];
34331616255SArtemy Kovalyov 	__be16		xlt_octowords;
34431616255SArtemy Kovalyov 	union {
34531616255SArtemy Kovalyov 		__be16	xlt_offset;
346e126ba97SEli Cohen 		__be16	bsf_octowords;
34731616255SArtemy Kovalyov 	};
348e126ba97SEli Cohen 	__be64		mkey_mask;
34931616255SArtemy Kovalyov 	__be32		xlt_offset_47_16;
35031616255SArtemy Kovalyov 	u8		rsvd1[28];
351e126ba97SEli Cohen };
352e126ba97SEli Cohen 
353e126ba97SEli Cohen struct mlx5_seg_set_psv {
354e126ba97SEli Cohen 	__be32		psv_num;
355e126ba97SEli Cohen 	__be16		syndrome;
356e126ba97SEli Cohen 	__be16		status;
357e126ba97SEli Cohen 	__be32		transient_sig;
358e126ba97SEli Cohen 	__be32		ref_tag;
359e126ba97SEli Cohen };
360e126ba97SEli Cohen 
361e126ba97SEli Cohen struct mlx5_seg_get_psv {
362e126ba97SEli Cohen 	u8		rsvd[19];
363e126ba97SEli Cohen 	u8		num_psv;
364e126ba97SEli Cohen 	__be32		l_key;
365e126ba97SEli Cohen 	__be64		va;
366e126ba97SEli Cohen 	__be32		psv_index[4];
367e126ba97SEli Cohen };
368e126ba97SEli Cohen 
369e126ba97SEli Cohen struct mlx5_seg_check_psv {
370e126ba97SEli Cohen 	u8		rsvd0[2];
371e126ba97SEli Cohen 	__be16		err_coalescing_op;
372e126ba97SEli Cohen 	u8		rsvd1[2];
373e126ba97SEli Cohen 	__be16		xport_err_op;
374e126ba97SEli Cohen 	u8		rsvd2[2];
375e126ba97SEli Cohen 	__be16		xport_err_mask;
376e126ba97SEli Cohen 	u8		rsvd3[7];
377e126ba97SEli Cohen 	u8		num_psv;
378e126ba97SEli Cohen 	__be32		l_key;
379e126ba97SEli Cohen 	__be64		va;
380e126ba97SEli Cohen 	__be32		psv_index[4];
381e126ba97SEli Cohen };
382e126ba97SEli Cohen 
383e126ba97SEli Cohen struct mlx5_rwqe_sig {
384e126ba97SEli Cohen 	u8	rsvd0[4];
385e126ba97SEli Cohen 	u8	signature;
386e126ba97SEli Cohen 	u8	rsvd1[11];
387e126ba97SEli Cohen };
388e126ba97SEli Cohen 
389e126ba97SEli Cohen struct mlx5_wqe_signature_seg {
390e126ba97SEli Cohen 	u8	rsvd0[4];
391e126ba97SEli Cohen 	u8	signature;
392e126ba97SEli Cohen 	u8	rsvd1[11];
393e126ba97SEli Cohen };
394e126ba97SEli Cohen 
3957bdf65d4SHaggai Eran #define MLX5_WQE_INLINE_SEG_BYTE_COUNT_MASK 0x3ff
3967bdf65d4SHaggai Eran 
397e126ba97SEli Cohen struct mlx5_wqe_inline_seg {
398e126ba97SEli Cohen 	__be32	byte_count;
399c2273219SShay Agroskin 	__be32	data[0];
400e126ba97SEli Cohen };
401e126ba97SEli Cohen 
402142537f4SSagi Grimberg enum mlx5_sig_type {
403142537f4SSagi Grimberg 	MLX5_DIF_CRC = 0x1,
404142537f4SSagi Grimberg 	MLX5_DIF_IPCS = 0x2,
405142537f4SSagi Grimberg };
406142537f4SSagi Grimberg 
407142537f4SSagi Grimberg struct mlx5_bsf_inl {
408142537f4SSagi Grimberg 	__be16		vld_refresh;
409142537f4SSagi Grimberg 	__be16		dif_apptag;
410142537f4SSagi Grimberg 	__be32		dif_reftag;
411142537f4SSagi Grimberg 	u8		sig_type;
412142537f4SSagi Grimberg 	u8		rp_inv_seed;
413142537f4SSagi Grimberg 	u8		rsvd[3];
414142537f4SSagi Grimberg 	u8		dif_inc_ref_guard_check;
415142537f4SSagi Grimberg 	__be16		dif_app_bitmask_check;
416142537f4SSagi Grimberg };
417142537f4SSagi Grimberg 
418e6631814SSagi Grimberg struct mlx5_bsf {
419e6631814SSagi Grimberg 	struct mlx5_bsf_basic {
420e6631814SSagi Grimberg 		u8		bsf_size_sbs;
421e6631814SSagi Grimberg 		u8		check_byte_mask;
422e6631814SSagi Grimberg 		union {
423e6631814SSagi Grimberg 			u8	copy_byte_mask;
424e6631814SSagi Grimberg 			u8	bs_selector;
425e6631814SSagi Grimberg 			u8	rsvd_wflags;
426e6631814SSagi Grimberg 		} wire;
427e6631814SSagi Grimberg 		union {
428e6631814SSagi Grimberg 			u8	bs_selector;
429e6631814SSagi Grimberg 			u8	rsvd_mflags;
430e6631814SSagi Grimberg 		} mem;
431e6631814SSagi Grimberg 		__be32		raw_data_size;
432e6631814SSagi Grimberg 		__be32		w_bfs_psv;
433e6631814SSagi Grimberg 		__be32		m_bfs_psv;
434e6631814SSagi Grimberg 	} basic;
435e6631814SSagi Grimberg 	struct mlx5_bsf_ext {
436e6631814SSagi Grimberg 		__be32		t_init_gen_pro_size;
437e6631814SSagi Grimberg 		__be32		rsvd_epi_size;
438e6631814SSagi Grimberg 		__be32		w_tfs_psv;
439e6631814SSagi Grimberg 		__be32		m_tfs_psv;
440e6631814SSagi Grimberg 	} ext;
441142537f4SSagi Grimberg 	struct mlx5_bsf_inl	w_inl;
442142537f4SSagi Grimberg 	struct mlx5_bsf_inl	m_inl;
443e6631814SSagi Grimberg };
444e6631814SSagi Grimberg 
44531616255SArtemy Kovalyov struct mlx5_mtt {
44631616255SArtemy Kovalyov 	__be64		ptag;
44731616255SArtemy Kovalyov };
44831616255SArtemy Kovalyov 
449e6631814SSagi Grimberg struct mlx5_klm {
450e6631814SSagi Grimberg 	__be32		bcount;
451e6631814SSagi Grimberg 	__be32		key;
452e6631814SSagi Grimberg 	__be64		va;
453e6631814SSagi Grimberg };
454e6631814SSagi Grimberg 
455e6631814SSagi Grimberg struct mlx5_stride_block_entry {
456e6631814SSagi Grimberg 	__be16		stride;
457e6631814SSagi Grimberg 	__be16		bcount;
458e6631814SSagi Grimberg 	__be32		key;
459e6631814SSagi Grimberg 	__be64		va;
460e6631814SSagi Grimberg };
461e6631814SSagi Grimberg 
462e6631814SSagi Grimberg struct mlx5_stride_block_ctrl_seg {
463e6631814SSagi Grimberg 	__be32		bcount_per_cycle;
464e6631814SSagi Grimberg 	__be32		op;
465e6631814SSagi Grimberg 	__be32		repeat_count;
466e6631814SSagi Grimberg 	u16		rsvd;
467e6631814SSagi Grimberg 	__be16		num_entries;
468e6631814SSagi Grimberg };
469e6631814SSagi Grimberg 
470e126ba97SEli Cohen struct mlx5_core_qp {
4715903325aSEli Cohen 	struct mlx5_core_rsc_common	common; /* must be first */
472e126ba97SEli Cohen 	void (*event)		(struct mlx5_core_qp *, int);
473e126ba97SEli Cohen 	int			qpn;
474e126ba97SEli Cohen 	struct mlx5_rsc_debug	*dbg;
475e126ba97SEli Cohen 	int			pid;
4764ac63ec7SYishai Hadas 	u16			uid;
477e126ba97SEli Cohen };
478e126ba97SEli Cohen 
47957cda166SMoni Shoua struct mlx5_core_dct {
48057cda166SMoni Shoua 	struct mlx5_core_qp	mqp;
48157cda166SMoni Shoua 	struct completion	drained;
48257cda166SMoni Shoua };
48357cda166SMoni Shoua 
484e126ba97SEli Cohen struct mlx5_qp_path {
485d3ae2bdeSNoa Osherovich 	u8			fl_free_ar;
486e126ba97SEli Cohen 	u8			rsvd3;
487d3ae2bdeSNoa Osherovich 	__be16			pkey_index;
488e126ba97SEli Cohen 	u8			rsvd0;
489e126ba97SEli Cohen 	u8			grh_mlid;
490e126ba97SEli Cohen 	__be16			rlid;
491e126ba97SEli Cohen 	u8			ackto_lt;
492e126ba97SEli Cohen 	u8			mgid_index;
493e126ba97SEli Cohen 	u8			static_rate;
494e126ba97SEli Cohen 	u8			hop_limit;
495e126ba97SEli Cohen 	__be32			tclass_flowlabel;
4962811ba51SAchiad Shochat 	union {
497e126ba97SEli Cohen 		u8		rgid[16];
4982811ba51SAchiad Shochat 		u8		rip[16];
4992811ba51SAchiad Shochat 	};
5002811ba51SAchiad Shochat 	u8			f_dscp_ecn_prio;
5012811ba51SAchiad Shochat 	u8			ecn_dscp;
5022811ba51SAchiad Shochat 	__be16			udp_sport;
5032811ba51SAchiad Shochat 	u8			dci_cfi_prio_sl;
504e126ba97SEli Cohen 	u8			port;
5052811ba51SAchiad Shochat 	u8			rmac[6];
506e126ba97SEli Cohen };
507e126ba97SEli Cohen 
5081a412fb1SSaeed Mahameed /* FIXME: use mlx5_ifc.h qpc */
509e126ba97SEli Cohen struct mlx5_qp_context {
510e126ba97SEli Cohen 	__be32			flags;
511e126ba97SEli Cohen 	__be32			flags_pd;
512e126ba97SEli Cohen 	u8			mtu_msgmax;
513e126ba97SEli Cohen 	u8			rq_size_stride;
514e126ba97SEli Cohen 	__be16			sq_crq_size;
515e126ba97SEli Cohen 	__be32			qp_counter_set_usr_page;
516e126ba97SEli Cohen 	__be32			wire_qpn;
517e126ba97SEli Cohen 	__be32			log_pg_sz_remote_qpn;
518e126ba97SEli Cohen 	struct			mlx5_qp_path pri_path;
519e126ba97SEli Cohen 	struct			mlx5_qp_path alt_path;
520e126ba97SEli Cohen 	__be32			params1;
521e126ba97SEli Cohen 	u8			reserved2[4];
522e126ba97SEli Cohen 	__be32			next_send_psn;
523e126ba97SEli Cohen 	__be32			cqn_send;
524b11a4f9cSHaggai Eran 	__be32			deth_sqpn;
525b11a4f9cSHaggai Eran 	u8			reserved3[4];
526e126ba97SEli Cohen 	__be32			last_acked_psn;
527e126ba97SEli Cohen 	__be32			ssn;
528e126ba97SEli Cohen 	__be32			params2;
529e126ba97SEli Cohen 	__be32			rnr_nextrecvpsn;
530e126ba97SEli Cohen 	__be32			xrcd;
531e126ba97SEli Cohen 	__be32			cqn_recv;
532e126ba97SEli Cohen 	__be64			db_rec_addr;
533e126ba97SEli Cohen 	__be32			qkey;
534e126ba97SEli Cohen 	__be32			rq_type_srqn;
535e126ba97SEli Cohen 	__be32			rmsn;
536e126ba97SEli Cohen 	__be16			hw_sq_wqe_counter;
537e126ba97SEli Cohen 	__be16			sw_sq_wqe_counter;
538e126ba97SEli Cohen 	__be16			hw_rcyclic_byte_counter;
539e126ba97SEli Cohen 	__be16			hw_rq_counter;
540e126ba97SEli Cohen 	__be16			sw_rcyclic_byte_counter;
541e126ba97SEli Cohen 	__be16			sw_rq_counter;
542e126ba97SEli Cohen 	u8			rsvd0[5];
543e126ba97SEli Cohen 	u8			cgs;
544e126ba97SEli Cohen 	u8			cs_req;
545e126ba97SEli Cohen 	u8			cs_res;
546e126ba97SEli Cohen 	__be64			dc_access_key;
547e126ba97SEli Cohen 	u8			rsvd1[24];
548e126ba97SEli Cohen };
549e126ba97SEli Cohen 
550e126ba97SEli Cohen static inline struct mlx5_core_qp *__mlx5_qp_lookup(struct mlx5_core_dev *dev, u32 qpn)
551e126ba97SEli Cohen {
552e126ba97SEli Cohen 	return radix_tree_lookup(&dev->priv.qp_table.tree, qpn);
553e126ba97SEli Cohen }
554e126ba97SEli Cohen 
555a606b0f6SMatan Barak static inline struct mlx5_core_mkey *__mlx5_mr_lookup(struct mlx5_core_dev *dev, u32 key)
556d5436ba0SSagi Grimberg {
557a606b0f6SMatan Barak 	return radix_tree_lookup(&dev->priv.mkey_table.tree, key);
558d5436ba0SSagi Grimberg }
559d5436ba0SSagi Grimberg 
56057cda166SMoni Shoua int mlx5_core_create_dct(struct mlx5_core_dev *dev,
56157cda166SMoni Shoua 			 struct mlx5_core_dct *qp,
562c5ae1954SYishai Hadas 			 u32 *in, int inlen,
563c5ae1954SYishai Hadas 			 u32 *out, int outlen);
564e126ba97SEli Cohen int mlx5_core_create_qp(struct mlx5_core_dev *dev,
565e126ba97SEli Cohen 			struct mlx5_core_qp *qp,
56609a7d9ecSSaeed Mahameed 			u32 *in,
567e126ba97SEli Cohen 			int inlen);
5681a412fb1SSaeed Mahameed int mlx5_core_qp_modify(struct mlx5_core_dev *dev, u16 opcode,
5691a412fb1SSaeed Mahameed 			u32 opt_param_mask, void *qpc,
570e126ba97SEli Cohen 			struct mlx5_core_qp *qp);
571e126ba97SEli Cohen int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
572e126ba97SEli Cohen 			 struct mlx5_core_qp *qp);
57357cda166SMoni Shoua int mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
57457cda166SMoni Shoua 			  struct mlx5_core_dct *dct);
575e126ba97SEli Cohen int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
57609a7d9ecSSaeed Mahameed 		       u32 *out, int outlen);
57757cda166SMoni Shoua int mlx5_core_dct_query(struct mlx5_core_dev *dev, struct mlx5_core_dct *dct,
57857cda166SMoni Shoua 			u32 *out, int outlen);
579e126ba97SEli Cohen 
580c1e0bfc1SMaor Gottlieb int mlx5_core_set_delay_drop(struct mlx5_core_dev *dev,
581c1e0bfc1SMaor Gottlieb 			     u32 timeout_usec);
582c1e0bfc1SMaor Gottlieb 
583e126ba97SEli Cohen int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn);
584e126ba97SEli Cohen int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn);
585e126ba97SEli Cohen void mlx5_init_qp_table(struct mlx5_core_dev *dev);
586e126ba97SEli Cohen void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev);
587e126ba97SEli Cohen int mlx5_debug_qp_add(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
588e126ba97SEli Cohen void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp);
589e2013b21Smajd@mellanox.com int mlx5_core_create_rq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen,
590e2013b21Smajd@mellanox.com 				struct mlx5_core_qp *rq);
591e2013b21Smajd@mellanox.com void mlx5_core_destroy_rq_tracked(struct mlx5_core_dev *dev,
592e2013b21Smajd@mellanox.com 				  struct mlx5_core_qp *rq);
593e2013b21Smajd@mellanox.com int mlx5_core_create_sq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen,
594e2013b21Smajd@mellanox.com 				struct mlx5_core_qp *sq);
595e2013b21Smajd@mellanox.com void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev,
596e2013b21Smajd@mellanox.com 				  struct mlx5_core_qp *sq);
597237cd218STariq Toukan int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id);
598237cd218STariq Toukan int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id);
599237cd218STariq Toukan int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
600237cd218STariq Toukan 			      int reset, void *out, int out_size);
601e126ba97SEli Cohen 
60227e95603SMoni Shoua struct mlx5_core_rsc_common *mlx5_core_res_hold(struct mlx5_core_dev *dev,
60327e95603SMoni Shoua 						int res_num,
60427e95603SMoni Shoua 						enum mlx5_res_type res_type);
60527e95603SMoni Shoua void mlx5_core_res_put(struct mlx5_core_rsc_common *res);
60627e95603SMoni Shoua 
607db81a5c3SEli Cohen static inline const char *mlx5_qp_type_str(int type)
608db81a5c3SEli Cohen {
609db81a5c3SEli Cohen 	switch (type) {
610db81a5c3SEli Cohen 	case MLX5_QP_ST_RC: return "RC";
611db81a5c3SEli Cohen 	case MLX5_QP_ST_UC: return "C";
612db81a5c3SEli Cohen 	case MLX5_QP_ST_UD: return "UD";
613db81a5c3SEli Cohen 	case MLX5_QP_ST_XRC: return "XRC";
614db81a5c3SEli Cohen 	case MLX5_QP_ST_MLX: return "MLX";
615db81a5c3SEli Cohen 	case MLX5_QP_ST_QP0: return "QP0";
616db81a5c3SEli Cohen 	case MLX5_QP_ST_QP1: return "QP1";
617db81a5c3SEli Cohen 	case MLX5_QP_ST_RAW_ETHERTYPE: return "RAW_ETHERTYPE";
618db81a5c3SEli Cohen 	case MLX5_QP_ST_RAW_IPV6: return "RAW_IPV6";
619db81a5c3SEli Cohen 	case MLX5_QP_ST_SNIFFER: return "SNIFFER";
620db81a5c3SEli Cohen 	case MLX5_QP_ST_SYNC_UMR: return "SYNC_UMR";
621db81a5c3SEli Cohen 	case MLX5_QP_ST_PTP_1588: return "PTP_1588";
622db81a5c3SEli Cohen 	case MLX5_QP_ST_REG_UMR: return "REG_UMR";
623db81a5c3SEli Cohen 	default: return "Invalid transport type";
624db81a5c3SEli Cohen 	}
625db81a5c3SEli Cohen }
626db81a5c3SEli Cohen 
627db81a5c3SEli Cohen static inline const char *mlx5_qp_state_str(int state)
628db81a5c3SEli Cohen {
629db81a5c3SEli Cohen 	switch (state) {
630db81a5c3SEli Cohen 	case MLX5_QP_STATE_RST:
631db81a5c3SEli Cohen 	return "RST";
632db81a5c3SEli Cohen 	case MLX5_QP_STATE_INIT:
633db81a5c3SEli Cohen 	return "INIT";
634db81a5c3SEli Cohen 	case MLX5_QP_STATE_RTR:
635db81a5c3SEli Cohen 	return "RTR";
636db81a5c3SEli Cohen 	case MLX5_QP_STATE_RTS:
637db81a5c3SEli Cohen 	return "RTS";
638db81a5c3SEli Cohen 	case MLX5_QP_STATE_SQER:
639db81a5c3SEli Cohen 	return "SQER";
640db81a5c3SEli Cohen 	case MLX5_QP_STATE_SQD:
641db81a5c3SEli Cohen 	return "SQD";
642db81a5c3SEli Cohen 	case MLX5_QP_STATE_ERR:
643db81a5c3SEli Cohen 	return "ERR";
644db81a5c3SEli Cohen 	case MLX5_QP_STATE_SQ_DRAINING:
645db81a5c3SEli Cohen 	return "SQ_DRAINING";
646db81a5c3SEli Cohen 	case MLX5_QP_STATE_SUSPENDED:
647db81a5c3SEli Cohen 	return "SUSPENDED";
648db81a5c3SEli Cohen 	default: return "Invalid QP state";
649db81a5c3SEli Cohen 	}
650db81a5c3SEli Cohen }
651db81a5c3SEli Cohen 
652e126ba97SEli Cohen #endif /* MLX5_QP_H */
653