]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. | |
3 | * Copyright (c) 2004 Infinicon Corporation. All rights reserved. | |
4 | * Copyright (c) 2004 Intel Corporation. All rights reserved. | |
5 | * Copyright (c) 2004 Topspin Corporation. All rights reserved. | |
6 | * Copyright (c) 2004 Voltaire Corporation. All rights reserved. | |
e2773c06 | 7 | * Copyright (c) 2005 Cisco Systems. All rights reserved. |
1da177e4 LT |
8 | * |
9 | * This software is available to you under a choice of one of two | |
10 | * licenses. You may choose to be licensed under the terms of the GNU | |
11 | * General Public License (GPL) Version 2, available from the file | |
12 | * COPYING in the main directory of this source tree, or the | |
13 | * OpenIB.org BSD license below: | |
14 | * | |
15 | * Redistribution and use in source and binary forms, with or | |
16 | * without modification, are permitted provided that the following | |
17 | * conditions are met: | |
18 | * | |
19 | * - Redistributions of source code must retain the above | |
20 | * copyright notice, this list of conditions and the following | |
21 | * disclaimer. | |
22 | * | |
23 | * - Redistributions in binary form must reproduce the above | |
24 | * copyright notice, this list of conditions and the following | |
25 | * disclaimer in the documentation and/or other materials | |
26 | * provided with the distribution. | |
27 | * | |
28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
29 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
31 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | |
32 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | |
33 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
34 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
35 | * SOFTWARE. | |
36 | * | |
37 | * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $ | |
38 | */ | |
39 | ||
40 | #if !defined(IB_VERBS_H) | |
41 | #define IB_VERBS_H | |
42 | ||
43 | #include <linux/types.h> | |
44 | #include <linux/device.h> | |
e2773c06 | 45 | |
1da177e4 | 46 | #include <asm/atomic.h> |
e2773c06 RD |
47 | #include <asm/scatterlist.h> |
48 | #include <asm/uaccess.h> | |
1da177e4 LT |
49 | |
50 | union ib_gid { | |
51 | u8 raw[16]; | |
52 | struct { | |
53 | u64 subnet_prefix; | |
54 | u64 interface_id; | |
55 | } global; | |
56 | }; | |
57 | ||
58 | enum ib_node_type { | |
59 | IB_NODE_CA = 1, | |
60 | IB_NODE_SWITCH, | |
61 | IB_NODE_ROUTER | |
62 | }; | |
63 | ||
64 | enum ib_device_cap_flags { | |
65 | IB_DEVICE_RESIZE_MAX_WR = 1, | |
66 | IB_DEVICE_BAD_PKEY_CNTR = (1<<1), | |
67 | IB_DEVICE_BAD_QKEY_CNTR = (1<<2), | |
68 | IB_DEVICE_RAW_MULTI = (1<<3), | |
69 | IB_DEVICE_AUTO_PATH_MIG = (1<<4), | |
70 | IB_DEVICE_CHANGE_PHY_PORT = (1<<5), | |
71 | IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6), | |
72 | IB_DEVICE_CURR_QP_STATE_MOD = (1<<7), | |
73 | IB_DEVICE_SHUTDOWN_PORT = (1<<8), | |
74 | IB_DEVICE_INIT_TYPE = (1<<9), | |
75 | IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10), | |
76 | IB_DEVICE_SYS_IMAGE_GUID = (1<<11), | |
77 | IB_DEVICE_RC_RNR_NAK_GEN = (1<<12), | |
78 | IB_DEVICE_SRQ_RESIZE = (1<<13), | |
79 | IB_DEVICE_N_NOTIFY_CQ = (1<<14), | |
80 | }; | |
81 | ||
82 | enum ib_atomic_cap { | |
83 | IB_ATOMIC_NONE, | |
84 | IB_ATOMIC_HCA, | |
85 | IB_ATOMIC_GLOB | |
86 | }; | |
87 | ||
88 | struct ib_device_attr { | |
89 | u64 fw_ver; | |
90 | u64 node_guid; | |
91 | u64 sys_image_guid; | |
92 | u64 max_mr_size; | |
93 | u64 page_size_cap; | |
94 | u32 vendor_id; | |
95 | u32 vendor_part_id; | |
96 | u32 hw_ver; | |
97 | int max_qp; | |
98 | int max_qp_wr; | |
99 | int device_cap_flags; | |
100 | int max_sge; | |
101 | int max_sge_rd; | |
102 | int max_cq; | |
103 | int max_cqe; | |
104 | int max_mr; | |
105 | int max_pd; | |
106 | int max_qp_rd_atom; | |
107 | int max_ee_rd_atom; | |
108 | int max_res_rd_atom; | |
109 | int max_qp_init_rd_atom; | |
110 | int max_ee_init_rd_atom; | |
111 | enum ib_atomic_cap atomic_cap; | |
112 | int max_ee; | |
113 | int max_rdd; | |
114 | int max_mw; | |
115 | int max_raw_ipv6_qp; | |
116 | int max_raw_ethy_qp; | |
117 | int max_mcast_grp; | |
118 | int max_mcast_qp_attach; | |
119 | int max_total_mcast_qp_attach; | |
120 | int max_ah; | |
121 | int max_fmr; | |
122 | int max_map_per_fmr; | |
123 | int max_srq; | |
124 | int max_srq_wr; | |
125 | int max_srq_sge; | |
126 | u16 max_pkeys; | |
127 | u8 local_ca_ack_delay; | |
128 | }; | |
129 | ||
130 | enum ib_mtu { | |
131 | IB_MTU_256 = 1, | |
132 | IB_MTU_512 = 2, | |
133 | IB_MTU_1024 = 3, | |
134 | IB_MTU_2048 = 4, | |
135 | IB_MTU_4096 = 5 | |
136 | }; | |
137 | ||
138 | static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) | |
139 | { | |
140 | switch (mtu) { | |
141 | case IB_MTU_256: return 256; | |
142 | case IB_MTU_512: return 512; | |
143 | case IB_MTU_1024: return 1024; | |
144 | case IB_MTU_2048: return 2048; | |
145 | case IB_MTU_4096: return 4096; | |
146 | default: return -1; | |
147 | } | |
148 | } | |
149 | ||
150 | enum ib_port_state { | |
151 | IB_PORT_NOP = 0, | |
152 | IB_PORT_DOWN = 1, | |
153 | IB_PORT_INIT = 2, | |
154 | IB_PORT_ARMED = 3, | |
155 | IB_PORT_ACTIVE = 4, | |
156 | IB_PORT_ACTIVE_DEFER = 5 | |
157 | }; | |
158 | ||
159 | enum ib_port_cap_flags { | |
160 | IB_PORT_SM = 1 << 1, | |
161 | IB_PORT_NOTICE_SUP = 1 << 2, | |
162 | IB_PORT_TRAP_SUP = 1 << 3, | |
163 | IB_PORT_OPT_IPD_SUP = 1 << 4, | |
164 | IB_PORT_AUTO_MIGR_SUP = 1 << 5, | |
165 | IB_PORT_SL_MAP_SUP = 1 << 6, | |
166 | IB_PORT_MKEY_NVRAM = 1 << 7, | |
167 | IB_PORT_PKEY_NVRAM = 1 << 8, | |
168 | IB_PORT_LED_INFO_SUP = 1 << 9, | |
169 | IB_PORT_SM_DISABLED = 1 << 10, | |
170 | IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, | |
171 | IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, | |
172 | IB_PORT_CM_SUP = 1 << 16, | |
173 | IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, | |
174 | IB_PORT_REINIT_SUP = 1 << 18, | |
175 | IB_PORT_DEVICE_MGMT_SUP = 1 << 19, | |
176 | IB_PORT_VENDOR_CLASS_SUP = 1 << 20, | |
177 | IB_PORT_DR_NOTICE_SUP = 1 << 21, | |
178 | IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, | |
179 | IB_PORT_BOOT_MGMT_SUP = 1 << 23, | |
180 | IB_PORT_LINK_LATENCY_SUP = 1 << 24, | |
181 | IB_PORT_CLIENT_REG_SUP = 1 << 25 | |
182 | }; | |
183 | ||
184 | enum ib_port_width { | |
185 | IB_WIDTH_1X = 1, | |
186 | IB_WIDTH_4X = 2, | |
187 | IB_WIDTH_8X = 4, | |
188 | IB_WIDTH_12X = 8 | |
189 | }; | |
190 | ||
191 | static inline int ib_width_enum_to_int(enum ib_port_width width) | |
192 | { | |
193 | switch (width) { | |
194 | case IB_WIDTH_1X: return 1; | |
195 | case IB_WIDTH_4X: return 4; | |
196 | case IB_WIDTH_8X: return 8; | |
197 | case IB_WIDTH_12X: return 12; | |
198 | default: return -1; | |
199 | } | |
200 | } | |
201 | ||
202 | struct ib_port_attr { | |
203 | enum ib_port_state state; | |
204 | enum ib_mtu max_mtu; | |
205 | enum ib_mtu active_mtu; | |
206 | int gid_tbl_len; | |
207 | u32 port_cap_flags; | |
208 | u32 max_msg_sz; | |
209 | u32 bad_pkey_cntr; | |
210 | u32 qkey_viol_cntr; | |
211 | u16 pkey_tbl_len; | |
212 | u16 lid; | |
213 | u16 sm_lid; | |
214 | u8 lmc; | |
215 | u8 max_vl_num; | |
216 | u8 sm_sl; | |
217 | u8 subnet_timeout; | |
218 | u8 init_type_reply; | |
219 | u8 active_width; | |
220 | u8 active_speed; | |
221 | u8 phys_state; | |
222 | }; | |
223 | ||
224 | enum ib_device_modify_flags { | |
225 | IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 | |
226 | }; | |
227 | ||
228 | struct ib_device_modify { | |
229 | u64 sys_image_guid; | |
230 | }; | |
231 | ||
232 | enum ib_port_modify_flags { | |
233 | IB_PORT_SHUTDOWN = 1, | |
234 | IB_PORT_INIT_TYPE = (1<<2), | |
235 | IB_PORT_RESET_QKEY_CNTR = (1<<3) | |
236 | }; | |
237 | ||
238 | struct ib_port_modify { | |
239 | u32 set_port_cap_mask; | |
240 | u32 clr_port_cap_mask; | |
241 | u8 init_type; | |
242 | }; | |
243 | ||
244 | enum ib_event_type { | |
245 | IB_EVENT_CQ_ERR, | |
246 | IB_EVENT_QP_FATAL, | |
247 | IB_EVENT_QP_REQ_ERR, | |
248 | IB_EVENT_QP_ACCESS_ERR, | |
249 | IB_EVENT_COMM_EST, | |
250 | IB_EVENT_SQ_DRAINED, | |
251 | IB_EVENT_PATH_MIG, | |
252 | IB_EVENT_PATH_MIG_ERR, | |
253 | IB_EVENT_DEVICE_FATAL, | |
254 | IB_EVENT_PORT_ACTIVE, | |
255 | IB_EVENT_PORT_ERR, | |
256 | IB_EVENT_LID_CHANGE, | |
257 | IB_EVENT_PKEY_CHANGE, | |
258 | IB_EVENT_SM_CHANGE | |
259 | }; | |
260 | ||
261 | struct ib_event { | |
262 | struct ib_device *device; | |
263 | union { | |
264 | struct ib_cq *cq; | |
265 | struct ib_qp *qp; | |
266 | u8 port_num; | |
267 | } element; | |
268 | enum ib_event_type event; | |
269 | }; | |
270 | ||
271 | struct ib_event_handler { | |
272 | struct ib_device *device; | |
273 | void (*handler)(struct ib_event_handler *, struct ib_event *); | |
274 | struct list_head list; | |
275 | }; | |
276 | ||
277 | #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \ | |
278 | do { \ | |
279 | (_ptr)->device = _device; \ | |
280 | (_ptr)->handler = _handler; \ | |
281 | INIT_LIST_HEAD(&(_ptr)->list); \ | |
282 | } while (0) | |
283 | ||
284 | struct ib_global_route { | |
285 | union ib_gid dgid; | |
286 | u32 flow_label; | |
287 | u8 sgid_index; | |
288 | u8 hop_limit; | |
289 | u8 traffic_class; | |
290 | }; | |
291 | ||
292 | enum { | |
293 | IB_MULTICAST_QPN = 0xffffff | |
294 | }; | |
295 | ||
296 | enum ib_ah_flags { | |
297 | IB_AH_GRH = 1 | |
298 | }; | |
299 | ||
300 | struct ib_ah_attr { | |
301 | struct ib_global_route grh; | |
302 | u16 dlid; | |
303 | u8 sl; | |
304 | u8 src_path_bits; | |
305 | u8 static_rate; | |
306 | u8 ah_flags; | |
307 | u8 port_num; | |
308 | }; | |
309 | ||
310 | enum ib_wc_status { | |
311 | IB_WC_SUCCESS, | |
312 | IB_WC_LOC_LEN_ERR, | |
313 | IB_WC_LOC_QP_OP_ERR, | |
314 | IB_WC_LOC_EEC_OP_ERR, | |
315 | IB_WC_LOC_PROT_ERR, | |
316 | IB_WC_WR_FLUSH_ERR, | |
317 | IB_WC_MW_BIND_ERR, | |
318 | IB_WC_BAD_RESP_ERR, | |
319 | IB_WC_LOC_ACCESS_ERR, | |
320 | IB_WC_REM_INV_REQ_ERR, | |
321 | IB_WC_REM_ACCESS_ERR, | |
322 | IB_WC_REM_OP_ERR, | |
323 | IB_WC_RETRY_EXC_ERR, | |
324 | IB_WC_RNR_RETRY_EXC_ERR, | |
325 | IB_WC_LOC_RDD_VIOL_ERR, | |
326 | IB_WC_REM_INV_RD_REQ_ERR, | |
327 | IB_WC_REM_ABORT_ERR, | |
328 | IB_WC_INV_EECN_ERR, | |
329 | IB_WC_INV_EEC_STATE_ERR, | |
330 | IB_WC_FATAL_ERR, | |
331 | IB_WC_RESP_TIMEOUT_ERR, | |
332 | IB_WC_GENERAL_ERR | |
333 | }; | |
334 | ||
335 | enum ib_wc_opcode { | |
336 | IB_WC_SEND, | |
337 | IB_WC_RDMA_WRITE, | |
338 | IB_WC_RDMA_READ, | |
339 | IB_WC_COMP_SWAP, | |
340 | IB_WC_FETCH_ADD, | |
341 | IB_WC_BIND_MW, | |
342 | /* | |
343 | * Set value of IB_WC_RECV so consumers can test if a completion is a | |
344 | * receive by testing (opcode & IB_WC_RECV). | |
345 | */ | |
346 | IB_WC_RECV = 1 << 7, | |
347 | IB_WC_RECV_RDMA_WITH_IMM | |
348 | }; | |
349 | ||
350 | enum ib_wc_flags { | |
351 | IB_WC_GRH = 1, | |
352 | IB_WC_WITH_IMM = (1<<1) | |
353 | }; | |
354 | ||
355 | struct ib_wc { | |
356 | u64 wr_id; | |
357 | enum ib_wc_status status; | |
358 | enum ib_wc_opcode opcode; | |
359 | u32 vendor_err; | |
360 | u32 byte_len; | |
361 | __be32 imm_data; | |
362 | u32 qp_num; | |
363 | u32 src_qp; | |
364 | int wc_flags; | |
365 | u16 pkey_index; | |
366 | u16 slid; | |
367 | u8 sl; | |
368 | u8 dlid_path_bits; | |
369 | u8 port_num; /* valid only for DR SMPs on switches */ | |
370 | }; | |
371 | ||
372 | enum ib_cq_notify { | |
373 | IB_CQ_SOLICITED, | |
374 | IB_CQ_NEXT_COMP | |
375 | }; | |
376 | ||
377 | struct ib_qp_cap { | |
378 | u32 max_send_wr; | |
379 | u32 max_recv_wr; | |
380 | u32 max_send_sge; | |
381 | u32 max_recv_sge; | |
382 | u32 max_inline_data; | |
383 | }; | |
384 | ||
385 | enum ib_sig_type { | |
386 | IB_SIGNAL_ALL_WR, | |
387 | IB_SIGNAL_REQ_WR | |
388 | }; | |
389 | ||
390 | enum ib_qp_type { | |
391 | /* | |
392 | * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries | |
393 | * here (and in that order) since the MAD layer uses them as | |
394 | * indices into a 2-entry table. | |
395 | */ | |
396 | IB_QPT_SMI, | |
397 | IB_QPT_GSI, | |
398 | ||
399 | IB_QPT_RC, | |
400 | IB_QPT_UC, | |
401 | IB_QPT_UD, | |
402 | IB_QPT_RAW_IPV6, | |
403 | IB_QPT_RAW_ETY | |
404 | }; | |
405 | ||
406 | struct ib_qp_init_attr { | |
407 | void (*event_handler)(struct ib_event *, void *); | |
408 | void *qp_context; | |
409 | struct ib_cq *send_cq; | |
410 | struct ib_cq *recv_cq; | |
411 | struct ib_srq *srq; | |
412 | struct ib_qp_cap cap; | |
413 | enum ib_sig_type sq_sig_type; | |
414 | enum ib_qp_type qp_type; | |
415 | u8 port_num; /* special QP types only */ | |
416 | }; | |
417 | ||
418 | enum ib_rnr_timeout { | |
419 | IB_RNR_TIMER_655_36 = 0, | |
420 | IB_RNR_TIMER_000_01 = 1, | |
421 | IB_RNR_TIMER_000_02 = 2, | |
422 | IB_RNR_TIMER_000_03 = 3, | |
423 | IB_RNR_TIMER_000_04 = 4, | |
424 | IB_RNR_TIMER_000_06 = 5, | |
425 | IB_RNR_TIMER_000_08 = 6, | |
426 | IB_RNR_TIMER_000_12 = 7, | |
427 | IB_RNR_TIMER_000_16 = 8, | |
428 | IB_RNR_TIMER_000_24 = 9, | |
429 | IB_RNR_TIMER_000_32 = 10, | |
430 | IB_RNR_TIMER_000_48 = 11, | |
431 | IB_RNR_TIMER_000_64 = 12, | |
432 | IB_RNR_TIMER_000_96 = 13, | |
433 | IB_RNR_TIMER_001_28 = 14, | |
434 | IB_RNR_TIMER_001_92 = 15, | |
435 | IB_RNR_TIMER_002_56 = 16, | |
436 | IB_RNR_TIMER_003_84 = 17, | |
437 | IB_RNR_TIMER_005_12 = 18, | |
438 | IB_RNR_TIMER_007_68 = 19, | |
439 | IB_RNR_TIMER_010_24 = 20, | |
440 | IB_RNR_TIMER_015_36 = 21, | |
441 | IB_RNR_TIMER_020_48 = 22, | |
442 | IB_RNR_TIMER_030_72 = 23, | |
443 | IB_RNR_TIMER_040_96 = 24, | |
444 | IB_RNR_TIMER_061_44 = 25, | |
445 | IB_RNR_TIMER_081_92 = 26, | |
446 | IB_RNR_TIMER_122_88 = 27, | |
447 | IB_RNR_TIMER_163_84 = 28, | |
448 | IB_RNR_TIMER_245_76 = 29, | |
449 | IB_RNR_TIMER_327_68 = 30, | |
450 | IB_RNR_TIMER_491_52 = 31 | |
451 | }; | |
452 | ||
453 | enum ib_qp_attr_mask { | |
454 | IB_QP_STATE = 1, | |
455 | IB_QP_CUR_STATE = (1<<1), | |
456 | IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), | |
457 | IB_QP_ACCESS_FLAGS = (1<<3), | |
458 | IB_QP_PKEY_INDEX = (1<<4), | |
459 | IB_QP_PORT = (1<<5), | |
460 | IB_QP_QKEY = (1<<6), | |
461 | IB_QP_AV = (1<<7), | |
462 | IB_QP_PATH_MTU = (1<<8), | |
463 | IB_QP_TIMEOUT = (1<<9), | |
464 | IB_QP_RETRY_CNT = (1<<10), | |
465 | IB_QP_RNR_RETRY = (1<<11), | |
466 | IB_QP_RQ_PSN = (1<<12), | |
467 | IB_QP_MAX_QP_RD_ATOMIC = (1<<13), | |
468 | IB_QP_ALT_PATH = (1<<14), | |
469 | IB_QP_MIN_RNR_TIMER = (1<<15), | |
470 | IB_QP_SQ_PSN = (1<<16), | |
471 | IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), | |
472 | IB_QP_PATH_MIG_STATE = (1<<18), | |
473 | IB_QP_CAP = (1<<19), | |
474 | IB_QP_DEST_QPN = (1<<20) | |
475 | }; | |
476 | ||
477 | enum ib_qp_state { | |
478 | IB_QPS_RESET, | |
479 | IB_QPS_INIT, | |
480 | IB_QPS_RTR, | |
481 | IB_QPS_RTS, | |
482 | IB_QPS_SQD, | |
483 | IB_QPS_SQE, | |
484 | IB_QPS_ERR | |
485 | }; | |
486 | ||
487 | enum ib_mig_state { | |
488 | IB_MIG_MIGRATED, | |
489 | IB_MIG_REARM, | |
490 | IB_MIG_ARMED | |
491 | }; | |
492 | ||
493 | struct ib_qp_attr { | |
494 | enum ib_qp_state qp_state; | |
495 | enum ib_qp_state cur_qp_state; | |
496 | enum ib_mtu path_mtu; | |
497 | enum ib_mig_state path_mig_state; | |
498 | u32 qkey; | |
499 | u32 rq_psn; | |
500 | u32 sq_psn; | |
501 | u32 dest_qp_num; | |
502 | int qp_access_flags; | |
503 | struct ib_qp_cap cap; | |
504 | struct ib_ah_attr ah_attr; | |
505 | struct ib_ah_attr alt_ah_attr; | |
506 | u16 pkey_index; | |
507 | u16 alt_pkey_index; | |
508 | u8 en_sqd_async_notify; | |
509 | u8 sq_draining; | |
510 | u8 max_rd_atomic; | |
511 | u8 max_dest_rd_atomic; | |
512 | u8 min_rnr_timer; | |
513 | u8 port_num; | |
514 | u8 timeout; | |
515 | u8 retry_cnt; | |
516 | u8 rnr_retry; | |
517 | u8 alt_port_num; | |
518 | u8 alt_timeout; | |
519 | }; | |
520 | ||
521 | enum ib_wr_opcode { | |
522 | IB_WR_RDMA_WRITE, | |
523 | IB_WR_RDMA_WRITE_WITH_IMM, | |
524 | IB_WR_SEND, | |
525 | IB_WR_SEND_WITH_IMM, | |
526 | IB_WR_RDMA_READ, | |
527 | IB_WR_ATOMIC_CMP_AND_SWP, | |
528 | IB_WR_ATOMIC_FETCH_AND_ADD | |
529 | }; | |
530 | ||
531 | enum ib_send_flags { | |
532 | IB_SEND_FENCE = 1, | |
533 | IB_SEND_SIGNALED = (1<<1), | |
534 | IB_SEND_SOLICITED = (1<<2), | |
535 | IB_SEND_INLINE = (1<<3) | |
536 | }; | |
537 | ||
538 | struct ib_sge { | |
539 | u64 addr; | |
540 | u32 length; | |
541 | u32 lkey; | |
542 | }; | |
543 | ||
544 | struct ib_send_wr { | |
545 | struct ib_send_wr *next; | |
546 | u64 wr_id; | |
547 | struct ib_sge *sg_list; | |
548 | int num_sge; | |
549 | enum ib_wr_opcode opcode; | |
550 | int send_flags; | |
e2773c06 | 551 | __be32 imm_data; |
1da177e4 LT |
552 | union { |
553 | struct { | |
554 | u64 remote_addr; | |
555 | u32 rkey; | |
556 | } rdma; | |
557 | struct { | |
558 | u64 remote_addr; | |
559 | u64 compare_add; | |
560 | u64 swap; | |
561 | u32 rkey; | |
562 | } atomic; | |
563 | struct { | |
564 | struct ib_ah *ah; | |
565 | struct ib_mad_hdr *mad_hdr; | |
566 | u32 remote_qpn; | |
567 | u32 remote_qkey; | |
568 | int timeout_ms; /* valid for MADs only */ | |
f75b7a52 | 569 | int retries; /* valid for MADs only */ |
1da177e4 LT |
570 | u16 pkey_index; /* valid for GSI only */ |
571 | u8 port_num; /* valid for DR SMPs on switch only */ | |
572 | } ud; | |
573 | } wr; | |
574 | }; | |
575 | ||
576 | struct ib_recv_wr { | |
577 | struct ib_recv_wr *next; | |
578 | u64 wr_id; | |
579 | struct ib_sge *sg_list; | |
580 | int num_sge; | |
581 | }; | |
582 | ||
583 | enum ib_access_flags { | |
584 | IB_ACCESS_LOCAL_WRITE = 1, | |
585 | IB_ACCESS_REMOTE_WRITE = (1<<1), | |
586 | IB_ACCESS_REMOTE_READ = (1<<2), | |
587 | IB_ACCESS_REMOTE_ATOMIC = (1<<3), | |
588 | IB_ACCESS_MW_BIND = (1<<4) | |
589 | }; | |
590 | ||
591 | struct ib_phys_buf { | |
592 | u64 addr; | |
593 | u64 size; | |
594 | }; | |
595 | ||
596 | struct ib_mr_attr { | |
597 | struct ib_pd *pd; | |
598 | u64 device_virt_addr; | |
599 | u64 size; | |
600 | int mr_access_flags; | |
601 | u32 lkey; | |
602 | u32 rkey; | |
603 | }; | |
604 | ||
605 | enum ib_mr_rereg_flags { | |
606 | IB_MR_REREG_TRANS = 1, | |
607 | IB_MR_REREG_PD = (1<<1), | |
608 | IB_MR_REREG_ACCESS = (1<<2) | |
609 | }; | |
610 | ||
611 | struct ib_mw_bind { | |
612 | struct ib_mr *mr; | |
613 | u64 wr_id; | |
614 | u64 addr; | |
615 | u32 length; | |
616 | int send_flags; | |
617 | int mw_access_flags; | |
618 | }; | |
619 | ||
620 | struct ib_fmr_attr { | |
621 | int max_pages; | |
622 | int max_maps; | |
623 | u8 page_size; | |
624 | }; | |
625 | ||
e2773c06 RD |
626 | struct ib_ucontext { |
627 | struct ib_device *device; | |
628 | struct list_head pd_list; | |
629 | struct list_head mr_list; | |
630 | struct list_head mw_list; | |
631 | struct list_head cq_list; | |
632 | struct list_head qp_list; | |
633 | struct list_head srq_list; | |
634 | struct list_head ah_list; | |
635 | spinlock_t lock; | |
636 | }; | |
637 | ||
638 | struct ib_uobject { | |
639 | u64 user_handle; /* handle given to us by userspace */ | |
640 | struct ib_ucontext *context; /* associated user context */ | |
641 | struct list_head list; /* link to context's list */ | |
642 | u32 id; /* index into kernel idr */ | |
643 | }; | |
644 | ||
645 | struct ib_umem { | |
646 | unsigned long user_base; | |
647 | unsigned long virt_base; | |
648 | size_t length; | |
649 | int offset; | |
650 | int page_size; | |
651 | int writable; | |
652 | struct list_head chunk_list; | |
653 | }; | |
654 | ||
655 | struct ib_umem_chunk { | |
656 | struct list_head list; | |
657 | int nents; | |
658 | int nmap; | |
659 | struct scatterlist page_list[0]; | |
660 | }; | |
661 | ||
662 | struct ib_udata { | |
663 | void __user *inbuf; | |
664 | void __user *outbuf; | |
665 | size_t inlen; | |
666 | size_t outlen; | |
667 | }; | |
668 | ||
669 | #define IB_UMEM_MAX_PAGE_CHUNK \ | |
670 | ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \ | |
671 | ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \ | |
672 | (void *) &((struct ib_umem_chunk *) 0)->page_list[0])) | |
673 | ||
674 | struct ib_umem_object { | |
675 | struct ib_uobject uobject; | |
676 | struct ib_umem umem; | |
677 | }; | |
678 | ||
1da177e4 | 679 | struct ib_pd { |
e2773c06 RD |
680 | struct ib_device *device; |
681 | struct ib_uobject *uobject; | |
682 | atomic_t usecnt; /* count all resources */ | |
1da177e4 LT |
683 | }; |
684 | ||
685 | struct ib_ah { | |
686 | struct ib_device *device; | |
687 | struct ib_pd *pd; | |
e2773c06 | 688 | struct ib_uobject *uobject; |
1da177e4 LT |
689 | }; |
690 | ||
691 | typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); | |
692 | ||
693 | struct ib_cq { | |
e2773c06 RD |
694 | struct ib_device *device; |
695 | struct ib_uobject *uobject; | |
696 | ib_comp_handler comp_handler; | |
697 | void (*event_handler)(struct ib_event *, void *); | |
698 | void * cq_context; | |
699 | int cqe; | |
700 | atomic_t usecnt; /* count number of work queues */ | |
1da177e4 LT |
701 | }; |
702 | ||
703 | struct ib_srq { | |
704 | struct ib_device *device; | |
e2773c06 | 705 | struct ib_uobject *uobject; |
1da177e4 LT |
706 | struct ib_pd *pd; |
707 | void *srq_context; | |
708 | atomic_t usecnt; | |
709 | }; | |
710 | ||
711 | struct ib_qp { | |
712 | struct ib_device *device; | |
713 | struct ib_pd *pd; | |
714 | struct ib_cq *send_cq; | |
715 | struct ib_cq *recv_cq; | |
716 | struct ib_srq *srq; | |
e2773c06 | 717 | struct ib_uobject *uobject; |
1da177e4 LT |
718 | void (*event_handler)(struct ib_event *, void *); |
719 | void *qp_context; | |
720 | u32 qp_num; | |
721 | enum ib_qp_type qp_type; | |
722 | }; | |
723 | ||
724 | struct ib_mr { | |
e2773c06 RD |
725 | struct ib_device *device; |
726 | struct ib_pd *pd; | |
727 | struct ib_uobject *uobject; | |
728 | u32 lkey; | |
729 | u32 rkey; | |
730 | atomic_t usecnt; /* count number of MWs */ | |
1da177e4 LT |
731 | }; |
732 | ||
733 | struct ib_mw { | |
734 | struct ib_device *device; | |
735 | struct ib_pd *pd; | |
e2773c06 | 736 | struct ib_uobject *uobject; |
1da177e4 LT |
737 | u32 rkey; |
738 | }; | |
739 | ||
740 | struct ib_fmr { | |
741 | struct ib_device *device; | |
742 | struct ib_pd *pd; | |
743 | struct list_head list; | |
744 | u32 lkey; | |
745 | u32 rkey; | |
746 | }; | |
747 | ||
748 | struct ib_mad; | |
749 | struct ib_grh; | |
750 | ||
751 | enum ib_process_mad_flags { | |
752 | IB_MAD_IGNORE_MKEY = 1, | |
753 | IB_MAD_IGNORE_BKEY = 2, | |
754 | IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY | |
755 | }; | |
756 | ||
757 | enum ib_mad_result { | |
758 | IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */ | |
759 | IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */ | |
760 | IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */ | |
761 | IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */ | |
762 | }; | |
763 | ||
764 | #define IB_DEVICE_NAME_MAX 64 | |
765 | ||
766 | struct ib_cache { | |
767 | rwlock_t lock; | |
768 | struct ib_event_handler event_handler; | |
769 | struct ib_pkey_cache **pkey_cache; | |
770 | struct ib_gid_cache **gid_cache; | |
771 | }; | |
772 | ||
773 | struct ib_device { | |
774 | struct device *dma_device; | |
775 | ||
776 | char name[IB_DEVICE_NAME_MAX]; | |
777 | ||
778 | struct list_head event_handler_list; | |
779 | spinlock_t event_handler_lock; | |
780 | ||
781 | struct list_head core_list; | |
782 | struct list_head client_data_list; | |
783 | spinlock_t client_data_lock; | |
784 | ||
785 | struct ib_cache cache; | |
786 | ||
787 | u32 flags; | |
788 | ||
789 | int (*query_device)(struct ib_device *device, | |
790 | struct ib_device_attr *device_attr); | |
791 | int (*query_port)(struct ib_device *device, | |
792 | u8 port_num, | |
793 | struct ib_port_attr *port_attr); | |
794 | int (*query_gid)(struct ib_device *device, | |
795 | u8 port_num, int index, | |
796 | union ib_gid *gid); | |
797 | int (*query_pkey)(struct ib_device *device, | |
798 | u8 port_num, u16 index, u16 *pkey); | |
799 | int (*modify_device)(struct ib_device *device, | |
800 | int device_modify_mask, | |
801 | struct ib_device_modify *device_modify); | |
802 | int (*modify_port)(struct ib_device *device, | |
803 | u8 port_num, int port_modify_mask, | |
804 | struct ib_port_modify *port_modify); | |
e2773c06 RD |
805 | struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, |
806 | struct ib_udata *udata); | |
807 | int (*dealloc_ucontext)(struct ib_ucontext *context); | |
808 | int (*mmap)(struct ib_ucontext *context, | |
809 | struct vm_area_struct *vma); | |
810 | struct ib_pd * (*alloc_pd)(struct ib_device *device, | |
811 | struct ib_ucontext *context, | |
812 | struct ib_udata *udata); | |
1da177e4 LT |
813 | int (*dealloc_pd)(struct ib_pd *pd); |
814 | struct ib_ah * (*create_ah)(struct ib_pd *pd, | |
815 | struct ib_ah_attr *ah_attr); | |
816 | int (*modify_ah)(struct ib_ah *ah, | |
817 | struct ib_ah_attr *ah_attr); | |
818 | int (*query_ah)(struct ib_ah *ah, | |
819 | struct ib_ah_attr *ah_attr); | |
820 | int (*destroy_ah)(struct ib_ah *ah); | |
821 | struct ib_qp * (*create_qp)(struct ib_pd *pd, | |
e2773c06 RD |
822 | struct ib_qp_init_attr *qp_init_attr, |
823 | struct ib_udata *udata); | |
1da177e4 LT |
824 | int (*modify_qp)(struct ib_qp *qp, |
825 | struct ib_qp_attr *qp_attr, | |
826 | int qp_attr_mask); | |
827 | int (*query_qp)(struct ib_qp *qp, | |
828 | struct ib_qp_attr *qp_attr, | |
829 | int qp_attr_mask, | |
830 | struct ib_qp_init_attr *qp_init_attr); | |
831 | int (*destroy_qp)(struct ib_qp *qp); | |
832 | int (*post_send)(struct ib_qp *qp, | |
833 | struct ib_send_wr *send_wr, | |
834 | struct ib_send_wr **bad_send_wr); | |
835 | int (*post_recv)(struct ib_qp *qp, | |
836 | struct ib_recv_wr *recv_wr, | |
837 | struct ib_recv_wr **bad_recv_wr); | |
e2773c06 RD |
838 | struct ib_cq * (*create_cq)(struct ib_device *device, int cqe, |
839 | struct ib_ucontext *context, | |
840 | struct ib_udata *udata); | |
1da177e4 LT |
841 | int (*destroy_cq)(struct ib_cq *cq); |
842 | int (*resize_cq)(struct ib_cq *cq, int *cqe); | |
843 | int (*poll_cq)(struct ib_cq *cq, int num_entries, | |
844 | struct ib_wc *wc); | |
845 | int (*peek_cq)(struct ib_cq *cq, int wc_cnt); | |
846 | int (*req_notify_cq)(struct ib_cq *cq, | |
847 | enum ib_cq_notify cq_notify); | |
848 | int (*req_ncomp_notif)(struct ib_cq *cq, | |
849 | int wc_cnt); | |
850 | struct ib_mr * (*get_dma_mr)(struct ib_pd *pd, | |
851 | int mr_access_flags); | |
852 | struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd, | |
853 | struct ib_phys_buf *phys_buf_array, | |
854 | int num_phys_buf, | |
855 | int mr_access_flags, | |
856 | u64 *iova_start); | |
e2773c06 RD |
857 | struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, |
858 | struct ib_umem *region, | |
859 | int mr_access_flags, | |
860 | struct ib_udata *udata); | |
1da177e4 LT |
861 | int (*query_mr)(struct ib_mr *mr, |
862 | struct ib_mr_attr *mr_attr); | |
863 | int (*dereg_mr)(struct ib_mr *mr); | |
864 | int (*rereg_phys_mr)(struct ib_mr *mr, | |
865 | int mr_rereg_mask, | |
866 | struct ib_pd *pd, | |
867 | struct ib_phys_buf *phys_buf_array, | |
868 | int num_phys_buf, | |
869 | int mr_access_flags, | |
870 | u64 *iova_start); | |
871 | struct ib_mw * (*alloc_mw)(struct ib_pd *pd); | |
872 | int (*bind_mw)(struct ib_qp *qp, | |
873 | struct ib_mw *mw, | |
874 | struct ib_mw_bind *mw_bind); | |
875 | int (*dealloc_mw)(struct ib_mw *mw); | |
876 | struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd, | |
877 | int mr_access_flags, | |
878 | struct ib_fmr_attr *fmr_attr); | |
879 | int (*map_phys_fmr)(struct ib_fmr *fmr, | |
880 | u64 *page_list, int list_len, | |
881 | u64 iova); | |
882 | int (*unmap_fmr)(struct list_head *fmr_list); | |
883 | int (*dealloc_fmr)(struct ib_fmr *fmr); | |
884 | int (*attach_mcast)(struct ib_qp *qp, | |
885 | union ib_gid *gid, | |
886 | u16 lid); | |
887 | int (*detach_mcast)(struct ib_qp *qp, | |
888 | union ib_gid *gid, | |
889 | u16 lid); | |
890 | int (*process_mad)(struct ib_device *device, | |
891 | int process_mad_flags, | |
892 | u8 port_num, | |
893 | struct ib_wc *in_wc, | |
894 | struct ib_grh *in_grh, | |
895 | struct ib_mad *in_mad, | |
896 | struct ib_mad *out_mad); | |
897 | ||
e2773c06 | 898 | struct module *owner; |
1da177e4 LT |
899 | struct class_device class_dev; |
900 | struct kobject ports_parent; | |
901 | struct list_head port_list; | |
902 | ||
903 | enum { | |
904 | IB_DEV_UNINITIALIZED, | |
905 | IB_DEV_REGISTERED, | |
906 | IB_DEV_UNREGISTERED | |
907 | } reg_state; | |
908 | ||
909 | u8 node_type; | |
910 | u8 phys_port_cnt; | |
911 | }; | |
912 | ||
913 | struct ib_client { | |
914 | char *name; | |
915 | void (*add) (struct ib_device *); | |
916 | void (*remove)(struct ib_device *); | |
917 | ||
918 | struct list_head list; | |
919 | }; | |
920 | ||
921 | struct ib_device *ib_alloc_device(size_t size); | |
922 | void ib_dealloc_device(struct ib_device *device); | |
923 | ||
924 | int ib_register_device (struct ib_device *device); | |
925 | void ib_unregister_device(struct ib_device *device); | |
926 | ||
927 | int ib_register_client (struct ib_client *client); | |
928 | void ib_unregister_client(struct ib_client *client); | |
929 | ||
930 | void *ib_get_client_data(struct ib_device *device, struct ib_client *client); | |
931 | void ib_set_client_data(struct ib_device *device, struct ib_client *client, | |
932 | void *data); | |
933 | ||
e2773c06 RD |
934 | static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) |
935 | { | |
936 | return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; | |
937 | } | |
938 | ||
939 | static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) | |
940 | { | |
941 | return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; | |
942 | } | |
943 | ||
1da177e4 LT |
944 | int ib_register_event_handler (struct ib_event_handler *event_handler); |
945 | int ib_unregister_event_handler(struct ib_event_handler *event_handler); | |
946 | void ib_dispatch_event(struct ib_event *event); | |
947 | ||
948 | int ib_query_device(struct ib_device *device, | |
949 | struct ib_device_attr *device_attr); | |
950 | ||
951 | int ib_query_port(struct ib_device *device, | |
952 | u8 port_num, struct ib_port_attr *port_attr); | |
953 | ||
954 | int ib_query_gid(struct ib_device *device, | |
955 | u8 port_num, int index, union ib_gid *gid); | |
956 | ||
957 | int ib_query_pkey(struct ib_device *device, | |
958 | u8 port_num, u16 index, u16 *pkey); | |
959 | ||
960 | int ib_modify_device(struct ib_device *device, | |
961 | int device_modify_mask, | |
962 | struct ib_device_modify *device_modify); | |
963 | ||
964 | int ib_modify_port(struct ib_device *device, | |
965 | u8 port_num, int port_modify_mask, | |
966 | struct ib_port_modify *port_modify); | |
967 | ||
968 | /** | |
969 | * ib_alloc_pd - Allocates an unused protection domain. | |
970 | * @device: The device on which to allocate the protection domain. | |
971 | * | |
972 | * A protection domain object provides an association between QPs, shared | |
973 | * receive queues, address handles, memory regions, and memory windows. | |
974 | */ | |
975 | struct ib_pd *ib_alloc_pd(struct ib_device *device); | |
976 | ||
977 | /** | |
978 | * ib_dealloc_pd - Deallocates a protection domain. | |
979 | * @pd: The protection domain to deallocate. | |
980 | */ | |
981 | int ib_dealloc_pd(struct ib_pd *pd); | |
982 | ||
983 | /** | |
984 | * ib_create_ah - Creates an address handle for the given address vector. | |
985 | * @pd: The protection domain associated with the address handle. | |
986 | * @ah_attr: The attributes of the address vector. | |
987 | * | |
988 | * The address handle is used to reference a local or global destination | |
989 | * in all UD QP post sends. | |
990 | */ | |
991 | struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); | |
992 | ||
993 | /** | |
994 | * ib_modify_ah - Modifies the address vector associated with an address | |
995 | * handle. | |
996 | * @ah: The address handle to modify. | |
997 | * @ah_attr: The new address vector attributes to associate with the | |
998 | * address handle. | |
999 | */ | |
1000 | int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); | |
1001 | ||
1002 | /** | |
1003 | * ib_query_ah - Queries the address vector associated with an address | |
1004 | * handle. | |
1005 | * @ah: The address handle to query. | |
1006 | * @ah_attr: The address vector attributes associated with the address | |
1007 | * handle. | |
1008 | */ | |
1009 | int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); | |
1010 | ||
1011 | /** | |
1012 | * ib_destroy_ah - Destroys an address handle. | |
1013 | * @ah: The address handle to destroy. | |
1014 | */ | |
1015 | int ib_destroy_ah(struct ib_ah *ah); | |
1016 | ||
1017 | /** | |
1018 | * ib_create_qp - Creates a QP associated with the specified protection | |
1019 | * domain. | |
1020 | * @pd: The protection domain associated with the QP. | |
1021 | * @qp_init_attr: A list of initial attributes required to create the QP. | |
1022 | */ | |
1023 | struct ib_qp *ib_create_qp(struct ib_pd *pd, | |
1024 | struct ib_qp_init_attr *qp_init_attr); | |
1025 | ||
1026 | /** | |
1027 | * ib_modify_qp - Modifies the attributes for the specified QP and then | |
1028 | * transitions the QP to the given state. | |
1029 | * @qp: The QP to modify. | |
1030 | * @qp_attr: On input, specifies the QP attributes to modify. On output, | |
1031 | * the current values of selected QP attributes are returned. | |
1032 | * @qp_attr_mask: A bit-mask used to specify which attributes of the QP | |
1033 | * are being modified. | |
1034 | */ | |
1035 | int ib_modify_qp(struct ib_qp *qp, | |
1036 | struct ib_qp_attr *qp_attr, | |
1037 | int qp_attr_mask); | |
1038 | ||
1039 | /** | |
1040 | * ib_query_qp - Returns the attribute list and current values for the | |
1041 | * specified QP. | |
1042 | * @qp: The QP to query. | |
1043 | * @qp_attr: The attributes of the specified QP. | |
1044 | * @qp_attr_mask: A bit-mask used to select specific attributes to query. | |
1045 | * @qp_init_attr: Additional attributes of the selected QP. | |
1046 | * | |
1047 | * The qp_attr_mask may be used to limit the query to gathering only the | |
1048 | * selected attributes. | |
1049 | */ | |
1050 | int ib_query_qp(struct ib_qp *qp, | |
1051 | struct ib_qp_attr *qp_attr, | |
1052 | int qp_attr_mask, | |
1053 | struct ib_qp_init_attr *qp_init_attr); | |
1054 | ||
1055 | /** | |
1056 | * ib_destroy_qp - Destroys the specified QP. | |
1057 | * @qp: The QP to destroy. | |
1058 | */ | |
1059 | int ib_destroy_qp(struct ib_qp *qp); | |
1060 | ||
1061 | /** | |
1062 | * ib_post_send - Posts a list of work requests to the send queue of | |
1063 | * the specified QP. | |
1064 | * @qp: The QP to post the work request on. | |
1065 | * @send_wr: A list of work requests to post on the send queue. | |
1066 | * @bad_send_wr: On an immediate failure, this parameter will reference | |
1067 | * the work request that failed to be posted on the QP. | |
1068 | */ | |
1069 | static inline int ib_post_send(struct ib_qp *qp, | |
1070 | struct ib_send_wr *send_wr, | |
1071 | struct ib_send_wr **bad_send_wr) | |
1072 | { | |
1073 | return qp->device->post_send(qp, send_wr, bad_send_wr); | |
1074 | } | |
1075 | ||
1076 | /** | |
1077 | * ib_post_recv - Posts a list of work requests to the receive queue of | |
1078 | * the specified QP. | |
1079 | * @qp: The QP to post the work request on. | |
1080 | * @recv_wr: A list of work requests to post on the receive queue. | |
1081 | * @bad_recv_wr: On an immediate failure, this parameter will reference | |
1082 | * the work request that failed to be posted on the QP. | |
1083 | */ | |
1084 | static inline int ib_post_recv(struct ib_qp *qp, | |
1085 | struct ib_recv_wr *recv_wr, | |
1086 | struct ib_recv_wr **bad_recv_wr) | |
1087 | { | |
1088 | return qp->device->post_recv(qp, recv_wr, bad_recv_wr); | |
1089 | } | |
1090 | ||
1091 | /** | |
1092 | * ib_create_cq - Creates a CQ on the specified device. | |
1093 | * @device: The device on which to create the CQ. | |
1094 | * @comp_handler: A user-specified callback that is invoked when a | |
1095 | * completion event occurs on the CQ. | |
1096 | * @event_handler: A user-specified callback that is invoked when an | |
1097 | * asynchronous event not associated with a completion occurs on the CQ. | |
1098 | * @cq_context: Context associated with the CQ returned to the user via | |
1099 | * the associated completion and event handlers. | |
1100 | * @cqe: The minimum size of the CQ. | |
1101 | * | |
1102 | * Users can examine the cq structure to determine the actual CQ size. | |
1103 | */ | |
1104 | struct ib_cq *ib_create_cq(struct ib_device *device, | |
1105 | ib_comp_handler comp_handler, | |
1106 | void (*event_handler)(struct ib_event *, void *), | |
1107 | void *cq_context, int cqe); | |
1108 | ||
1109 | /** | |
1110 | * ib_resize_cq - Modifies the capacity of the CQ. | |
1111 | * @cq: The CQ to resize. | |
1112 | * @cqe: The minimum size of the CQ. | |
1113 | * | |
1114 | * Users can examine the cq structure to determine the actual CQ size. | |
1115 | */ | |
1116 | int ib_resize_cq(struct ib_cq *cq, int cqe); | |
1117 | ||
1118 | /** | |
1119 | * ib_destroy_cq - Destroys the specified CQ. | |
1120 | * @cq: The CQ to destroy. | |
1121 | */ | |
1122 | int ib_destroy_cq(struct ib_cq *cq); | |
1123 | ||
1124 | /** | |
1125 | * ib_poll_cq - poll a CQ for completion(s) | |
1126 | * @cq:the CQ being polled | |
1127 | * @num_entries:maximum number of completions to return | |
1128 | * @wc:array of at least @num_entries &struct ib_wc where completions | |
1129 | * will be returned | |
1130 | * | |
1131 | * Poll a CQ for (possibly multiple) completions. If the return value | |
1132 | * is < 0, an error occurred. If the return value is >= 0, it is the | |
1133 | * number of completions returned. If the return value is | |
1134 | * non-negative and < num_entries, then the CQ was emptied. | |
1135 | */ | |
1136 | static inline int ib_poll_cq(struct ib_cq *cq, int num_entries, | |
1137 | struct ib_wc *wc) | |
1138 | { | |
1139 | return cq->device->poll_cq(cq, num_entries, wc); | |
1140 | } | |
1141 | ||
1142 | /** | |
1143 | * ib_peek_cq - Returns the number of unreaped completions currently | |
1144 | * on the specified CQ. | |
1145 | * @cq: The CQ to peek. | |
1146 | * @wc_cnt: A minimum number of unreaped completions to check for. | |
1147 | * | |
1148 | * If the number of unreaped completions is greater than or equal to wc_cnt, | |
1149 | * this function returns wc_cnt, otherwise, it returns the actual number of | |
1150 | * unreaped completions. | |
1151 | */ | |
1152 | int ib_peek_cq(struct ib_cq *cq, int wc_cnt); | |
1153 | ||
1154 | /** | |
1155 | * ib_req_notify_cq - Request completion notification on a CQ. | |
1156 | * @cq: The CQ to generate an event for. | |
1157 | * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will | |
1158 | * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP, | |
1159 | * notification will occur on the next completion. | |
1160 | */ | |
1161 | static inline int ib_req_notify_cq(struct ib_cq *cq, | |
1162 | enum ib_cq_notify cq_notify) | |
1163 | { | |
1164 | return cq->device->req_notify_cq(cq, cq_notify); | |
1165 | } | |
1166 | ||
1167 | /** | |
1168 | * ib_req_ncomp_notif - Request completion notification when there are | |
1169 | * at least the specified number of unreaped completions on the CQ. | |
1170 | * @cq: The CQ to generate an event for. | |
1171 | * @wc_cnt: The number of unreaped completions that should be on the | |
1172 | * CQ before an event is generated. | |
1173 | */ | |
1174 | static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt) | |
1175 | { | |
1176 | return cq->device->req_ncomp_notif ? | |
1177 | cq->device->req_ncomp_notif(cq, wc_cnt) : | |
1178 | -ENOSYS; | |
1179 | } | |
1180 | ||
1181 | /** | |
1182 | * ib_get_dma_mr - Returns a memory region for system memory that is | |
1183 | * usable for DMA. | |
1184 | * @pd: The protection domain associated with the memory region. | |
1185 | * @mr_access_flags: Specifies the memory access rights. | |
1186 | */ | |
1187 | struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags); | |
1188 | ||
1189 | /** | |
1190 | * ib_reg_phys_mr - Prepares a virtually addressed memory region for use | |
1191 | * by an HCA. | |
1192 | * @pd: The protection domain associated assigned to the registered region. | |
1193 | * @phys_buf_array: Specifies a list of physical buffers to use in the | |
1194 | * memory region. | |
1195 | * @num_phys_buf: Specifies the size of the phys_buf_array. | |
1196 | * @mr_access_flags: Specifies the memory access rights. | |
1197 | * @iova_start: The offset of the region's starting I/O virtual address. | |
1198 | */ | |
1199 | struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd, | |
1200 | struct ib_phys_buf *phys_buf_array, | |
1201 | int num_phys_buf, | |
1202 | int mr_access_flags, | |
1203 | u64 *iova_start); | |
1204 | ||
1205 | /** | |
1206 | * ib_rereg_phys_mr - Modifies the attributes of an existing memory region. | |
1207 | * Conceptually, this call performs the functions deregister memory region | |
1208 | * followed by register physical memory region. Where possible, | |
1209 | * resources are reused instead of deallocated and reallocated. | |
1210 | * @mr: The memory region to modify. | |
1211 | * @mr_rereg_mask: A bit-mask used to indicate which of the following | |
1212 | * properties of the memory region are being modified. | |
1213 | * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies | |
1214 | * the new protection domain to associated with the memory region, | |
1215 | * otherwise, this parameter is ignored. | |
1216 | * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this | |
1217 | * field specifies a list of physical buffers to use in the new | |
1218 | * translation, otherwise, this parameter is ignored. | |
1219 | * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this | |
1220 | * field specifies the size of the phys_buf_array, otherwise, this | |
1221 | * parameter is ignored. | |
1222 | * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this | |
1223 | * field specifies the new memory access rights, otherwise, this | |
1224 | * parameter is ignored. | |
1225 | * @iova_start: The offset of the region's starting I/O virtual address. | |
1226 | */ | |
1227 | int ib_rereg_phys_mr(struct ib_mr *mr, | |
1228 | int mr_rereg_mask, | |
1229 | struct ib_pd *pd, | |
1230 | struct ib_phys_buf *phys_buf_array, | |
1231 | int num_phys_buf, | |
1232 | int mr_access_flags, | |
1233 | u64 *iova_start); | |
1234 | ||
1235 | /** | |
1236 | * ib_query_mr - Retrieves information about a specific memory region. | |
1237 | * @mr: The memory region to retrieve information about. | |
1238 | * @mr_attr: The attributes of the specified memory region. | |
1239 | */ | |
1240 | int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr); | |
1241 | ||
1242 | /** | |
1243 | * ib_dereg_mr - Deregisters a memory region and removes it from the | |
1244 | * HCA translation table. | |
1245 | * @mr: The memory region to deregister. | |
1246 | */ | |
1247 | int ib_dereg_mr(struct ib_mr *mr); | |
1248 | ||
1249 | /** | |
1250 | * ib_alloc_mw - Allocates a memory window. | |
1251 | * @pd: The protection domain associated with the memory window. | |
1252 | */ | |
1253 | struct ib_mw *ib_alloc_mw(struct ib_pd *pd); | |
1254 | ||
1255 | /** | |
1256 | * ib_bind_mw - Posts a work request to the send queue of the specified | |
1257 | * QP, which binds the memory window to the given address range and | |
1258 | * remote access attributes. | |
1259 | * @qp: QP to post the bind work request on. | |
1260 | * @mw: The memory window to bind. | |
1261 | * @mw_bind: Specifies information about the memory window, including | |
1262 | * its address range, remote access rights, and associated memory region. | |
1263 | */ | |
1264 | static inline int ib_bind_mw(struct ib_qp *qp, | |
1265 | struct ib_mw *mw, | |
1266 | struct ib_mw_bind *mw_bind) | |
1267 | { | |
1268 | /* XXX reference counting in corresponding MR? */ | |
1269 | return mw->device->bind_mw ? | |
1270 | mw->device->bind_mw(qp, mw, mw_bind) : | |
1271 | -ENOSYS; | |
1272 | } | |
1273 | ||
1274 | /** | |
1275 | * ib_dealloc_mw - Deallocates a memory window. | |
1276 | * @mw: The memory window to deallocate. | |
1277 | */ | |
1278 | int ib_dealloc_mw(struct ib_mw *mw); | |
1279 | ||
1280 | /** | |
1281 | * ib_alloc_fmr - Allocates a unmapped fast memory region. | |
1282 | * @pd: The protection domain associated with the unmapped region. | |
1283 | * @mr_access_flags: Specifies the memory access rights. | |
1284 | * @fmr_attr: Attributes of the unmapped region. | |
1285 | * | |
1286 | * A fast memory region must be mapped before it can be used as part of | |
1287 | * a work request. | |
1288 | */ | |
1289 | struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd, | |
1290 | int mr_access_flags, | |
1291 | struct ib_fmr_attr *fmr_attr); | |
1292 | ||
1293 | /** | |
1294 | * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region. | |
1295 | * @fmr: The fast memory region to associate with the pages. | |
1296 | * @page_list: An array of physical pages to map to the fast memory region. | |
1297 | * @list_len: The number of pages in page_list. | |
1298 | * @iova: The I/O virtual address to use with the mapped region. | |
1299 | */ | |
1300 | static inline int ib_map_phys_fmr(struct ib_fmr *fmr, | |
1301 | u64 *page_list, int list_len, | |
1302 | u64 iova) | |
1303 | { | |
1304 | return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova); | |
1305 | } | |
1306 | ||
1307 | /** | |
1308 | * ib_unmap_fmr - Removes the mapping from a list of fast memory regions. | |
1309 | * @fmr_list: A linked list of fast memory regions to unmap. | |
1310 | */ | |
1311 | int ib_unmap_fmr(struct list_head *fmr_list); | |
1312 | ||
1313 | /** | |
1314 | * ib_dealloc_fmr - Deallocates a fast memory region. | |
1315 | * @fmr: The fast memory region to deallocate. | |
1316 | */ | |
1317 | int ib_dealloc_fmr(struct ib_fmr *fmr); | |
1318 | ||
1319 | /** | |
1320 | * ib_attach_mcast - Attaches the specified QP to a multicast group. | |
1321 | * @qp: QP to attach to the multicast group. The QP must be type | |
1322 | * IB_QPT_UD. | |
1323 | * @gid: Multicast group GID. | |
1324 | * @lid: Multicast group LID in host byte order. | |
1325 | * | |
1326 | * In order to send and receive multicast packets, subnet | |
1327 | * administration must have created the multicast group and configured | |
1328 | * the fabric appropriately. The port associated with the specified | |
1329 | * QP must also be a member of the multicast group. | |
1330 | */ | |
1331 | int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); | |
1332 | ||
1333 | /** | |
1334 | * ib_detach_mcast - Detaches the specified QP from a multicast group. | |
1335 | * @qp: QP to detach from the multicast group. | |
1336 | * @gid: Multicast group GID. | |
1337 | * @lid: Multicast group LID in host byte order. | |
1338 | */ | |
1339 | int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); | |
1340 | ||
1341 | #endif /* IB_VERBS_H */ |