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