]>
Commit | Line | Data |
---|---|---|
e126ba97 | 1 | /* |
6cf0a15f | 2 | * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved. |
e126ba97 EC |
3 | * |
4 | * This software is available to you under a choice of one of two | |
5 | * licenses. You may choose to be licensed under the terms of the GNU | |
6 | * General Public License (GPL) Version 2, available from the file | |
7 | * COPYING in the main directory of this source tree, or the | |
8 | * OpenIB.org BSD license below: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistributions of source code must retain the above | |
15 | * copyright notice, this list of conditions and the following | |
16 | * disclaimer. | |
17 | * | |
18 | * - Redistributions in binary form must reproduce the above | |
19 | * copyright notice, this list of conditions and the following | |
20 | * disclaimer in the documentation and/or other materials | |
21 | * provided with the distribution. | |
22 | * | |
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
27 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
28 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
29 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
30 | * SOFTWARE. | |
31 | */ | |
32 | ||
33 | #ifndef MLX5_IB_H | |
34 | #define MLX5_IB_H | |
35 | ||
36 | #include <linux/kernel.h> | |
37 | #include <linux/sched.h> | |
38 | #include <rdma/ib_verbs.h> | |
39 | #include <rdma/ib_smi.h> | |
40 | #include <linux/mlx5/driver.h> | |
41 | #include <linux/mlx5/cq.h> | |
42 | #include <linux/mlx5/qp.h> | |
43 | #include <linux/mlx5/srq.h> | |
44 | #include <linux/types.h> | |
146d2f1a | 45 | #include <linux/mlx5/transobj.h> |
d2370e0a | 46 | #include <rdma/ib_user_verbs.h> |
e126ba97 EC |
47 | |
48 | #define mlx5_ib_dbg(dev, format, arg...) \ | |
49 | pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ | |
50 | __LINE__, current->pid, ##arg) | |
51 | ||
52 | #define mlx5_ib_err(dev, format, arg...) \ | |
53 | pr_err("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ | |
54 | __LINE__, current->pid, ##arg) | |
55 | ||
56 | #define mlx5_ib_warn(dev, format, arg...) \ | |
57 | pr_warn("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \ | |
58 | __LINE__, current->pid, ##arg) | |
59 | ||
b368d7cb MB |
60 | #define field_avail(type, fld, sz) (offsetof(type, fld) + \ |
61 | sizeof(((type *)0)->fld) <= (sz)) | |
cfb5e088 HA |
62 | #define MLX5_IB_DEFAULT_UIDX 0xffffff |
63 | #define MLX5_USER_ASSIGNED_UIDX_MASK __mlx5_mask(qpc, user_index) | |
b368d7cb | 64 | |
e126ba97 EC |
65 | enum { |
66 | MLX5_IB_MMAP_CMD_SHIFT = 8, | |
67 | MLX5_IB_MMAP_CMD_MASK = 0xff, | |
68 | }; | |
69 | ||
70 | enum mlx5_ib_mmap_cmd { | |
71 | MLX5_IB_MMAP_REGULAR_PAGE = 0, | |
d69e3bcf | 72 | MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES = 1, |
37aa5c36 GL |
73 | MLX5_IB_MMAP_WC_PAGE = 2, |
74 | MLX5_IB_MMAP_NC_PAGE = 3, | |
d69e3bcf MB |
75 | /* 5 is chosen in order to be compatible with old versions of libmlx5 */ |
76 | MLX5_IB_MMAP_CORE_CLOCK = 5, | |
e126ba97 EC |
77 | }; |
78 | ||
79 | enum { | |
80 | MLX5_RES_SCAT_DATA32_CQE = 0x1, | |
81 | MLX5_RES_SCAT_DATA64_CQE = 0x2, | |
82 | MLX5_REQ_SCAT_DATA32_CQE = 0x11, | |
83 | MLX5_REQ_SCAT_DATA64_CQE = 0x22, | |
84 | }; | |
85 | ||
86 | enum mlx5_ib_latency_class { | |
87 | MLX5_IB_LATENCY_CLASS_LOW, | |
88 | MLX5_IB_LATENCY_CLASS_MEDIUM, | |
89 | MLX5_IB_LATENCY_CLASS_HIGH, | |
90 | MLX5_IB_LATENCY_CLASS_FAST_PATH | |
91 | }; | |
92 | ||
93 | enum mlx5_ib_mad_ifc_flags { | |
94 | MLX5_MAD_IFC_IGNORE_MKEY = 1, | |
95 | MLX5_MAD_IFC_IGNORE_BKEY = 2, | |
96 | MLX5_MAD_IFC_NET_VIEW = 4, | |
97 | }; | |
98 | ||
051f2630 LR |
99 | enum { |
100 | MLX5_CROSS_CHANNEL_UUAR = 0, | |
101 | }; | |
102 | ||
cfb5e088 HA |
103 | enum { |
104 | MLX5_CQE_VERSION_V0, | |
105 | MLX5_CQE_VERSION_V1, | |
106 | }; | |
107 | ||
7c2344c3 MG |
108 | struct mlx5_ib_vma_private_data { |
109 | struct list_head list; | |
110 | struct vm_area_struct *vma; | |
111 | }; | |
112 | ||
e126ba97 EC |
113 | struct mlx5_ib_ucontext { |
114 | struct ib_ucontext ibucontext; | |
115 | struct list_head db_page_list; | |
116 | ||
117 | /* protect doorbell record alloc/free | |
118 | */ | |
119 | struct mutex db_page_mutex; | |
120 | struct mlx5_uuar_info uuari; | |
cfb5e088 | 121 | u8 cqe_version; |
146d2f1a | 122 | /* Transport Domain number */ |
123 | u32 tdn; | |
7c2344c3 | 124 | struct list_head vma_private_list; |
e126ba97 EC |
125 | }; |
126 | ||
127 | static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext) | |
128 | { | |
129 | return container_of(ibucontext, struct mlx5_ib_ucontext, ibucontext); | |
130 | } | |
131 | ||
132 | struct mlx5_ib_pd { | |
133 | struct ib_pd ibpd; | |
134 | u32 pdn; | |
e126ba97 EC |
135 | }; |
136 | ||
038d2ef8 | 137 | #define MLX5_IB_FLOW_MCAST_PRIO (MLX5_BY_PASS_NUM_PRIOS - 1) |
35d19011 | 138 | #define MLX5_IB_FLOW_LAST_PRIO (MLX5_BY_PASS_NUM_REGULAR_PRIOS - 1) |
038d2ef8 MG |
139 | #if (MLX5_IB_FLOW_LAST_PRIO <= 0) |
140 | #error "Invalid number of bypass priorities" | |
141 | #endif | |
142 | #define MLX5_IB_FLOW_LEFTOVERS_PRIO (MLX5_IB_FLOW_MCAST_PRIO + 1) | |
143 | ||
144 | #define MLX5_IB_NUM_FLOW_FT (MLX5_IB_FLOW_LEFTOVERS_PRIO + 1) | |
cc0e5d42 | 145 | #define MLX5_IB_NUM_SNIFFER_FTS 2 |
038d2ef8 MG |
146 | struct mlx5_ib_flow_prio { |
147 | struct mlx5_flow_table *flow_table; | |
148 | unsigned int refcount; | |
149 | }; | |
150 | ||
151 | struct mlx5_ib_flow_handler { | |
152 | struct list_head list; | |
153 | struct ib_flow ibflow; | |
5497adc6 | 154 | struct mlx5_ib_flow_prio *prio; |
038d2ef8 MG |
155 | struct mlx5_flow_rule *rule; |
156 | }; | |
157 | ||
158 | struct mlx5_ib_flow_db { | |
159 | struct mlx5_ib_flow_prio prios[MLX5_IB_NUM_FLOW_FT]; | |
cc0e5d42 | 160 | struct mlx5_ib_flow_prio sniffer[MLX5_IB_NUM_SNIFFER_FTS]; |
9ef9c640 | 161 | struct mlx5_flow_table *lag_demux_ft; |
038d2ef8 MG |
162 | /* Protect flow steering bypass flow tables |
163 | * when add/del flow rules. | |
164 | * only single add/removal of flow steering rule could be done | |
165 | * simultaneously. | |
166 | */ | |
167 | struct mutex lock; | |
168 | }; | |
169 | ||
e126ba97 EC |
170 | /* Use macros here so that don't have to duplicate |
171 | * enum ib_send_flags and enum ib_qp_type for low-level driver | |
172 | */ | |
173 | ||
174 | #define MLX5_IB_SEND_UMR_UNREG IB_SEND_RESERVED_START | |
968e78dd HE |
175 | #define MLX5_IB_SEND_UMR_FAIL_IF_FREE (IB_SEND_RESERVED_START << 1) |
176 | #define MLX5_IB_SEND_UMR_UPDATE_MTT (IB_SEND_RESERVED_START << 2) | |
56e11d62 NO |
177 | |
178 | #define MLX5_IB_SEND_UMR_UPDATE_TRANSLATION (IB_SEND_RESERVED_START << 3) | |
179 | #define MLX5_IB_SEND_UMR_UPDATE_PD (IB_SEND_RESERVED_START << 4) | |
180 | #define MLX5_IB_SEND_UMR_UPDATE_ACCESS IB_SEND_RESERVED_END | |
181 | ||
e126ba97 | 182 | #define MLX5_IB_QPT_REG_UMR IB_QPT_RESERVED1 |
d16e91da HE |
183 | /* |
184 | * IB_QPT_GSI creates the software wrapper around GSI, and MLX5_IB_QPT_HW_GSI | |
185 | * creates the actual hardware QP. | |
186 | */ | |
187 | #define MLX5_IB_QPT_HW_GSI IB_QPT_RESERVED2 | |
e126ba97 EC |
188 | #define MLX5_IB_WR_UMR IB_WR_RESERVED1 |
189 | ||
b11a4f9c HE |
190 | /* Private QP creation flags to be passed in ib_qp_init_attr.create_flags. |
191 | * | |
192 | * These flags are intended for internal use by the mlx5_ib driver, and they | |
193 | * rely on the range reserved for that use in the ib_qp_create_flags enum. | |
194 | */ | |
195 | ||
196 | /* Create a UD QP whose source QP number is 1 */ | |
197 | static inline enum ib_qp_create_flags mlx5_ib_create_qp_sqpn_qp1(void) | |
198 | { | |
199 | return IB_QP_CREATE_RESERVED_START; | |
200 | } | |
201 | ||
e126ba97 EC |
202 | struct wr_list { |
203 | u16 opcode; | |
204 | u16 next; | |
205 | }; | |
206 | ||
207 | struct mlx5_ib_wq { | |
208 | u64 *wrid; | |
209 | u32 *wr_data; | |
210 | struct wr_list *w_list; | |
211 | unsigned *wqe_head; | |
212 | u16 unsig_count; | |
213 | ||
214 | /* serialize post to the work queue | |
215 | */ | |
216 | spinlock_t lock; | |
217 | int wqe_cnt; | |
218 | int max_post; | |
219 | int max_gs; | |
220 | int offset; | |
221 | int wqe_shift; | |
222 | unsigned head; | |
223 | unsigned tail; | |
224 | u16 cur_post; | |
225 | u16 last_poll; | |
226 | void *qend; | |
227 | }; | |
228 | ||
79b20a6c YH |
229 | struct mlx5_ib_rwq { |
230 | struct ib_wq ibwq; | |
350d0e4c | 231 | struct mlx5_core_qp core_qp; |
79b20a6c YH |
232 | u32 rq_num_pas; |
233 | u32 log_rq_stride; | |
234 | u32 log_rq_size; | |
235 | u32 rq_page_offset; | |
236 | u32 log_page_size; | |
237 | struct ib_umem *umem; | |
238 | size_t buf_size; | |
239 | unsigned int page_shift; | |
240 | int create_type; | |
241 | struct mlx5_db db; | |
242 | u32 user_index; | |
243 | u32 wqe_count; | |
244 | u32 wqe_shift; | |
245 | int wq_sig; | |
246 | }; | |
247 | ||
e126ba97 EC |
248 | enum { |
249 | MLX5_QP_USER, | |
250 | MLX5_QP_KERNEL, | |
251 | MLX5_QP_EMPTY | |
252 | }; | |
253 | ||
79b20a6c YH |
254 | enum { |
255 | MLX5_WQ_USER, | |
256 | MLX5_WQ_KERNEL | |
257 | }; | |
258 | ||
c5f90929 YH |
259 | struct mlx5_ib_rwq_ind_table { |
260 | struct ib_rwq_ind_table ib_rwq_ind_tbl; | |
261 | u32 rqtn; | |
262 | }; | |
263 | ||
6aec21f6 HE |
264 | /* |
265 | * Connect-IB can trigger up to four concurrent pagefaults | |
266 | * per-QP. | |
267 | */ | |
268 | enum mlx5_ib_pagefault_context { | |
269 | MLX5_IB_PAGEFAULT_RESPONDER_READ, | |
270 | MLX5_IB_PAGEFAULT_REQUESTOR_READ, | |
271 | MLX5_IB_PAGEFAULT_RESPONDER_WRITE, | |
272 | MLX5_IB_PAGEFAULT_REQUESTOR_WRITE, | |
273 | MLX5_IB_PAGEFAULT_CONTEXTS | |
274 | }; | |
275 | ||
276 | static inline enum mlx5_ib_pagefault_context | |
277 | mlx5_ib_get_pagefault_context(struct mlx5_pagefault *pagefault) | |
278 | { | |
279 | return pagefault->flags & (MLX5_PFAULT_REQUESTOR | MLX5_PFAULT_WRITE); | |
280 | } | |
281 | ||
282 | struct mlx5_ib_pfault { | |
283 | struct work_struct work; | |
284 | struct mlx5_pagefault mpfault; | |
285 | }; | |
286 | ||
19098df2 | 287 | struct mlx5_ib_ubuffer { |
288 | struct ib_umem *umem; | |
289 | int buf_size; | |
290 | u64 buf_addr; | |
291 | }; | |
292 | ||
293 | struct mlx5_ib_qp_base { | |
294 | struct mlx5_ib_qp *container_mibqp; | |
295 | struct mlx5_core_qp mqp; | |
296 | struct mlx5_ib_ubuffer ubuffer; | |
297 | }; | |
298 | ||
299 | struct mlx5_ib_qp_trans { | |
300 | struct mlx5_ib_qp_base base; | |
301 | u16 xrcdn; | |
302 | u8 alt_port; | |
303 | u8 atomic_rd_en; | |
304 | u8 resp_depth; | |
305 | }; | |
306 | ||
28d61370 YH |
307 | struct mlx5_ib_rss_qp { |
308 | u32 tirn; | |
309 | }; | |
310 | ||
038d2ef8 | 311 | struct mlx5_ib_rq { |
0fb2ed66 | 312 | struct mlx5_ib_qp_base base; |
313 | struct mlx5_ib_wq *rq; | |
314 | struct mlx5_ib_ubuffer ubuffer; | |
315 | struct mlx5_db *doorbell; | |
038d2ef8 | 316 | u32 tirn; |
0fb2ed66 | 317 | u8 state; |
318 | }; | |
319 | ||
320 | struct mlx5_ib_sq { | |
321 | struct mlx5_ib_qp_base base; | |
322 | struct mlx5_ib_wq *sq; | |
323 | struct mlx5_ib_ubuffer ubuffer; | |
324 | struct mlx5_db *doorbell; | |
325 | u32 tisn; | |
326 | u8 state; | |
038d2ef8 MG |
327 | }; |
328 | ||
329 | struct mlx5_ib_raw_packet_qp { | |
0fb2ed66 | 330 | struct mlx5_ib_sq sq; |
038d2ef8 MG |
331 | struct mlx5_ib_rq rq; |
332 | }; | |
333 | ||
e126ba97 EC |
334 | struct mlx5_ib_qp { |
335 | struct ib_qp ibqp; | |
038d2ef8 | 336 | union { |
0fb2ed66 | 337 | struct mlx5_ib_qp_trans trans_qp; |
338 | struct mlx5_ib_raw_packet_qp raw_packet_qp; | |
28d61370 | 339 | struct mlx5_ib_rss_qp rss_qp; |
038d2ef8 | 340 | }; |
e126ba97 EC |
341 | struct mlx5_buf buf; |
342 | ||
343 | struct mlx5_db db; | |
344 | struct mlx5_ib_wq rq; | |
345 | ||
e126ba97 EC |
346 | u8 sq_signal_bits; |
347 | u8 fm_cache; | |
e126ba97 EC |
348 | struct mlx5_ib_wq sq; |
349 | ||
e126ba97 EC |
350 | /* serialize qp state modifications |
351 | */ | |
352 | struct mutex mutex; | |
e126ba97 EC |
353 | u32 flags; |
354 | u8 port; | |
e126ba97 | 355 | u8 state; |
e126ba97 EC |
356 | int wq_sig; |
357 | int scat_cqe; | |
358 | int max_inline_data; | |
359 | struct mlx5_bf *bf; | |
360 | int has_rq; | |
361 | ||
362 | /* only for user space QPs. For kernel | |
363 | * we have it from the bf object | |
364 | */ | |
365 | int uuarn; | |
366 | ||
367 | int create_type; | |
e1e66cc2 SG |
368 | |
369 | /* Store signature errors */ | |
370 | bool signature_en; | |
6aec21f6 HE |
371 | |
372 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | |
373 | /* | |
374 | * A flag that is true for QP's that are in a state that doesn't | |
375 | * allow page faults, and shouldn't schedule any more faults. | |
376 | */ | |
377 | int disable_page_faults; | |
378 | /* | |
379 | * The disable_page_faults_lock protects a QP's disable_page_faults | |
380 | * field, allowing for a thread to atomically check whether the QP | |
381 | * allows page faults, and if so schedule a page fault. | |
382 | */ | |
383 | spinlock_t disable_page_faults_lock; | |
384 | struct mlx5_ib_pfault pagefaults[MLX5_IB_PAGEFAULT_CONTEXTS]; | |
385 | #endif | |
89ea94a7 MG |
386 | struct list_head qps_list; |
387 | struct list_head cq_recv_list; | |
388 | struct list_head cq_send_list; | |
e126ba97 EC |
389 | }; |
390 | ||
391 | struct mlx5_ib_cq_buf { | |
392 | struct mlx5_buf buf; | |
393 | struct ib_umem *umem; | |
394 | int cqe_size; | |
bde51583 | 395 | int nent; |
e126ba97 EC |
396 | }; |
397 | ||
398 | enum mlx5_ib_qp_flags { | |
f0313965 ES |
399 | MLX5_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, |
400 | MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, | |
401 | MLX5_IB_QP_CROSS_CHANNEL = IB_QP_CREATE_CROSS_CHANNEL, | |
402 | MLX5_IB_QP_MANAGED_SEND = IB_QP_CREATE_MANAGED_SEND, | |
403 | MLX5_IB_QP_MANAGED_RECV = IB_QP_CREATE_MANAGED_RECV, | |
404 | MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 5, | |
b11a4f9c HE |
405 | /* QP uses 1 as its source QP number */ |
406 | MLX5_IB_QP_SQPN_QP1 = 1 << 6, | |
358e42ea | 407 | MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7, |
e126ba97 EC |
408 | }; |
409 | ||
968e78dd | 410 | struct mlx5_umr_wr { |
e622f2f4 | 411 | struct ib_send_wr wr; |
968e78dd HE |
412 | union { |
413 | u64 virt_addr; | |
414 | u64 offset; | |
415 | } target; | |
416 | struct ib_pd *pd; | |
417 | unsigned int page_shift; | |
418 | unsigned int npages; | |
419 | u32 length; | |
420 | int access_flags; | |
421 | u32 mkey; | |
422 | }; | |
423 | ||
e622f2f4 CH |
424 | static inline struct mlx5_umr_wr *umr_wr(struct ib_send_wr *wr) |
425 | { | |
426 | return container_of(wr, struct mlx5_umr_wr, wr); | |
427 | } | |
428 | ||
e126ba97 EC |
429 | struct mlx5_shared_mr_info { |
430 | int mr_id; | |
431 | struct ib_umem *umem; | |
432 | }; | |
433 | ||
434 | struct mlx5_ib_cq { | |
435 | struct ib_cq ibcq; | |
436 | struct mlx5_core_cq mcq; | |
437 | struct mlx5_ib_cq_buf buf; | |
438 | struct mlx5_db db; | |
439 | ||
440 | /* serialize access to the CQ | |
441 | */ | |
442 | spinlock_t lock; | |
443 | ||
444 | /* protect resize cq | |
445 | */ | |
446 | struct mutex resize_mutex; | |
bde51583 | 447 | struct mlx5_ib_cq_buf *resize_buf; |
e126ba97 EC |
448 | struct ib_umem *resize_umem; |
449 | int cqe_size; | |
89ea94a7 MG |
450 | struct list_head list_send_qp; |
451 | struct list_head list_recv_qp; | |
051f2630 | 452 | u32 create_flags; |
25361e02 HE |
453 | struct list_head wc_list; |
454 | enum ib_cq_notify_flags notify_flags; | |
455 | struct work_struct notify_work; | |
456 | }; | |
457 | ||
458 | struct mlx5_ib_wc { | |
459 | struct ib_wc wc; | |
460 | struct list_head list; | |
e126ba97 EC |
461 | }; |
462 | ||
463 | struct mlx5_ib_srq { | |
464 | struct ib_srq ibsrq; | |
465 | struct mlx5_core_srq msrq; | |
466 | struct mlx5_buf buf; | |
467 | struct mlx5_db db; | |
468 | u64 *wrid; | |
469 | /* protect SRQ hanlding | |
470 | */ | |
471 | spinlock_t lock; | |
472 | int head; | |
473 | int tail; | |
474 | u16 wqe_ctr; | |
475 | struct ib_umem *umem; | |
476 | /* serialize arming a SRQ | |
477 | */ | |
478 | struct mutex mutex; | |
479 | int wq_sig; | |
480 | }; | |
481 | ||
482 | struct mlx5_ib_xrcd { | |
483 | struct ib_xrcd ibxrcd; | |
484 | u32 xrcdn; | |
485 | }; | |
486 | ||
cc149f75 HE |
487 | enum mlx5_ib_mtt_access_flags { |
488 | MLX5_IB_MTT_READ = (1 << 0), | |
489 | MLX5_IB_MTT_WRITE = (1 << 1), | |
490 | }; | |
491 | ||
492 | #define MLX5_IB_MTT_PRESENT (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE) | |
493 | ||
e126ba97 EC |
494 | struct mlx5_ib_mr { |
495 | struct ib_mr ibmr; | |
8a187ee5 SG |
496 | void *descs; |
497 | dma_addr_t desc_map; | |
498 | int ndescs; | |
499 | int max_descs; | |
500 | int desc_size; | |
b005d316 | 501 | int access_mode; |
a606b0f6 | 502 | struct mlx5_core_mkey mmkey; |
e126ba97 EC |
503 | struct ib_umem *umem; |
504 | struct mlx5_shared_mr_info *smr_info; | |
505 | struct list_head list; | |
506 | int order; | |
507 | int umred; | |
e126ba97 | 508 | int npages; |
746b5583 | 509 | struct mlx5_ib_dev *dev; |
ec22eb53 | 510 | u32 out[MLX5_ST_SZ_DW(create_mkey_out)]; |
3121e3c4 | 511 | struct mlx5_core_sig_ctx *sig; |
b4cfe447 | 512 | int live; |
8a187ee5 | 513 | void *descs_alloc; |
56e11d62 | 514 | int access_flags; /* Needed for rereg MR */ |
e126ba97 EC |
515 | }; |
516 | ||
d2370e0a MB |
517 | struct mlx5_ib_mw { |
518 | struct ib_mw ibmw; | |
519 | struct mlx5_core_mkey mmkey; | |
e126ba97 EC |
520 | }; |
521 | ||
a74d2416 | 522 | struct mlx5_ib_umr_context { |
add08d76 | 523 | struct ib_cqe cqe; |
a74d2416 SR |
524 | enum ib_wc_status status; |
525 | struct completion done; | |
526 | }; | |
527 | ||
e126ba97 EC |
528 | struct umr_common { |
529 | struct ib_pd *pd; | |
530 | struct ib_cq *cq; | |
531 | struct ib_qp *qp; | |
e126ba97 EC |
532 | /* control access to UMR QP |
533 | */ | |
534 | struct semaphore sem; | |
535 | }; | |
536 | ||
537 | enum { | |
538 | MLX5_FMR_INVALID, | |
539 | MLX5_FMR_VALID, | |
540 | MLX5_FMR_BUSY, | |
541 | }; | |
542 | ||
e126ba97 EC |
543 | struct mlx5_cache_ent { |
544 | struct list_head head; | |
545 | /* sync access to the cahce entry | |
546 | */ | |
547 | spinlock_t lock; | |
548 | ||
549 | ||
550 | struct dentry *dir; | |
551 | char name[4]; | |
552 | u32 order; | |
553 | u32 size; | |
554 | u32 cur; | |
555 | u32 miss; | |
556 | u32 limit; | |
557 | ||
558 | struct dentry *fsize; | |
559 | struct dentry *fcur; | |
560 | struct dentry *fmiss; | |
561 | struct dentry *flimit; | |
562 | ||
563 | struct mlx5_ib_dev *dev; | |
564 | struct work_struct work; | |
565 | struct delayed_work dwork; | |
746b5583 | 566 | int pending; |
e126ba97 EC |
567 | }; |
568 | ||
569 | struct mlx5_mr_cache { | |
570 | struct workqueue_struct *wq; | |
571 | struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES]; | |
572 | int stopped; | |
573 | struct dentry *root; | |
574 | unsigned long last_add; | |
575 | }; | |
576 | ||
d16e91da HE |
577 | struct mlx5_ib_gsi_qp; |
578 | ||
579 | struct mlx5_ib_port_resources { | |
7722f47e | 580 | struct mlx5_ib_resources *devr; |
d16e91da | 581 | struct mlx5_ib_gsi_qp *gsi; |
7722f47e | 582 | struct work_struct pkey_change_work; |
d16e91da HE |
583 | }; |
584 | ||
e126ba97 EC |
585 | struct mlx5_ib_resources { |
586 | struct ib_cq *c0; | |
587 | struct ib_xrcd *x0; | |
588 | struct ib_xrcd *x1; | |
589 | struct ib_pd *p0; | |
590 | struct ib_srq *s0; | |
4aa17b28 | 591 | struct ib_srq *s1; |
d16e91da HE |
592 | struct mlx5_ib_port_resources ports[2]; |
593 | /* Protects changes to the port resources */ | |
594 | struct mutex mutex; | |
e126ba97 EC |
595 | }; |
596 | ||
0837e86a MB |
597 | struct mlx5_ib_port { |
598 | u16 q_cnt_id; | |
599 | }; | |
600 | ||
fc24fc5e AS |
601 | struct mlx5_roce { |
602 | /* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL | |
603 | * netdev pointer | |
604 | */ | |
605 | rwlock_t netdev_lock; | |
606 | struct net_device *netdev; | |
607 | struct notifier_block nb; | |
13eab21f | 608 | atomic_t next_port; |
fc24fc5e AS |
609 | }; |
610 | ||
e126ba97 EC |
611 | struct mlx5_ib_dev { |
612 | struct ib_device ib_dev; | |
9603b61d | 613 | struct mlx5_core_dev *mdev; |
fc24fc5e | 614 | struct mlx5_roce roce; |
e126ba97 | 615 | MLX5_DECLARE_DOORBELL_LOCK(uar_lock); |
e126ba97 | 616 | int num_ports; |
e126ba97 EC |
617 | /* serialize update of capability mask |
618 | */ | |
619 | struct mutex cap_mask_mutex; | |
620 | bool ib_active; | |
621 | struct umr_common umrc; | |
622 | /* sync used page count stats | |
623 | */ | |
e126ba97 EC |
624 | struct mlx5_ib_resources devr; |
625 | struct mlx5_mr_cache cache; | |
746b5583 EC |
626 | struct timer_list delay_timer; |
627 | int fill_delay; | |
8cdd312c HE |
628 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING |
629 | struct ib_odp_caps odp_caps; | |
6aec21f6 HE |
630 | /* |
631 | * Sleepable RCU that prevents destruction of MRs while they are still | |
632 | * being used by a page fault handler. | |
633 | */ | |
634 | struct srcu_struct mr_srcu; | |
8cdd312c | 635 | #endif |
038d2ef8 | 636 | struct mlx5_ib_flow_db flow_db; |
89ea94a7 MG |
637 | /* protect resources needed as part of reset flow */ |
638 | spinlock_t reset_flow_resource_lock; | |
639 | struct list_head qp_list; | |
0837e86a MB |
640 | /* Array with num_ports elements */ |
641 | struct mlx5_ib_port *port; | |
e126ba97 EC |
642 | }; |
643 | ||
644 | static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq) | |
645 | { | |
646 | return container_of(mcq, struct mlx5_ib_cq, mcq); | |
647 | } | |
648 | ||
649 | static inline struct mlx5_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd) | |
650 | { | |
651 | return container_of(ibxrcd, struct mlx5_ib_xrcd, ibxrcd); | |
652 | } | |
653 | ||
654 | static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev) | |
655 | { | |
656 | return container_of(ibdev, struct mlx5_ib_dev, ib_dev); | |
657 | } | |
658 | ||
e126ba97 EC |
659 | static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq) |
660 | { | |
661 | return container_of(ibcq, struct mlx5_ib_cq, ibcq); | |
662 | } | |
663 | ||
664 | static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp) | |
665 | { | |
19098df2 | 666 | return container_of(mqp, struct mlx5_ib_qp_base, mqp)->container_mibqp; |
e126ba97 EC |
667 | } |
668 | ||
350d0e4c YH |
669 | static inline struct mlx5_ib_rwq *to_mibrwq(struct mlx5_core_qp *core_qp) |
670 | { | |
671 | return container_of(core_qp, struct mlx5_ib_rwq, core_qp); | |
672 | } | |
673 | ||
a606b0f6 | 674 | static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mkey *mmkey) |
d5436ba0 | 675 | { |
a606b0f6 | 676 | return container_of(mmkey, struct mlx5_ib_mr, mmkey); |
d5436ba0 SG |
677 | } |
678 | ||
e126ba97 EC |
679 | static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd) |
680 | { | |
681 | return container_of(ibpd, struct mlx5_ib_pd, ibpd); | |
682 | } | |
683 | ||
684 | static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq) | |
685 | { | |
686 | return container_of(ibsrq, struct mlx5_ib_srq, ibsrq); | |
687 | } | |
688 | ||
689 | static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp) | |
690 | { | |
691 | return container_of(ibqp, struct mlx5_ib_qp, ibqp); | |
692 | } | |
693 | ||
79b20a6c YH |
694 | static inline struct mlx5_ib_rwq *to_mrwq(struct ib_wq *ibwq) |
695 | { | |
696 | return container_of(ibwq, struct mlx5_ib_rwq, ibwq); | |
697 | } | |
698 | ||
c5f90929 YH |
699 | static inline struct mlx5_ib_rwq_ind_table *to_mrwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl) |
700 | { | |
701 | return container_of(ib_rwq_ind_tbl, struct mlx5_ib_rwq_ind_table, ib_rwq_ind_tbl); | |
702 | } | |
703 | ||
e126ba97 EC |
704 | static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq) |
705 | { | |
706 | return container_of(msrq, struct mlx5_ib_srq, msrq); | |
707 | } | |
708 | ||
709 | static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr) | |
710 | { | |
711 | return container_of(ibmr, struct mlx5_ib_mr, ibmr); | |
712 | } | |
713 | ||
d2370e0a MB |
714 | static inline struct mlx5_ib_mw *to_mmw(struct ib_mw *ibmw) |
715 | { | |
716 | return container_of(ibmw, struct mlx5_ib_mw, ibmw); | |
717 | } | |
718 | ||
e126ba97 EC |
719 | struct mlx5_ib_ah { |
720 | struct ib_ah ibah; | |
721 | struct mlx5_av av; | |
722 | }; | |
723 | ||
724 | static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah) | |
725 | { | |
726 | return container_of(ibah, struct mlx5_ib_ah, ibah); | |
727 | } | |
728 | ||
e126ba97 EC |
729 | int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt, |
730 | struct mlx5_db *db); | |
731 | void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db); | |
732 | void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); | |
733 | void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq); | |
734 | void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index); | |
735 | int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey, | |
a97e2d86 IW |
736 | u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh, |
737 | const void *in_mad, void *response_mad); | |
e126ba97 EC |
738 | struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); |
739 | int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr); | |
740 | int mlx5_ib_destroy_ah(struct ib_ah *ah); | |
741 | struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, | |
742 | struct ib_srq_init_attr *init_attr, | |
743 | struct ib_udata *udata); | |
744 | int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, | |
745 | enum ib_srq_attr_mask attr_mask, struct ib_udata *udata); | |
746 | int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr); | |
747 | int mlx5_ib_destroy_srq(struct ib_srq *srq); | |
748 | int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr, | |
749 | struct ib_recv_wr **bad_wr); | |
750 | struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd, | |
751 | struct ib_qp_init_attr *init_attr, | |
752 | struct ib_udata *udata); | |
753 | int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, | |
754 | int attr_mask, struct ib_udata *udata); | |
755 | int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, | |
756 | struct ib_qp_init_attr *qp_init_attr); | |
757 | int mlx5_ib_destroy_qp(struct ib_qp *qp); | |
758 | int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |
759 | struct ib_send_wr **bad_wr); | |
760 | int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, | |
761 | struct ib_recv_wr **bad_wr); | |
762 | void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n); | |
c1395a2a | 763 | int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index, |
19098df2 | 764 | void *buffer, u32 length, |
765 | struct mlx5_ib_qp_base *base); | |
bcf4c1ea MB |
766 | struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, |
767 | const struct ib_cq_init_attr *attr, | |
768 | struct ib_ucontext *context, | |
e126ba97 EC |
769 | struct ib_udata *udata); |
770 | int mlx5_ib_destroy_cq(struct ib_cq *cq); | |
771 | int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc); | |
772 | int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags); | |
773 | int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); | |
774 | int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata); | |
775 | struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc); | |
776 | struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, | |
777 | u64 virt_addr, int access_flags, | |
778 | struct ib_udata *udata); | |
d2370e0a MB |
779 | struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type, |
780 | struct ib_udata *udata); | |
781 | int mlx5_ib_dealloc_mw(struct ib_mw *mw); | |
832a6b06 HE |
782 | int mlx5_ib_update_mtt(struct mlx5_ib_mr *mr, u64 start_page_index, |
783 | int npages, int zap); | |
56e11d62 NO |
784 | int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, |
785 | u64 length, u64 virt_addr, int access_flags, | |
786 | struct ib_pd *pd, struct ib_udata *udata); | |
e126ba97 | 787 | int mlx5_ib_dereg_mr(struct ib_mr *ibmr); |
9bee178b SG |
788 | struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, |
789 | enum ib_mr_type mr_type, | |
790 | u32 max_num_sg); | |
ff2ba993 | 791 | int mlx5_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, |
9aa8b321 | 792 | unsigned int *sg_offset); |
e126ba97 | 793 | int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, |
a97e2d86 | 794 | const struct ib_wc *in_wc, const struct ib_grh *in_grh, |
4cd7c947 IW |
795 | const struct ib_mad_hdr *in, size_t in_mad_size, |
796 | struct ib_mad_hdr *out, size_t *out_mad_size, | |
797 | u16 *out_mad_pkey_index); | |
e126ba97 EC |
798 | struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev, |
799 | struct ib_ucontext *context, | |
800 | struct ib_udata *udata); | |
801 | int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd); | |
e126ba97 EC |
802 | int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset); |
803 | int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port); | |
1b5daf11 MD |
804 | int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev, |
805 | struct ib_smp *out_mad); | |
806 | int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev, | |
807 | __be64 *sys_image_guid); | |
808 | int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev, | |
809 | u16 *max_pkeys); | |
810 | int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev, | |
811 | u32 *vendor_id); | |
812 | int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc); | |
813 | int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid); | |
814 | int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u8 port, u16 index, | |
815 | u16 *pkey); | |
816 | int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u8 port, int index, | |
817 | union ib_gid *gid); | |
818 | int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port, | |
819 | struct ib_port_attr *props); | |
e126ba97 EC |
820 | int mlx5_ib_query_port(struct ib_device *ibdev, u8 port, |
821 | struct ib_port_attr *props); | |
822 | int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev); | |
823 | void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev); | |
824 | void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift, | |
825 | int *ncont, int *order); | |
832a6b06 HE |
826 | void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem, |
827 | int page_shift, size_t offset, size_t num_pages, | |
828 | __be64 *pas, int access_flags); | |
e126ba97 | 829 | void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem, |
cc149f75 | 830 | int page_shift, __be64 *pas, int access_flags); |
e126ba97 EC |
831 | void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num); |
832 | int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq); | |
833 | int mlx5_mr_cache_init(struct mlx5_ib_dev *dev); | |
834 | int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev); | |
835 | int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift); | |
d5436ba0 SG |
836 | int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask, |
837 | struct ib_mr_status *mr_status); | |
79b20a6c YH |
838 | struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd, |
839 | struct ib_wq_init_attr *init_attr, | |
840 | struct ib_udata *udata); | |
841 | int mlx5_ib_destroy_wq(struct ib_wq *wq); | |
842 | int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr, | |
843 | u32 wq_attr_mask, struct ib_udata *udata); | |
c5f90929 YH |
844 | struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device, |
845 | struct ib_rwq_ind_table_init_attr *init_attr, | |
846 | struct ib_udata *udata); | |
847 | int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table); | |
e126ba97 | 848 | |
8cdd312c | 849 | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING |
6aec21f6 HE |
850 | extern struct workqueue_struct *mlx5_ib_page_fault_wq; |
851 | ||
938fe83c | 852 | void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev); |
6aec21f6 HE |
853 | void mlx5_ib_mr_pfault_handler(struct mlx5_ib_qp *qp, |
854 | struct mlx5_ib_pfault *pfault); | |
855 | void mlx5_ib_odp_create_qp(struct mlx5_ib_qp *qp); | |
856 | int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev); | |
857 | void mlx5_ib_odp_remove_one(struct mlx5_ib_dev *ibdev); | |
858 | int __init mlx5_ib_odp_init(void); | |
859 | void mlx5_ib_odp_cleanup(void); | |
860 | void mlx5_ib_qp_disable_pagefaults(struct mlx5_ib_qp *qp); | |
861 | void mlx5_ib_qp_enable_pagefaults(struct mlx5_ib_qp *qp); | |
b4cfe447 HE |
862 | void mlx5_ib_invalidate_range(struct ib_umem *umem, unsigned long start, |
863 | unsigned long end); | |
6aec21f6 | 864 | #else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ |
938fe83c | 865 | static inline void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev) |
8cdd312c | 866 | { |
938fe83c | 867 | return; |
8cdd312c | 868 | } |
6aec21f6 HE |
869 | |
870 | static inline void mlx5_ib_odp_create_qp(struct mlx5_ib_qp *qp) {} | |
871 | static inline int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev) { return 0; } | |
872 | static inline void mlx5_ib_odp_remove_one(struct mlx5_ib_dev *ibdev) {} | |
873 | static inline int mlx5_ib_odp_init(void) { return 0; } | |
874 | static inline void mlx5_ib_odp_cleanup(void) {} | |
875 | static inline void mlx5_ib_qp_disable_pagefaults(struct mlx5_ib_qp *qp) {} | |
876 | static inline void mlx5_ib_qp_enable_pagefaults(struct mlx5_ib_qp *qp) {} | |
877 | ||
8cdd312c HE |
878 | #endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */ |
879 | ||
9967c70a AB |
880 | int mlx5_ib_get_vf_config(struct ib_device *device, int vf, |
881 | u8 port, struct ifla_vf_info *info); | |
882 | int mlx5_ib_set_vf_link_state(struct ib_device *device, int vf, | |
883 | u8 port, int state); | |
884 | int mlx5_ib_get_vf_stats(struct ib_device *device, int vf, | |
885 | u8 port, struct ifla_vf_stats *stats); | |
886 | int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port, | |
887 | u64 guid, int type); | |
888 | ||
2811ba51 AS |
889 | __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, |
890 | int index); | |
891 | ||
d16e91da HE |
892 | /* GSI QP helper functions */ |
893 | struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd, | |
894 | struct ib_qp_init_attr *init_attr); | |
895 | int mlx5_ib_gsi_destroy_qp(struct ib_qp *qp); | |
896 | int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr, | |
897 | int attr_mask); | |
898 | int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr, | |
899 | int qp_attr_mask, | |
900 | struct ib_qp_init_attr *qp_init_attr); | |
901 | int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr, | |
902 | struct ib_send_wr **bad_wr); | |
903 | int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr, | |
904 | struct ib_recv_wr **bad_wr); | |
7722f47e | 905 | void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi); |
d16e91da | 906 | |
25361e02 HE |
907 | int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc); |
908 | ||
e126ba97 EC |
909 | static inline void init_query_mad(struct ib_smp *mad) |
910 | { | |
911 | mad->base_version = 1; | |
912 | mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; | |
913 | mad->class_version = 1; | |
914 | mad->method = IB_MGMT_METHOD_GET; | |
915 | } | |
916 | ||
917 | static inline u8 convert_access(int acc) | |
918 | { | |
919 | return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) | | |
920 | (acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) | | |
921 | (acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) | | |
922 | (acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) | | |
923 | MLX5_PERM_LOCAL_READ; | |
924 | } | |
925 | ||
b636401f SG |
926 | static inline int is_qp1(enum ib_qp_type qp_type) |
927 | { | |
d16e91da | 928 | return qp_type == MLX5_IB_QPT_HW_GSI; |
b636401f SG |
929 | } |
930 | ||
cc149f75 HE |
931 | #define MLX5_MAX_UMR_SHIFT 16 |
932 | #define MLX5_MAX_UMR_PAGES (1 << MLX5_MAX_UMR_SHIFT) | |
933 | ||
051f2630 LR |
934 | static inline u32 check_cq_create_flags(u32 flags) |
935 | { | |
936 | /* | |
937 | * It returns non-zero value for unsupported CQ | |
938 | * create flags, otherwise it returns zero. | |
939 | */ | |
34356f64 LR |
940 | return (flags & ~(IB_CQ_FLAGS_IGNORE_OVERRUN | |
941 | IB_CQ_FLAGS_TIMESTAMP_COMPLETION)); | |
051f2630 | 942 | } |
cfb5e088 HA |
943 | |
944 | static inline int verify_assign_uidx(u8 cqe_version, u32 cmd_uidx, | |
945 | u32 *user_index) | |
946 | { | |
947 | if (cqe_version) { | |
948 | if ((cmd_uidx == MLX5_IB_DEFAULT_UIDX) || | |
949 | (cmd_uidx & ~MLX5_USER_ASSIGNED_UIDX_MASK)) | |
950 | return -EINVAL; | |
951 | *user_index = cmd_uidx; | |
952 | } else { | |
953 | *user_index = MLX5_IB_DEFAULT_UIDX; | |
954 | } | |
955 | ||
956 | return 0; | |
957 | } | |
e126ba97 | 958 | #endif /* MLX5_IB_H */ |