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