IB/core: Remove IB_DEVICE_SEND_W_INV capability flag
[linux-block.git] / include / rdma / ib_verbs.h
CommitLineData
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.
37 *
38 * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
39 */
40
41#if !defined(IB_VERBS_H)
42#define IB_VERBS_H
43
44#include <linux/types.h>
45#include <linux/device.h>
9b513090
RC
46#include <linux/mm.h>
47#include <linux/dma-mapping.h>
459d6e2a 48#include <linux/kref.h>
bfb3ea12
DB
49#include <linux/list.h>
50#include <linux/rwsem.h>
87ae9afd 51#include <linux/scatterlist.h>
e2773c06 52
1da177e4 53#include <asm/atomic.h>
e2773c06 54#include <asm/uaccess.h>
1da177e4
LT
55
56union ib_gid {
57 u8 raw[16];
58 struct {
97f52eb4
SH
59 __be64 subnet_prefix;
60 __be64 interface_id;
1da177e4
LT
61 } global;
62};
63
07ebafba
TT
64enum rdma_node_type {
65 /* IB values map to NodeInfo:NodeType. */
66 RDMA_NODE_IB_CA = 1,
67 RDMA_NODE_IB_SWITCH,
68 RDMA_NODE_IB_ROUTER,
69 RDMA_NODE_RNIC
1da177e4
LT
70};
71
07ebafba
TT
72enum rdma_transport_type {
73 RDMA_TRANSPORT_IB,
74 RDMA_TRANSPORT_IWARP
75};
76
77enum rdma_transport_type
78rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
79
1da177e4
LT
80enum ib_device_cap_flags {
81 IB_DEVICE_RESIZE_MAX_WR = 1,
82 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
83 IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
84 IB_DEVICE_RAW_MULTI = (1<<3),
85 IB_DEVICE_AUTO_PATH_MIG = (1<<4),
86 IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
87 IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
88 IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
89 IB_DEVICE_SHUTDOWN_PORT = (1<<8),
90 IB_DEVICE_INIT_TYPE = (1<<9),
91 IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
92 IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
93 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
94 IB_DEVICE_SRQ_RESIZE = (1<<13),
95 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
07ebafba 96 IB_DEVICE_ZERO_STAG = (1<<15),
0f39cf3d 97 IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */
e0605d91
EC
98 IB_DEVICE_MEM_WINDOW = (1<<17),
99 /*
100 * Devices should set IB_DEVICE_UD_IP_SUM if they support
101 * insertion of UDP and TCP checksum on outgoing UD IPoIB
102 * messages and can verify the validity of checksum for
103 * incoming messages. Setting this flag implies that the
104 * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode.
105 */
106 IB_DEVICE_UD_IP_CSUM = (1<<18),
c93570f2 107 IB_DEVICE_UD_TSO = (1<<19),
1da177e4
LT
108};
109
110enum ib_atomic_cap {
111 IB_ATOMIC_NONE,
112 IB_ATOMIC_HCA,
113 IB_ATOMIC_GLOB
114};
115
116struct ib_device_attr {
117 u64 fw_ver;
97f52eb4 118 __be64 sys_image_guid;
1da177e4
LT
119 u64 max_mr_size;
120 u64 page_size_cap;
121 u32 vendor_id;
122 u32 vendor_part_id;
123 u32 hw_ver;
124 int max_qp;
125 int max_qp_wr;
126 int device_cap_flags;
127 int max_sge;
128 int max_sge_rd;
129 int max_cq;
130 int max_cqe;
131 int max_mr;
132 int max_pd;
133 int max_qp_rd_atom;
134 int max_ee_rd_atom;
135 int max_res_rd_atom;
136 int max_qp_init_rd_atom;
137 int max_ee_init_rd_atom;
138 enum ib_atomic_cap atomic_cap;
139 int max_ee;
140 int max_rdd;
141 int max_mw;
142 int max_raw_ipv6_qp;
143 int max_raw_ethy_qp;
144 int max_mcast_grp;
145 int max_mcast_qp_attach;
146 int max_total_mcast_qp_attach;
147 int max_ah;
148 int max_fmr;
149 int max_map_per_fmr;
150 int max_srq;
151 int max_srq_wr;
152 int max_srq_sge;
153 u16 max_pkeys;
154 u8 local_ca_ack_delay;
155};
156
157enum ib_mtu {
158 IB_MTU_256 = 1,
159 IB_MTU_512 = 2,
160 IB_MTU_1024 = 3,
161 IB_MTU_2048 = 4,
162 IB_MTU_4096 = 5
163};
164
165static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
166{
167 switch (mtu) {
168 case IB_MTU_256: return 256;
169 case IB_MTU_512: return 512;
170 case IB_MTU_1024: return 1024;
171 case IB_MTU_2048: return 2048;
172 case IB_MTU_4096: return 4096;
173 default: return -1;
174 }
175}
176
177enum ib_port_state {
178 IB_PORT_NOP = 0,
179 IB_PORT_DOWN = 1,
180 IB_PORT_INIT = 2,
181 IB_PORT_ARMED = 3,
182 IB_PORT_ACTIVE = 4,
183 IB_PORT_ACTIVE_DEFER = 5
184};
185
186enum ib_port_cap_flags {
187 IB_PORT_SM = 1 << 1,
188 IB_PORT_NOTICE_SUP = 1 << 2,
189 IB_PORT_TRAP_SUP = 1 << 3,
190 IB_PORT_OPT_IPD_SUP = 1 << 4,
191 IB_PORT_AUTO_MIGR_SUP = 1 << 5,
192 IB_PORT_SL_MAP_SUP = 1 << 6,
193 IB_PORT_MKEY_NVRAM = 1 << 7,
194 IB_PORT_PKEY_NVRAM = 1 << 8,
195 IB_PORT_LED_INFO_SUP = 1 << 9,
196 IB_PORT_SM_DISABLED = 1 << 10,
197 IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
198 IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
199 IB_PORT_CM_SUP = 1 << 16,
200 IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
201 IB_PORT_REINIT_SUP = 1 << 18,
202 IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
203 IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
204 IB_PORT_DR_NOTICE_SUP = 1 << 21,
205 IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
206 IB_PORT_BOOT_MGMT_SUP = 1 << 23,
207 IB_PORT_LINK_LATENCY_SUP = 1 << 24,
208 IB_PORT_CLIENT_REG_SUP = 1 << 25
209};
210
211enum ib_port_width {
212 IB_WIDTH_1X = 1,
213 IB_WIDTH_4X = 2,
214 IB_WIDTH_8X = 4,
215 IB_WIDTH_12X = 8
216};
217
218static inline int ib_width_enum_to_int(enum ib_port_width width)
219{
220 switch (width) {
221 case IB_WIDTH_1X: return 1;
222 case IB_WIDTH_4X: return 4;
223 case IB_WIDTH_8X: return 8;
224 case IB_WIDTH_12X: return 12;
225 default: return -1;
226 }
227}
228
229struct ib_port_attr {
230 enum ib_port_state state;
231 enum ib_mtu max_mtu;
232 enum ib_mtu active_mtu;
233 int gid_tbl_len;
234 u32 port_cap_flags;
235 u32 max_msg_sz;
236 u32 bad_pkey_cntr;
237 u32 qkey_viol_cntr;
238 u16 pkey_tbl_len;
239 u16 lid;
240 u16 sm_lid;
241 u8 lmc;
242 u8 max_vl_num;
243 u8 sm_sl;
244 u8 subnet_timeout;
245 u8 init_type_reply;
246 u8 active_width;
247 u8 active_speed;
248 u8 phys_state;
249};
250
251enum ib_device_modify_flags {
c5bcbbb9
RD
252 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0,
253 IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
1da177e4
LT
254};
255
256struct ib_device_modify {
257 u64 sys_image_guid;
c5bcbbb9 258 char node_desc[64];
1da177e4
LT
259};
260
261enum ib_port_modify_flags {
262 IB_PORT_SHUTDOWN = 1,
263 IB_PORT_INIT_TYPE = (1<<2),
264 IB_PORT_RESET_QKEY_CNTR = (1<<3)
265};
266
267struct ib_port_modify {
268 u32 set_port_cap_mask;
269 u32 clr_port_cap_mask;
270 u8 init_type;
271};
272
273enum ib_event_type {
274 IB_EVENT_CQ_ERR,
275 IB_EVENT_QP_FATAL,
276 IB_EVENT_QP_REQ_ERR,
277 IB_EVENT_QP_ACCESS_ERR,
278 IB_EVENT_COMM_EST,
279 IB_EVENT_SQ_DRAINED,
280 IB_EVENT_PATH_MIG,
281 IB_EVENT_PATH_MIG_ERR,
282 IB_EVENT_DEVICE_FATAL,
283 IB_EVENT_PORT_ACTIVE,
284 IB_EVENT_PORT_ERR,
285 IB_EVENT_LID_CHANGE,
286 IB_EVENT_PKEY_CHANGE,
d41fcc67
RD
287 IB_EVENT_SM_CHANGE,
288 IB_EVENT_SRQ_ERR,
289 IB_EVENT_SRQ_LIMIT_REACHED,
63942c9a
LA
290 IB_EVENT_QP_LAST_WQE_REACHED,
291 IB_EVENT_CLIENT_REREGISTER
1da177e4
LT
292};
293
294struct ib_event {
295 struct ib_device *device;
296 union {
297 struct ib_cq *cq;
298 struct ib_qp *qp;
d41fcc67 299 struct ib_srq *srq;
1da177e4
LT
300 u8 port_num;
301 } element;
302 enum ib_event_type event;
303};
304
305struct ib_event_handler {
306 struct ib_device *device;
307 void (*handler)(struct ib_event_handler *, struct ib_event *);
308 struct list_head list;
309};
310
311#define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
312 do { \
313 (_ptr)->device = _device; \
314 (_ptr)->handler = _handler; \
315 INIT_LIST_HEAD(&(_ptr)->list); \
316 } while (0)
317
318struct ib_global_route {
319 union ib_gid dgid;
320 u32 flow_label;
321 u8 sgid_index;
322 u8 hop_limit;
323 u8 traffic_class;
324};
325
513789ed 326struct ib_grh {
97f52eb4
SH
327 __be32 version_tclass_flow;
328 __be16 paylen;
513789ed
HR
329 u8 next_hdr;
330 u8 hop_limit;
331 union ib_gid sgid;
332 union ib_gid dgid;
333};
334
1da177e4
LT
335enum {
336 IB_MULTICAST_QPN = 0xffffff
337};
338
97f52eb4
SH
339#define IB_LID_PERMISSIVE __constant_htons(0xFFFF)
340
1da177e4
LT
341enum ib_ah_flags {
342 IB_AH_GRH = 1
343};
344
bf6a9e31
JM
345enum ib_rate {
346 IB_RATE_PORT_CURRENT = 0,
347 IB_RATE_2_5_GBPS = 2,
348 IB_RATE_5_GBPS = 5,
349 IB_RATE_10_GBPS = 3,
350 IB_RATE_20_GBPS = 6,
351 IB_RATE_30_GBPS = 4,
352 IB_RATE_40_GBPS = 7,
353 IB_RATE_60_GBPS = 8,
354 IB_RATE_80_GBPS = 9,
355 IB_RATE_120_GBPS = 10
356};
357
358/**
359 * ib_rate_to_mult - Convert the IB rate enum to a multiple of the
360 * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be
361 * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
362 * @rate: rate to convert.
363 */
364int ib_rate_to_mult(enum ib_rate rate) __attribute_const__;
365
366/**
367 * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate
368 * enum.
369 * @mult: multiple to convert.
370 */
371enum ib_rate mult_to_ib_rate(int mult) __attribute_const__;
372
1da177e4
LT
373struct ib_ah_attr {
374 struct ib_global_route grh;
375 u16 dlid;
376 u8 sl;
377 u8 src_path_bits;
378 u8 static_rate;
379 u8 ah_flags;
380 u8 port_num;
381};
382
383enum ib_wc_status {
384 IB_WC_SUCCESS,
385 IB_WC_LOC_LEN_ERR,
386 IB_WC_LOC_QP_OP_ERR,
387 IB_WC_LOC_EEC_OP_ERR,
388 IB_WC_LOC_PROT_ERR,
389 IB_WC_WR_FLUSH_ERR,
390 IB_WC_MW_BIND_ERR,
391 IB_WC_BAD_RESP_ERR,
392 IB_WC_LOC_ACCESS_ERR,
393 IB_WC_REM_INV_REQ_ERR,
394 IB_WC_REM_ACCESS_ERR,
395 IB_WC_REM_OP_ERR,
396 IB_WC_RETRY_EXC_ERR,
397 IB_WC_RNR_RETRY_EXC_ERR,
398 IB_WC_LOC_RDD_VIOL_ERR,
399 IB_WC_REM_INV_RD_REQ_ERR,
400 IB_WC_REM_ABORT_ERR,
401 IB_WC_INV_EECN_ERR,
402 IB_WC_INV_EEC_STATE_ERR,
403 IB_WC_FATAL_ERR,
404 IB_WC_RESP_TIMEOUT_ERR,
405 IB_WC_GENERAL_ERR
406};
407
408enum ib_wc_opcode {
409 IB_WC_SEND,
410 IB_WC_RDMA_WRITE,
411 IB_WC_RDMA_READ,
412 IB_WC_COMP_SWAP,
413 IB_WC_FETCH_ADD,
414 IB_WC_BIND_MW,
c93570f2 415 IB_WC_LSO,
1da177e4
LT
416/*
417 * Set value of IB_WC_RECV so consumers can test if a completion is a
418 * receive by testing (opcode & IB_WC_RECV).
419 */
420 IB_WC_RECV = 1 << 7,
421 IB_WC_RECV_RDMA_WITH_IMM
422};
423
424enum ib_wc_flags {
425 IB_WC_GRH = 1,
426 IB_WC_WITH_IMM = (1<<1)
427};
428
429struct ib_wc {
430 u64 wr_id;
431 enum ib_wc_status status;
432 enum ib_wc_opcode opcode;
433 u32 vendor_err;
434 u32 byte_len;
062dbb69 435 struct ib_qp *qp;
1da177e4 436 __be32 imm_data;
1da177e4
LT
437 u32 src_qp;
438 int wc_flags;
439 u16 pkey_index;
440 u16 slid;
441 u8 sl;
442 u8 dlid_path_bits;
443 u8 port_num; /* valid only for DR SMPs on switches */
e0605d91 444 int csum_ok;
1da177e4
LT
445};
446
ed23a727
RD
447enum ib_cq_notify_flags {
448 IB_CQ_SOLICITED = 1 << 0,
449 IB_CQ_NEXT_COMP = 1 << 1,
450 IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP,
451 IB_CQ_REPORT_MISSED_EVENTS = 1 << 2,
1da177e4
LT
452};
453
d41fcc67
RD
454enum ib_srq_attr_mask {
455 IB_SRQ_MAX_WR = 1 << 0,
456 IB_SRQ_LIMIT = 1 << 1,
457};
458
459struct ib_srq_attr {
460 u32 max_wr;
461 u32 max_sge;
462 u32 srq_limit;
463};
464
465struct ib_srq_init_attr {
466 void (*event_handler)(struct ib_event *, void *);
467 void *srq_context;
468 struct ib_srq_attr attr;
469};
470
1da177e4
LT
471struct ib_qp_cap {
472 u32 max_send_wr;
473 u32 max_recv_wr;
474 u32 max_send_sge;
475 u32 max_recv_sge;
476 u32 max_inline_data;
477};
478
479enum ib_sig_type {
480 IB_SIGNAL_ALL_WR,
481 IB_SIGNAL_REQ_WR
482};
483
484enum ib_qp_type {
485 /*
486 * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
487 * here (and in that order) since the MAD layer uses them as
488 * indices into a 2-entry table.
489 */
490 IB_QPT_SMI,
491 IB_QPT_GSI,
492
493 IB_QPT_RC,
494 IB_QPT_UC,
495 IB_QPT_UD,
496 IB_QPT_RAW_IPV6,
497 IB_QPT_RAW_ETY
498};
499
b846f25a
EC
500enum ib_qp_create_flags {
501 IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0,
502};
503
1da177e4
LT
504struct ib_qp_init_attr {
505 void (*event_handler)(struct ib_event *, void *);
506 void *qp_context;
507 struct ib_cq *send_cq;
508 struct ib_cq *recv_cq;
509 struct ib_srq *srq;
510 struct ib_qp_cap cap;
511 enum ib_sig_type sq_sig_type;
512 enum ib_qp_type qp_type;
b846f25a 513 enum ib_qp_create_flags create_flags;
1da177e4
LT
514 u8 port_num; /* special QP types only */
515};
516
517enum ib_rnr_timeout {
518 IB_RNR_TIMER_655_36 = 0,
519 IB_RNR_TIMER_000_01 = 1,
520 IB_RNR_TIMER_000_02 = 2,
521 IB_RNR_TIMER_000_03 = 3,
522 IB_RNR_TIMER_000_04 = 4,
523 IB_RNR_TIMER_000_06 = 5,
524 IB_RNR_TIMER_000_08 = 6,
525 IB_RNR_TIMER_000_12 = 7,
526 IB_RNR_TIMER_000_16 = 8,
527 IB_RNR_TIMER_000_24 = 9,
528 IB_RNR_TIMER_000_32 = 10,
529 IB_RNR_TIMER_000_48 = 11,
530 IB_RNR_TIMER_000_64 = 12,
531 IB_RNR_TIMER_000_96 = 13,
532 IB_RNR_TIMER_001_28 = 14,
533 IB_RNR_TIMER_001_92 = 15,
534 IB_RNR_TIMER_002_56 = 16,
535 IB_RNR_TIMER_003_84 = 17,
536 IB_RNR_TIMER_005_12 = 18,
537 IB_RNR_TIMER_007_68 = 19,
538 IB_RNR_TIMER_010_24 = 20,
539 IB_RNR_TIMER_015_36 = 21,
540 IB_RNR_TIMER_020_48 = 22,
541 IB_RNR_TIMER_030_72 = 23,
542 IB_RNR_TIMER_040_96 = 24,
543 IB_RNR_TIMER_061_44 = 25,
544 IB_RNR_TIMER_081_92 = 26,
545 IB_RNR_TIMER_122_88 = 27,
546 IB_RNR_TIMER_163_84 = 28,
547 IB_RNR_TIMER_245_76 = 29,
548 IB_RNR_TIMER_327_68 = 30,
549 IB_RNR_TIMER_491_52 = 31
550};
551
552enum ib_qp_attr_mask {
553 IB_QP_STATE = 1,
554 IB_QP_CUR_STATE = (1<<1),
555 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
556 IB_QP_ACCESS_FLAGS = (1<<3),
557 IB_QP_PKEY_INDEX = (1<<4),
558 IB_QP_PORT = (1<<5),
559 IB_QP_QKEY = (1<<6),
560 IB_QP_AV = (1<<7),
561 IB_QP_PATH_MTU = (1<<8),
562 IB_QP_TIMEOUT = (1<<9),
563 IB_QP_RETRY_CNT = (1<<10),
564 IB_QP_RNR_RETRY = (1<<11),
565 IB_QP_RQ_PSN = (1<<12),
566 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
567 IB_QP_ALT_PATH = (1<<14),
568 IB_QP_MIN_RNR_TIMER = (1<<15),
569 IB_QP_SQ_PSN = (1<<16),
570 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
571 IB_QP_PATH_MIG_STATE = (1<<18),
572 IB_QP_CAP = (1<<19),
573 IB_QP_DEST_QPN = (1<<20)
574};
575
576enum ib_qp_state {
577 IB_QPS_RESET,
578 IB_QPS_INIT,
579 IB_QPS_RTR,
580 IB_QPS_RTS,
581 IB_QPS_SQD,
582 IB_QPS_SQE,
583 IB_QPS_ERR
584};
585
586enum ib_mig_state {
587 IB_MIG_MIGRATED,
588 IB_MIG_REARM,
589 IB_MIG_ARMED
590};
591
592struct ib_qp_attr {
593 enum ib_qp_state qp_state;
594 enum ib_qp_state cur_qp_state;
595 enum ib_mtu path_mtu;
596 enum ib_mig_state path_mig_state;
597 u32 qkey;
598 u32 rq_psn;
599 u32 sq_psn;
600 u32 dest_qp_num;
601 int qp_access_flags;
602 struct ib_qp_cap cap;
603 struct ib_ah_attr ah_attr;
604 struct ib_ah_attr alt_ah_attr;
605 u16 pkey_index;
606 u16 alt_pkey_index;
607 u8 en_sqd_async_notify;
608 u8 sq_draining;
609 u8 max_rd_atomic;
610 u8 max_dest_rd_atomic;
611 u8 min_rnr_timer;
612 u8 port_num;
613 u8 timeout;
614 u8 retry_cnt;
615 u8 rnr_retry;
616 u8 alt_port_num;
617 u8 alt_timeout;
618};
619
620enum ib_wr_opcode {
621 IB_WR_RDMA_WRITE,
622 IB_WR_RDMA_WRITE_WITH_IMM,
623 IB_WR_SEND,
624 IB_WR_SEND_WITH_IMM,
625 IB_WR_RDMA_READ,
626 IB_WR_ATOMIC_CMP_AND_SWP,
c93570f2 627 IB_WR_ATOMIC_FETCH_AND_ADD,
0f39cf3d
RD
628 IB_WR_LSO,
629 IB_WR_SEND_WITH_INV,
1da177e4
LT
630};
631
632enum ib_send_flags {
633 IB_SEND_FENCE = 1,
634 IB_SEND_SIGNALED = (1<<1),
635 IB_SEND_SOLICITED = (1<<2),
e0605d91
EC
636 IB_SEND_INLINE = (1<<3),
637 IB_SEND_IP_CSUM = (1<<4)
1da177e4
LT
638};
639
640struct ib_sge {
641 u64 addr;
642 u32 length;
643 u32 lkey;
644};
645
646struct ib_send_wr {
647 struct ib_send_wr *next;
648 u64 wr_id;
649 struct ib_sge *sg_list;
650 int num_sge;
651 enum ib_wr_opcode opcode;
652 int send_flags;
0f39cf3d
RD
653 union {
654 __be32 imm_data;
655 u32 invalidate_rkey;
656 } ex;
1da177e4
LT
657 union {
658 struct {
659 u64 remote_addr;
660 u32 rkey;
661 } rdma;
662 struct {
663 u64 remote_addr;
664 u64 compare_add;
665 u64 swap;
666 u32 rkey;
667 } atomic;
668 struct {
669 struct ib_ah *ah;
c93570f2
EC
670 void *header;
671 int hlen;
672 int mss;
1da177e4
LT
673 u32 remote_qpn;
674 u32 remote_qkey;
1da177e4
LT
675 u16 pkey_index; /* valid for GSI only */
676 u8 port_num; /* valid for DR SMPs on switch only */
677 } ud;
678 } wr;
679};
680
681struct ib_recv_wr {
682 struct ib_recv_wr *next;
683 u64 wr_id;
684 struct ib_sge *sg_list;
685 int num_sge;
686};
687
688enum ib_access_flags {
689 IB_ACCESS_LOCAL_WRITE = 1,
690 IB_ACCESS_REMOTE_WRITE = (1<<1),
691 IB_ACCESS_REMOTE_READ = (1<<2),
692 IB_ACCESS_REMOTE_ATOMIC = (1<<3),
693 IB_ACCESS_MW_BIND = (1<<4)
694};
695
696struct ib_phys_buf {
697 u64 addr;
698 u64 size;
699};
700
701struct ib_mr_attr {
702 struct ib_pd *pd;
703 u64 device_virt_addr;
704 u64 size;
705 int mr_access_flags;
706 u32 lkey;
707 u32 rkey;
708};
709
710enum ib_mr_rereg_flags {
711 IB_MR_REREG_TRANS = 1,
712 IB_MR_REREG_PD = (1<<1),
713 IB_MR_REREG_ACCESS = (1<<2)
714};
715
716struct ib_mw_bind {
717 struct ib_mr *mr;
718 u64 wr_id;
719 u64 addr;
720 u32 length;
721 int send_flags;
722 int mw_access_flags;
723};
724
725struct ib_fmr_attr {
726 int max_pages;
727 int max_maps;
d36f34aa 728 u8 page_shift;
1da177e4
LT
729};
730
e2773c06
RD
731struct ib_ucontext {
732 struct ib_device *device;
733 struct list_head pd_list;
734 struct list_head mr_list;
735 struct list_head mw_list;
736 struct list_head cq_list;
737 struct list_head qp_list;
738 struct list_head srq_list;
739 struct list_head ah_list;
f7c6a7b5 740 int closing;
e2773c06
RD
741};
742
743struct ib_uobject {
744 u64 user_handle; /* handle given to us by userspace */
745 struct ib_ucontext *context; /* associated user context */
9ead190b 746 void *object; /* containing object */
e2773c06 747 struct list_head list; /* link to context's list */
b3d636b0 748 int id; /* index into kernel idr */
9ead190b
RD
749 struct kref ref;
750 struct rw_semaphore mutex; /* protects .live */
751 int live;
e2773c06
RD
752};
753
e2773c06
RD
754struct ib_udata {
755 void __user *inbuf;
756 void __user *outbuf;
757 size_t inlen;
758 size_t outlen;
759};
760
1da177e4 761struct ib_pd {
e2773c06
RD
762 struct ib_device *device;
763 struct ib_uobject *uobject;
764 atomic_t usecnt; /* count all resources */
1da177e4
LT
765};
766
767struct ib_ah {
768 struct ib_device *device;
769 struct ib_pd *pd;
e2773c06 770 struct ib_uobject *uobject;
1da177e4
LT
771};
772
773typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
774
775struct ib_cq {
e2773c06
RD
776 struct ib_device *device;
777 struct ib_uobject *uobject;
778 ib_comp_handler comp_handler;
779 void (*event_handler)(struct ib_event *, void *);
780 void * cq_context;
781 int cqe;
782 atomic_t usecnt; /* count number of work queues */
1da177e4
LT
783};
784
785struct ib_srq {
d41fcc67
RD
786 struct ib_device *device;
787 struct ib_pd *pd;
788 struct ib_uobject *uobject;
789 void (*event_handler)(struct ib_event *, void *);
790 void *srq_context;
1da177e4
LT
791 atomic_t usecnt;
792};
793
794struct ib_qp {
795 struct ib_device *device;
796 struct ib_pd *pd;
797 struct ib_cq *send_cq;
798 struct ib_cq *recv_cq;
799 struct ib_srq *srq;
e2773c06 800 struct ib_uobject *uobject;
1da177e4
LT
801 void (*event_handler)(struct ib_event *, void *);
802 void *qp_context;
803 u32 qp_num;
804 enum ib_qp_type qp_type;
805};
806
807struct ib_mr {
e2773c06
RD
808 struct ib_device *device;
809 struct ib_pd *pd;
810 struct ib_uobject *uobject;
811 u32 lkey;
812 u32 rkey;
813 atomic_t usecnt; /* count number of MWs */
1da177e4
LT
814};
815
816struct ib_mw {
817 struct ib_device *device;
818 struct ib_pd *pd;
e2773c06 819 struct ib_uobject *uobject;
1da177e4
LT
820 u32 rkey;
821};
822
823struct ib_fmr {
824 struct ib_device *device;
825 struct ib_pd *pd;
826 struct list_head list;
827 u32 lkey;
828 u32 rkey;
829};
830
831struct ib_mad;
832struct ib_grh;
833
834enum ib_process_mad_flags {
835 IB_MAD_IGNORE_MKEY = 1,
836 IB_MAD_IGNORE_BKEY = 2,
837 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
838};
839
840enum ib_mad_result {
841 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
842 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
843 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
844 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
845};
846
847#define IB_DEVICE_NAME_MAX 64
848
849struct ib_cache {
850 rwlock_t lock;
851 struct ib_event_handler event_handler;
852 struct ib_pkey_cache **pkey_cache;
853 struct ib_gid_cache **gid_cache;
6fb9cdbf 854 u8 *lmc_cache;
1da177e4
LT
855};
856
9b513090
RC
857struct ib_dma_mapping_ops {
858 int (*mapping_error)(struct ib_device *dev,
859 u64 dma_addr);
860 u64 (*map_single)(struct ib_device *dev,
861 void *ptr, size_t size,
862 enum dma_data_direction direction);
863 void (*unmap_single)(struct ib_device *dev,
864 u64 addr, size_t size,
865 enum dma_data_direction direction);
866 u64 (*map_page)(struct ib_device *dev,
867 struct page *page, unsigned long offset,
868 size_t size,
869 enum dma_data_direction direction);
870 void (*unmap_page)(struct ib_device *dev,
871 u64 addr, size_t size,
872 enum dma_data_direction direction);
873 int (*map_sg)(struct ib_device *dev,
874 struct scatterlist *sg, int nents,
875 enum dma_data_direction direction);
876 void (*unmap_sg)(struct ib_device *dev,
877 struct scatterlist *sg, int nents,
878 enum dma_data_direction direction);
879 u64 (*dma_address)(struct ib_device *dev,
880 struct scatterlist *sg);
881 unsigned int (*dma_len)(struct ib_device *dev,
882 struct scatterlist *sg);
883 void (*sync_single_for_cpu)(struct ib_device *dev,
884 u64 dma_handle,
885 size_t size,
886 enum dma_data_direction dir);
887 void (*sync_single_for_device)(struct ib_device *dev,
888 u64 dma_handle,
889 size_t size,
890 enum dma_data_direction dir);
891 void *(*alloc_coherent)(struct ib_device *dev,
892 size_t size,
893 u64 *dma_handle,
894 gfp_t flag);
895 void (*free_coherent)(struct ib_device *dev,
896 size_t size, void *cpu_addr,
897 u64 dma_handle);
898};
899
07ebafba
TT
900struct iw_cm_verbs;
901
1da177e4
LT
902struct ib_device {
903 struct device *dma_device;
904
905 char name[IB_DEVICE_NAME_MAX];
906
907 struct list_head event_handler_list;
908 spinlock_t event_handler_lock;
909
910 struct list_head core_list;
911 struct list_head client_data_list;
912 spinlock_t client_data_lock;
913
914 struct ib_cache cache;
5eb620c8
YE
915 int *pkey_tbl_len;
916 int *gid_tbl_len;
1da177e4 917
f4fd0b22
MT
918 int num_comp_vectors;
919
07ebafba
TT
920 struct iw_cm_verbs *iwcm;
921
1da177e4
LT
922 int (*query_device)(struct ib_device *device,
923 struct ib_device_attr *device_attr);
924 int (*query_port)(struct ib_device *device,
925 u8 port_num,
926 struct ib_port_attr *port_attr);
927 int (*query_gid)(struct ib_device *device,
928 u8 port_num, int index,
929 union ib_gid *gid);
930 int (*query_pkey)(struct ib_device *device,
931 u8 port_num, u16 index, u16 *pkey);
932 int (*modify_device)(struct ib_device *device,
933 int device_modify_mask,
934 struct ib_device_modify *device_modify);
935 int (*modify_port)(struct ib_device *device,
936 u8 port_num, int port_modify_mask,
937 struct ib_port_modify *port_modify);
e2773c06
RD
938 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
939 struct ib_udata *udata);
940 int (*dealloc_ucontext)(struct ib_ucontext *context);
941 int (*mmap)(struct ib_ucontext *context,
942 struct vm_area_struct *vma);
943 struct ib_pd * (*alloc_pd)(struct ib_device *device,
944 struct ib_ucontext *context,
945 struct ib_udata *udata);
1da177e4
LT
946 int (*dealloc_pd)(struct ib_pd *pd);
947 struct ib_ah * (*create_ah)(struct ib_pd *pd,
948 struct ib_ah_attr *ah_attr);
949 int (*modify_ah)(struct ib_ah *ah,
950 struct ib_ah_attr *ah_attr);
951 int (*query_ah)(struct ib_ah *ah,
952 struct ib_ah_attr *ah_attr);
953 int (*destroy_ah)(struct ib_ah *ah);
d41fcc67
RD
954 struct ib_srq * (*create_srq)(struct ib_pd *pd,
955 struct ib_srq_init_attr *srq_init_attr,
956 struct ib_udata *udata);
957 int (*modify_srq)(struct ib_srq *srq,
958 struct ib_srq_attr *srq_attr,
9bc57e2d
RC
959 enum ib_srq_attr_mask srq_attr_mask,
960 struct ib_udata *udata);
d41fcc67
RD
961 int (*query_srq)(struct ib_srq *srq,
962 struct ib_srq_attr *srq_attr);
963 int (*destroy_srq)(struct ib_srq *srq);
964 int (*post_srq_recv)(struct ib_srq *srq,
965 struct ib_recv_wr *recv_wr,
966 struct ib_recv_wr **bad_recv_wr);
1da177e4 967 struct ib_qp * (*create_qp)(struct ib_pd *pd,
e2773c06
RD
968 struct ib_qp_init_attr *qp_init_attr,
969 struct ib_udata *udata);
1da177e4
LT
970 int (*modify_qp)(struct ib_qp *qp,
971 struct ib_qp_attr *qp_attr,
9bc57e2d
RC
972 int qp_attr_mask,
973 struct ib_udata *udata);
1da177e4
LT
974 int (*query_qp)(struct ib_qp *qp,
975 struct ib_qp_attr *qp_attr,
976 int qp_attr_mask,
977 struct ib_qp_init_attr *qp_init_attr);
978 int (*destroy_qp)(struct ib_qp *qp);
979 int (*post_send)(struct ib_qp *qp,
980 struct ib_send_wr *send_wr,
981 struct ib_send_wr **bad_send_wr);
982 int (*post_recv)(struct ib_qp *qp,
983 struct ib_recv_wr *recv_wr,
984 struct ib_recv_wr **bad_recv_wr);
e2773c06 985 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
f4fd0b22 986 int comp_vector,
e2773c06
RD
987 struct ib_ucontext *context,
988 struct ib_udata *udata);
2dd57162
EC
989 int (*modify_cq)(struct ib_cq *cq, u16 cq_count,
990 u16 cq_period);
1da177e4 991 int (*destroy_cq)(struct ib_cq *cq);
33b9b3ee
RD
992 int (*resize_cq)(struct ib_cq *cq, int cqe,
993 struct ib_udata *udata);
1da177e4
LT
994 int (*poll_cq)(struct ib_cq *cq, int num_entries,
995 struct ib_wc *wc);
996 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
997 int (*req_notify_cq)(struct ib_cq *cq,
ed23a727 998 enum ib_cq_notify_flags flags);
1da177e4
LT
999 int (*req_ncomp_notif)(struct ib_cq *cq,
1000 int wc_cnt);
1001 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
1002 int mr_access_flags);
1003 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
1004 struct ib_phys_buf *phys_buf_array,
1005 int num_phys_buf,
1006 int mr_access_flags,
1007 u64 *iova_start);
e2773c06 1008 struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
f7c6a7b5
RD
1009 u64 start, u64 length,
1010 u64 virt_addr,
e2773c06
RD
1011 int mr_access_flags,
1012 struct ib_udata *udata);
1da177e4
LT
1013 int (*query_mr)(struct ib_mr *mr,
1014 struct ib_mr_attr *mr_attr);
1015 int (*dereg_mr)(struct ib_mr *mr);
1016 int (*rereg_phys_mr)(struct ib_mr *mr,
1017 int mr_rereg_mask,
1018 struct ib_pd *pd,
1019 struct ib_phys_buf *phys_buf_array,
1020 int num_phys_buf,
1021 int mr_access_flags,
1022 u64 *iova_start);
1023 struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
1024 int (*bind_mw)(struct ib_qp *qp,
1025 struct ib_mw *mw,
1026 struct ib_mw_bind *mw_bind);
1027 int (*dealloc_mw)(struct ib_mw *mw);
1028 struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
1029 int mr_access_flags,
1030 struct ib_fmr_attr *fmr_attr);
1031 int (*map_phys_fmr)(struct ib_fmr *fmr,
1032 u64 *page_list, int list_len,
1033 u64 iova);
1034 int (*unmap_fmr)(struct list_head *fmr_list);
1035 int (*dealloc_fmr)(struct ib_fmr *fmr);
1036 int (*attach_mcast)(struct ib_qp *qp,
1037 union ib_gid *gid,
1038 u16 lid);
1039 int (*detach_mcast)(struct ib_qp *qp,
1040 union ib_gid *gid,
1041 u16 lid);
1042 int (*process_mad)(struct ib_device *device,
1043 int process_mad_flags,
1044 u8 port_num,
1045 struct ib_wc *in_wc,
1046 struct ib_grh *in_grh,
1047 struct ib_mad *in_mad,
1048 struct ib_mad *out_mad);
1049
9b513090
RC
1050 struct ib_dma_mapping_ops *dma_ops;
1051
e2773c06 1052 struct module *owner;
f4e91eb4 1053 struct device dev;
35be0681 1054 struct kobject *ports_parent;
1da177e4
LT
1055 struct list_head port_list;
1056
1057 enum {
1058 IB_DEV_UNINITIALIZED,
1059 IB_DEV_REGISTERED,
1060 IB_DEV_UNREGISTERED
1061 } reg_state;
1062
883a99c7 1063 u64 uverbs_cmd_mask;
274c0891
RD
1064 int uverbs_abi_ver;
1065
c5bcbbb9 1066 char node_desc[64];
cf311cd4 1067 __be64 node_guid;
1da177e4
LT
1068 u8 node_type;
1069 u8 phys_port_cnt;
1070};
1071
1072struct ib_client {
1073 char *name;
1074 void (*add) (struct ib_device *);
1075 void (*remove)(struct ib_device *);
1076
1077 struct list_head list;
1078};
1079
1080struct ib_device *ib_alloc_device(size_t size);
1081void ib_dealloc_device(struct ib_device *device);
1082
1083int ib_register_device (struct ib_device *device);
1084void ib_unregister_device(struct ib_device *device);
1085
1086int ib_register_client (struct ib_client *client);
1087void ib_unregister_client(struct ib_client *client);
1088
1089void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
1090void ib_set_client_data(struct ib_device *device, struct ib_client *client,
1091 void *data);
1092
e2773c06
RD
1093static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
1094{
1095 return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
1096}
1097
1098static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
1099{
1100 return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
1101}
1102
8a51866f
RD
1103/**
1104 * ib_modify_qp_is_ok - Check that the supplied attribute mask
1105 * contains all required attributes and no attributes not allowed for
1106 * the given QP state transition.
1107 * @cur_state: Current QP state
1108 * @next_state: Next QP state
1109 * @type: QP type
1110 * @mask: Mask of supplied QP attributes
1111 *
1112 * This function is a helper function that a low-level driver's
1113 * modify_qp method can use to validate the consumer's input. It
1114 * checks that cur_state and next_state are valid QP states, that a
1115 * transition from cur_state to next_state is allowed by the IB spec,
1116 * and that the attribute mask supplied is allowed for the transition.
1117 */
1118int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
1119 enum ib_qp_type type, enum ib_qp_attr_mask mask);
1120
1da177e4
LT
1121int ib_register_event_handler (struct ib_event_handler *event_handler);
1122int ib_unregister_event_handler(struct ib_event_handler *event_handler);
1123void ib_dispatch_event(struct ib_event *event);
1124
1125int ib_query_device(struct ib_device *device,
1126 struct ib_device_attr *device_attr);
1127
1128int ib_query_port(struct ib_device *device,
1129 u8 port_num, struct ib_port_attr *port_attr);
1130
1131int ib_query_gid(struct ib_device *device,
1132 u8 port_num, int index, union ib_gid *gid);
1133
1134int ib_query_pkey(struct ib_device *device,
1135 u8 port_num, u16 index, u16 *pkey);
1136
1137int ib_modify_device(struct ib_device *device,
1138 int device_modify_mask,
1139 struct ib_device_modify *device_modify);
1140
1141int ib_modify_port(struct ib_device *device,
1142 u8 port_num, int port_modify_mask,
1143 struct ib_port_modify *port_modify);
1144
5eb620c8
YE
1145int ib_find_gid(struct ib_device *device, union ib_gid *gid,
1146 u8 *port_num, u16 *index);
1147
1148int ib_find_pkey(struct ib_device *device,
1149 u8 port_num, u16 pkey, u16 *index);
1150
1da177e4
LT
1151/**
1152 * ib_alloc_pd - Allocates an unused protection domain.
1153 * @device: The device on which to allocate the protection domain.
1154 *
1155 * A protection domain object provides an association between QPs, shared
1156 * receive queues, address handles, memory regions, and memory windows.
1157 */
1158struct ib_pd *ib_alloc_pd(struct ib_device *device);
1159
1160/**
1161 * ib_dealloc_pd - Deallocates a protection domain.
1162 * @pd: The protection domain to deallocate.
1163 */
1164int ib_dealloc_pd(struct ib_pd *pd);
1165
1166/**
1167 * ib_create_ah - Creates an address handle for the given address vector.
1168 * @pd: The protection domain associated with the address handle.
1169 * @ah_attr: The attributes of the address vector.
1170 *
1171 * The address handle is used to reference a local or global destination
1172 * in all UD QP post sends.
1173 */
1174struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
1175
4e00d694
SH
1176/**
1177 * ib_init_ah_from_wc - Initializes address handle attributes from a
1178 * work completion.
1179 * @device: Device on which the received message arrived.
1180 * @port_num: Port on which the received message arrived.
1181 * @wc: Work completion associated with the received message.
1182 * @grh: References the received global route header. This parameter is
1183 * ignored unless the work completion indicates that the GRH is valid.
1184 * @ah_attr: Returned attributes that can be used when creating an address
1185 * handle for replying to the message.
1186 */
1187int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
1188 struct ib_grh *grh, struct ib_ah_attr *ah_attr);
1189
513789ed
HR
1190/**
1191 * ib_create_ah_from_wc - Creates an address handle associated with the
1192 * sender of the specified work completion.
1193 * @pd: The protection domain associated with the address handle.
1194 * @wc: Work completion information associated with a received message.
1195 * @grh: References the received global route header. This parameter is
1196 * ignored unless the work completion indicates that the GRH is valid.
1197 * @port_num: The outbound port number to associate with the address.
1198 *
1199 * The address handle is used to reference a local or global destination
1200 * in all UD QP post sends.
1201 */
1202struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
1203 struct ib_grh *grh, u8 port_num);
1204
1da177e4
LT
1205/**
1206 * ib_modify_ah - Modifies the address vector associated with an address
1207 * handle.
1208 * @ah: The address handle to modify.
1209 * @ah_attr: The new address vector attributes to associate with the
1210 * address handle.
1211 */
1212int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1213
1214/**
1215 * ib_query_ah - Queries the address vector associated with an address
1216 * handle.
1217 * @ah: The address handle to query.
1218 * @ah_attr: The address vector attributes associated with the address
1219 * handle.
1220 */
1221int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1222
1223/**
1224 * ib_destroy_ah - Destroys an address handle.
1225 * @ah: The address handle to destroy.
1226 */
1227int ib_destroy_ah(struct ib_ah *ah);
1228
d41fcc67
RD
1229/**
1230 * ib_create_srq - Creates a SRQ associated with the specified protection
1231 * domain.
1232 * @pd: The protection domain associated with the SRQ.
abb6e9ba
DB
1233 * @srq_init_attr: A list of initial attributes required to create the
1234 * SRQ. If SRQ creation succeeds, then the attributes are updated to
1235 * the actual capabilities of the created SRQ.
d41fcc67
RD
1236 *
1237 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
1238 * requested size of the SRQ, and set to the actual values allocated
1239 * on return. If ib_create_srq() succeeds, then max_wr and max_sge
1240 * will always be at least as large as the requested values.
1241 */
1242struct ib_srq *ib_create_srq(struct ib_pd *pd,
1243 struct ib_srq_init_attr *srq_init_attr);
1244
1245/**
1246 * ib_modify_srq - Modifies the attributes for the specified SRQ.
1247 * @srq: The SRQ to modify.
1248 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
1249 * the current values of selected SRQ attributes are returned.
1250 * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
1251 * are being modified.
1252 *
1253 * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
1254 * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
1255 * the number of receives queued drops below the limit.
1256 */
1257int ib_modify_srq(struct ib_srq *srq,
1258 struct ib_srq_attr *srq_attr,
1259 enum ib_srq_attr_mask srq_attr_mask);
1260
1261/**
1262 * ib_query_srq - Returns the attribute list and current values for the
1263 * specified SRQ.
1264 * @srq: The SRQ to query.
1265 * @srq_attr: The attributes of the specified SRQ.
1266 */
1267int ib_query_srq(struct ib_srq *srq,
1268 struct ib_srq_attr *srq_attr);
1269
1270/**
1271 * ib_destroy_srq - Destroys the specified SRQ.
1272 * @srq: The SRQ to destroy.
1273 */
1274int ib_destroy_srq(struct ib_srq *srq);
1275
1276/**
1277 * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
1278 * @srq: The SRQ to post the work request on.
1279 * @recv_wr: A list of work requests to post on the receive queue.
1280 * @bad_recv_wr: On an immediate failure, this parameter will reference
1281 * the work request that failed to be posted on the QP.
1282 */
1283static inline int ib_post_srq_recv(struct ib_srq *srq,
1284 struct ib_recv_wr *recv_wr,
1285 struct ib_recv_wr **bad_recv_wr)
1286{
1287 return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
1288}
1289
1da177e4
LT
1290/**
1291 * ib_create_qp - Creates a QP associated with the specified protection
1292 * domain.
1293 * @pd: The protection domain associated with the QP.
abb6e9ba
DB
1294 * @qp_init_attr: A list of initial attributes required to create the
1295 * QP. If QP creation succeeds, then the attributes are updated to
1296 * the actual capabilities of the created QP.
1da177e4
LT
1297 */
1298struct ib_qp *ib_create_qp(struct ib_pd *pd,
1299 struct ib_qp_init_attr *qp_init_attr);
1300
1301/**
1302 * ib_modify_qp - Modifies the attributes for the specified QP and then
1303 * transitions the QP to the given state.
1304 * @qp: The QP to modify.
1305 * @qp_attr: On input, specifies the QP attributes to modify. On output,
1306 * the current values of selected QP attributes are returned.
1307 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
1308 * are being modified.
1309 */
1310int ib_modify_qp(struct ib_qp *qp,
1311 struct ib_qp_attr *qp_attr,
1312 int qp_attr_mask);
1313
1314/**
1315 * ib_query_qp - Returns the attribute list and current values for the
1316 * specified QP.
1317 * @qp: The QP to query.
1318 * @qp_attr: The attributes of the specified QP.
1319 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
1320 * @qp_init_attr: Additional attributes of the selected QP.
1321 *
1322 * The qp_attr_mask may be used to limit the query to gathering only the
1323 * selected attributes.
1324 */
1325int ib_query_qp(struct ib_qp *qp,
1326 struct ib_qp_attr *qp_attr,
1327 int qp_attr_mask,
1328 struct ib_qp_init_attr *qp_init_attr);
1329
1330/**
1331 * ib_destroy_qp - Destroys the specified QP.
1332 * @qp: The QP to destroy.
1333 */
1334int ib_destroy_qp(struct ib_qp *qp);
1335
1336/**
1337 * ib_post_send - Posts a list of work requests to the send queue of
1338 * the specified QP.
1339 * @qp: The QP to post the work request on.
1340 * @send_wr: A list of work requests to post on the send queue.
1341 * @bad_send_wr: On an immediate failure, this parameter will reference
1342 * the work request that failed to be posted on the QP.
1343 */
1344static inline int ib_post_send(struct ib_qp *qp,
1345 struct ib_send_wr *send_wr,
1346 struct ib_send_wr **bad_send_wr)
1347{
1348 return qp->device->post_send(qp, send_wr, bad_send_wr);
1349}
1350
1351/**
1352 * ib_post_recv - Posts a list of work requests to the receive queue of
1353 * the specified QP.
1354 * @qp: The QP to post the work request on.
1355 * @recv_wr: A list of work requests to post on the receive queue.
1356 * @bad_recv_wr: On an immediate failure, this parameter will reference
1357 * the work request that failed to be posted on the QP.
1358 */
1359static inline int ib_post_recv(struct ib_qp *qp,
1360 struct ib_recv_wr *recv_wr,
1361 struct ib_recv_wr **bad_recv_wr)
1362{
1363 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1364}
1365
1366/**
1367 * ib_create_cq - Creates a CQ on the specified device.
1368 * @device: The device on which to create the CQ.
1369 * @comp_handler: A user-specified callback that is invoked when a
1370 * completion event occurs on the CQ.
1371 * @event_handler: A user-specified callback that is invoked when an
1372 * asynchronous event not associated with a completion occurs on the CQ.
1373 * @cq_context: Context associated with the CQ returned to the user via
1374 * the associated completion and event handlers.
1375 * @cqe: The minimum size of the CQ.
f4fd0b22
MT
1376 * @comp_vector - Completion vector used to signal completion events.
1377 * Must be >= 0 and < context->num_comp_vectors.
1da177e4
LT
1378 *
1379 * Users can examine the cq structure to determine the actual CQ size.
1380 */
1381struct ib_cq *ib_create_cq(struct ib_device *device,
1382 ib_comp_handler comp_handler,
1383 void (*event_handler)(struct ib_event *, void *),
f4fd0b22 1384 void *cq_context, int cqe, int comp_vector);
1da177e4
LT
1385
1386/**
1387 * ib_resize_cq - Modifies the capacity of the CQ.
1388 * @cq: The CQ to resize.
1389 * @cqe: The minimum size of the CQ.
1390 *
1391 * Users can examine the cq structure to determine the actual CQ size.
1392 */
1393int ib_resize_cq(struct ib_cq *cq, int cqe);
1394
2dd57162
EC
1395/**
1396 * ib_modify_cq - Modifies moderation params of the CQ
1397 * @cq: The CQ to modify.
1398 * @cq_count: number of CQEs that will trigger an event
1399 * @cq_period: max period of time in usec before triggering an event
1400 *
1401 */
1402int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
1403
1da177e4
LT
1404/**
1405 * ib_destroy_cq - Destroys the specified CQ.
1406 * @cq: The CQ to destroy.
1407 */
1408int ib_destroy_cq(struct ib_cq *cq);
1409
1410/**
1411 * ib_poll_cq - poll a CQ for completion(s)
1412 * @cq:the CQ being polled
1413 * @num_entries:maximum number of completions to return
1414 * @wc:array of at least @num_entries &struct ib_wc where completions
1415 * will be returned
1416 *
1417 * Poll a CQ for (possibly multiple) completions. If the return value
1418 * is < 0, an error occurred. If the return value is >= 0, it is the
1419 * number of completions returned. If the return value is
1420 * non-negative and < num_entries, then the CQ was emptied.
1421 */
1422static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
1423 struct ib_wc *wc)
1424{
1425 return cq->device->poll_cq(cq, num_entries, wc);
1426}
1427
1428/**
1429 * ib_peek_cq - Returns the number of unreaped completions currently
1430 * on the specified CQ.
1431 * @cq: The CQ to peek.
1432 * @wc_cnt: A minimum number of unreaped completions to check for.
1433 *
1434 * If the number of unreaped completions is greater than or equal to wc_cnt,
1435 * this function returns wc_cnt, otherwise, it returns the actual number of
1436 * unreaped completions.
1437 */
1438int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1439
1440/**
1441 * ib_req_notify_cq - Request completion notification on a CQ.
1442 * @cq: The CQ to generate an event for.
ed23a727
RD
1443 * @flags:
1444 * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP
1445 * to request an event on the next solicited event or next work
1446 * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS
1447 * may also be |ed in to request a hint about missed events, as
1448 * described below.
1449 *
1450 * Return Value:
1451 * < 0 means an error occurred while requesting notification
1452 * == 0 means notification was requested successfully, and if
1453 * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events
1454 * were missed and it is safe to wait for another event. In
1455 * this case is it guaranteed that any work completions added
1456 * to the CQ since the last CQ poll will trigger a completion
1457 * notification event.
1458 * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed
1459 * in. It means that the consumer must poll the CQ again to
1460 * make sure it is empty to avoid missing an event because of a
1461 * race between requesting notification and an entry being
1462 * added to the CQ. This return value means it is possible
1463 * (but not guaranteed) that a work completion has been added
1464 * to the CQ since the last poll without triggering a
1465 * completion notification event.
1da177e4
LT
1466 */
1467static inline int ib_req_notify_cq(struct ib_cq *cq,
ed23a727 1468 enum ib_cq_notify_flags flags)
1da177e4 1469{
ed23a727 1470 return cq->device->req_notify_cq(cq, flags);
1da177e4
LT
1471}
1472
1473/**
1474 * ib_req_ncomp_notif - Request completion notification when there are
1475 * at least the specified number of unreaped completions on the CQ.
1476 * @cq: The CQ to generate an event for.
1477 * @wc_cnt: The number of unreaped completions that should be on the
1478 * CQ before an event is generated.
1479 */
1480static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1481{
1482 return cq->device->req_ncomp_notif ?
1483 cq->device->req_ncomp_notif(cq, wc_cnt) :
1484 -ENOSYS;
1485}
1486
1487/**
1488 * ib_get_dma_mr - Returns a memory region for system memory that is
1489 * usable for DMA.
1490 * @pd: The protection domain associated with the memory region.
1491 * @mr_access_flags: Specifies the memory access rights.
9b513090
RC
1492 *
1493 * Note that the ib_dma_*() functions defined below must be used
1494 * to create/destroy addresses used with the Lkey or Rkey returned
1495 * by ib_get_dma_mr().
1da177e4
LT
1496 */
1497struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1498
9b513090
RC
1499/**
1500 * ib_dma_mapping_error - check a DMA addr for error
1501 * @dev: The device for which the dma_addr was created
1502 * @dma_addr: The DMA address to check
1503 */
1504static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
1505{
d1998ef3
BC
1506 if (dev->dma_ops)
1507 return dev->dma_ops->mapping_error(dev, dma_addr);
1508 return dma_mapping_error(dma_addr);
9b513090
RC
1509}
1510
1511/**
1512 * ib_dma_map_single - Map a kernel virtual address to DMA address
1513 * @dev: The device for which the dma_addr is to be created
1514 * @cpu_addr: The kernel virtual address
1515 * @size: The size of the region in bytes
1516 * @direction: The direction of the DMA
1517 */
1518static inline u64 ib_dma_map_single(struct ib_device *dev,
1519 void *cpu_addr, size_t size,
1520 enum dma_data_direction direction)
1521{
d1998ef3
BC
1522 if (dev->dma_ops)
1523 return dev->dma_ops->map_single(dev, cpu_addr, size, direction);
1524 return dma_map_single(dev->dma_device, cpu_addr, size, direction);
9b513090
RC
1525}
1526
1527/**
1528 * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single()
1529 * @dev: The device for which the DMA address was created
1530 * @addr: The DMA address
1531 * @size: The size of the region in bytes
1532 * @direction: The direction of the DMA
1533 */
1534static inline void ib_dma_unmap_single(struct ib_device *dev,
1535 u64 addr, size_t size,
1536 enum dma_data_direction direction)
1537{
d1998ef3
BC
1538 if (dev->dma_ops)
1539 dev->dma_ops->unmap_single(dev, addr, size, direction);
1540 else
9b513090
RC
1541 dma_unmap_single(dev->dma_device, addr, size, direction);
1542}
1543
cb9fbc5c
AK
1544static inline u64 ib_dma_map_single_attrs(struct ib_device *dev,
1545 void *cpu_addr, size_t size,
1546 enum dma_data_direction direction,
1547 struct dma_attrs *attrs)
1548{
1549 return dma_map_single_attrs(dev->dma_device, cpu_addr, size,
1550 direction, attrs);
1551}
1552
1553static inline void ib_dma_unmap_single_attrs(struct ib_device *dev,
1554 u64 addr, size_t size,
1555 enum dma_data_direction direction,
1556 struct dma_attrs *attrs)
1557{
1558 return dma_unmap_single_attrs(dev->dma_device, addr, size,
1559 direction, attrs);
1560}
1561
9b513090
RC
1562/**
1563 * ib_dma_map_page - Map a physical page to DMA address
1564 * @dev: The device for which the dma_addr is to be created
1565 * @page: The page to be mapped
1566 * @offset: The offset within the page
1567 * @size: The size of the region in bytes
1568 * @direction: The direction of the DMA
1569 */
1570static inline u64 ib_dma_map_page(struct ib_device *dev,
1571 struct page *page,
1572 unsigned long offset,
1573 size_t size,
1574 enum dma_data_direction direction)
1575{
d1998ef3
BC
1576 if (dev->dma_ops)
1577 return dev->dma_ops->map_page(dev, page, offset, size, direction);
1578 return dma_map_page(dev->dma_device, page, offset, size, direction);
9b513090
RC
1579}
1580
1581/**
1582 * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page()
1583 * @dev: The device for which the DMA address was created
1584 * @addr: The DMA address
1585 * @size: The size of the region in bytes
1586 * @direction: The direction of the DMA
1587 */
1588static inline void ib_dma_unmap_page(struct ib_device *dev,
1589 u64 addr, size_t size,
1590 enum dma_data_direction direction)
1591{
d1998ef3
BC
1592 if (dev->dma_ops)
1593 dev->dma_ops->unmap_page(dev, addr, size, direction);
1594 else
9b513090
RC
1595 dma_unmap_page(dev->dma_device, addr, size, direction);
1596}
1597
1598/**
1599 * ib_dma_map_sg - Map a scatter/gather list to DMA addresses
1600 * @dev: The device for which the DMA addresses are to be created
1601 * @sg: The array of scatter/gather entries
1602 * @nents: The number of scatter/gather entries
1603 * @direction: The direction of the DMA
1604 */
1605static inline int ib_dma_map_sg(struct ib_device *dev,
1606 struct scatterlist *sg, int nents,
1607 enum dma_data_direction direction)
1608{
d1998ef3
BC
1609 if (dev->dma_ops)
1610 return dev->dma_ops->map_sg(dev, sg, nents, direction);
1611 return dma_map_sg(dev->dma_device, sg, nents, direction);
9b513090
RC
1612}
1613
1614/**
1615 * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses
1616 * @dev: The device for which the DMA addresses were created
1617 * @sg: The array of scatter/gather entries
1618 * @nents: The number of scatter/gather entries
1619 * @direction: The direction of the DMA
1620 */
1621static inline void ib_dma_unmap_sg(struct ib_device *dev,
1622 struct scatterlist *sg, int nents,
1623 enum dma_data_direction direction)
1624{
d1998ef3
BC
1625 if (dev->dma_ops)
1626 dev->dma_ops->unmap_sg(dev, sg, nents, direction);
1627 else
9b513090
RC
1628 dma_unmap_sg(dev->dma_device, sg, nents, direction);
1629}
1630
cb9fbc5c
AK
1631static inline int ib_dma_map_sg_attrs(struct ib_device *dev,
1632 struct scatterlist *sg, int nents,
1633 enum dma_data_direction direction,
1634 struct dma_attrs *attrs)
1635{
1636 return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
1637}
1638
1639static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
1640 struct scatterlist *sg, int nents,
1641 enum dma_data_direction direction,
1642 struct dma_attrs *attrs)
1643{
1644 dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
1645}
9b513090
RC
1646/**
1647 * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
1648 * @dev: The device for which the DMA addresses were created
1649 * @sg: The scatter/gather entry
1650 */
1651static inline u64 ib_sg_dma_address(struct ib_device *dev,
1652 struct scatterlist *sg)
1653{
d1998ef3
BC
1654 if (dev->dma_ops)
1655 return dev->dma_ops->dma_address(dev, sg);
1656 return sg_dma_address(sg);
9b513090
RC
1657}
1658
1659/**
1660 * ib_sg_dma_len - Return the DMA length from a scatter/gather entry
1661 * @dev: The device for which the DMA addresses were created
1662 * @sg: The scatter/gather entry
1663 */
1664static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
1665 struct scatterlist *sg)
1666{
d1998ef3
BC
1667 if (dev->dma_ops)
1668 return dev->dma_ops->dma_len(dev, sg);
1669 return sg_dma_len(sg);
9b513090
RC
1670}
1671
1672/**
1673 * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
1674 * @dev: The device for which the DMA address was created
1675 * @addr: The DMA address
1676 * @size: The size of the region in bytes
1677 * @dir: The direction of the DMA
1678 */
1679static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
1680 u64 addr,
1681 size_t size,
1682 enum dma_data_direction dir)
1683{
d1998ef3
BC
1684 if (dev->dma_ops)
1685 dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir);
1686 else
9b513090
RC
1687 dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
1688}
1689
1690/**
1691 * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device
1692 * @dev: The device for which the DMA address was created
1693 * @addr: The DMA address
1694 * @size: The size of the region in bytes
1695 * @dir: The direction of the DMA
1696 */
1697static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
1698 u64 addr,
1699 size_t size,
1700 enum dma_data_direction dir)
1701{
d1998ef3
BC
1702 if (dev->dma_ops)
1703 dev->dma_ops->sync_single_for_device(dev, addr, size, dir);
1704 else
9b513090
RC
1705 dma_sync_single_for_device(dev->dma_device, addr, size, dir);
1706}
1707
1708/**
1709 * ib_dma_alloc_coherent - Allocate memory and map it for DMA
1710 * @dev: The device for which the DMA address is requested
1711 * @size: The size of the region to allocate in bytes
1712 * @dma_handle: A pointer for returning the DMA address of the region
1713 * @flag: memory allocator flags
1714 */
1715static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
1716 size_t size,
1717 u64 *dma_handle,
1718 gfp_t flag)
1719{
d1998ef3
BC
1720 if (dev->dma_ops)
1721 return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
c59a3da1
RD
1722 else {
1723 dma_addr_t handle;
1724 void *ret;
1725
1726 ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
1727 *dma_handle = handle;
1728 return ret;
1729 }
9b513090
RC
1730}
1731
1732/**
1733 * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent()
1734 * @dev: The device for which the DMA addresses were allocated
1735 * @size: The size of the region
1736 * @cpu_addr: the address returned by ib_dma_alloc_coherent()
1737 * @dma_handle: the DMA address returned by ib_dma_alloc_coherent()
1738 */
1739static inline void ib_dma_free_coherent(struct ib_device *dev,
1740 size_t size, void *cpu_addr,
1741 u64 dma_handle)
1742{
d1998ef3
BC
1743 if (dev->dma_ops)
1744 dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
1745 else
9b513090
RC
1746 dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
1747}
1748
1da177e4
LT
1749/**
1750 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
1751 * by an HCA.
1752 * @pd: The protection domain associated assigned to the registered region.
1753 * @phys_buf_array: Specifies a list of physical buffers to use in the
1754 * memory region.
1755 * @num_phys_buf: Specifies the size of the phys_buf_array.
1756 * @mr_access_flags: Specifies the memory access rights.
1757 * @iova_start: The offset of the region's starting I/O virtual address.
1758 */
1759struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
1760 struct ib_phys_buf *phys_buf_array,
1761 int num_phys_buf,
1762 int mr_access_flags,
1763 u64 *iova_start);
1764
1765/**
1766 * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
1767 * Conceptually, this call performs the functions deregister memory region
1768 * followed by register physical memory region. Where possible,
1769 * resources are reused instead of deallocated and reallocated.
1770 * @mr: The memory region to modify.
1771 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1772 * properties of the memory region are being modified.
1773 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1774 * the new protection domain to associated with the memory region,
1775 * otherwise, this parameter is ignored.
1776 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1777 * field specifies a list of physical buffers to use in the new
1778 * translation, otherwise, this parameter is ignored.
1779 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1780 * field specifies the size of the phys_buf_array, otherwise, this
1781 * parameter is ignored.
1782 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1783 * field specifies the new memory access rights, otherwise, this
1784 * parameter is ignored.
1785 * @iova_start: The offset of the region's starting I/O virtual address.
1786 */
1787int ib_rereg_phys_mr(struct ib_mr *mr,
1788 int mr_rereg_mask,
1789 struct ib_pd *pd,
1790 struct ib_phys_buf *phys_buf_array,
1791 int num_phys_buf,
1792 int mr_access_flags,
1793 u64 *iova_start);
1794
1795/**
1796 * ib_query_mr - Retrieves information about a specific memory region.
1797 * @mr: The memory region to retrieve information about.
1798 * @mr_attr: The attributes of the specified memory region.
1799 */
1800int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1801
1802/**
1803 * ib_dereg_mr - Deregisters a memory region and removes it from the
1804 * HCA translation table.
1805 * @mr: The memory region to deregister.
1806 */
1807int ib_dereg_mr(struct ib_mr *mr);
1808
1809/**
1810 * ib_alloc_mw - Allocates a memory window.
1811 * @pd: The protection domain associated with the memory window.
1812 */
1813struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
1814
1815/**
1816 * ib_bind_mw - Posts a work request to the send queue of the specified
1817 * QP, which binds the memory window to the given address range and
1818 * remote access attributes.
1819 * @qp: QP to post the bind work request on.
1820 * @mw: The memory window to bind.
1821 * @mw_bind: Specifies information about the memory window, including
1822 * its address range, remote access rights, and associated memory region.
1823 */
1824static inline int ib_bind_mw(struct ib_qp *qp,
1825 struct ib_mw *mw,
1826 struct ib_mw_bind *mw_bind)
1827{
1828 /* XXX reference counting in corresponding MR? */
1829 return mw->device->bind_mw ?
1830 mw->device->bind_mw(qp, mw, mw_bind) :
1831 -ENOSYS;
1832}
1833
1834/**
1835 * ib_dealloc_mw - Deallocates a memory window.
1836 * @mw: The memory window to deallocate.
1837 */
1838int ib_dealloc_mw(struct ib_mw *mw);
1839
1840/**
1841 * ib_alloc_fmr - Allocates a unmapped fast memory region.
1842 * @pd: The protection domain associated with the unmapped region.
1843 * @mr_access_flags: Specifies the memory access rights.
1844 * @fmr_attr: Attributes of the unmapped region.
1845 *
1846 * A fast memory region must be mapped before it can be used as part of
1847 * a work request.
1848 */
1849struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
1850 int mr_access_flags,
1851 struct ib_fmr_attr *fmr_attr);
1852
1853/**
1854 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1855 * @fmr: The fast memory region to associate with the pages.
1856 * @page_list: An array of physical pages to map to the fast memory region.
1857 * @list_len: The number of pages in page_list.
1858 * @iova: The I/O virtual address to use with the mapped region.
1859 */
1860static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
1861 u64 *page_list, int list_len,
1862 u64 iova)
1863{
1864 return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
1865}
1866
1867/**
1868 * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
1869 * @fmr_list: A linked list of fast memory regions to unmap.
1870 */
1871int ib_unmap_fmr(struct list_head *fmr_list);
1872
1873/**
1874 * ib_dealloc_fmr - Deallocates a fast memory region.
1875 * @fmr: The fast memory region to deallocate.
1876 */
1877int ib_dealloc_fmr(struct ib_fmr *fmr);
1878
1879/**
1880 * ib_attach_mcast - Attaches the specified QP to a multicast group.
1881 * @qp: QP to attach to the multicast group. The QP must be type
1882 * IB_QPT_UD.
1883 * @gid: Multicast group GID.
1884 * @lid: Multicast group LID in host byte order.
1885 *
1886 * In order to send and receive multicast packets, subnet
1887 * administration must have created the multicast group and configured
1888 * the fabric appropriately. The port associated with the specified
1889 * QP must also be a member of the multicast group.
1890 */
1891int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1892
1893/**
1894 * ib_detach_mcast - Detaches the specified QP from a multicast group.
1895 * @qp: QP to detach from the multicast group.
1896 * @gid: Multicast group GID.
1897 * @lid: Multicast group LID in host byte order.
1898 */
1899int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1900
1901#endif /* IB_VERBS_H */