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. |
f7c6a7b5 | 8 | * Copyright (c) 2005, 2006, 2007 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. | |
1da177e4 LT |
37 | */ |
38 | ||
39 | #if !defined(IB_VERBS_H) | |
40 | #define IB_VERBS_H | |
41 | ||
42 | #include <linux/types.h> | |
43 | #include <linux/device.h> | |
9b513090 RC |
44 | #include <linux/mm.h> |
45 | #include <linux/dma-mapping.h> | |
459d6e2a | 46 | #include <linux/kref.h> |
bfb3ea12 DB |
47 | #include <linux/list.h> |
48 | #include <linux/rwsem.h> | |
87ae9afd | 49 | #include <linux/scatterlist.h> |
f0626710 | 50 | #include <linux/workqueue.h> |
dd5f03be | 51 | #include <uapi/linux/if_ether.h> |
e2773c06 | 52 | |
60063497 | 53 | #include <linux/atomic.h> |
e2773c06 | 54 | #include <asm/uaccess.h> |
1da177e4 | 55 | |
f0626710 TH |
56 | extern struct workqueue_struct *ib_wq; |
57 | ||
1da177e4 LT |
58 | union ib_gid { |
59 | u8 raw[16]; | |
60 | struct { | |
97f52eb4 SH |
61 | __be64 subnet_prefix; |
62 | __be64 interface_id; | |
1da177e4 LT |
63 | } global; |
64 | }; | |
65 | ||
07ebafba TT |
66 | enum rdma_node_type { |
67 | /* IB values map to NodeInfo:NodeType. */ | |
68 | RDMA_NODE_IB_CA = 1, | |
69 | RDMA_NODE_IB_SWITCH, | |
70 | RDMA_NODE_IB_ROUTER, | |
180771a3 UM |
71 | RDMA_NODE_RNIC, |
72 | RDMA_NODE_USNIC, | |
5db5765e | 73 | RDMA_NODE_USNIC_UDP, |
1da177e4 LT |
74 | }; |
75 | ||
07ebafba TT |
76 | enum rdma_transport_type { |
77 | RDMA_TRANSPORT_IB, | |
180771a3 | 78 | RDMA_TRANSPORT_IWARP, |
248567f7 UM |
79 | RDMA_TRANSPORT_USNIC, |
80 | RDMA_TRANSPORT_USNIC_UDP | |
07ebafba TT |
81 | }; |
82 | ||
8385fd84 RD |
83 | __attribute_const__ enum rdma_transport_type |
84 | rdma_node_get_transport(enum rdma_node_type node_type); | |
07ebafba | 85 | |
a3f5adaf EC |
86 | enum rdma_link_layer { |
87 | IB_LINK_LAYER_UNSPECIFIED, | |
88 | IB_LINK_LAYER_INFINIBAND, | |
89 | IB_LINK_LAYER_ETHERNET, | |
90 | }; | |
91 | ||
1da177e4 LT |
92 | enum ib_device_cap_flags { |
93 | IB_DEVICE_RESIZE_MAX_WR = 1, | |
94 | IB_DEVICE_BAD_PKEY_CNTR = (1<<1), | |
95 | IB_DEVICE_BAD_QKEY_CNTR = (1<<2), | |
96 | IB_DEVICE_RAW_MULTI = (1<<3), | |
97 | IB_DEVICE_AUTO_PATH_MIG = (1<<4), | |
98 | IB_DEVICE_CHANGE_PHY_PORT = (1<<5), | |
99 | IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6), | |
100 | IB_DEVICE_CURR_QP_STATE_MOD = (1<<7), | |
101 | IB_DEVICE_SHUTDOWN_PORT = (1<<8), | |
102 | IB_DEVICE_INIT_TYPE = (1<<9), | |
103 | IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10), | |
104 | IB_DEVICE_SYS_IMAGE_GUID = (1<<11), | |
105 | IB_DEVICE_RC_RNR_NAK_GEN = (1<<12), | |
106 | IB_DEVICE_SRQ_RESIZE = (1<<13), | |
107 | IB_DEVICE_N_NOTIFY_CQ = (1<<14), | |
96f15c03 | 108 | IB_DEVICE_LOCAL_DMA_LKEY = (1<<15), |
0f39cf3d | 109 | IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */ |
e0605d91 EC |
110 | IB_DEVICE_MEM_WINDOW = (1<<17), |
111 | /* | |
112 | * Devices should set IB_DEVICE_UD_IP_SUM if they support | |
113 | * insertion of UDP and TCP checksum on outgoing UD IPoIB | |
114 | * messages and can verify the validity of checksum for | |
115 | * incoming messages. Setting this flag implies that the | |
116 | * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode. | |
117 | */ | |
118 | IB_DEVICE_UD_IP_CSUM = (1<<18), | |
c93570f2 | 119 | IB_DEVICE_UD_TSO = (1<<19), |
59991f94 | 120 | IB_DEVICE_XRC = (1<<20), |
00f7ec36 | 121 | IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21), |
47ee1b9f | 122 | IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22), |
7083e42e | 123 | IB_DEVICE_MEM_WINDOW_TYPE_2A = (1<<23), |
319a441d | 124 | IB_DEVICE_MEM_WINDOW_TYPE_2B = (1<<24), |
1b01d335 | 125 | IB_DEVICE_MANAGED_FLOW_STEERING = (1<<29), |
860f10a7 SG |
126 | IB_DEVICE_SIGNATURE_HANDOVER = (1<<30), |
127 | IB_DEVICE_ON_DEMAND_PAGING = (1<<31), | |
1b01d335 SG |
128 | }; |
129 | ||
130 | enum ib_signature_prot_cap { | |
131 | IB_PROT_T10DIF_TYPE_1 = 1, | |
132 | IB_PROT_T10DIF_TYPE_2 = 1 << 1, | |
133 | IB_PROT_T10DIF_TYPE_3 = 1 << 2, | |
134 | }; | |
135 | ||
136 | enum ib_signature_guard_cap { | |
137 | IB_GUARD_T10DIF_CRC = 1, | |
138 | IB_GUARD_T10DIF_CSUM = 1 << 1, | |
1da177e4 LT |
139 | }; |
140 | ||
141 | enum ib_atomic_cap { | |
142 | IB_ATOMIC_NONE, | |
143 | IB_ATOMIC_HCA, | |
144 | IB_ATOMIC_GLOB | |
145 | }; | |
146 | ||
860f10a7 SG |
147 | enum ib_odp_general_cap_bits { |
148 | IB_ODP_SUPPORT = 1 << 0, | |
149 | }; | |
150 | ||
151 | enum ib_odp_transport_cap_bits { | |
152 | IB_ODP_SUPPORT_SEND = 1 << 0, | |
153 | IB_ODP_SUPPORT_RECV = 1 << 1, | |
154 | IB_ODP_SUPPORT_WRITE = 1 << 2, | |
155 | IB_ODP_SUPPORT_READ = 1 << 3, | |
156 | IB_ODP_SUPPORT_ATOMIC = 1 << 4, | |
157 | }; | |
158 | ||
159 | struct ib_odp_caps { | |
160 | uint64_t general_caps; | |
161 | struct { | |
162 | uint32_t rc_odp_caps; | |
163 | uint32_t uc_odp_caps; | |
164 | uint32_t ud_odp_caps; | |
165 | } per_transport_caps; | |
166 | }; | |
167 | ||
1da177e4 LT |
168 | struct ib_device_attr { |
169 | u64 fw_ver; | |
97f52eb4 | 170 | __be64 sys_image_guid; |
1da177e4 LT |
171 | u64 max_mr_size; |
172 | u64 page_size_cap; | |
173 | u32 vendor_id; | |
174 | u32 vendor_part_id; | |
175 | u32 hw_ver; | |
176 | int max_qp; | |
177 | int max_qp_wr; | |
178 | int device_cap_flags; | |
179 | int max_sge; | |
180 | int max_sge_rd; | |
181 | int max_cq; | |
182 | int max_cqe; | |
183 | int max_mr; | |
184 | int max_pd; | |
185 | int max_qp_rd_atom; | |
186 | int max_ee_rd_atom; | |
187 | int max_res_rd_atom; | |
188 | int max_qp_init_rd_atom; | |
189 | int max_ee_init_rd_atom; | |
190 | enum ib_atomic_cap atomic_cap; | |
5e80ba8f | 191 | enum ib_atomic_cap masked_atomic_cap; |
1da177e4 LT |
192 | int max_ee; |
193 | int max_rdd; | |
194 | int max_mw; | |
195 | int max_raw_ipv6_qp; | |
196 | int max_raw_ethy_qp; | |
197 | int max_mcast_grp; | |
198 | int max_mcast_qp_attach; | |
199 | int max_total_mcast_qp_attach; | |
200 | int max_ah; | |
201 | int max_fmr; | |
202 | int max_map_per_fmr; | |
203 | int max_srq; | |
204 | int max_srq_wr; | |
205 | int max_srq_sge; | |
00f7ec36 | 206 | unsigned int max_fast_reg_page_list_len; |
1da177e4 LT |
207 | u16 max_pkeys; |
208 | u8 local_ca_ack_delay; | |
1b01d335 SG |
209 | int sig_prot_cap; |
210 | int sig_guard_cap; | |
860f10a7 | 211 | struct ib_odp_caps odp_caps; |
1da177e4 LT |
212 | }; |
213 | ||
214 | enum ib_mtu { | |
215 | IB_MTU_256 = 1, | |
216 | IB_MTU_512 = 2, | |
217 | IB_MTU_1024 = 3, | |
218 | IB_MTU_2048 = 4, | |
219 | IB_MTU_4096 = 5 | |
220 | }; | |
221 | ||
222 | static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) | |
223 | { | |
224 | switch (mtu) { | |
225 | case IB_MTU_256: return 256; | |
226 | case IB_MTU_512: return 512; | |
227 | case IB_MTU_1024: return 1024; | |
228 | case IB_MTU_2048: return 2048; | |
229 | case IB_MTU_4096: return 4096; | |
230 | default: return -1; | |
231 | } | |
232 | } | |
233 | ||
234 | enum ib_port_state { | |
235 | IB_PORT_NOP = 0, | |
236 | IB_PORT_DOWN = 1, | |
237 | IB_PORT_INIT = 2, | |
238 | IB_PORT_ARMED = 3, | |
239 | IB_PORT_ACTIVE = 4, | |
240 | IB_PORT_ACTIVE_DEFER = 5 | |
241 | }; | |
242 | ||
243 | enum ib_port_cap_flags { | |
244 | IB_PORT_SM = 1 << 1, | |
245 | IB_PORT_NOTICE_SUP = 1 << 2, | |
246 | IB_PORT_TRAP_SUP = 1 << 3, | |
247 | IB_PORT_OPT_IPD_SUP = 1 << 4, | |
248 | IB_PORT_AUTO_MIGR_SUP = 1 << 5, | |
249 | IB_PORT_SL_MAP_SUP = 1 << 6, | |
250 | IB_PORT_MKEY_NVRAM = 1 << 7, | |
251 | IB_PORT_PKEY_NVRAM = 1 << 8, | |
252 | IB_PORT_LED_INFO_SUP = 1 << 9, | |
253 | IB_PORT_SM_DISABLED = 1 << 10, | |
254 | IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, | |
255 | IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, | |
71eeba16 | 256 | IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, |
1da177e4 LT |
257 | IB_PORT_CM_SUP = 1 << 16, |
258 | IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, | |
259 | IB_PORT_REINIT_SUP = 1 << 18, | |
260 | IB_PORT_DEVICE_MGMT_SUP = 1 << 19, | |
261 | IB_PORT_VENDOR_CLASS_SUP = 1 << 20, | |
262 | IB_PORT_DR_NOTICE_SUP = 1 << 21, | |
263 | IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, | |
264 | IB_PORT_BOOT_MGMT_SUP = 1 << 23, | |
265 | IB_PORT_LINK_LATENCY_SUP = 1 << 24, | |
b4a26a27 MS |
266 | IB_PORT_CLIENT_REG_SUP = 1 << 25, |
267 | IB_PORT_IP_BASED_GIDS = 1 << 26 | |
1da177e4 LT |
268 | }; |
269 | ||
270 | enum ib_port_width { | |
271 | IB_WIDTH_1X = 1, | |
272 | IB_WIDTH_4X = 2, | |
273 | IB_WIDTH_8X = 4, | |
274 | IB_WIDTH_12X = 8 | |
275 | }; | |
276 | ||
277 | static inline int ib_width_enum_to_int(enum ib_port_width width) | |
278 | { | |
279 | switch (width) { | |
280 | case IB_WIDTH_1X: return 1; | |
281 | case IB_WIDTH_4X: return 4; | |
282 | case IB_WIDTH_8X: return 8; | |
283 | case IB_WIDTH_12X: return 12; | |
284 | default: return -1; | |
285 | } | |
286 | } | |
287 | ||
2e96691c OG |
288 | enum ib_port_speed { |
289 | IB_SPEED_SDR = 1, | |
290 | IB_SPEED_DDR = 2, | |
291 | IB_SPEED_QDR = 4, | |
292 | IB_SPEED_FDR10 = 8, | |
293 | IB_SPEED_FDR = 16, | |
294 | IB_SPEED_EDR = 32 | |
295 | }; | |
296 | ||
7f624d02 SW |
297 | struct ib_protocol_stats { |
298 | /* TBD... */ | |
299 | }; | |
300 | ||
301 | struct iw_protocol_stats { | |
302 | u64 ipInReceives; | |
303 | u64 ipInHdrErrors; | |
304 | u64 ipInTooBigErrors; | |
305 | u64 ipInNoRoutes; | |
306 | u64 ipInAddrErrors; | |
307 | u64 ipInUnknownProtos; | |
308 | u64 ipInTruncatedPkts; | |
309 | u64 ipInDiscards; | |
310 | u64 ipInDelivers; | |
311 | u64 ipOutForwDatagrams; | |
312 | u64 ipOutRequests; | |
313 | u64 ipOutDiscards; | |
314 | u64 ipOutNoRoutes; | |
315 | u64 ipReasmTimeout; | |
316 | u64 ipReasmReqds; | |
317 | u64 ipReasmOKs; | |
318 | u64 ipReasmFails; | |
319 | u64 ipFragOKs; | |
320 | u64 ipFragFails; | |
321 | u64 ipFragCreates; | |
322 | u64 ipInMcastPkts; | |
323 | u64 ipOutMcastPkts; | |
324 | u64 ipInBcastPkts; | |
325 | u64 ipOutBcastPkts; | |
326 | ||
327 | u64 tcpRtoAlgorithm; | |
328 | u64 tcpRtoMin; | |
329 | u64 tcpRtoMax; | |
330 | u64 tcpMaxConn; | |
331 | u64 tcpActiveOpens; | |
332 | u64 tcpPassiveOpens; | |
333 | u64 tcpAttemptFails; | |
334 | u64 tcpEstabResets; | |
335 | u64 tcpCurrEstab; | |
336 | u64 tcpInSegs; | |
337 | u64 tcpOutSegs; | |
338 | u64 tcpRetransSegs; | |
339 | u64 tcpInErrs; | |
340 | u64 tcpOutRsts; | |
341 | }; | |
342 | ||
343 | union rdma_protocol_stats { | |
344 | struct ib_protocol_stats ib; | |
345 | struct iw_protocol_stats iw; | |
346 | }; | |
347 | ||
1da177e4 LT |
348 | struct ib_port_attr { |
349 | enum ib_port_state state; | |
350 | enum ib_mtu max_mtu; | |
351 | enum ib_mtu active_mtu; | |
352 | int gid_tbl_len; | |
353 | u32 port_cap_flags; | |
354 | u32 max_msg_sz; | |
355 | u32 bad_pkey_cntr; | |
356 | u32 qkey_viol_cntr; | |
357 | u16 pkey_tbl_len; | |
358 | u16 lid; | |
359 | u16 sm_lid; | |
360 | u8 lmc; | |
361 | u8 max_vl_num; | |
362 | u8 sm_sl; | |
363 | u8 subnet_timeout; | |
364 | u8 init_type_reply; | |
365 | u8 active_width; | |
366 | u8 active_speed; | |
367 | u8 phys_state; | |
368 | }; | |
369 | ||
370 | enum ib_device_modify_flags { | |
c5bcbbb9 RD |
371 | IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0, |
372 | IB_DEVICE_MODIFY_NODE_DESC = 1 << 1 | |
1da177e4 LT |
373 | }; |
374 | ||
375 | struct ib_device_modify { | |
376 | u64 sys_image_guid; | |
c5bcbbb9 | 377 | char node_desc[64]; |
1da177e4 LT |
378 | }; |
379 | ||
380 | enum ib_port_modify_flags { | |
381 | IB_PORT_SHUTDOWN = 1, | |
382 | IB_PORT_INIT_TYPE = (1<<2), | |
383 | IB_PORT_RESET_QKEY_CNTR = (1<<3) | |
384 | }; | |
385 | ||
386 | struct ib_port_modify { | |
387 | u32 set_port_cap_mask; | |
388 | u32 clr_port_cap_mask; | |
389 | u8 init_type; | |
390 | }; | |
391 | ||
392 | enum ib_event_type { | |
393 | IB_EVENT_CQ_ERR, | |
394 | IB_EVENT_QP_FATAL, | |
395 | IB_EVENT_QP_REQ_ERR, | |
396 | IB_EVENT_QP_ACCESS_ERR, | |
397 | IB_EVENT_COMM_EST, | |
398 | IB_EVENT_SQ_DRAINED, | |
399 | IB_EVENT_PATH_MIG, | |
400 | IB_EVENT_PATH_MIG_ERR, | |
401 | IB_EVENT_DEVICE_FATAL, | |
402 | IB_EVENT_PORT_ACTIVE, | |
403 | IB_EVENT_PORT_ERR, | |
404 | IB_EVENT_LID_CHANGE, | |
405 | IB_EVENT_PKEY_CHANGE, | |
d41fcc67 RD |
406 | IB_EVENT_SM_CHANGE, |
407 | IB_EVENT_SRQ_ERR, | |
408 | IB_EVENT_SRQ_LIMIT_REACHED, | |
63942c9a | 409 | IB_EVENT_QP_LAST_WQE_REACHED, |
761d90ed OG |
410 | IB_EVENT_CLIENT_REREGISTER, |
411 | IB_EVENT_GID_CHANGE, | |
1da177e4 LT |
412 | }; |
413 | ||
414 | struct ib_event { | |
415 | struct ib_device *device; | |
416 | union { | |
417 | struct ib_cq *cq; | |
418 | struct ib_qp *qp; | |
d41fcc67 | 419 | struct ib_srq *srq; |
1da177e4 LT |
420 | u8 port_num; |
421 | } element; | |
422 | enum ib_event_type event; | |
423 | }; | |
424 | ||
425 | struct ib_event_handler { | |
426 | struct ib_device *device; | |
427 | void (*handler)(struct ib_event_handler *, struct ib_event *); | |
428 | struct list_head list; | |
429 | }; | |
430 | ||
431 | #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \ | |
432 | do { \ | |
433 | (_ptr)->device = _device; \ | |
434 | (_ptr)->handler = _handler; \ | |
435 | INIT_LIST_HEAD(&(_ptr)->list); \ | |
436 | } while (0) | |
437 | ||
438 | struct ib_global_route { | |
439 | union ib_gid dgid; | |
440 | u32 flow_label; | |
441 | u8 sgid_index; | |
442 | u8 hop_limit; | |
443 | u8 traffic_class; | |
444 | }; | |
445 | ||
513789ed | 446 | struct ib_grh { |
97f52eb4 SH |
447 | __be32 version_tclass_flow; |
448 | __be16 paylen; | |
513789ed HR |
449 | u8 next_hdr; |
450 | u8 hop_limit; | |
451 | union ib_gid sgid; | |
452 | union ib_gid dgid; | |
453 | }; | |
454 | ||
1da177e4 LT |
455 | enum { |
456 | IB_MULTICAST_QPN = 0xffffff | |
457 | }; | |
458 | ||
f3a7c66b | 459 | #define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF) |
97f52eb4 | 460 | |
1da177e4 LT |
461 | enum ib_ah_flags { |
462 | IB_AH_GRH = 1 | |
463 | }; | |
464 | ||
bf6a9e31 JM |
465 | enum ib_rate { |
466 | IB_RATE_PORT_CURRENT = 0, | |
467 | IB_RATE_2_5_GBPS = 2, | |
468 | IB_RATE_5_GBPS = 5, | |
469 | IB_RATE_10_GBPS = 3, | |
470 | IB_RATE_20_GBPS = 6, | |
471 | IB_RATE_30_GBPS = 4, | |
472 | IB_RATE_40_GBPS = 7, | |
473 | IB_RATE_60_GBPS = 8, | |
474 | IB_RATE_80_GBPS = 9, | |
71eeba16 MA |
475 | IB_RATE_120_GBPS = 10, |
476 | IB_RATE_14_GBPS = 11, | |
477 | IB_RATE_56_GBPS = 12, | |
478 | IB_RATE_112_GBPS = 13, | |
479 | IB_RATE_168_GBPS = 14, | |
480 | IB_RATE_25_GBPS = 15, | |
481 | IB_RATE_100_GBPS = 16, | |
482 | IB_RATE_200_GBPS = 17, | |
483 | IB_RATE_300_GBPS = 18 | |
bf6a9e31 JM |
484 | }; |
485 | ||
486 | /** | |
487 | * ib_rate_to_mult - Convert the IB rate enum to a multiple of the | |
488 | * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be | |
489 | * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. | |
490 | * @rate: rate to convert. | |
491 | */ | |
8385fd84 | 492 | __attribute_const__ int ib_rate_to_mult(enum ib_rate rate); |
bf6a9e31 | 493 | |
71eeba16 MA |
494 | /** |
495 | * ib_rate_to_mbps - Convert the IB rate enum to Mbps. | |
496 | * For example, IB_RATE_2_5_GBPS will be converted to 2500. | |
497 | * @rate: rate to convert. | |
498 | */ | |
8385fd84 | 499 | __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate); |
71eeba16 | 500 | |
17cd3a2d SG |
501 | enum ib_mr_create_flags { |
502 | IB_MR_SIGNATURE_EN = 1, | |
503 | }; | |
504 | ||
505 | /** | |
506 | * ib_mr_init_attr - Memory region init attributes passed to routine | |
507 | * ib_create_mr. | |
508 | * @max_reg_descriptors: max number of registration descriptors that | |
509 | * may be used with registration work requests. | |
510 | * @flags: MR creation flags bit mask. | |
511 | */ | |
512 | struct ib_mr_init_attr { | |
513 | int max_reg_descriptors; | |
514 | u32 flags; | |
515 | }; | |
516 | ||
1b01d335 | 517 | /** |
78eda2bb SG |
518 | * Signature types |
519 | * IB_SIG_TYPE_NONE: Unprotected. | |
520 | * IB_SIG_TYPE_T10_DIF: Type T10-DIF | |
1b01d335 | 521 | */ |
78eda2bb SG |
522 | enum ib_signature_type { |
523 | IB_SIG_TYPE_NONE, | |
524 | IB_SIG_TYPE_T10_DIF, | |
1b01d335 SG |
525 | }; |
526 | ||
527 | /** | |
528 | * Signature T10-DIF block-guard types | |
529 | * IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. | |
530 | * IB_T10DIF_CSUM: Corresponds to IP checksum rules. | |
531 | */ | |
532 | enum ib_t10_dif_bg_type { | |
533 | IB_T10DIF_CRC, | |
534 | IB_T10DIF_CSUM | |
535 | }; | |
536 | ||
537 | /** | |
538 | * struct ib_t10_dif_domain - Parameters specific for T10-DIF | |
539 | * domain. | |
1b01d335 SG |
540 | * @bg_type: T10-DIF block guard type (CRC|CSUM) |
541 | * @pi_interval: protection information interval. | |
542 | * @bg: seed of guard computation. | |
543 | * @app_tag: application tag of guard block | |
544 | * @ref_tag: initial guard block reference tag. | |
78eda2bb SG |
545 | * @ref_remap: Indicate wethear the reftag increments each block |
546 | * @app_escape: Indicate to skip block check if apptag=0xffff | |
547 | * @ref_escape: Indicate to skip block check if reftag=0xffffffff | |
548 | * @apptag_check_mask: check bitmask of application tag. | |
1b01d335 SG |
549 | */ |
550 | struct ib_t10_dif_domain { | |
1b01d335 SG |
551 | enum ib_t10_dif_bg_type bg_type; |
552 | u16 pi_interval; | |
553 | u16 bg; | |
554 | u16 app_tag; | |
555 | u32 ref_tag; | |
78eda2bb SG |
556 | bool ref_remap; |
557 | bool app_escape; | |
558 | bool ref_escape; | |
559 | u16 apptag_check_mask; | |
1b01d335 SG |
560 | }; |
561 | ||
562 | /** | |
563 | * struct ib_sig_domain - Parameters for signature domain | |
564 | * @sig_type: specific signauture type | |
565 | * @sig: union of all signature domain attributes that may | |
566 | * be used to set domain layout. | |
567 | */ | |
568 | struct ib_sig_domain { | |
569 | enum ib_signature_type sig_type; | |
570 | union { | |
571 | struct ib_t10_dif_domain dif; | |
572 | } sig; | |
573 | }; | |
574 | ||
575 | /** | |
576 | * struct ib_sig_attrs - Parameters for signature handover operation | |
577 | * @check_mask: bitmask for signature byte check (8 bytes) | |
578 | * @mem: memory domain layout desciptor. | |
579 | * @wire: wire domain layout desciptor. | |
580 | */ | |
581 | struct ib_sig_attrs { | |
582 | u8 check_mask; | |
583 | struct ib_sig_domain mem; | |
584 | struct ib_sig_domain wire; | |
585 | }; | |
586 | ||
587 | enum ib_sig_err_type { | |
588 | IB_SIG_BAD_GUARD, | |
589 | IB_SIG_BAD_REFTAG, | |
590 | IB_SIG_BAD_APPTAG, | |
591 | }; | |
592 | ||
593 | /** | |
594 | * struct ib_sig_err - signature error descriptor | |
595 | */ | |
596 | struct ib_sig_err { | |
597 | enum ib_sig_err_type err_type; | |
598 | u32 expected; | |
599 | u32 actual; | |
600 | u64 sig_err_offset; | |
601 | u32 key; | |
602 | }; | |
603 | ||
604 | enum ib_mr_status_check { | |
605 | IB_MR_CHECK_SIG_STATUS = 1, | |
606 | }; | |
607 | ||
608 | /** | |
609 | * struct ib_mr_status - Memory region status container | |
610 | * | |
611 | * @fail_status: Bitmask of MR checks status. For each | |
612 | * failed check a corresponding status bit is set. | |
613 | * @sig_err: Additional info for IB_MR_CEHCK_SIG_STATUS | |
614 | * failure. | |
615 | */ | |
616 | struct ib_mr_status { | |
617 | u32 fail_status; | |
618 | struct ib_sig_err sig_err; | |
619 | }; | |
620 | ||
bf6a9e31 JM |
621 | /** |
622 | * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate | |
623 | * enum. | |
624 | * @mult: multiple to convert. | |
625 | */ | |
8385fd84 | 626 | __attribute_const__ enum ib_rate mult_to_ib_rate(int mult); |
bf6a9e31 | 627 | |
1da177e4 LT |
628 | struct ib_ah_attr { |
629 | struct ib_global_route grh; | |
630 | u16 dlid; | |
631 | u8 sl; | |
632 | u8 src_path_bits; | |
633 | u8 static_rate; | |
634 | u8 ah_flags; | |
635 | u8 port_num; | |
dd5f03be MB |
636 | u8 dmac[ETH_ALEN]; |
637 | u16 vlan_id; | |
1da177e4 LT |
638 | }; |
639 | ||
640 | enum ib_wc_status { | |
641 | IB_WC_SUCCESS, | |
642 | IB_WC_LOC_LEN_ERR, | |
643 | IB_WC_LOC_QP_OP_ERR, | |
644 | IB_WC_LOC_EEC_OP_ERR, | |
645 | IB_WC_LOC_PROT_ERR, | |
646 | IB_WC_WR_FLUSH_ERR, | |
647 | IB_WC_MW_BIND_ERR, | |
648 | IB_WC_BAD_RESP_ERR, | |
649 | IB_WC_LOC_ACCESS_ERR, | |
650 | IB_WC_REM_INV_REQ_ERR, | |
651 | IB_WC_REM_ACCESS_ERR, | |
652 | IB_WC_REM_OP_ERR, | |
653 | IB_WC_RETRY_EXC_ERR, | |
654 | IB_WC_RNR_RETRY_EXC_ERR, | |
655 | IB_WC_LOC_RDD_VIOL_ERR, | |
656 | IB_WC_REM_INV_RD_REQ_ERR, | |
657 | IB_WC_REM_ABORT_ERR, | |
658 | IB_WC_INV_EECN_ERR, | |
659 | IB_WC_INV_EEC_STATE_ERR, | |
660 | IB_WC_FATAL_ERR, | |
661 | IB_WC_RESP_TIMEOUT_ERR, | |
662 | IB_WC_GENERAL_ERR | |
663 | }; | |
664 | ||
665 | enum ib_wc_opcode { | |
666 | IB_WC_SEND, | |
667 | IB_WC_RDMA_WRITE, | |
668 | IB_WC_RDMA_READ, | |
669 | IB_WC_COMP_SWAP, | |
670 | IB_WC_FETCH_ADD, | |
671 | IB_WC_BIND_MW, | |
c93570f2 | 672 | IB_WC_LSO, |
00f7ec36 SW |
673 | IB_WC_LOCAL_INV, |
674 | IB_WC_FAST_REG_MR, | |
5e80ba8f VS |
675 | IB_WC_MASKED_COMP_SWAP, |
676 | IB_WC_MASKED_FETCH_ADD, | |
1da177e4 LT |
677 | /* |
678 | * Set value of IB_WC_RECV so consumers can test if a completion is a | |
679 | * receive by testing (opcode & IB_WC_RECV). | |
680 | */ | |
681 | IB_WC_RECV = 1 << 7, | |
682 | IB_WC_RECV_RDMA_WITH_IMM | |
683 | }; | |
684 | ||
685 | enum ib_wc_flags { | |
686 | IB_WC_GRH = 1, | |
00f7ec36 SW |
687 | IB_WC_WITH_IMM = (1<<1), |
688 | IB_WC_WITH_INVALIDATE = (1<<2), | |
d927d505 | 689 | IB_WC_IP_CSUM_OK = (1<<3), |
dd5f03be MB |
690 | IB_WC_WITH_SMAC = (1<<4), |
691 | IB_WC_WITH_VLAN = (1<<5), | |
1da177e4 LT |
692 | }; |
693 | ||
694 | struct ib_wc { | |
695 | u64 wr_id; | |
696 | enum ib_wc_status status; | |
697 | enum ib_wc_opcode opcode; | |
698 | u32 vendor_err; | |
699 | u32 byte_len; | |
062dbb69 | 700 | struct ib_qp *qp; |
00f7ec36 SW |
701 | union { |
702 | __be32 imm_data; | |
703 | u32 invalidate_rkey; | |
704 | } ex; | |
1da177e4 LT |
705 | u32 src_qp; |
706 | int wc_flags; | |
707 | u16 pkey_index; | |
708 | u16 slid; | |
709 | u8 sl; | |
710 | u8 dlid_path_bits; | |
711 | u8 port_num; /* valid only for DR SMPs on switches */ | |
dd5f03be MB |
712 | u8 smac[ETH_ALEN]; |
713 | u16 vlan_id; | |
1da177e4 LT |
714 | }; |
715 | ||
ed23a727 RD |
716 | enum ib_cq_notify_flags { |
717 | IB_CQ_SOLICITED = 1 << 0, | |
718 | IB_CQ_NEXT_COMP = 1 << 1, | |
719 | IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP, | |
720 | IB_CQ_REPORT_MISSED_EVENTS = 1 << 2, | |
1da177e4 LT |
721 | }; |
722 | ||
96104eda | 723 | enum ib_srq_type { |
418d5130 SH |
724 | IB_SRQT_BASIC, |
725 | IB_SRQT_XRC | |
96104eda SH |
726 | }; |
727 | ||
d41fcc67 RD |
728 | enum ib_srq_attr_mask { |
729 | IB_SRQ_MAX_WR = 1 << 0, | |
730 | IB_SRQ_LIMIT = 1 << 1, | |
731 | }; | |
732 | ||
733 | struct ib_srq_attr { | |
734 | u32 max_wr; | |
735 | u32 max_sge; | |
736 | u32 srq_limit; | |
737 | }; | |
738 | ||
739 | struct ib_srq_init_attr { | |
740 | void (*event_handler)(struct ib_event *, void *); | |
741 | void *srq_context; | |
742 | struct ib_srq_attr attr; | |
96104eda | 743 | enum ib_srq_type srq_type; |
418d5130 SH |
744 | |
745 | union { | |
746 | struct { | |
747 | struct ib_xrcd *xrcd; | |
748 | struct ib_cq *cq; | |
749 | } xrc; | |
750 | } ext; | |
d41fcc67 RD |
751 | }; |
752 | ||
1da177e4 LT |
753 | struct ib_qp_cap { |
754 | u32 max_send_wr; | |
755 | u32 max_recv_wr; | |
756 | u32 max_send_sge; | |
757 | u32 max_recv_sge; | |
758 | u32 max_inline_data; | |
759 | }; | |
760 | ||
761 | enum ib_sig_type { | |
762 | IB_SIGNAL_ALL_WR, | |
763 | IB_SIGNAL_REQ_WR | |
764 | }; | |
765 | ||
766 | enum ib_qp_type { | |
767 | /* | |
768 | * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries | |
769 | * here (and in that order) since the MAD layer uses them as | |
770 | * indices into a 2-entry table. | |
771 | */ | |
772 | IB_QPT_SMI, | |
773 | IB_QPT_GSI, | |
774 | ||
775 | IB_QPT_RC, | |
776 | IB_QPT_UC, | |
777 | IB_QPT_UD, | |
778 | IB_QPT_RAW_IPV6, | |
b42b63cf | 779 | IB_QPT_RAW_ETHERTYPE, |
c938a616 | 780 | IB_QPT_RAW_PACKET = 8, |
b42b63cf SH |
781 | IB_QPT_XRC_INI = 9, |
782 | IB_QPT_XRC_TGT, | |
0134f16b JM |
783 | IB_QPT_MAX, |
784 | /* Reserve a range for qp types internal to the low level driver. | |
785 | * These qp types will not be visible at the IB core layer, so the | |
786 | * IB_QPT_MAX usages should not be affected in the core layer | |
787 | */ | |
788 | IB_QPT_RESERVED1 = 0x1000, | |
789 | IB_QPT_RESERVED2, | |
790 | IB_QPT_RESERVED3, | |
791 | IB_QPT_RESERVED4, | |
792 | IB_QPT_RESERVED5, | |
793 | IB_QPT_RESERVED6, | |
794 | IB_QPT_RESERVED7, | |
795 | IB_QPT_RESERVED8, | |
796 | IB_QPT_RESERVED9, | |
797 | IB_QPT_RESERVED10, | |
1da177e4 LT |
798 | }; |
799 | ||
b846f25a | 800 | enum ib_qp_create_flags { |
47ee1b9f RL |
801 | IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, |
802 | IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1, | |
90f1d1b4 | 803 | IB_QP_CREATE_NETIF_QP = 1 << 5, |
1b01d335 | 804 | IB_QP_CREATE_SIGNATURE_EN = 1 << 6, |
09b93088 | 805 | IB_QP_CREATE_USE_GFP_NOIO = 1 << 7, |
d2b57063 JM |
806 | /* reserve bits 26-31 for low level drivers' internal use */ |
807 | IB_QP_CREATE_RESERVED_START = 1 << 26, | |
808 | IB_QP_CREATE_RESERVED_END = 1 << 31, | |
b846f25a EC |
809 | }; |
810 | ||
73c40c61 YH |
811 | |
812 | /* | |
813 | * Note: users may not call ib_close_qp or ib_destroy_qp from the event_handler | |
814 | * callback to destroy the passed in QP. | |
815 | */ | |
816 | ||
1da177e4 LT |
817 | struct ib_qp_init_attr { |
818 | void (*event_handler)(struct ib_event *, void *); | |
819 | void *qp_context; | |
820 | struct ib_cq *send_cq; | |
821 | struct ib_cq *recv_cq; | |
822 | struct ib_srq *srq; | |
b42b63cf | 823 | struct ib_xrcd *xrcd; /* XRC TGT QPs only */ |
1da177e4 LT |
824 | struct ib_qp_cap cap; |
825 | enum ib_sig_type sq_sig_type; | |
826 | enum ib_qp_type qp_type; | |
b846f25a | 827 | enum ib_qp_create_flags create_flags; |
1da177e4 LT |
828 | u8 port_num; /* special QP types only */ |
829 | }; | |
830 | ||
0e0ec7e0 SH |
831 | struct ib_qp_open_attr { |
832 | void (*event_handler)(struct ib_event *, void *); | |
833 | void *qp_context; | |
834 | u32 qp_num; | |
835 | enum ib_qp_type qp_type; | |
836 | }; | |
837 | ||
1da177e4 LT |
838 | enum ib_rnr_timeout { |
839 | IB_RNR_TIMER_655_36 = 0, | |
840 | IB_RNR_TIMER_000_01 = 1, | |
841 | IB_RNR_TIMER_000_02 = 2, | |
842 | IB_RNR_TIMER_000_03 = 3, | |
843 | IB_RNR_TIMER_000_04 = 4, | |
844 | IB_RNR_TIMER_000_06 = 5, | |
845 | IB_RNR_TIMER_000_08 = 6, | |
846 | IB_RNR_TIMER_000_12 = 7, | |
847 | IB_RNR_TIMER_000_16 = 8, | |
848 | IB_RNR_TIMER_000_24 = 9, | |
849 | IB_RNR_TIMER_000_32 = 10, | |
850 | IB_RNR_TIMER_000_48 = 11, | |
851 | IB_RNR_TIMER_000_64 = 12, | |
852 | IB_RNR_TIMER_000_96 = 13, | |
853 | IB_RNR_TIMER_001_28 = 14, | |
854 | IB_RNR_TIMER_001_92 = 15, | |
855 | IB_RNR_TIMER_002_56 = 16, | |
856 | IB_RNR_TIMER_003_84 = 17, | |
857 | IB_RNR_TIMER_005_12 = 18, | |
858 | IB_RNR_TIMER_007_68 = 19, | |
859 | IB_RNR_TIMER_010_24 = 20, | |
860 | IB_RNR_TIMER_015_36 = 21, | |
861 | IB_RNR_TIMER_020_48 = 22, | |
862 | IB_RNR_TIMER_030_72 = 23, | |
863 | IB_RNR_TIMER_040_96 = 24, | |
864 | IB_RNR_TIMER_061_44 = 25, | |
865 | IB_RNR_TIMER_081_92 = 26, | |
866 | IB_RNR_TIMER_122_88 = 27, | |
867 | IB_RNR_TIMER_163_84 = 28, | |
868 | IB_RNR_TIMER_245_76 = 29, | |
869 | IB_RNR_TIMER_327_68 = 30, | |
870 | IB_RNR_TIMER_491_52 = 31 | |
871 | }; | |
872 | ||
873 | enum ib_qp_attr_mask { | |
874 | IB_QP_STATE = 1, | |
875 | IB_QP_CUR_STATE = (1<<1), | |
876 | IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), | |
877 | IB_QP_ACCESS_FLAGS = (1<<3), | |
878 | IB_QP_PKEY_INDEX = (1<<4), | |
879 | IB_QP_PORT = (1<<5), | |
880 | IB_QP_QKEY = (1<<6), | |
881 | IB_QP_AV = (1<<7), | |
882 | IB_QP_PATH_MTU = (1<<8), | |
883 | IB_QP_TIMEOUT = (1<<9), | |
884 | IB_QP_RETRY_CNT = (1<<10), | |
885 | IB_QP_RNR_RETRY = (1<<11), | |
886 | IB_QP_RQ_PSN = (1<<12), | |
887 | IB_QP_MAX_QP_RD_ATOMIC = (1<<13), | |
888 | IB_QP_ALT_PATH = (1<<14), | |
889 | IB_QP_MIN_RNR_TIMER = (1<<15), | |
890 | IB_QP_SQ_PSN = (1<<16), | |
891 | IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), | |
892 | IB_QP_PATH_MIG_STATE = (1<<18), | |
893 | IB_QP_CAP = (1<<19), | |
dd5f03be MB |
894 | IB_QP_DEST_QPN = (1<<20), |
895 | IB_QP_SMAC = (1<<21), | |
896 | IB_QP_ALT_SMAC = (1<<22), | |
897 | IB_QP_VID = (1<<23), | |
898 | IB_QP_ALT_VID = (1<<24), | |
1da177e4 LT |
899 | }; |
900 | ||
901 | enum ib_qp_state { | |
902 | IB_QPS_RESET, | |
903 | IB_QPS_INIT, | |
904 | IB_QPS_RTR, | |
905 | IB_QPS_RTS, | |
906 | IB_QPS_SQD, | |
907 | IB_QPS_SQE, | |
908 | IB_QPS_ERR | |
909 | }; | |
910 | ||
911 | enum ib_mig_state { | |
912 | IB_MIG_MIGRATED, | |
913 | IB_MIG_REARM, | |
914 | IB_MIG_ARMED | |
915 | }; | |
916 | ||
7083e42e SM |
917 | enum ib_mw_type { |
918 | IB_MW_TYPE_1 = 1, | |
919 | IB_MW_TYPE_2 = 2 | |
920 | }; | |
921 | ||
1da177e4 LT |
922 | struct ib_qp_attr { |
923 | enum ib_qp_state qp_state; | |
924 | enum ib_qp_state cur_qp_state; | |
925 | enum ib_mtu path_mtu; | |
926 | enum ib_mig_state path_mig_state; | |
927 | u32 qkey; | |
928 | u32 rq_psn; | |
929 | u32 sq_psn; | |
930 | u32 dest_qp_num; | |
931 | int qp_access_flags; | |
932 | struct ib_qp_cap cap; | |
933 | struct ib_ah_attr ah_attr; | |
934 | struct ib_ah_attr alt_ah_attr; | |
935 | u16 pkey_index; | |
936 | u16 alt_pkey_index; | |
937 | u8 en_sqd_async_notify; | |
938 | u8 sq_draining; | |
939 | u8 max_rd_atomic; | |
940 | u8 max_dest_rd_atomic; | |
941 | u8 min_rnr_timer; | |
942 | u8 port_num; | |
943 | u8 timeout; | |
944 | u8 retry_cnt; | |
945 | u8 rnr_retry; | |
946 | u8 alt_port_num; | |
947 | u8 alt_timeout; | |
dd5f03be MB |
948 | u8 smac[ETH_ALEN]; |
949 | u8 alt_smac[ETH_ALEN]; | |
950 | u16 vlan_id; | |
951 | u16 alt_vlan_id; | |
1da177e4 LT |
952 | }; |
953 | ||
954 | enum ib_wr_opcode { | |
955 | IB_WR_RDMA_WRITE, | |
956 | IB_WR_RDMA_WRITE_WITH_IMM, | |
957 | IB_WR_SEND, | |
958 | IB_WR_SEND_WITH_IMM, | |
959 | IB_WR_RDMA_READ, | |
960 | IB_WR_ATOMIC_CMP_AND_SWP, | |
c93570f2 | 961 | IB_WR_ATOMIC_FETCH_AND_ADD, |
0f39cf3d RD |
962 | IB_WR_LSO, |
963 | IB_WR_SEND_WITH_INV, | |
00f7ec36 SW |
964 | IB_WR_RDMA_READ_WITH_INV, |
965 | IB_WR_LOCAL_INV, | |
966 | IB_WR_FAST_REG_MR, | |
5e80ba8f VS |
967 | IB_WR_MASKED_ATOMIC_CMP_AND_SWP, |
968 | IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, | |
7083e42e | 969 | IB_WR_BIND_MW, |
1b01d335 | 970 | IB_WR_REG_SIG_MR, |
0134f16b JM |
971 | /* reserve values for low level drivers' internal use. |
972 | * These values will not be used at all in the ib core layer. | |
973 | */ | |
974 | IB_WR_RESERVED1 = 0xf0, | |
975 | IB_WR_RESERVED2, | |
976 | IB_WR_RESERVED3, | |
977 | IB_WR_RESERVED4, | |
978 | IB_WR_RESERVED5, | |
979 | IB_WR_RESERVED6, | |
980 | IB_WR_RESERVED7, | |
981 | IB_WR_RESERVED8, | |
982 | IB_WR_RESERVED9, | |
983 | IB_WR_RESERVED10, | |
1da177e4 LT |
984 | }; |
985 | ||
986 | enum ib_send_flags { | |
987 | IB_SEND_FENCE = 1, | |
988 | IB_SEND_SIGNALED = (1<<1), | |
989 | IB_SEND_SOLICITED = (1<<2), | |
e0605d91 | 990 | IB_SEND_INLINE = (1<<3), |
0134f16b JM |
991 | IB_SEND_IP_CSUM = (1<<4), |
992 | ||
993 | /* reserve bits 26-31 for low level drivers' internal use */ | |
994 | IB_SEND_RESERVED_START = (1 << 26), | |
995 | IB_SEND_RESERVED_END = (1 << 31), | |
1da177e4 LT |
996 | }; |
997 | ||
998 | struct ib_sge { | |
999 | u64 addr; | |
1000 | u32 length; | |
1001 | u32 lkey; | |
1002 | }; | |
1003 | ||
00f7ec36 SW |
1004 | struct ib_fast_reg_page_list { |
1005 | struct ib_device *device; | |
1006 | u64 *page_list; | |
1007 | unsigned int max_page_list_len; | |
1008 | }; | |
1009 | ||
7083e42e SM |
1010 | /** |
1011 | * struct ib_mw_bind_info - Parameters for a memory window bind operation. | |
1012 | * @mr: A memory region to bind the memory window to. | |
1013 | * @addr: The address where the memory window should begin. | |
1014 | * @length: The length of the memory window, in bytes. | |
1015 | * @mw_access_flags: Access flags from enum ib_access_flags for the window. | |
1016 | * | |
1017 | * This struct contains the shared parameters for type 1 and type 2 | |
1018 | * memory window bind operations. | |
1019 | */ | |
1020 | struct ib_mw_bind_info { | |
1021 | struct ib_mr *mr; | |
1022 | u64 addr; | |
1023 | u64 length; | |
1024 | int mw_access_flags; | |
1025 | }; | |
1026 | ||
1da177e4 LT |
1027 | struct ib_send_wr { |
1028 | struct ib_send_wr *next; | |
1029 | u64 wr_id; | |
1030 | struct ib_sge *sg_list; | |
1031 | int num_sge; | |
1032 | enum ib_wr_opcode opcode; | |
1033 | int send_flags; | |
0f39cf3d RD |
1034 | union { |
1035 | __be32 imm_data; | |
1036 | u32 invalidate_rkey; | |
1037 | } ex; | |
1da177e4 LT |
1038 | union { |
1039 | struct { | |
1040 | u64 remote_addr; | |
1041 | u32 rkey; | |
1042 | } rdma; | |
1043 | struct { | |
1044 | u64 remote_addr; | |
1045 | u64 compare_add; | |
1046 | u64 swap; | |
5e80ba8f VS |
1047 | u64 compare_add_mask; |
1048 | u64 swap_mask; | |
1da177e4 LT |
1049 | u32 rkey; |
1050 | } atomic; | |
1051 | struct { | |
1052 | struct ib_ah *ah; | |
c93570f2 EC |
1053 | void *header; |
1054 | int hlen; | |
1055 | int mss; | |
1da177e4 LT |
1056 | u32 remote_qpn; |
1057 | u32 remote_qkey; | |
1da177e4 LT |
1058 | u16 pkey_index; /* valid for GSI only */ |
1059 | u8 port_num; /* valid for DR SMPs on switch only */ | |
1060 | } ud; | |
00f7ec36 SW |
1061 | struct { |
1062 | u64 iova_start; | |
1063 | struct ib_fast_reg_page_list *page_list; | |
1064 | unsigned int page_shift; | |
1065 | unsigned int page_list_len; | |
1066 | u32 length; | |
1067 | int access_flags; | |
1068 | u32 rkey; | |
1069 | } fast_reg; | |
7083e42e SM |
1070 | struct { |
1071 | struct ib_mw *mw; | |
1072 | /* The new rkey for the memory window. */ | |
1073 | u32 rkey; | |
1074 | struct ib_mw_bind_info bind_info; | |
1075 | } bind_mw; | |
1b01d335 SG |
1076 | struct { |
1077 | struct ib_sig_attrs *sig_attrs; | |
1078 | struct ib_mr *sig_mr; | |
1079 | int access_flags; | |
1080 | struct ib_sge *prot; | |
1081 | } sig_handover; | |
1da177e4 | 1082 | } wr; |
b42b63cf | 1083 | u32 xrc_remote_srq_num; /* XRC TGT QPs only */ |
1da177e4 LT |
1084 | }; |
1085 | ||
1086 | struct ib_recv_wr { | |
1087 | struct ib_recv_wr *next; | |
1088 | u64 wr_id; | |
1089 | struct ib_sge *sg_list; | |
1090 | int num_sge; | |
1091 | }; | |
1092 | ||
1093 | enum ib_access_flags { | |
1094 | IB_ACCESS_LOCAL_WRITE = 1, | |
1095 | IB_ACCESS_REMOTE_WRITE = (1<<1), | |
1096 | IB_ACCESS_REMOTE_READ = (1<<2), | |
1097 | IB_ACCESS_REMOTE_ATOMIC = (1<<3), | |
7083e42e | 1098 | IB_ACCESS_MW_BIND = (1<<4), |
860f10a7 SG |
1099 | IB_ZERO_BASED = (1<<5), |
1100 | IB_ACCESS_ON_DEMAND = (1<<6), | |
1da177e4 LT |
1101 | }; |
1102 | ||
1103 | struct ib_phys_buf { | |
1104 | u64 addr; | |
1105 | u64 size; | |
1106 | }; | |
1107 | ||
1108 | struct ib_mr_attr { | |
1109 | struct ib_pd *pd; | |
1110 | u64 device_virt_addr; | |
1111 | u64 size; | |
1112 | int mr_access_flags; | |
1113 | u32 lkey; | |
1114 | u32 rkey; | |
1115 | }; | |
1116 | ||
1117 | enum ib_mr_rereg_flags { | |
1118 | IB_MR_REREG_TRANS = 1, | |
1119 | IB_MR_REREG_PD = (1<<1), | |
7e6edb9b MB |
1120 | IB_MR_REREG_ACCESS = (1<<2), |
1121 | IB_MR_REREG_SUPPORTED = ((IB_MR_REREG_ACCESS << 1) - 1) | |
1da177e4 LT |
1122 | }; |
1123 | ||
7083e42e SM |
1124 | /** |
1125 | * struct ib_mw_bind - Parameters for a type 1 memory window bind operation. | |
1126 | * @wr_id: Work request id. | |
1127 | * @send_flags: Flags from ib_send_flags enum. | |
1128 | * @bind_info: More parameters of the bind operation. | |
1129 | */ | |
1da177e4 | 1130 | struct ib_mw_bind { |
7083e42e SM |
1131 | u64 wr_id; |
1132 | int send_flags; | |
1133 | struct ib_mw_bind_info bind_info; | |
1da177e4 LT |
1134 | }; |
1135 | ||
1136 | struct ib_fmr_attr { | |
1137 | int max_pages; | |
1138 | int max_maps; | |
d36f34aa | 1139 | u8 page_shift; |
1da177e4 LT |
1140 | }; |
1141 | ||
e2773c06 RD |
1142 | struct ib_ucontext { |
1143 | struct ib_device *device; | |
1144 | struct list_head pd_list; | |
1145 | struct list_head mr_list; | |
1146 | struct list_head mw_list; | |
1147 | struct list_head cq_list; | |
1148 | struct list_head qp_list; | |
1149 | struct list_head srq_list; | |
1150 | struct list_head ah_list; | |
53d0bd1e | 1151 | struct list_head xrcd_list; |
436f2ad0 | 1152 | struct list_head rule_list; |
f7c6a7b5 | 1153 | int closing; |
e2773c06 RD |
1154 | }; |
1155 | ||
1156 | struct ib_uobject { | |
1157 | u64 user_handle; /* handle given to us by userspace */ | |
1158 | struct ib_ucontext *context; /* associated user context */ | |
9ead190b | 1159 | void *object; /* containing object */ |
e2773c06 | 1160 | struct list_head list; /* link to context's list */ |
b3d636b0 | 1161 | int id; /* index into kernel idr */ |
9ead190b RD |
1162 | struct kref ref; |
1163 | struct rw_semaphore mutex; /* protects .live */ | |
1164 | int live; | |
e2773c06 RD |
1165 | }; |
1166 | ||
e2773c06 | 1167 | struct ib_udata { |
309243ec | 1168 | const void __user *inbuf; |
e2773c06 RD |
1169 | void __user *outbuf; |
1170 | size_t inlen; | |
1171 | size_t outlen; | |
1172 | }; | |
1173 | ||
1da177e4 | 1174 | struct ib_pd { |
e2773c06 RD |
1175 | struct ib_device *device; |
1176 | struct ib_uobject *uobject; | |
1177 | atomic_t usecnt; /* count all resources */ | |
1da177e4 LT |
1178 | }; |
1179 | ||
59991f94 SH |
1180 | struct ib_xrcd { |
1181 | struct ib_device *device; | |
d3d72d90 | 1182 | atomic_t usecnt; /* count all exposed resources */ |
53d0bd1e | 1183 | struct inode *inode; |
d3d72d90 SH |
1184 | |
1185 | struct mutex tgt_qp_mutex; | |
1186 | struct list_head tgt_qp_list; | |
59991f94 SH |
1187 | }; |
1188 | ||
1da177e4 LT |
1189 | struct ib_ah { |
1190 | struct ib_device *device; | |
1191 | struct ib_pd *pd; | |
e2773c06 | 1192 | struct ib_uobject *uobject; |
1da177e4 LT |
1193 | }; |
1194 | ||
1195 | typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); | |
1196 | ||
1197 | struct ib_cq { | |
e2773c06 RD |
1198 | struct ib_device *device; |
1199 | struct ib_uobject *uobject; | |
1200 | ib_comp_handler comp_handler; | |
1201 | void (*event_handler)(struct ib_event *, void *); | |
4deccd6d | 1202 | void *cq_context; |
e2773c06 RD |
1203 | int cqe; |
1204 | atomic_t usecnt; /* count number of work queues */ | |
1da177e4 LT |
1205 | }; |
1206 | ||
1207 | struct ib_srq { | |
d41fcc67 RD |
1208 | struct ib_device *device; |
1209 | struct ib_pd *pd; | |
1210 | struct ib_uobject *uobject; | |
1211 | void (*event_handler)(struct ib_event *, void *); | |
1212 | void *srq_context; | |
96104eda | 1213 | enum ib_srq_type srq_type; |
1da177e4 | 1214 | atomic_t usecnt; |
418d5130 SH |
1215 | |
1216 | union { | |
1217 | struct { | |
1218 | struct ib_xrcd *xrcd; | |
1219 | struct ib_cq *cq; | |
1220 | u32 srq_num; | |
1221 | } xrc; | |
1222 | } ext; | |
1da177e4 LT |
1223 | }; |
1224 | ||
1225 | struct ib_qp { | |
1226 | struct ib_device *device; | |
1227 | struct ib_pd *pd; | |
1228 | struct ib_cq *send_cq; | |
1229 | struct ib_cq *recv_cq; | |
1230 | struct ib_srq *srq; | |
b42b63cf | 1231 | struct ib_xrcd *xrcd; /* XRC TGT QPs only */ |
d3d72d90 | 1232 | struct list_head xrcd_list; |
319a441d HHZ |
1233 | /* count times opened, mcast attaches, flow attaches */ |
1234 | atomic_t usecnt; | |
0e0ec7e0 SH |
1235 | struct list_head open_list; |
1236 | struct ib_qp *real_qp; | |
e2773c06 | 1237 | struct ib_uobject *uobject; |
1da177e4 LT |
1238 | void (*event_handler)(struct ib_event *, void *); |
1239 | void *qp_context; | |
1240 | u32 qp_num; | |
1241 | enum ib_qp_type qp_type; | |
1242 | }; | |
1243 | ||
1244 | struct ib_mr { | |
e2773c06 RD |
1245 | struct ib_device *device; |
1246 | struct ib_pd *pd; | |
1247 | struct ib_uobject *uobject; | |
1248 | u32 lkey; | |
1249 | u32 rkey; | |
1250 | atomic_t usecnt; /* count number of MWs */ | |
1da177e4 LT |
1251 | }; |
1252 | ||
1253 | struct ib_mw { | |
1254 | struct ib_device *device; | |
1255 | struct ib_pd *pd; | |
e2773c06 | 1256 | struct ib_uobject *uobject; |
1da177e4 | 1257 | u32 rkey; |
7083e42e | 1258 | enum ib_mw_type type; |
1da177e4 LT |
1259 | }; |
1260 | ||
1261 | struct ib_fmr { | |
1262 | struct ib_device *device; | |
1263 | struct ib_pd *pd; | |
1264 | struct list_head list; | |
1265 | u32 lkey; | |
1266 | u32 rkey; | |
1267 | }; | |
1268 | ||
319a441d HHZ |
1269 | /* Supported steering options */ |
1270 | enum ib_flow_attr_type { | |
1271 | /* steering according to rule specifications */ | |
1272 | IB_FLOW_ATTR_NORMAL = 0x0, | |
1273 | /* default unicast and multicast rule - | |
1274 | * receive all Eth traffic which isn't steered to any QP | |
1275 | */ | |
1276 | IB_FLOW_ATTR_ALL_DEFAULT = 0x1, | |
1277 | /* default multicast rule - | |
1278 | * receive all Eth multicast traffic which isn't steered to any QP | |
1279 | */ | |
1280 | IB_FLOW_ATTR_MC_DEFAULT = 0x2, | |
1281 | /* sniffer rule - receive all port traffic */ | |
1282 | IB_FLOW_ATTR_SNIFFER = 0x3 | |
1283 | }; | |
1284 | ||
1285 | /* Supported steering header types */ | |
1286 | enum ib_flow_spec_type { | |
1287 | /* L2 headers*/ | |
1288 | IB_FLOW_SPEC_ETH = 0x20, | |
240ae00e | 1289 | IB_FLOW_SPEC_IB = 0x22, |
319a441d HHZ |
1290 | /* L3 header*/ |
1291 | IB_FLOW_SPEC_IPV4 = 0x30, | |
1292 | /* L4 headers*/ | |
1293 | IB_FLOW_SPEC_TCP = 0x40, | |
1294 | IB_FLOW_SPEC_UDP = 0x41 | |
1295 | }; | |
240ae00e | 1296 | #define IB_FLOW_SPEC_LAYER_MASK 0xF0 |
22878dbc MB |
1297 | #define IB_FLOW_SPEC_SUPPORT_LAYERS 4 |
1298 | ||
319a441d HHZ |
1299 | /* Flow steering rule priority is set according to it's domain. |
1300 | * Lower domain value means higher priority. | |
1301 | */ | |
1302 | enum ib_flow_domain { | |
1303 | IB_FLOW_DOMAIN_USER, | |
1304 | IB_FLOW_DOMAIN_ETHTOOL, | |
1305 | IB_FLOW_DOMAIN_RFS, | |
1306 | IB_FLOW_DOMAIN_NIC, | |
1307 | IB_FLOW_DOMAIN_NUM /* Must be last */ | |
1308 | }; | |
1309 | ||
1310 | struct ib_flow_eth_filter { | |
1311 | u8 dst_mac[6]; | |
1312 | u8 src_mac[6]; | |
1313 | __be16 ether_type; | |
1314 | __be16 vlan_tag; | |
1315 | }; | |
1316 | ||
1317 | struct ib_flow_spec_eth { | |
1318 | enum ib_flow_spec_type type; | |
1319 | u16 size; | |
1320 | struct ib_flow_eth_filter val; | |
1321 | struct ib_flow_eth_filter mask; | |
1322 | }; | |
1323 | ||
240ae00e MB |
1324 | struct ib_flow_ib_filter { |
1325 | __be16 dlid; | |
1326 | __u8 sl; | |
1327 | }; | |
1328 | ||
1329 | struct ib_flow_spec_ib { | |
1330 | enum ib_flow_spec_type type; | |
1331 | u16 size; | |
1332 | struct ib_flow_ib_filter val; | |
1333 | struct ib_flow_ib_filter mask; | |
1334 | }; | |
1335 | ||
319a441d HHZ |
1336 | struct ib_flow_ipv4_filter { |
1337 | __be32 src_ip; | |
1338 | __be32 dst_ip; | |
1339 | }; | |
1340 | ||
1341 | struct ib_flow_spec_ipv4 { | |
1342 | enum ib_flow_spec_type type; | |
1343 | u16 size; | |
1344 | struct ib_flow_ipv4_filter val; | |
1345 | struct ib_flow_ipv4_filter mask; | |
1346 | }; | |
1347 | ||
1348 | struct ib_flow_tcp_udp_filter { | |
1349 | __be16 dst_port; | |
1350 | __be16 src_port; | |
1351 | }; | |
1352 | ||
1353 | struct ib_flow_spec_tcp_udp { | |
1354 | enum ib_flow_spec_type type; | |
1355 | u16 size; | |
1356 | struct ib_flow_tcp_udp_filter val; | |
1357 | struct ib_flow_tcp_udp_filter mask; | |
1358 | }; | |
1359 | ||
1360 | union ib_flow_spec { | |
1361 | struct { | |
1362 | enum ib_flow_spec_type type; | |
1363 | u16 size; | |
1364 | }; | |
1365 | struct ib_flow_spec_eth eth; | |
240ae00e | 1366 | struct ib_flow_spec_ib ib; |
319a441d HHZ |
1367 | struct ib_flow_spec_ipv4 ipv4; |
1368 | struct ib_flow_spec_tcp_udp tcp_udp; | |
1369 | }; | |
1370 | ||
1371 | struct ib_flow_attr { | |
1372 | enum ib_flow_attr_type type; | |
1373 | u16 size; | |
1374 | u16 priority; | |
1375 | u32 flags; | |
1376 | u8 num_of_specs; | |
1377 | u8 port; | |
1378 | /* Following are the optional layers according to user request | |
1379 | * struct ib_flow_spec_xxx | |
1380 | * struct ib_flow_spec_yyy | |
1381 | */ | |
1382 | }; | |
1383 | ||
1384 | struct ib_flow { | |
1385 | struct ib_qp *qp; | |
1386 | struct ib_uobject *uobject; | |
1387 | }; | |
1388 | ||
1da177e4 LT |
1389 | struct ib_mad; |
1390 | struct ib_grh; | |
1391 | ||
1392 | enum ib_process_mad_flags { | |
1393 | IB_MAD_IGNORE_MKEY = 1, | |
1394 | IB_MAD_IGNORE_BKEY = 2, | |
1395 | IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY | |
1396 | }; | |
1397 | ||
1398 | enum ib_mad_result { | |
1399 | IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */ | |
1400 | IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */ | |
1401 | IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */ | |
1402 | IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */ | |
1403 | }; | |
1404 | ||
1405 | #define IB_DEVICE_NAME_MAX 64 | |
1406 | ||
1407 | struct ib_cache { | |
1408 | rwlock_t lock; | |
1409 | struct ib_event_handler event_handler; | |
1410 | struct ib_pkey_cache **pkey_cache; | |
1411 | struct ib_gid_cache **gid_cache; | |
6fb9cdbf | 1412 | u8 *lmc_cache; |
1da177e4 LT |
1413 | }; |
1414 | ||
9b513090 RC |
1415 | struct ib_dma_mapping_ops { |
1416 | int (*mapping_error)(struct ib_device *dev, | |
1417 | u64 dma_addr); | |
1418 | u64 (*map_single)(struct ib_device *dev, | |
1419 | void *ptr, size_t size, | |
1420 | enum dma_data_direction direction); | |
1421 | void (*unmap_single)(struct ib_device *dev, | |
1422 | u64 addr, size_t size, | |
1423 | enum dma_data_direction direction); | |
1424 | u64 (*map_page)(struct ib_device *dev, | |
1425 | struct page *page, unsigned long offset, | |
1426 | size_t size, | |
1427 | enum dma_data_direction direction); | |
1428 | void (*unmap_page)(struct ib_device *dev, | |
1429 | u64 addr, size_t size, | |
1430 | enum dma_data_direction direction); | |
1431 | int (*map_sg)(struct ib_device *dev, | |
1432 | struct scatterlist *sg, int nents, | |
1433 | enum dma_data_direction direction); | |
1434 | void (*unmap_sg)(struct ib_device *dev, | |
1435 | struct scatterlist *sg, int nents, | |
1436 | enum dma_data_direction direction); | |
9b513090 RC |
1437 | void (*sync_single_for_cpu)(struct ib_device *dev, |
1438 | u64 dma_handle, | |
1439 | size_t size, | |
4deccd6d | 1440 | enum dma_data_direction dir); |
9b513090 RC |
1441 | void (*sync_single_for_device)(struct ib_device *dev, |
1442 | u64 dma_handle, | |
1443 | size_t size, | |
1444 | enum dma_data_direction dir); | |
1445 | void *(*alloc_coherent)(struct ib_device *dev, | |
1446 | size_t size, | |
1447 | u64 *dma_handle, | |
1448 | gfp_t flag); | |
1449 | void (*free_coherent)(struct ib_device *dev, | |
1450 | size_t size, void *cpu_addr, | |
1451 | u64 dma_handle); | |
1452 | }; | |
1453 | ||
07ebafba TT |
1454 | struct iw_cm_verbs; |
1455 | ||
1da177e4 LT |
1456 | struct ib_device { |
1457 | struct device *dma_device; | |
1458 | ||
1459 | char name[IB_DEVICE_NAME_MAX]; | |
1460 | ||
1461 | struct list_head event_handler_list; | |
1462 | spinlock_t event_handler_lock; | |
1463 | ||
17a55f79 | 1464 | spinlock_t client_data_lock; |
1da177e4 LT |
1465 | struct list_head core_list; |
1466 | struct list_head client_data_list; | |
1da177e4 LT |
1467 | |
1468 | struct ib_cache cache; | |
5eb620c8 YE |
1469 | int *pkey_tbl_len; |
1470 | int *gid_tbl_len; | |
1da177e4 | 1471 | |
f4fd0b22 MT |
1472 | int num_comp_vectors; |
1473 | ||
07ebafba TT |
1474 | struct iw_cm_verbs *iwcm; |
1475 | ||
7f624d02 SW |
1476 | int (*get_protocol_stats)(struct ib_device *device, |
1477 | union rdma_protocol_stats *stats); | |
1da177e4 LT |
1478 | int (*query_device)(struct ib_device *device, |
1479 | struct ib_device_attr *device_attr); | |
1480 | int (*query_port)(struct ib_device *device, | |
1481 | u8 port_num, | |
1482 | struct ib_port_attr *port_attr); | |
a3f5adaf EC |
1483 | enum rdma_link_layer (*get_link_layer)(struct ib_device *device, |
1484 | u8 port_num); | |
1da177e4 LT |
1485 | int (*query_gid)(struct ib_device *device, |
1486 | u8 port_num, int index, | |
1487 | union ib_gid *gid); | |
1488 | int (*query_pkey)(struct ib_device *device, | |
1489 | u8 port_num, u16 index, u16 *pkey); | |
1490 | int (*modify_device)(struct ib_device *device, | |
1491 | int device_modify_mask, | |
1492 | struct ib_device_modify *device_modify); | |
1493 | int (*modify_port)(struct ib_device *device, | |
1494 | u8 port_num, int port_modify_mask, | |
1495 | struct ib_port_modify *port_modify); | |
e2773c06 RD |
1496 | struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, |
1497 | struct ib_udata *udata); | |
1498 | int (*dealloc_ucontext)(struct ib_ucontext *context); | |
1499 | int (*mmap)(struct ib_ucontext *context, | |
1500 | struct vm_area_struct *vma); | |
1501 | struct ib_pd * (*alloc_pd)(struct ib_device *device, | |
1502 | struct ib_ucontext *context, | |
1503 | struct ib_udata *udata); | |
1da177e4 LT |
1504 | int (*dealloc_pd)(struct ib_pd *pd); |
1505 | struct ib_ah * (*create_ah)(struct ib_pd *pd, | |
1506 | struct ib_ah_attr *ah_attr); | |
1507 | int (*modify_ah)(struct ib_ah *ah, | |
1508 | struct ib_ah_attr *ah_attr); | |
1509 | int (*query_ah)(struct ib_ah *ah, | |
1510 | struct ib_ah_attr *ah_attr); | |
1511 | int (*destroy_ah)(struct ib_ah *ah); | |
d41fcc67 RD |
1512 | struct ib_srq * (*create_srq)(struct ib_pd *pd, |
1513 | struct ib_srq_init_attr *srq_init_attr, | |
1514 | struct ib_udata *udata); | |
1515 | int (*modify_srq)(struct ib_srq *srq, | |
1516 | struct ib_srq_attr *srq_attr, | |
9bc57e2d RC |
1517 | enum ib_srq_attr_mask srq_attr_mask, |
1518 | struct ib_udata *udata); | |
d41fcc67 RD |
1519 | int (*query_srq)(struct ib_srq *srq, |
1520 | struct ib_srq_attr *srq_attr); | |
1521 | int (*destroy_srq)(struct ib_srq *srq); | |
1522 | int (*post_srq_recv)(struct ib_srq *srq, | |
1523 | struct ib_recv_wr *recv_wr, | |
1524 | struct ib_recv_wr **bad_recv_wr); | |
1da177e4 | 1525 | struct ib_qp * (*create_qp)(struct ib_pd *pd, |
e2773c06 RD |
1526 | struct ib_qp_init_attr *qp_init_attr, |
1527 | struct ib_udata *udata); | |
1da177e4 LT |
1528 | int (*modify_qp)(struct ib_qp *qp, |
1529 | struct ib_qp_attr *qp_attr, | |
9bc57e2d RC |
1530 | int qp_attr_mask, |
1531 | struct ib_udata *udata); | |
1da177e4 LT |
1532 | int (*query_qp)(struct ib_qp *qp, |
1533 | struct ib_qp_attr *qp_attr, | |
1534 | int qp_attr_mask, | |
1535 | struct ib_qp_init_attr *qp_init_attr); | |
1536 | int (*destroy_qp)(struct ib_qp *qp); | |
1537 | int (*post_send)(struct ib_qp *qp, | |
1538 | struct ib_send_wr *send_wr, | |
1539 | struct ib_send_wr **bad_send_wr); | |
1540 | int (*post_recv)(struct ib_qp *qp, | |
1541 | struct ib_recv_wr *recv_wr, | |
1542 | struct ib_recv_wr **bad_recv_wr); | |
e2773c06 | 1543 | struct ib_cq * (*create_cq)(struct ib_device *device, int cqe, |
f4fd0b22 | 1544 | int comp_vector, |
e2773c06 RD |
1545 | struct ib_ucontext *context, |
1546 | struct ib_udata *udata); | |
2dd57162 EC |
1547 | int (*modify_cq)(struct ib_cq *cq, u16 cq_count, |
1548 | u16 cq_period); | |
1da177e4 | 1549 | int (*destroy_cq)(struct ib_cq *cq); |
33b9b3ee RD |
1550 | int (*resize_cq)(struct ib_cq *cq, int cqe, |
1551 | struct ib_udata *udata); | |
1da177e4 LT |
1552 | int (*poll_cq)(struct ib_cq *cq, int num_entries, |
1553 | struct ib_wc *wc); | |
1554 | int (*peek_cq)(struct ib_cq *cq, int wc_cnt); | |
1555 | int (*req_notify_cq)(struct ib_cq *cq, | |
ed23a727 | 1556 | enum ib_cq_notify_flags flags); |
1da177e4 LT |
1557 | int (*req_ncomp_notif)(struct ib_cq *cq, |
1558 | int wc_cnt); | |
1559 | struct ib_mr * (*get_dma_mr)(struct ib_pd *pd, | |
1560 | int mr_access_flags); | |
1561 | struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd, | |
1562 | struct ib_phys_buf *phys_buf_array, | |
1563 | int num_phys_buf, | |
1564 | int mr_access_flags, | |
1565 | u64 *iova_start); | |
e2773c06 | 1566 | struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, |
f7c6a7b5 RD |
1567 | u64 start, u64 length, |
1568 | u64 virt_addr, | |
e2773c06 RD |
1569 | int mr_access_flags, |
1570 | struct ib_udata *udata); | |
7e6edb9b MB |
1571 | int (*rereg_user_mr)(struct ib_mr *mr, |
1572 | int flags, | |
1573 | u64 start, u64 length, | |
1574 | u64 virt_addr, | |
1575 | int mr_access_flags, | |
1576 | struct ib_pd *pd, | |
1577 | struct ib_udata *udata); | |
1da177e4 LT |
1578 | int (*query_mr)(struct ib_mr *mr, |
1579 | struct ib_mr_attr *mr_attr); | |
1580 | int (*dereg_mr)(struct ib_mr *mr); | |
17cd3a2d SG |
1581 | int (*destroy_mr)(struct ib_mr *mr); |
1582 | struct ib_mr * (*create_mr)(struct ib_pd *pd, | |
1583 | struct ib_mr_init_attr *mr_init_attr); | |
00f7ec36 SW |
1584 | struct ib_mr * (*alloc_fast_reg_mr)(struct ib_pd *pd, |
1585 | int max_page_list_len); | |
1586 | struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device, | |
1587 | int page_list_len); | |
1588 | void (*free_fast_reg_page_list)(struct ib_fast_reg_page_list *page_list); | |
1da177e4 LT |
1589 | int (*rereg_phys_mr)(struct ib_mr *mr, |
1590 | int mr_rereg_mask, | |
1591 | struct ib_pd *pd, | |
1592 | struct ib_phys_buf *phys_buf_array, | |
1593 | int num_phys_buf, | |
1594 | int mr_access_flags, | |
1595 | u64 *iova_start); | |
7083e42e SM |
1596 | struct ib_mw * (*alloc_mw)(struct ib_pd *pd, |
1597 | enum ib_mw_type type); | |
1da177e4 LT |
1598 | int (*bind_mw)(struct ib_qp *qp, |
1599 | struct ib_mw *mw, | |
1600 | struct ib_mw_bind *mw_bind); | |
1601 | int (*dealloc_mw)(struct ib_mw *mw); | |
1602 | struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd, | |
1603 | int mr_access_flags, | |
1604 | struct ib_fmr_attr *fmr_attr); | |
1605 | int (*map_phys_fmr)(struct ib_fmr *fmr, | |
1606 | u64 *page_list, int list_len, | |
1607 | u64 iova); | |
1608 | int (*unmap_fmr)(struct list_head *fmr_list); | |
1609 | int (*dealloc_fmr)(struct ib_fmr *fmr); | |
1610 | int (*attach_mcast)(struct ib_qp *qp, | |
1611 | union ib_gid *gid, | |
1612 | u16 lid); | |
1613 | int (*detach_mcast)(struct ib_qp *qp, | |
1614 | union ib_gid *gid, | |
1615 | u16 lid); | |
1616 | int (*process_mad)(struct ib_device *device, | |
1617 | int process_mad_flags, | |
1618 | u8 port_num, | |
1619 | struct ib_wc *in_wc, | |
1620 | struct ib_grh *in_grh, | |
1621 | struct ib_mad *in_mad, | |
1622 | struct ib_mad *out_mad); | |
59991f94 SH |
1623 | struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device, |
1624 | struct ib_ucontext *ucontext, | |
1625 | struct ib_udata *udata); | |
1626 | int (*dealloc_xrcd)(struct ib_xrcd *xrcd); | |
319a441d HHZ |
1627 | struct ib_flow * (*create_flow)(struct ib_qp *qp, |
1628 | struct ib_flow_attr | |
1629 | *flow_attr, | |
1630 | int domain); | |
1631 | int (*destroy_flow)(struct ib_flow *flow_id); | |
1b01d335 SG |
1632 | int (*check_mr_status)(struct ib_mr *mr, u32 check_mask, |
1633 | struct ib_mr_status *mr_status); | |
1da177e4 | 1634 | |
9b513090 RC |
1635 | struct ib_dma_mapping_ops *dma_ops; |
1636 | ||
e2773c06 | 1637 | struct module *owner; |
f4e91eb4 | 1638 | struct device dev; |
35be0681 | 1639 | struct kobject *ports_parent; |
1da177e4 LT |
1640 | struct list_head port_list; |
1641 | ||
1642 | enum { | |
1643 | IB_DEV_UNINITIALIZED, | |
1644 | IB_DEV_REGISTERED, | |
1645 | IB_DEV_UNREGISTERED | |
1646 | } reg_state; | |
1647 | ||
274c0891 | 1648 | int uverbs_abi_ver; |
17a55f79 | 1649 | u64 uverbs_cmd_mask; |
f21519b2 | 1650 | u64 uverbs_ex_cmd_mask; |
274c0891 | 1651 | |
c5bcbbb9 | 1652 | char node_desc[64]; |
cf311cd4 | 1653 | __be64 node_guid; |
96f15c03 | 1654 | u32 local_dma_lkey; |
1da177e4 LT |
1655 | u8 node_type; |
1656 | u8 phys_port_cnt; | |
1657 | }; | |
1658 | ||
1659 | struct ib_client { | |
1660 | char *name; | |
1661 | void (*add) (struct ib_device *); | |
1662 | void (*remove)(struct ib_device *); | |
1663 | ||
1664 | struct list_head list; | |
1665 | }; | |
1666 | ||
1667 | struct ib_device *ib_alloc_device(size_t size); | |
1668 | void ib_dealloc_device(struct ib_device *device); | |
1669 | ||
9a6edb60 RC |
1670 | int ib_register_device(struct ib_device *device, |
1671 | int (*port_callback)(struct ib_device *, | |
1672 | u8, struct kobject *)); | |
1da177e4 LT |
1673 | void ib_unregister_device(struct ib_device *device); |
1674 | ||
1675 | int ib_register_client (struct ib_client *client); | |
1676 | void ib_unregister_client(struct ib_client *client); | |
1677 | ||
1678 | void *ib_get_client_data(struct ib_device *device, struct ib_client *client); | |
1679 | void ib_set_client_data(struct ib_device *device, struct ib_client *client, | |
1680 | void *data); | |
1681 | ||
e2773c06 RD |
1682 | static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) |
1683 | { | |
1684 | return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; | |
1685 | } | |
1686 | ||
1687 | static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) | |
1688 | { | |
5a77abf9 EC |
1689 | size_t copy_sz; |
1690 | ||
1691 | copy_sz = min_t(size_t, len, udata->outlen); | |
1692 | return copy_to_user(udata->outbuf, src, copy_sz) ? -EFAULT : 0; | |
e2773c06 RD |
1693 | } |
1694 | ||
8a51866f RD |
1695 | /** |
1696 | * ib_modify_qp_is_ok - Check that the supplied attribute mask | |
1697 | * contains all required attributes and no attributes not allowed for | |
1698 | * the given QP state transition. | |
1699 | * @cur_state: Current QP state | |
1700 | * @next_state: Next QP state | |
1701 | * @type: QP type | |
1702 | * @mask: Mask of supplied QP attributes | |
dd5f03be | 1703 | * @ll : link layer of port |
8a51866f RD |
1704 | * |
1705 | * This function is a helper function that a low-level driver's | |
1706 | * modify_qp method can use to validate the consumer's input. It | |
1707 | * checks that cur_state and next_state are valid QP states, that a | |
1708 | * transition from cur_state to next_state is allowed by the IB spec, | |
1709 | * and that the attribute mask supplied is allowed for the transition. | |
1710 | */ | |
1711 | int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, | |
dd5f03be MB |
1712 | enum ib_qp_type type, enum ib_qp_attr_mask mask, |
1713 | enum rdma_link_layer ll); | |
8a51866f | 1714 | |
1da177e4 LT |
1715 | int ib_register_event_handler (struct ib_event_handler *event_handler); |
1716 | int ib_unregister_event_handler(struct ib_event_handler *event_handler); | |
1717 | void ib_dispatch_event(struct ib_event *event); | |
1718 | ||
1719 | int ib_query_device(struct ib_device *device, | |
1720 | struct ib_device_attr *device_attr); | |
1721 | ||
1722 | int ib_query_port(struct ib_device *device, | |
1723 | u8 port_num, struct ib_port_attr *port_attr); | |
1724 | ||
a3f5adaf EC |
1725 | enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, |
1726 | u8 port_num); | |
1727 | ||
1da177e4 LT |
1728 | int ib_query_gid(struct ib_device *device, |
1729 | u8 port_num, int index, union ib_gid *gid); | |
1730 | ||
1731 | int ib_query_pkey(struct ib_device *device, | |
1732 | u8 port_num, u16 index, u16 *pkey); | |
1733 | ||
1734 | int ib_modify_device(struct ib_device *device, | |
1735 | int device_modify_mask, | |
1736 | struct ib_device_modify *device_modify); | |
1737 | ||
1738 | int ib_modify_port(struct ib_device *device, | |
1739 | u8 port_num, int port_modify_mask, | |
1740 | struct ib_port_modify *port_modify); | |
1741 | ||
5eb620c8 YE |
1742 | int ib_find_gid(struct ib_device *device, union ib_gid *gid, |
1743 | u8 *port_num, u16 *index); | |
1744 | ||
1745 | int ib_find_pkey(struct ib_device *device, | |
1746 | u8 port_num, u16 pkey, u16 *index); | |
1747 | ||
1da177e4 LT |
1748 | /** |
1749 | * ib_alloc_pd - Allocates an unused protection domain. | |
1750 | * @device: The device on which to allocate the protection domain. | |
1751 | * | |
1752 | * A protection domain object provides an association between QPs, shared | |
1753 | * receive queues, address handles, memory regions, and memory windows. | |
1754 | */ | |
1755 | struct ib_pd *ib_alloc_pd(struct ib_device *device); | |
1756 | ||
1757 | /** | |
1758 | * ib_dealloc_pd - Deallocates a protection domain. | |
1759 | * @pd: The protection domain to deallocate. | |
1760 | */ | |
1761 | int ib_dealloc_pd(struct ib_pd *pd); | |
1762 | ||
1763 | /** | |
1764 | * ib_create_ah - Creates an address handle for the given address vector. | |
1765 | * @pd: The protection domain associated with the address handle. | |
1766 | * @ah_attr: The attributes of the address vector. | |
1767 | * | |
1768 | * The address handle is used to reference a local or global destination | |
1769 | * in all UD QP post sends. | |
1770 | */ | |
1771 | struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); | |
1772 | ||
4e00d694 SH |
1773 | /** |
1774 | * ib_init_ah_from_wc - Initializes address handle attributes from a | |
1775 | * work completion. | |
1776 | * @device: Device on which the received message arrived. | |
1777 | * @port_num: Port on which the received message arrived. | |
1778 | * @wc: Work completion associated with the received message. | |
1779 | * @grh: References the received global route header. This parameter is | |
1780 | * ignored unless the work completion indicates that the GRH is valid. | |
1781 | * @ah_attr: Returned attributes that can be used when creating an address | |
1782 | * handle for replying to the message. | |
1783 | */ | |
1784 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, | |
1785 | struct ib_grh *grh, struct ib_ah_attr *ah_attr); | |
1786 | ||
513789ed HR |
1787 | /** |
1788 | * ib_create_ah_from_wc - Creates an address handle associated with the | |
1789 | * sender of the specified work completion. | |
1790 | * @pd: The protection domain associated with the address handle. | |
1791 | * @wc: Work completion information associated with a received message. | |
1792 | * @grh: References the received global route header. This parameter is | |
1793 | * ignored unless the work completion indicates that the GRH is valid. | |
1794 | * @port_num: The outbound port number to associate with the address. | |
1795 | * | |
1796 | * The address handle is used to reference a local or global destination | |
1797 | * in all UD QP post sends. | |
1798 | */ | |
1799 | struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, | |
1800 | struct ib_grh *grh, u8 port_num); | |
1801 | ||
1da177e4 LT |
1802 | /** |
1803 | * ib_modify_ah - Modifies the address vector associated with an address | |
1804 | * handle. | |
1805 | * @ah: The address handle to modify. | |
1806 | * @ah_attr: The new address vector attributes to associate with the | |
1807 | * address handle. | |
1808 | */ | |
1809 | int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); | |
1810 | ||
1811 | /** | |
1812 | * ib_query_ah - Queries the address vector associated with an address | |
1813 | * handle. | |
1814 | * @ah: The address handle to query. | |
1815 | * @ah_attr: The address vector attributes associated with the address | |
1816 | * handle. | |
1817 | */ | |
1818 | int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); | |
1819 | ||
1820 | /** | |
1821 | * ib_destroy_ah - Destroys an address handle. | |
1822 | * @ah: The address handle to destroy. | |
1823 | */ | |
1824 | int ib_destroy_ah(struct ib_ah *ah); | |
1825 | ||
d41fcc67 RD |
1826 | /** |
1827 | * ib_create_srq - Creates a SRQ associated with the specified protection | |
1828 | * domain. | |
1829 | * @pd: The protection domain associated with the SRQ. | |
abb6e9ba DB |
1830 | * @srq_init_attr: A list of initial attributes required to create the |
1831 | * SRQ. If SRQ creation succeeds, then the attributes are updated to | |
1832 | * the actual capabilities of the created SRQ. | |
d41fcc67 RD |
1833 | * |
1834 | * srq_attr->max_wr and srq_attr->max_sge are read the determine the | |
1835 | * requested size of the SRQ, and set to the actual values allocated | |
1836 | * on return. If ib_create_srq() succeeds, then max_wr and max_sge | |
1837 | * will always be at least as large as the requested values. | |
1838 | */ | |
1839 | struct ib_srq *ib_create_srq(struct ib_pd *pd, | |
1840 | struct ib_srq_init_attr *srq_init_attr); | |
1841 | ||
1842 | /** | |
1843 | * ib_modify_srq - Modifies the attributes for the specified SRQ. | |
1844 | * @srq: The SRQ to modify. | |
1845 | * @srq_attr: On input, specifies the SRQ attributes to modify. On output, | |
1846 | * the current values of selected SRQ attributes are returned. | |
1847 | * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ | |
1848 | * are being modified. | |
1849 | * | |
1850 | * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or | |
1851 | * IB_SRQ_LIMIT to set the SRQ's limit and request notification when | |
1852 | * the number of receives queued drops below the limit. | |
1853 | */ | |
1854 | int ib_modify_srq(struct ib_srq *srq, | |
1855 | struct ib_srq_attr *srq_attr, | |
1856 | enum ib_srq_attr_mask srq_attr_mask); | |
1857 | ||
1858 | /** | |
1859 | * ib_query_srq - Returns the attribute list and current values for the | |
1860 | * specified SRQ. | |
1861 | * @srq: The SRQ to query. | |
1862 | * @srq_attr: The attributes of the specified SRQ. | |
1863 | */ | |
1864 | int ib_query_srq(struct ib_srq *srq, | |
1865 | struct ib_srq_attr *srq_attr); | |
1866 | ||
1867 | /** | |
1868 | * ib_destroy_srq - Destroys the specified SRQ. | |
1869 | * @srq: The SRQ to destroy. | |
1870 | */ | |
1871 | int ib_destroy_srq(struct ib_srq *srq); | |
1872 | ||
1873 | /** | |
1874 | * ib_post_srq_recv - Posts a list of work requests to the specified SRQ. | |
1875 | * @srq: The SRQ to post the work request on. | |
1876 | * @recv_wr: A list of work requests to post on the receive queue. | |
1877 | * @bad_recv_wr: On an immediate failure, this parameter will reference | |
1878 | * the work request that failed to be posted on the QP. | |
1879 | */ | |
1880 | static inline int ib_post_srq_recv(struct ib_srq *srq, | |
1881 | struct ib_recv_wr *recv_wr, | |
1882 | struct ib_recv_wr **bad_recv_wr) | |
1883 | { | |
1884 | return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr); | |
1885 | } | |
1886 | ||
1da177e4 LT |
1887 | /** |
1888 | * ib_create_qp - Creates a QP associated with the specified protection | |
1889 | * domain. | |
1890 | * @pd: The protection domain associated with the QP. | |
abb6e9ba DB |
1891 | * @qp_init_attr: A list of initial attributes required to create the |
1892 | * QP. If QP creation succeeds, then the attributes are updated to | |
1893 | * the actual capabilities of the created QP. | |
1da177e4 LT |
1894 | */ |
1895 | struct ib_qp *ib_create_qp(struct ib_pd *pd, | |
1896 | struct ib_qp_init_attr *qp_init_attr); | |
1897 | ||
1898 | /** | |
1899 | * ib_modify_qp - Modifies the attributes for the specified QP and then | |
1900 | * transitions the QP to the given state. | |
1901 | * @qp: The QP to modify. | |
1902 | * @qp_attr: On input, specifies the QP attributes to modify. On output, | |
1903 | * the current values of selected QP attributes are returned. | |
1904 | * @qp_attr_mask: A bit-mask used to specify which attributes of the QP | |
1905 | * are being modified. | |
1906 | */ | |
1907 | int ib_modify_qp(struct ib_qp *qp, | |
1908 | struct ib_qp_attr *qp_attr, | |
1909 | int qp_attr_mask); | |
1910 | ||
1911 | /** | |
1912 | * ib_query_qp - Returns the attribute list and current values for the | |
1913 | * specified QP. | |
1914 | * @qp: The QP to query. | |
1915 | * @qp_attr: The attributes of the specified QP. | |
1916 | * @qp_attr_mask: A bit-mask used to select specific attributes to query. | |
1917 | * @qp_init_attr: Additional attributes of the selected QP. | |
1918 | * | |
1919 | * The qp_attr_mask may be used to limit the query to gathering only the | |
1920 | * selected attributes. | |
1921 | */ | |
1922 | int ib_query_qp(struct ib_qp *qp, | |
1923 | struct ib_qp_attr *qp_attr, | |
1924 | int qp_attr_mask, | |
1925 | struct ib_qp_init_attr *qp_init_attr); | |
1926 | ||
1927 | /** | |
1928 | * ib_destroy_qp - Destroys the specified QP. | |
1929 | * @qp: The QP to destroy. | |
1930 | */ | |
1931 | int ib_destroy_qp(struct ib_qp *qp); | |
1932 | ||
d3d72d90 | 1933 | /** |
0e0ec7e0 SH |
1934 | * ib_open_qp - Obtain a reference to an existing sharable QP. |
1935 | * @xrcd - XRC domain | |
1936 | * @qp_open_attr: Attributes identifying the QP to open. | |
1937 | * | |
1938 | * Returns a reference to a sharable QP. | |
1939 | */ | |
1940 | struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd, | |
1941 | struct ib_qp_open_attr *qp_open_attr); | |
1942 | ||
1943 | /** | |
1944 | * ib_close_qp - Release an external reference to a QP. | |
d3d72d90 SH |
1945 | * @qp: The QP handle to release |
1946 | * | |
0e0ec7e0 SH |
1947 | * The opened QP handle is released by the caller. The underlying |
1948 | * shared QP is not destroyed until all internal references are released. | |
d3d72d90 | 1949 | */ |
0e0ec7e0 | 1950 | int ib_close_qp(struct ib_qp *qp); |
d3d72d90 | 1951 | |
1da177e4 LT |
1952 | /** |
1953 | * ib_post_send - Posts a list of work requests to the send queue of | |
1954 | * the specified QP. | |
1955 | * @qp: The QP to post the work request on. | |
1956 | * @send_wr: A list of work requests to post on the send queue. | |
1957 | * @bad_send_wr: On an immediate failure, this parameter will reference | |
1958 | * the work request that failed to be posted on the QP. | |
55464d46 BVA |
1959 | * |
1960 | * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate | |
1961 | * error is returned, the QP state shall not be affected, | |
1962 | * ib_post_send() will return an immediate error after queueing any | |
1963 | * earlier work requests in the list. | |
1da177e4 LT |
1964 | */ |
1965 | static inline int ib_post_send(struct ib_qp *qp, | |
1966 | struct ib_send_wr *send_wr, | |
1967 | struct ib_send_wr **bad_send_wr) | |
1968 | { | |
1969 | return qp->device->post_send(qp, send_wr, bad_send_wr); | |
1970 | } | |
1971 | ||
1972 | /** | |
1973 | * ib_post_recv - Posts a list of work requests to the receive queue of | |
1974 | * the specified QP. | |
1975 | * @qp: The QP to post the work request on. | |
1976 | * @recv_wr: A list of work requests to post on the receive queue. | |
1977 | * @bad_recv_wr: On an immediate failure, this parameter will reference | |
1978 | * the work request that failed to be posted on the QP. | |
1979 | */ | |
1980 | static inline int ib_post_recv(struct ib_qp *qp, | |
1981 | struct ib_recv_wr *recv_wr, | |
1982 | struct ib_recv_wr **bad_recv_wr) | |
1983 | { | |
1984 | return qp->device->post_recv(qp, recv_wr, bad_recv_wr); | |
1985 | } | |
1986 | ||
1987 | /** | |
1988 | * ib_create_cq - Creates a CQ on the specified device. | |
1989 | * @device: The device on which to create the CQ. | |
1990 | * @comp_handler: A user-specified callback that is invoked when a | |
1991 | * completion event occurs on the CQ. | |
1992 | * @event_handler: A user-specified callback that is invoked when an | |
1993 | * asynchronous event not associated with a completion occurs on the CQ. | |
1994 | * @cq_context: Context associated with the CQ returned to the user via | |
1995 | * the associated completion and event handlers. | |
1996 | * @cqe: The minimum size of the CQ. | |
f4fd0b22 MT |
1997 | * @comp_vector - Completion vector used to signal completion events. |
1998 | * Must be >= 0 and < context->num_comp_vectors. | |
1da177e4 LT |
1999 | * |
2000 | * Users can examine the cq structure to determine the actual CQ size. | |
2001 | */ | |
2002 | struct ib_cq *ib_create_cq(struct ib_device *device, | |
2003 | ib_comp_handler comp_handler, | |
2004 | void (*event_handler)(struct ib_event *, void *), | |
f4fd0b22 | 2005 | void *cq_context, int cqe, int comp_vector); |
1da177e4 LT |
2006 | |
2007 | /** | |
2008 | * ib_resize_cq - Modifies the capacity of the CQ. | |
2009 | * @cq: The CQ to resize. | |
2010 | * @cqe: The minimum size of the CQ. | |
2011 | * | |
2012 | * Users can examine the cq structure to determine the actual CQ size. | |
2013 | */ | |
2014 | int ib_resize_cq(struct ib_cq *cq, int cqe); | |
2015 | ||
2dd57162 EC |
2016 | /** |
2017 | * ib_modify_cq - Modifies moderation params of the CQ | |
2018 | * @cq: The CQ to modify. | |
2019 | * @cq_count: number of CQEs that will trigger an event | |
2020 | * @cq_period: max period of time in usec before triggering an event | |
2021 | * | |
2022 | */ | |
2023 | int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); | |
2024 | ||
1da177e4 LT |
2025 | /** |
2026 | * ib_destroy_cq - Destroys the specified CQ. | |
2027 | * @cq: The CQ to destroy. | |
2028 | */ | |
2029 | int ib_destroy_cq(struct ib_cq *cq); | |
2030 | ||
2031 | /** | |
2032 | * ib_poll_cq - poll a CQ for completion(s) | |
2033 | * @cq:the CQ being polled | |
2034 | * @num_entries:maximum number of completions to return | |
2035 | * @wc:array of at least @num_entries &struct ib_wc where completions | |
2036 | * will be returned | |
2037 | * | |
2038 | * Poll a CQ for (possibly multiple) completions. If the return value | |
2039 | * is < 0, an error occurred. If the return value is >= 0, it is the | |
2040 | * number of completions returned. If the return value is | |
2041 | * non-negative and < num_entries, then the CQ was emptied. | |
2042 | */ | |
2043 | static inline int ib_poll_cq(struct ib_cq *cq, int num_entries, | |
2044 | struct ib_wc *wc) | |
2045 | { | |
2046 | return cq->device->poll_cq(cq, num_entries, wc); | |
2047 | } | |
2048 | ||
2049 | /** | |
2050 | * ib_peek_cq - Returns the number of unreaped completions currently | |
2051 | * on the specified CQ. | |
2052 | * @cq: The CQ to peek. | |
2053 | * @wc_cnt: A minimum number of unreaped completions to check for. | |
2054 | * | |
2055 | * If the number of unreaped completions is greater than or equal to wc_cnt, | |
2056 | * this function returns wc_cnt, otherwise, it returns the actual number of | |
2057 | * unreaped completions. | |
2058 | */ | |
2059 | int ib_peek_cq(struct ib_cq *cq, int wc_cnt); | |
2060 | ||
2061 | /** | |
2062 | * ib_req_notify_cq - Request completion notification on a CQ. | |
2063 | * @cq: The CQ to generate an event for. | |
ed23a727 RD |
2064 | * @flags: |
2065 | * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP | |
2066 | * to request an event on the next solicited event or next work | |
2067 | * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS | |
2068 | * may also be |ed in to request a hint about missed events, as | |
2069 | * described below. | |
2070 | * | |
2071 | * Return Value: | |
2072 | * < 0 means an error occurred while requesting notification | |
2073 | * == 0 means notification was requested successfully, and if | |
2074 | * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events | |
2075 | * were missed and it is safe to wait for another event. In | |
2076 | * this case is it guaranteed that any work completions added | |
2077 | * to the CQ since the last CQ poll will trigger a completion | |
2078 | * notification event. | |
2079 | * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed | |
2080 | * in. It means that the consumer must poll the CQ again to | |
2081 | * make sure it is empty to avoid missing an event because of a | |
2082 | * race between requesting notification and an entry being | |
2083 | * added to the CQ. This return value means it is possible | |
2084 | * (but not guaranteed) that a work completion has been added | |
2085 | * to the CQ since the last poll without triggering a | |
2086 | * completion notification event. | |
1da177e4 LT |
2087 | */ |
2088 | static inline int ib_req_notify_cq(struct ib_cq *cq, | |
ed23a727 | 2089 | enum ib_cq_notify_flags flags) |
1da177e4 | 2090 | { |
ed23a727 | 2091 | return cq->device->req_notify_cq(cq, flags); |
1da177e4 LT |
2092 | } |
2093 | ||
2094 | /** | |
2095 | * ib_req_ncomp_notif - Request completion notification when there are | |
2096 | * at least the specified number of unreaped completions on the CQ. | |
2097 | * @cq: The CQ to generate an event for. | |
2098 | * @wc_cnt: The number of unreaped completions that should be on the | |
2099 | * CQ before an event is generated. | |
2100 | */ | |
2101 | static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt) | |
2102 | { | |
2103 | return cq->device->req_ncomp_notif ? | |
2104 | cq->device->req_ncomp_notif(cq, wc_cnt) : | |
2105 | -ENOSYS; | |
2106 | } | |
2107 | ||
2108 | /** | |
2109 | * ib_get_dma_mr - Returns a memory region for system memory that is | |
2110 | * usable for DMA. | |
2111 | * @pd: The protection domain associated with the memory region. | |
2112 | * @mr_access_flags: Specifies the memory access rights. | |
9b513090 RC |
2113 | * |
2114 | * Note that the ib_dma_*() functions defined below must be used | |
2115 | * to create/destroy addresses used with the Lkey or Rkey returned | |
2116 | * by ib_get_dma_mr(). | |
1da177e4 LT |
2117 | */ |
2118 | struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags); | |
2119 | ||
9b513090 RC |
2120 | /** |
2121 | * ib_dma_mapping_error - check a DMA addr for error | |
2122 | * @dev: The device for which the dma_addr was created | |
2123 | * @dma_addr: The DMA address to check | |
2124 | */ | |
2125 | static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) | |
2126 | { | |
d1998ef3 BC |
2127 | if (dev->dma_ops) |
2128 | return dev->dma_ops->mapping_error(dev, dma_addr); | |
8d8bb39b | 2129 | return dma_mapping_error(dev->dma_device, dma_addr); |
9b513090 RC |
2130 | } |
2131 | ||
2132 | /** | |
2133 | * ib_dma_map_single - Map a kernel virtual address to DMA address | |
2134 | * @dev: The device for which the dma_addr is to be created | |
2135 | * @cpu_addr: The kernel virtual address | |
2136 | * @size: The size of the region in bytes | |
2137 | * @direction: The direction of the DMA | |
2138 | */ | |
2139 | static inline u64 ib_dma_map_single(struct ib_device *dev, | |
2140 | void *cpu_addr, size_t size, | |
2141 | enum dma_data_direction direction) | |
2142 | { | |
d1998ef3 BC |
2143 | if (dev->dma_ops) |
2144 | return dev->dma_ops->map_single(dev, cpu_addr, size, direction); | |
2145 | return dma_map_single(dev->dma_device, cpu_addr, size, direction); | |
9b513090 RC |
2146 | } |
2147 | ||
2148 | /** | |
2149 | * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single() | |
2150 | * @dev: The device for which the DMA address was created | |
2151 | * @addr: The DMA address | |
2152 | * @size: The size of the region in bytes | |
2153 | * @direction: The direction of the DMA | |
2154 | */ | |
2155 | static inline void ib_dma_unmap_single(struct ib_device *dev, | |
2156 | u64 addr, size_t size, | |
2157 | enum dma_data_direction direction) | |
2158 | { | |
d1998ef3 BC |
2159 | if (dev->dma_ops) |
2160 | dev->dma_ops->unmap_single(dev, addr, size, direction); | |
2161 | else | |
9b513090 RC |
2162 | dma_unmap_single(dev->dma_device, addr, size, direction); |
2163 | } | |
2164 | ||
cb9fbc5c AK |
2165 | static inline u64 ib_dma_map_single_attrs(struct ib_device *dev, |
2166 | void *cpu_addr, size_t size, | |
2167 | enum dma_data_direction direction, | |
2168 | struct dma_attrs *attrs) | |
2169 | { | |
2170 | return dma_map_single_attrs(dev->dma_device, cpu_addr, size, | |
2171 | direction, attrs); | |
2172 | } | |
2173 | ||
2174 | static inline void ib_dma_unmap_single_attrs(struct ib_device *dev, | |
2175 | u64 addr, size_t size, | |
2176 | enum dma_data_direction direction, | |
2177 | struct dma_attrs *attrs) | |
2178 | { | |
2179 | return dma_unmap_single_attrs(dev->dma_device, addr, size, | |
2180 | direction, attrs); | |
2181 | } | |
2182 | ||
9b513090 RC |
2183 | /** |
2184 | * ib_dma_map_page - Map a physical page to DMA address | |
2185 | * @dev: The device for which the dma_addr is to be created | |
2186 | * @page: The page to be mapped | |
2187 | * @offset: The offset within the page | |
2188 | * @size: The size of the region in bytes | |
2189 | * @direction: The direction of the DMA | |
2190 | */ | |
2191 | static inline u64 ib_dma_map_page(struct ib_device *dev, | |
2192 | struct page *page, | |
2193 | unsigned long offset, | |
2194 | size_t size, | |
2195 | enum dma_data_direction direction) | |
2196 | { | |
d1998ef3 BC |
2197 | if (dev->dma_ops) |
2198 | return dev->dma_ops->map_page(dev, page, offset, size, direction); | |
2199 | return dma_map_page(dev->dma_device, page, offset, size, direction); | |
9b513090 RC |
2200 | } |
2201 | ||
2202 | /** | |
2203 | * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page() | |
2204 | * @dev: The device for which the DMA address was created | |
2205 | * @addr: The DMA address | |
2206 | * @size: The size of the region in bytes | |
2207 | * @direction: The direction of the DMA | |
2208 | */ | |
2209 | static inline void ib_dma_unmap_page(struct ib_device *dev, | |
2210 | u64 addr, size_t size, | |
2211 | enum dma_data_direction direction) | |
2212 | { | |
d1998ef3 BC |
2213 | if (dev->dma_ops) |
2214 | dev->dma_ops->unmap_page(dev, addr, size, direction); | |
2215 | else | |
9b513090 RC |
2216 | dma_unmap_page(dev->dma_device, addr, size, direction); |
2217 | } | |
2218 | ||
2219 | /** | |
2220 | * ib_dma_map_sg - Map a scatter/gather list to DMA addresses | |
2221 | * @dev: The device for which the DMA addresses are to be created | |
2222 | * @sg: The array of scatter/gather entries | |
2223 | * @nents: The number of scatter/gather entries | |
2224 | * @direction: The direction of the DMA | |
2225 | */ | |
2226 | static inline int ib_dma_map_sg(struct ib_device *dev, | |
2227 | struct scatterlist *sg, int nents, | |
2228 | enum dma_data_direction direction) | |
2229 | { | |
d1998ef3 BC |
2230 | if (dev->dma_ops) |
2231 | return dev->dma_ops->map_sg(dev, sg, nents, direction); | |
2232 | return dma_map_sg(dev->dma_device, sg, nents, direction); | |
9b513090 RC |
2233 | } |
2234 | ||
2235 | /** | |
2236 | * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses | |
2237 | * @dev: The device for which the DMA addresses were created | |
2238 | * @sg: The array of scatter/gather entries | |
2239 | * @nents: The number of scatter/gather entries | |
2240 | * @direction: The direction of the DMA | |
2241 | */ | |
2242 | static inline void ib_dma_unmap_sg(struct ib_device *dev, | |
2243 | struct scatterlist *sg, int nents, | |
2244 | enum dma_data_direction direction) | |
2245 | { | |
d1998ef3 BC |
2246 | if (dev->dma_ops) |
2247 | dev->dma_ops->unmap_sg(dev, sg, nents, direction); | |
2248 | else | |
9b513090 RC |
2249 | dma_unmap_sg(dev->dma_device, sg, nents, direction); |
2250 | } | |
2251 | ||
cb9fbc5c AK |
2252 | static inline int ib_dma_map_sg_attrs(struct ib_device *dev, |
2253 | struct scatterlist *sg, int nents, | |
2254 | enum dma_data_direction direction, | |
2255 | struct dma_attrs *attrs) | |
2256 | { | |
2257 | return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs); | |
2258 | } | |
2259 | ||
2260 | static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, | |
2261 | struct scatterlist *sg, int nents, | |
2262 | enum dma_data_direction direction, | |
2263 | struct dma_attrs *attrs) | |
2264 | { | |
2265 | dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs); | |
2266 | } | |
9b513090 RC |
2267 | /** |
2268 | * ib_sg_dma_address - Return the DMA address from a scatter/gather entry | |
2269 | * @dev: The device for which the DMA addresses were created | |
2270 | * @sg: The scatter/gather entry | |
ea58a595 MM |
2271 | * |
2272 | * Note: this function is obsolete. To do: change all occurrences of | |
2273 | * ib_sg_dma_address() into sg_dma_address(). | |
9b513090 RC |
2274 | */ |
2275 | static inline u64 ib_sg_dma_address(struct ib_device *dev, | |
2276 | struct scatterlist *sg) | |
2277 | { | |
d1998ef3 | 2278 | return sg_dma_address(sg); |
9b513090 RC |
2279 | } |
2280 | ||
2281 | /** | |
2282 | * ib_sg_dma_len - Return the DMA length from a scatter/gather entry | |
2283 | * @dev: The device for which the DMA addresses were created | |
2284 | * @sg: The scatter/gather entry | |
ea58a595 MM |
2285 | * |
2286 | * Note: this function is obsolete. To do: change all occurrences of | |
2287 | * ib_sg_dma_len() into sg_dma_len(). | |
9b513090 RC |
2288 | */ |
2289 | static inline unsigned int ib_sg_dma_len(struct ib_device *dev, | |
2290 | struct scatterlist *sg) | |
2291 | { | |
d1998ef3 | 2292 | return sg_dma_len(sg); |
9b513090 RC |
2293 | } |
2294 | ||
2295 | /** | |
2296 | * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU | |
2297 | * @dev: The device for which the DMA address was created | |
2298 | * @addr: The DMA address | |
2299 | * @size: The size of the region in bytes | |
2300 | * @dir: The direction of the DMA | |
2301 | */ | |
2302 | static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev, | |
2303 | u64 addr, | |
2304 | size_t size, | |
2305 | enum dma_data_direction dir) | |
2306 | { | |
d1998ef3 BC |
2307 | if (dev->dma_ops) |
2308 | dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir); | |
2309 | else | |
9b513090 RC |
2310 | dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); |
2311 | } | |
2312 | ||
2313 | /** | |
2314 | * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device | |
2315 | * @dev: The device for which the DMA address was created | |
2316 | * @addr: The DMA address | |
2317 | * @size: The size of the region in bytes | |
2318 | * @dir: The direction of the DMA | |
2319 | */ | |
2320 | static inline void ib_dma_sync_single_for_device(struct ib_device *dev, | |
2321 | u64 addr, | |
2322 | size_t size, | |
2323 | enum dma_data_direction dir) | |
2324 | { | |
d1998ef3 BC |
2325 | if (dev->dma_ops) |
2326 | dev->dma_ops->sync_single_for_device(dev, addr, size, dir); | |
2327 | else | |
9b513090 RC |
2328 | dma_sync_single_for_device(dev->dma_device, addr, size, dir); |
2329 | } | |
2330 | ||
2331 | /** | |
2332 | * ib_dma_alloc_coherent - Allocate memory and map it for DMA | |
2333 | * @dev: The device for which the DMA address is requested | |
2334 | * @size: The size of the region to allocate in bytes | |
2335 | * @dma_handle: A pointer for returning the DMA address of the region | |
2336 | * @flag: memory allocator flags | |
2337 | */ | |
2338 | static inline void *ib_dma_alloc_coherent(struct ib_device *dev, | |
2339 | size_t size, | |
2340 | u64 *dma_handle, | |
2341 | gfp_t flag) | |
2342 | { | |
d1998ef3 BC |
2343 | if (dev->dma_ops) |
2344 | return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag); | |
c59a3da1 RD |
2345 | else { |
2346 | dma_addr_t handle; | |
2347 | void *ret; | |
2348 | ||
2349 | ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag); | |
2350 | *dma_handle = handle; | |
2351 | return ret; | |
2352 | } | |
9b513090 RC |
2353 | } |
2354 | ||
2355 | /** | |
2356 | * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent() | |
2357 | * @dev: The device for which the DMA addresses were allocated | |
2358 | * @size: The size of the region | |
2359 | * @cpu_addr: the address returned by ib_dma_alloc_coherent() | |
2360 | * @dma_handle: the DMA address returned by ib_dma_alloc_coherent() | |
2361 | */ | |
2362 | static inline void ib_dma_free_coherent(struct ib_device *dev, | |
2363 | size_t size, void *cpu_addr, | |
2364 | u64 dma_handle) | |
2365 | { | |
d1998ef3 BC |
2366 | if (dev->dma_ops) |
2367 | dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); | |
2368 | else | |
9b513090 RC |
2369 | dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle); |
2370 | } | |
2371 | ||
1da177e4 LT |
2372 | /** |
2373 | * ib_reg_phys_mr - Prepares a virtually addressed memory region for use | |
2374 | * by an HCA. | |
2375 | * @pd: The protection domain associated assigned to the registered region. | |
2376 | * @phys_buf_array: Specifies a list of physical buffers to use in the | |
2377 | * memory region. | |
2378 | * @num_phys_buf: Specifies the size of the phys_buf_array. | |
2379 | * @mr_access_flags: Specifies the memory access rights. | |
2380 | * @iova_start: The offset of the region's starting I/O virtual address. | |
2381 | */ | |
2382 | struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd, | |
2383 | struct ib_phys_buf *phys_buf_array, | |
2384 | int num_phys_buf, | |
2385 | int mr_access_flags, | |
2386 | u64 *iova_start); | |
2387 | ||
2388 | /** | |
2389 | * ib_rereg_phys_mr - Modifies the attributes of an existing memory region. | |
2390 | * Conceptually, this call performs the functions deregister memory region | |
2391 | * followed by register physical memory region. Where possible, | |
2392 | * resources are reused instead of deallocated and reallocated. | |
2393 | * @mr: The memory region to modify. | |
2394 | * @mr_rereg_mask: A bit-mask used to indicate which of the following | |
2395 | * properties of the memory region are being modified. | |
2396 | * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies | |
2397 | * the new protection domain to associated with the memory region, | |
2398 | * otherwise, this parameter is ignored. | |
2399 | * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this | |
2400 | * field specifies a list of physical buffers to use in the new | |
2401 | * translation, otherwise, this parameter is ignored. | |
2402 | * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this | |
2403 | * field specifies the size of the phys_buf_array, otherwise, this | |
2404 | * parameter is ignored. | |
2405 | * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this | |
2406 | * field specifies the new memory access rights, otherwise, this | |
2407 | * parameter is ignored. | |
2408 | * @iova_start: The offset of the region's starting I/O virtual address. | |
2409 | */ | |
2410 | int ib_rereg_phys_mr(struct ib_mr *mr, | |
2411 | int mr_rereg_mask, | |
2412 | struct ib_pd *pd, | |
2413 | struct ib_phys_buf *phys_buf_array, | |
2414 | int num_phys_buf, | |
2415 | int mr_access_flags, | |
2416 | u64 *iova_start); | |
2417 | ||
2418 | /** | |
2419 | * ib_query_mr - Retrieves information about a specific memory region. | |
2420 | * @mr: The memory region to retrieve information about. | |
2421 | * @mr_attr: The attributes of the specified memory region. | |
2422 | */ | |
2423 | int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr); | |
2424 | ||
2425 | /** | |
2426 | * ib_dereg_mr - Deregisters a memory region and removes it from the | |
2427 | * HCA translation table. | |
2428 | * @mr: The memory region to deregister. | |
7083e42e SM |
2429 | * |
2430 | * This function can fail, if the memory region has memory windows bound to it. | |
1da177e4 LT |
2431 | */ |
2432 | int ib_dereg_mr(struct ib_mr *mr); | |
2433 | ||
17cd3a2d SG |
2434 | |
2435 | /** | |
2436 | * ib_create_mr - Allocates a memory region that may be used for | |
2437 | * signature handover operations. | |
2438 | * @pd: The protection domain associated with the region. | |
2439 | * @mr_init_attr: memory region init attributes. | |
2440 | */ | |
2441 | struct ib_mr *ib_create_mr(struct ib_pd *pd, | |
2442 | struct ib_mr_init_attr *mr_init_attr); | |
2443 | ||
2444 | /** | |
2445 | * ib_destroy_mr - Destroys a memory region that was created using | |
2446 | * ib_create_mr and removes it from HW translation tables. | |
2447 | * @mr: The memory region to destroy. | |
2448 | * | |
2449 | * This function can fail, if the memory region has memory windows bound to it. | |
2450 | */ | |
2451 | int ib_destroy_mr(struct ib_mr *mr); | |
2452 | ||
00f7ec36 SW |
2453 | /** |
2454 | * ib_alloc_fast_reg_mr - Allocates memory region usable with the | |
2455 | * IB_WR_FAST_REG_MR send work request. | |
2456 | * @pd: The protection domain associated with the region. | |
2457 | * @max_page_list_len: requested max physical buffer list length to be | |
2458 | * used with fast register work requests for this MR. | |
2459 | */ | |
2460 | struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); | |
2461 | ||
2462 | /** | |
2463 | * ib_alloc_fast_reg_page_list - Allocates a page list array | |
2464 | * @device - ib device pointer. | |
2465 | * @page_list_len - size of the page list array to be allocated. | |
2466 | * | |
2467 | * This allocates and returns a struct ib_fast_reg_page_list * and a | |
2468 | * page_list array that is at least page_list_len in size. The actual | |
2469 | * size is returned in max_page_list_len. The caller is responsible | |
2470 | * for initializing the contents of the page_list array before posting | |
2471 | * a send work request with the IB_WC_FAST_REG_MR opcode. | |
2472 | * | |
2473 | * The page_list array entries must be translated using one of the | |
2474 | * ib_dma_*() functions just like the addresses passed to | |
2475 | * ib_map_phys_fmr(). Once the ib_post_send() is issued, the struct | |
2476 | * ib_fast_reg_page_list must not be modified by the caller until the | |
2477 | * IB_WC_FAST_REG_MR work request completes. | |
2478 | */ | |
2479 | struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list( | |
2480 | struct ib_device *device, int page_list_len); | |
2481 | ||
2482 | /** | |
2483 | * ib_free_fast_reg_page_list - Deallocates a previously allocated | |
2484 | * page list array. | |
2485 | * @page_list - struct ib_fast_reg_page_list pointer to be deallocated. | |
2486 | */ | |
2487 | void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list); | |
2488 | ||
2489 | /** | |
2490 | * ib_update_fast_reg_key - updates the key portion of the fast_reg MR | |
2491 | * R_Key and L_Key. | |
2492 | * @mr - struct ib_mr pointer to be updated. | |
2493 | * @newkey - new key to be used. | |
2494 | */ | |
2495 | static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey) | |
2496 | { | |
2497 | mr->lkey = (mr->lkey & 0xffffff00) | newkey; | |
2498 | mr->rkey = (mr->rkey & 0xffffff00) | newkey; | |
2499 | } | |
2500 | ||
7083e42e SM |
2501 | /** |
2502 | * ib_inc_rkey - increments the key portion of the given rkey. Can be used | |
2503 | * for calculating a new rkey for type 2 memory windows. | |
2504 | * @rkey - the rkey to increment. | |
2505 | */ | |
2506 | static inline u32 ib_inc_rkey(u32 rkey) | |
2507 | { | |
2508 | const u32 mask = 0x000000ff; | |
2509 | return ((rkey + 1) & mask) | (rkey & ~mask); | |
2510 | } | |
2511 | ||
1da177e4 LT |
2512 | /** |
2513 | * ib_alloc_mw - Allocates a memory window. | |
2514 | * @pd: The protection domain associated with the memory window. | |
7083e42e | 2515 | * @type: The type of the memory window (1 or 2). |
1da177e4 | 2516 | */ |
7083e42e | 2517 | struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type); |
1da177e4 LT |
2518 | |
2519 | /** | |
2520 | * ib_bind_mw - Posts a work request to the send queue of the specified | |
2521 | * QP, which binds the memory window to the given address range and | |
2522 | * remote access attributes. | |
2523 | * @qp: QP to post the bind work request on. | |
2524 | * @mw: The memory window to bind. | |
2525 | * @mw_bind: Specifies information about the memory window, including | |
2526 | * its address range, remote access rights, and associated memory region. | |
7083e42e SM |
2527 | * |
2528 | * If there is no immediate error, the function will update the rkey member | |
2529 | * of the mw parameter to its new value. The bind operation can still fail | |
2530 | * asynchronously. | |
1da177e4 LT |
2531 | */ |
2532 | static inline int ib_bind_mw(struct ib_qp *qp, | |
2533 | struct ib_mw *mw, | |
2534 | struct ib_mw_bind *mw_bind) | |
2535 | { | |
2536 | /* XXX reference counting in corresponding MR? */ | |
2537 | return mw->device->bind_mw ? | |
2538 | mw->device->bind_mw(qp, mw, mw_bind) : | |
2539 | -ENOSYS; | |
2540 | } | |
2541 | ||
2542 | /** | |
2543 | * ib_dealloc_mw - Deallocates a memory window. | |
2544 | * @mw: The memory window to deallocate. | |
2545 | */ | |
2546 | int ib_dealloc_mw(struct ib_mw *mw); | |
2547 | ||
2548 | /** | |
2549 | * ib_alloc_fmr - Allocates a unmapped fast memory region. | |
2550 | * @pd: The protection domain associated with the unmapped region. | |
2551 | * @mr_access_flags: Specifies the memory access rights. | |
2552 | * @fmr_attr: Attributes of the unmapped region. | |
2553 | * | |
2554 | * A fast memory region must be mapped before it can be used as part of | |
2555 | * a work request. | |
2556 | */ | |
2557 | struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd, | |
2558 | int mr_access_flags, | |
2559 | struct ib_fmr_attr *fmr_attr); | |
2560 | ||
2561 | /** | |
2562 | * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region. | |
2563 | * @fmr: The fast memory region to associate with the pages. | |
2564 | * @page_list: An array of physical pages to map to the fast memory region. | |
2565 | * @list_len: The number of pages in page_list. | |
2566 | * @iova: The I/O virtual address to use with the mapped region. | |
2567 | */ | |
2568 | static inline int ib_map_phys_fmr(struct ib_fmr *fmr, | |
2569 | u64 *page_list, int list_len, | |
2570 | u64 iova) | |
2571 | { | |
2572 | return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova); | |
2573 | } | |
2574 | ||
2575 | /** | |
2576 | * ib_unmap_fmr - Removes the mapping from a list of fast memory regions. | |
2577 | * @fmr_list: A linked list of fast memory regions to unmap. | |
2578 | */ | |
2579 | int ib_unmap_fmr(struct list_head *fmr_list); | |
2580 | ||
2581 | /** | |
2582 | * ib_dealloc_fmr - Deallocates a fast memory region. | |
2583 | * @fmr: The fast memory region to deallocate. | |
2584 | */ | |
2585 | int ib_dealloc_fmr(struct ib_fmr *fmr); | |
2586 | ||
2587 | /** | |
2588 | * ib_attach_mcast - Attaches the specified QP to a multicast group. | |
2589 | * @qp: QP to attach to the multicast group. The QP must be type | |
2590 | * IB_QPT_UD. | |
2591 | * @gid: Multicast group GID. | |
2592 | * @lid: Multicast group LID in host byte order. | |
2593 | * | |
2594 | * In order to send and receive multicast packets, subnet | |
2595 | * administration must have created the multicast group and configured | |
2596 | * the fabric appropriately. The port associated with the specified | |
2597 | * QP must also be a member of the multicast group. | |
2598 | */ | |
2599 | int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); | |
2600 | ||
2601 | /** | |
2602 | * ib_detach_mcast - Detaches the specified QP from a multicast group. | |
2603 | * @qp: QP to detach from the multicast group. | |
2604 | * @gid: Multicast group GID. | |
2605 | * @lid: Multicast group LID in host byte order. | |
2606 | */ | |
2607 | int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); | |
2608 | ||
59991f94 SH |
2609 | /** |
2610 | * ib_alloc_xrcd - Allocates an XRC domain. | |
2611 | * @device: The device on which to allocate the XRC domain. | |
2612 | */ | |
2613 | struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device); | |
2614 | ||
2615 | /** | |
2616 | * ib_dealloc_xrcd - Deallocates an XRC domain. | |
2617 | * @xrcd: The XRC domain to deallocate. | |
2618 | */ | |
2619 | int ib_dealloc_xrcd(struct ib_xrcd *xrcd); | |
2620 | ||
319a441d HHZ |
2621 | struct ib_flow *ib_create_flow(struct ib_qp *qp, |
2622 | struct ib_flow_attr *flow_attr, int domain); | |
2623 | int ib_destroy_flow(struct ib_flow *flow_id); | |
2624 | ||
1c636f80 EC |
2625 | static inline int ib_check_mr_access(int flags) |
2626 | { | |
2627 | /* | |
2628 | * Local write permission is required if remote write or | |
2629 | * remote atomic permission is also requested. | |
2630 | */ | |
2631 | if (flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) && | |
2632 | !(flags & IB_ACCESS_LOCAL_WRITE)) | |
2633 | return -EINVAL; | |
2634 | ||
2635 | return 0; | |
2636 | } | |
2637 | ||
1b01d335 SG |
2638 | /** |
2639 | * ib_check_mr_status: lightweight check of MR status. | |
2640 | * This routine may provide status checks on a selected | |
2641 | * ib_mr. first use is for signature status check. | |
2642 | * | |
2643 | * @mr: A memory region. | |
2644 | * @check_mask: Bitmask of which checks to perform from | |
2645 | * ib_mr_status_check enumeration. | |
2646 | * @mr_status: The container of relevant status checks. | |
2647 | * failed checks will be indicated in the status bitmask | |
2648 | * and the relevant info shall be in the error item. | |
2649 | */ | |
2650 | int ib_check_mr_status(struct ib_mr *mr, u32 check_mask, | |
2651 | struct ib_mr_status *mr_status); | |
2652 | ||
1da177e4 | 2653 | #endif /* IB_VERBS_H */ |