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, 2007 Cisco Systems. All rights reserved.
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:
16 * Redistribution and use in source and binary forms, with or
17 * without modification, are permitted provided that the following
20 * - Redistributions of source code must retain the above
21 * copyright notice, this list of conditions and the following
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.
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
38 * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
41 #if !defined(IB_VERBS_H)
44 #include <iba\ib_ci.h>
54 #include "ib_verbs_ex.h"
57 /* IB values map to NodeInfo:NodeType. */
64 enum rdma_transport_type {
69 enum rdma_transport_type
70 rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
72 enum ib_device_cap_flags {
73 IB_DEVICE_RESIZE_MAX_WR = 1,
74 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
75 IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
76 IB_DEVICE_RAW_MULTI = (1<<3),
77 IB_DEVICE_AUTO_PATH_MIG = (1<<4),
78 IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
79 IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
80 IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
81 IB_DEVICE_SHUTDOWN_PORT = (1<<8),
82 IB_DEVICE_INIT_TYPE = (1<<9),
83 IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
84 IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
85 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
86 IB_DEVICE_SRQ_RESIZE = (1<<13),
87 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
88 IB_DEVICE_ZERO_STAG = (1<<15),
89 IB_DEVICE_SEND_W_INV = (1<<16),
90 IB_DEVICE_MEM_WINDOW = (1<<17)
99 struct ib_device_attr {
101 __be64 sys_image_guid;
109 int device_cap_flags;
119 int max_qp_init_rd_atom;
120 int max_ee_init_rd_atom;
121 enum ib_atomic_cap atomic_cap;
128 int max_mcast_qp_attach;
129 int max_total_mcast_qp_attach;
137 u8 local_ca_ack_delay;
148 static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
151 case IB_MTU_256: return 256;
152 case IB_MTU_512: return 512;
153 case IB_MTU_1024: return 1024;
154 case IB_MTU_2048: return 2048;
155 case IB_MTU_4096: return 4096;
166 IB_PORT_ACTIVE_DEFER = 5
169 enum ib_port_cap_flags {
171 IB_PORT_NOTICE_SUP = 1 << 2,
172 IB_PORT_TRAP_SUP = 1 << 3,
173 IB_PORT_OPT_IPD_SUP = 1 << 4,
174 IB_PORT_AUTO_MIGR_SUP = 1 << 5,
175 IB_PORT_SL_MAP_SUP = 1 << 6,
176 IB_PORT_MKEY_NVRAM = 1 << 7,
177 IB_PORT_PKEY_NVRAM = 1 << 8,
178 IB_PORT_LED_INFO_SUP = 1 << 9,
179 IB_PORT_SM_DISABLED = 1 << 10,
180 IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
181 IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
182 IB_PORT_CM_SUP = 1 << 16,
183 IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
184 IB_PORT_REINIT_SUP = 1 << 18,
185 IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
186 IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
187 IB_PORT_DR_NOTICE_SUP = 1 << 21,
188 IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
189 IB_PORT_BOOT_MGMT_SUP = 1 << 23,
190 IB_PORT_LINK_LATENCY_SUP = 1 << 24,
191 IB_PORT_CLIENT_REG_SUP = 1 << 25
201 static inline int ib_width_enum_to_int(enum ib_port_width width)
204 case IB_WIDTH_1X: return 1;
205 case IB_WIDTH_4X: return 4;
206 case IB_WIDTH_8X: return 8;
207 case IB_WIDTH_12X: return 12;
212 struct ib_port_attr {
213 enum ib_port_state state;
215 enum ib_mtu active_mtu;
234 enum ib_device_modify_flags {
235 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0,
236 IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
239 struct ib_device_modify {
244 enum ib_port_modify_flags {
245 IB_PORT_SHUTDOWN = 1,
246 IB_PORT_INIT_TYPE = (1<<2),
247 IB_PORT_RESET_QKEY_CNTR = (1<<3)
250 struct ib_port_modify {
251 u32 set_port_cap_mask;
252 u32 clr_port_cap_mask;
257 IB_EVENT_CQ_ERR = IB_AE_CQ_ERROR,
258 IB_EVENT_QP_FATAL = IB_AE_QP_FATAL,
259 IB_EVENT_QP_REQ_ERR = IB_AE_WQ_REQ_ERROR,
260 IB_EVENT_QP_ACCESS_ERR = IB_AE_WQ_ACCESS_ERROR,
261 IB_EVENT_COMM_EST = IB_AE_QP_COMM,
262 IB_EVENT_SQ_DRAINED = IB_AE_SQ_DRAINED,
263 IB_EVENT_PATH_MIG = IB_AE_QP_APM,
264 IB_EVENT_PATH_MIG_ERR = IB_AE_QP_APM_ERROR,
265 IB_EVENT_DEVICE_FATAL = IB_AE_LOCAL_FATAL,
266 IB_EVENT_PORT_ACTIVE = IB_AE_PORT_ACTIVE,
267 IB_EVENT_PORT_ERR = IB_AE_PORT_DOWN,
268 IB_EVENT_SRQ_LIMIT_REACHED = IB_AE_SRQ_LIMIT_REACHED,
269 IB_EVENT_SRQ_ERR = IB_AE_SRQ_CATAS_ERROR,
270 IB_EVENT_QP_LAST_WQE_REACHED = IB_AE_SRQ_QP_LAST_WQE_REACHED,
271 IB_EVENT_LID_CHANGE = IB_AE_UNKNOWN + 1,
272 IB_EVENT_PKEY_CHANGE,
274 IB_EVENT_CLIENT_REREGISTER
278 struct ib_device *device;
285 enum ib_event_type event;
286 struct ib_event_ex x;
289 struct ib_event_handler {
290 struct ib_device *device;
291 void (*handler)(struct ib_event_handler *, struct ib_event *);
292 struct list_head list;
295 #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
297 (_ptr)->device = _device; \
298 (_ptr)->handler = _handler; \
299 INIT_LIST_HEAD(&(_ptr)->list); \
302 struct ib_global_route {
311 __be32 version_tclass_flow;
320 IB_MULTICAST_QPN = 0xffffff
323 #define XIB_LID_PERMISSIVE __constant_htons(0xFFFF)
330 IB_RATE_PORT_CURRENT = 0,
331 IB_RATE_2_5_GBPS = 2,
339 IB_RATE_120_GBPS = 10
343 * ib_rate_to_mult - Convert the IB rate enum to a multiple of the
344 * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be
345 * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
346 * @rate: rate to convert.
348 int ib_rate_to_mult(enum ib_rate rate) __attribute_const__;
351 * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate
353 * @mult: multiple to convert.
355 enum ib_rate mult_to_ib_rate(int mult) __attribute_const__;
358 struct ib_global_route grh;
371 IB_WC_LOC_EEC_OP_ERR,
376 IB_WC_LOC_ACCESS_ERR,
377 IB_WC_REM_INV_REQ_ERR,
378 IB_WC_REM_ACCESS_ERR,
381 IB_WC_RNR_RETRY_EXC_ERR,
382 IB_WC_LOC_RDD_VIOL_ERR,
383 IB_WC_REM_INV_RD_REQ_ERR,
386 IB_WC_INV_EEC_STATE_ERR,
388 IB_WC_RESP_TIMEOUT_ERR,
400 * Set value of XIB_WC_RECV so consumers can test if a completion is a
401 * receive by testing (opcode & XIB_WC_RECV).
403 XIB_WC_RECV = 1 << 7,
404 XIB_WC_RECV_RDMA_WITH_IMM
409 IB_WC_WITH_IMM = (1<<1),
410 IB_WC_FORWARD = (1<<2)
415 enum ib_wc_status status;
416 enum ib_wc_opcode opcode;
427 u8 port_num; /* valid only for DR SMPs on switches */
430 enum ib_cq_notify_flags {
431 IB_CQ_SOLICITED = 1 << 0,
432 IB_CQ_NEXT_COMP = 1 << 1,
433 IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP,
434 IB_CQ_REPORT_MISSED_EVENTS = 1 << 2,
437 enum ib_srq_attr_mask {
438 XIB_SRQ_MAX_WR = 1 << 0,
439 XIB_SRQ_LIMIT = 1 << 1,
448 struct ib_srq_init_attr {
449 void (*event_handler)(struct ib_event *, void *);
451 struct ib_srq_attr attr;
469 * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
470 * here (and in that order) since the MAD layer uses them as
471 * indices into a 2-entry table.
483 struct ib_qp_init_attr {
484 void (*event_handler)(struct ib_event *, void *);
486 struct ib_cq *send_cq;
487 struct ib_cq *recv_cq;
489 struct ib_qp_cap cap;
490 enum ib_sig_type sq_sig_type;
491 enum ib_qp_type qp_type;
492 u8 port_num; /* special QP types only */
495 enum ib_rnr_timeout {
496 IB_RNR_TIMER_655_36 = 0,
497 IB_RNR_TIMER_000_01 = 1,
498 IB_RNR_TIMER_000_02 = 2,
499 IB_RNR_TIMER_000_03 = 3,
500 IB_RNR_TIMER_000_04 = 4,
501 IB_RNR_TIMER_000_06 = 5,
502 IB_RNR_TIMER_000_08 = 6,
503 IB_RNR_TIMER_000_12 = 7,
504 IB_RNR_TIMER_000_16 = 8,
505 IB_RNR_TIMER_000_24 = 9,
506 IB_RNR_TIMER_000_32 = 10,
507 IB_RNR_TIMER_000_48 = 11,
508 IB_RNR_TIMER_000_64 = 12,
509 IB_RNR_TIMER_000_96 = 13,
510 IB_RNR_TIMER_001_28 = 14,
511 IB_RNR_TIMER_001_92 = 15,
512 IB_RNR_TIMER_002_56 = 16,
513 IB_RNR_TIMER_003_84 = 17,
514 IB_RNR_TIMER_005_12 = 18,
515 IB_RNR_TIMER_007_68 = 19,
516 IB_RNR_TIMER_010_24 = 20,
517 IB_RNR_TIMER_015_36 = 21,
518 IB_RNR_TIMER_020_48 = 22,
519 IB_RNR_TIMER_030_72 = 23,
520 IB_RNR_TIMER_040_96 = 24,
521 IB_RNR_TIMER_061_44 = 25,
522 IB_RNR_TIMER_081_92 = 26,
523 IB_RNR_TIMER_122_88 = 27,
524 IB_RNR_TIMER_163_84 = 28,
525 IB_RNR_TIMER_245_76 = 29,
526 IB_RNR_TIMER_327_68 = 30,
527 IB_RNR_TIMER_491_52 = 31
530 enum ib_qp_attr_mask {
532 IB_QP_CUR_STATE = (1<<1),
533 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
534 IB_QP_ACCESS_FLAGS = (1<<3),
535 IB_QP_PKEY_INDEX = (1<<4),
539 IB_QP_PATH_MTU = (1<<8),
540 IB_QP_TIMEOUT = (1<<9),
541 IB_QP_RETRY_CNT = (1<<10),
542 IB_QP_RNR_RETRY = (1<<11),
543 IB_QP_RQ_PSN = (1<<12),
544 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
545 IB_QP_ALT_PATH = (1<<14),
546 IB_QP_MIN_RNR_TIMER = (1<<15),
547 IB_QP_SQ_PSN = (1<<16),
548 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
549 IB_QP_PATH_MIG_STATE = (1<<18),
551 IB_QP_DEST_QPN = (1<<20)
571 enum ib_qp_state qp_state;
572 enum ib_qp_state cur_qp_state;
573 enum ib_mtu path_mtu;
574 enum ib_mig_state path_mig_state;
580 struct ib_qp_cap cap;
581 struct ib_ah_attr ah_attr;
582 struct ib_ah_attr alt_ah_attr;
585 u8 en_sqd_async_notify;
588 u8 max_dest_rd_atomic;
600 IB_WR_RDMA_WRITE_WITH_IMM,
604 IB_WR_ATOMIC_CMP_AND_SWP,
605 IB_WR_ATOMIC_FETCH_AND_ADD
610 IB_SEND_SIGNALED = (1<<1),
611 IB_SEND_SOLICITED = (1<<2),
612 IB_SEND_INLINE = (1<<3)
622 struct ib_send_wr *next;
624 struct ib_sge *sg_list;
626 enum ib_wr_opcode opcode;
644 u16 pkey_index; /* valid for GSI only */
645 u8 port_num; /* valid for DR SMPs on switch only */
651 struct ib_recv_wr *next;
653 struct ib_sge *sg_list;
657 enum ib_access_flags {
658 IB_ACCESS_LOCAL_WRITE = 1,
659 IB_ACCESS_REMOTE_WRITE = (1<<1),
660 IB_ACCESS_REMOTE_READ = (1<<2),
661 IB_ACCESS_REMOTE_ATOMIC = (1<<3),
662 IB_ACCESS_MW_BIND = (1<<4)
672 u64 device_virt_addr;
679 enum ib_mr_rereg_flags {
680 IB_MR_REREG_TRANS = 1,
681 IB_MR_REREG_PD = (1<<1),
682 IB_MR_REREG_ACCESS = (1<<2)
700 struct ib_device *device;
702 struct ib_ucontext_ex x;
712 #define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
714 (udata)->inbuf = (void *) (ibuf); \
715 (udata)->outbuf = (void *) (obuf); \
716 (udata)->inlen = (ilen); \
717 (udata)->outlen = (olen); \
721 struct ib_device *device;
722 struct ib_ucontext *p_uctx;
723 atomic_t usecnt; /* count all resources */
727 struct ib_device *device;
729 struct ib_ucontext *p_uctx;
732 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
735 struct ib_device *device;
736 struct ib_ucontext *p_uctx;
737 ib_comp_handler comp_handler;
738 void (*event_handler)(struct ib_event *, void *);
741 atomic_t usecnt; /* count number of work queues */
746 struct ib_device *device;
748 struct ib_ucontext *p_uctx;
749 void (*event_handler)(struct ib_event *, void *);
756 struct ib_device *device;
758 struct ib_cq *send_cq;
759 struct ib_cq *recv_cq;
761 struct ib_ucontext *p_uctx;
762 void (*event_handler)(struct ib_event *, void *);
765 enum ib_qp_type qp_type;
770 struct ib_device *device;
772 struct ib_ucontext *p_uctx;
775 atomic_t usecnt; /* count number of MWs */
779 struct ib_device *device;
781 struct ib_ucontext *p_uctx;
786 struct ib_device *device;
788 struct list_head list;
796 enum ib_process_mad_flags {
797 IB_MAD_IGNORE_MKEY = 1,
798 IB_MAD_IGNORE_BKEY = 2,
799 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
803 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
804 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
805 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
806 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
809 #define IB_DEVICE_NAME_MAX 64
813 struct ib_event_handler event_handler;
814 struct ib_pkey_cache **pkey_cache;
815 struct ib_gid_cache **gid_cache;
817 struct ib_cache_ex x;
820 struct ib_dma_mapping_ops {
821 int (*mapping_error)(struct ib_device *dev,
823 u64 (*map_single)(struct ib_device *dev,
824 void *ptr, size_t size,
825 enum dma_data_direction direction);
826 void (*unmap_single)(struct ib_device *dev,
827 u64 addr, size_t size,
828 enum dma_data_direction direction);
829 u64 (*map_page)(struct ib_device *dev,
830 dma_addr_t page, unsigned long offset,
832 enum dma_data_direction direction);
833 void (*unmap_page)(struct ib_device *dev,
834 u64 addr, size_t size,
835 enum dma_data_direction direction);
836 int (*map_sg)(struct ib_device *dev,
837 struct scatterlist *sg, int nents,
838 enum dma_data_direction direction);
839 void (*unmap_sg)(struct ib_device *dev,
840 struct scatterlist *sg, int nents,
841 enum dma_data_direction direction);
842 u64 (*dma_address)(struct ib_device *dev,
843 struct scatterlist *sg);
844 unsigned int (*dma_len)(struct ib_device *dev,
845 struct scatterlist *sg);
846 void (*sync_single_for_cpu)(struct ib_device *dev,
849 enum dma_data_direction dir);
850 void (*sync_single_for_device)(struct ib_device *dev,
853 enum dma_data_direction dir);
854 void *(*alloc_coherent)(struct ib_device *dev,
858 void (*free_coherent)(struct ib_device *dev,
859 size_t size, void *cpu_addr,
866 struct mlx4_dev *dma_device;
868 char name[IB_DEVICE_NAME_MAX];
870 struct list_head event_handler_list;
871 spinlock_t event_handler_lock;
873 struct list_head core_list;
874 struct list_head client_data_list;
875 spinlock_t client_data_lock;
877 struct ib_cache cache;
883 int num_comp_vectors;
885 struct iw_cm_verbs *iwcm;
887 int (*query_device)(struct ib_device *device,
888 struct ib_device_attr *device_attr);
889 int (*query_port)(struct ib_device *device,
891 struct ib_port_attr *port_attr);
892 int (*query_gid_chunk)(struct ib_device *device,
893 u8 port_num, int index,
894 union ib_gid gid[8], int size);
895 int (*query_pkey_chunk)(struct ib_device *device,
896 u8 port_num, u16 index, __be16 pkey[32], int size);
897 int (*modify_device)(struct ib_device *device,
898 int device_modify_mask,
899 struct ib_device_modify *device_modify);
900 int (*modify_port)(struct ib_device *device,
901 u8 port_num, int port_modify_mask,
902 struct ib_port_modify *port_modify);
903 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
904 struct ib_udata *udata);
905 int (*dealloc_ucontext)(struct ib_ucontext *context);
906 int (*mmap)(struct ib_ucontext *context,
907 struct vm_area_struct *vma);
908 struct ib_pd * (*alloc_pd)(struct ib_device *device,
909 struct ib_ucontext *context,
910 struct ib_udata *udata);
911 int (*dealloc_pd)(struct ib_pd *pd);
912 struct ib_ah * (*create_ah)(struct ib_pd *pd,
913 struct ib_ah_attr *ah_attr);
914 int (*modify_ah)(struct ib_ah *ah,
915 struct ib_ah_attr *ah_attr);
916 int (*query_ah)(struct ib_ah *ah,
917 struct ib_ah_attr *ah_attr);
918 int (*destroy_ah)(struct ib_ah *ah);
919 struct ib_srq * (*create_srq)(struct ib_pd *pd,
920 struct ib_srq_init_attr *srq_init_attr,
921 struct ib_udata *udata);
922 int (*modify_srq)(struct ib_srq *srq,
923 struct ib_srq_attr *srq_attr,
924 enum ib_srq_attr_mask srq_attr_mask,
925 struct ib_udata *udata);
926 int (*query_srq)(struct ib_srq *srq,
927 struct ib_srq_attr *srq_attr);
928 int (*destroy_srq)(struct ib_srq *srq);
929 int (*post_srq_recv)(struct ib_srq *srq,
930 ib_recv_wr_t *recv_wr,
931 ib_recv_wr_t **bad_recv_wr);
932 struct ib_qp * (*create_qp)(struct ib_pd *pd,
933 struct ib_qp_init_attr *qp_init_attr,
934 struct ib_udata *udata);
935 int (*modify_qp)(struct ib_qp *qp,
936 struct ib_qp_attr *qp_attr,
938 struct ib_udata *udata);
939 int (*query_qp)(struct ib_qp *qp,
940 struct ib_qp_attr *qp_attr,
942 struct ib_qp_init_attr *qp_init_attr);
943 int (*destroy_qp)(struct ib_qp *qp);
944 int (*post_send)(struct ib_qp *qp,
945 ib_send_wr_t *send_wr,
946 ib_send_wr_t **bad_send_wr);
947 int (*post_recv)(struct ib_qp *qp,
948 ib_recv_wr_t *recv_wr,
949 ib_recv_wr_t **bad_recv_wr);
950 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
952 struct ib_ucontext *context,
953 struct ib_udata *udata);
954 int (*modify_cq)(struct ib_cq *cq, u16 cq_count,
956 int (*destroy_cq)(struct ib_cq *cq);
957 int (*resize_cq)(struct ib_cq *cq, int cqe,
958 struct ib_udata *udata);
959 int (*poll_cq)(struct ib_cq *ibcq,
960 ib_wc_t** const pp_free_wclist, ib_wc_t** const pp_done_wclist);
961 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
962 int (*req_notify_cq)(struct ib_cq *cq,
963 enum ib_cq_notify_flags flags);
964 int (*req_ncomp_notif)(struct ib_cq *cq,
966 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
967 int mr_access_flags);
968 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
969 struct ib_phys_buf *phys_buf_array,
973 struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
974 u64 start, u64 length,
977 struct ib_udata *udata);
978 int (*query_mr)(struct ib_mr *mr,
979 struct ib_mr_attr *mr_attr);
980 int (*dereg_mr)(struct ib_mr *mr);
981 int (*rereg_phys_mr)(struct ib_mr *mr,
984 struct ib_phys_buf *phys_buf_array,
988 struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
989 int (*bind_mw)(struct ib_qp *qp,
991 struct ib_mw_bind *mw_bind);
992 int (*dealloc_mw)(struct ib_mw *mw);
993 struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
995 struct ib_fmr_attr *fmr_attr);
996 int (*map_phys_fmr)(struct ib_fmr *fmr,
997 u64 *page_list, int list_len,
999 int (*unmap_fmr)(struct list_head *fmr_list);
1000 int (*dealloc_fmr)(struct ib_fmr *fmr);
1001 int (*attach_mcast)(struct ib_qp *qp,
1004 int (*detach_mcast)(struct ib_qp *qp,
1007 int (*process_mad)(struct ib_device *device,
1008 int process_mad_flags,
1011 struct ib_grh *in_grh,
1012 struct ib_mad *in_mad,
1013 struct ib_mad *out_mad);
1015 struct ib_dma_mapping_ops *dma_ops;
1016 struct list_head port_list;
1019 IB_DEV_UNINITIALIZED,
1024 u64 uverbs_cmd_mask;
1031 struct ib_device_ex x;
1036 void (*add) (struct ib_device *);
1037 void (*remove)(struct ib_device *);
1039 struct list_head list;
1042 struct ib_device *ib_alloc_device(size_t size);
1043 void ib_dealloc_device(struct ib_device *device);
1045 int ib_register_device (struct ib_device *device);
1046 void ib_unregister_device(struct ib_device *device);
1048 int ib_register_client (struct ib_client *client);
1049 void ib_unregister_client(struct ib_client *client);
1051 void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
1052 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
1055 static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
1057 if (len > udata->inlen)
1059 memcpy(dest, udata->inbuf, len);
1063 static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
1065 if (len > udata->outlen)
1067 memcpy(udata->outbuf, src, len);
1072 * ib_modify_qp_is_ok - Check that the supplied attribute mask
1073 * contains all required attributes and no attributes not allowed for
1074 * the given QP state transition.
1075 * @cur_state: Current QP state
1076 * @next_state: Next QP state
1078 * @mask: Mask of supplied QP attributes
1080 * This function is a helper function that a low-level driver's
1081 * modify_qp method can use to validate the consumer's input. It
1082 * checks that cur_state and next_state are valid QP states, that a
1083 * transition from cur_state to next_state is allowed by the IB spec,
1084 * and that the attribute mask supplied is allowed for the transition.
1086 int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
1087 enum ib_qp_type type, enum ib_qp_attr_mask mask);
1089 int ib_register_event_handler (struct ib_event_handler *event_handler);
1090 int ib_unregister_event_handler(struct ib_event_handler *event_handler);
1091 void ib_dispatch_event(struct ib_event *event);
1093 int ib_query_device(struct ib_device *device,
1094 struct ib_device_attr *device_attr);
1096 int ib_query_port(struct ib_device *device,
1097 u8 port_num, struct ib_port_attr *port_attr);
1099 int ib_query_gid_chunk(struct ib_device *device,
1100 u8 port_num, int index, union ib_gid gid[8], int size);
1102 int ib_query_pkey_chunk(struct ib_device *device,
1103 u8 port_num, u16 index, __be16 pkey[32], int size);
1105 int ib_modify_device(struct ib_device *device,
1106 int device_modify_mask,
1107 struct ib_device_modify *device_modify);
1109 int ib_modify_port(struct ib_device *device,
1110 u8 port_num, int port_modify_mask,
1111 struct ib_port_modify *port_modify);
1113 int ib_find_gid(struct ib_device *device, union ib_gid *gid,
1114 u8 *port_num, u16 *index);
1116 int ib_find_pkey(struct ib_device *device,
1117 u8 port_num, __be16 pkey, u16 *index);
1120 * ib_alloc_pd - Allocates an unused protection domain.
1121 * @device: The device on which to allocate the protection domain.
1123 * A protection domain object provides an association between QPs, shared
1124 * receive queues, address handles, memory regions, and memory windows.
1126 struct ib_pd *ib_alloc_pd(struct ib_device *device);
1129 * ib_dealloc_pd - Deallocates a protection domain.
1130 * @pd: The protection domain to deallocate.
1132 int ib_dealloc_pd(struct ib_pd *pd);
1135 * ib_create_ah - Creates an address handle for the given address vector.
1136 * @pd: The protection domain associated with the address handle.
1137 * @ah_attr: The attributes of the address vector.
1139 * The address handle is used to reference a local or global destination
1140 * in all UD QP post sends.
1142 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
1145 * ib_init_ah_from_wc - Initializes address handle attributes from a
1147 * @device: Device on which the received message arrived.
1148 * @port_num: Port on which the received message arrived.
1149 * @wc: Work completion associated with the received message.
1150 * @grh: References the received global route header. This parameter is
1151 * ignored unless the work completion indicates that the GRH is valid.
1152 * @ah_attr: Returned attributes that can be used when creating an address
1153 * handle for replying to the message.
1155 int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, ib_wc_t *wc,
1156 struct ib_grh *grh, struct ib_ah_attr *ah_attr);
1159 * ib_create_ah_from_wc - Creates an address handle associated with the
1160 * sender of the specified work completion.
1161 * @pd: The protection domain associated with the address handle.
1162 * @wc: Work completion information associated with a received message.
1163 * @grh: References the received global route header. This parameter is
1164 * ignored unless the work completion indicates that the GRH is valid.
1165 * @port_num: The outbound port number to associate with the address.
1167 * The address handle is used to reference a local or global destination
1168 * in all UD QP post sends.
1170 struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, ib_wc_t *wc,
1171 struct ib_grh *grh, u8 port_num);
1174 * ib_modify_ah - Modifies the address vector associated with an address
1176 * @ah: The address handle to modify.
1177 * @ah_attr: The new address vector attributes to associate with the
1180 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1183 * ib_query_ah - Queries the address vector associated with an address
1185 * @ah: The address handle to query.
1186 * @ah_attr: The address vector attributes associated with the address
1189 int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1192 * ib_destroy_ah - Destroys an address handle.
1193 * @ah: The address handle to destroy.
1195 int ib_destroy_ah(struct ib_ah *ah);
1198 * ib_create_srq - Creates a SRQ associated with the specified protection
1200 * @pd: The protection domain associated with the SRQ.
1201 * @srq_init_attr: A list of initial attributes required to create the
1202 * SRQ. If SRQ creation succeeds, then the attributes are updated to
1203 * the actual capabilities of the created SRQ.
1205 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
1206 * requested size of the SRQ, and set to the actual values allocated
1207 * on return. If ib_create_srq() succeeds, then max_wr and max_sge
1208 * will always be at least as large as the requested values.
1210 struct ib_srq *ib_create_srq(struct ib_pd *pd,
1211 struct ib_srq_init_attr *srq_init_attr);
1214 * ib_modify_srq - Modifies the attributes for the specified SRQ.
1215 * @srq: The SRQ to modify.
1216 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
1217 * the current values of selected SRQ attributes are returned.
1218 * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
1219 * are being modified.
1221 * The mask may contain XIB_SRQ_MAX_WR to resize the SRQ and/or
1222 * XIB_SRQ_LIMIT to set the SRQ's limit and request notification when
1223 * the number of receives queued drops below the limit.
1225 int ib_modify_srq(struct ib_srq *srq,
1226 struct ib_srq_attr *srq_attr,
1227 enum ib_srq_attr_mask srq_attr_mask);
1230 * ib_query_srq - Returns the attribute list and current values for the
1232 * @srq: The SRQ to query.
1233 * @srq_attr: The attributes of the specified SRQ.
1235 int ib_query_srq(struct ib_srq *srq,
1236 struct ib_srq_attr *srq_attr);
1239 * ib_destroy_srq - Destroys the specified SRQ.
1240 * @srq: The SRQ to destroy.
1242 int ib_destroy_srq(struct ib_srq *srq);
1245 * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
1246 * @srq: The SRQ to post the work request on.
1247 * @recv_wr: A list of work requests to post on the receive queue.
1248 * @bad_recv_wr: On an immediate failure, this parameter will reference
1249 * the work request that failed to be posted on the QP.
1251 static inline int ib_post_srq_recv(struct ib_srq *srq,
1252 ib_recv_wr_t *recv_wr,
1253 ib_recv_wr_t **bad_recv_wr)
1255 return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
1259 * ib_create_qp - Creates a QP associated with the specified protection
1261 * @pd: The protection domain associated with the QP.
1262 * @qp_init_attr: A list of initial attributes required to create the
1263 * QP. If QP creation succeeds, then the attributes are updated to
1264 * the actual capabilities of the created QP.
1266 struct ib_qp *ib_create_qp(struct ib_pd *pd,
1267 struct ib_qp_init_attr *qp_init_attr);
1270 * ib_modify_qp - Modifies the attributes for the specified QP and then
1271 * transitions the QP to the given state.
1272 * @qp: The QP to modify.
1273 * @qp_attr: On input, specifies the QP attributes to modify. On output,
1274 * the current values of selected QP attributes are returned.
1275 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
1276 * are being modified.
1278 int ib_modify_qp(struct ib_qp *qp,
1279 struct ib_qp_attr *qp_attr,
1283 * ib_query_qp - Returns the attribute list and current values for the
1285 * @qp: The QP to query.
1286 * @qp_attr: The attributes of the specified QP.
1287 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
1288 * @qp_init_attr: Additional attributes of the selected QP.
1290 * The qp_attr_mask may be used to limit the query to gathering only the
1291 * selected attributes.
1293 int ib_query_qp(struct ib_qp *qp,
1294 struct ib_qp_attr *qp_attr,
1296 struct ib_qp_init_attr *qp_init_attr);
1299 * ib_modify_cq - Modifies moderation params of the CQ
1300 * @cq: The CQ to modify.
1301 * @cq_count: number of CQEs that will tirgger an event
1302 * @cq_period: max period of time beofre triggering an event
1304 * Users can examine the cq structure to determine the actual CQ size.
1306 int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
1309 * ib_destroy_qp - Destroys the specified QP.
1310 * @qp: The QP to destroy.
1312 int ib_destroy_qp(struct ib_qp *qp);
1315 * ib_post_send - Posts a list of work requests to the send queue of
1317 * @qp: The QP to post the work request on.
1318 * @send_wr: A list of work requests to post on the send queue.
1319 * @bad_send_wr: On an immediate failure, this parameter will reference
1320 * the work request that failed to be posted on the QP.
1322 static inline int ib_post_send(struct ib_qp *qp,
1323 ib_send_wr_t *send_wr,
1324 ib_send_wr_t **bad_send_wr)
1326 return qp->device->post_send(qp, send_wr, bad_send_wr);
1330 * ib_post_recv - Posts a list of work requests to the receive queue of
1332 * @qp: The QP to post the work request on.
1333 * @recv_wr: A list of work requests to post on the receive queue.
1334 * @bad_recv_wr: On an immediate failure, this parameter will reference
1335 * the work request that failed to be posted on the QP.
1337 static inline int ib_post_recv(struct ib_qp *qp,
1338 ib_recv_wr_t *recv_wr,
1339 ib_recv_wr_t **bad_recv_wr)
1341 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1345 * ib_create_cq - Creates a CQ on the specified device.
1346 * @device: The device on which to create the CQ.
1347 * @comp_handler: A user-specified callback that is invoked when a
1348 * completion event occurs on the CQ.
1349 * @event_handler: A user-specified callback that is invoked when an
1350 * asynchronous event not associated with a completion occurs on the CQ.
1351 * @cq_context: Context associated with the CQ returned to the user via
1352 * the associated completion and event handlers.
1353 * @cqe: The minimum size of the CQ.
1354 * @comp_vector - Completion vector used to signal completion events.
1355 * Must be >= 0 and < context->num_comp_vectors.
1357 * Users can examine the cq structure to determine the actual CQ size.
1359 struct ib_cq *ib_create_cq(struct ib_device *device,
1360 ib_comp_handler comp_handler,
1361 void (*event_handler)(struct ib_event *, void *),
1362 void *cq_context, int cqe, int comp_vector);
1365 * ib_resize_cq - Modifies the capacity of the CQ.
1366 * @cq: The CQ to resize.
1367 * @cqe: The minimum size of the CQ.
1369 * Users can examine the cq structure to determine the actual CQ size.
1371 int ib_resize_cq(struct ib_cq *cq, int cqe);
1374 * ib_destroy_cq - Destroys the specified CQ.
1375 * @cq: The CQ to destroy.
1377 int ib_destroy_cq(struct ib_cq *cq);
1380 * ib_poll_cq - poll a CQ for completion(s)
1381 * @cq:the CQ being polled
1383 * On input, a list of work completion structures provided by
1384 * the client. These are used to report completed work requests through
1385 * the pp_done_wclist.
1387 * On output, this contains the list of work completions structures for
1388 * which no work completion was found.
1389 * @pp_done_wclist:A list of work completions retrieved from the completion queue.
1391 * Poll a CQ for (possibly multiple) completions. If the return value
1392 * is < 0, an error occurred. If the return value is >= 0, it is the
1393 * number of completions returned. If the return value is
1394 * non-negative and < num_entries, then the CQ was emptied.
1396 static inline int ib_poll_cq(struct ib_cq *cq, ib_wc_t** const pp_free_wclist,
1397 ib_wc_t** const pp_done_wclist)
1399 return cq->device->poll_cq(cq, pp_free_wclist, pp_done_wclist);
1403 * ib_peek_cq - Returns the number of unreaped completions currently
1404 * on the specified CQ.
1405 * @cq: The CQ to peek.
1406 * @wc_cnt: A minimum number of unreaped completions to check for.
1408 * If the number of unreaped completions is greater than or equal to wc_cnt,
1409 * this function returns wc_cnt, otherwise, it returns the actual number of
1410 * unreaped completions.
1412 int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1415 * ib_req_notify_cq - Request completion notification on a CQ.
1416 * @cq: The CQ to generate an event for.
1418 * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP
1419 * to request an event on the next solicited event or next work
1420 * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS
1421 * may also be |ed in to request a hint about missed events, as
1425 * < 0 means an error occurred while requesting notification
1426 * == 0 means notification was requested successfully, and if
1427 * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events
1428 * were missed and it is safe to wait for another event. In
1429 * this case is it guaranteed that any work completions added
1430 * to the CQ since the last CQ poll will trigger a completion
1431 * notification event.
1432 * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed
1433 * in. It means that the consumer must poll the CQ again to
1434 * make sure it is empty to avoid missing an event because of a
1435 * race between requesting notification and an entry being
1436 * added to the CQ. This return value means it is possible
1437 * (but not guaranteed) that a work completion has been added
1438 * to the CQ since the last poll without triggering a
1439 * completion notification event.
1441 static inline int ib_req_notify_cq(struct ib_cq *cq,
1442 enum ib_cq_notify_flags flags)
1444 return cq->device->req_notify_cq(cq, flags);
1448 * ib_req_ncomp_notif - Request completion notification when there are
1449 * at least the specified number of unreaped completions on the CQ.
1450 * @cq: The CQ to generate an event for.
1451 * @wc_cnt: The number of unreaped completions that should be on the
1452 * CQ before an event is generated.
1454 static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1456 return cq->device->req_ncomp_notif ?
1457 cq->device->req_ncomp_notif(cq, wc_cnt) :
1462 * ib_get_dma_mr - Returns a memory region for system memory that is
1464 * @pd: The protection domain associated with the memory region.
1465 * @mr_access_flags: Specifies the memory access rights.
1467 * Note that the ib_dma_*() functions defined below must be used
1468 * to create/destroy addresses used with the Lkey or Rkey returned
1469 * by ib_get_dma_mr().
1471 struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1474 // TODO: do we need that
1476 * ib_dma_mapping_error - check a DMA addr for error
1477 * @dev: The device for which the dma_addr was created
1478 * @dma_addr: The DMA address to check
1480 static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
1483 return dev->dma_ops->mapping_error(dev, dma_addr);
1484 return dma_mapping_error(dma_addr);
1488 * ib_dma_map_single - Map a kernel virtual address to DMA address
1489 * @dev: The device for which the dma_addr is to be created
1490 * @cpu_addr: The kernel virtual address
1491 * @size: The size of the region in bytes
1492 * @direction: The direction of the DMA
1494 static inline u64 ib_dma_map_single(struct ib_device *dev,
1495 void *cpu_addr, size_t size,
1496 enum dma_data_direction direction)
1499 return dev->dma_ops->map_single(dev, cpu_addr, size, direction);
1500 return dma_map_single(dev->dma_device, cpu_addr, size, direction);
1504 * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single()
1505 * @dev: The device for which the DMA address was created
1506 * @addr: The DMA address
1507 * @size: The size of the region in bytes
1508 * @direction: The direction of the DMA
1510 static inline void ib_dma_unmap_single(struct ib_device *dev,
1511 u64 addr, size_t size,
1512 enum dma_data_direction direction)
1515 dev->dma_ops->unmap_single(dev, addr, size, direction);
1517 dma_unmap_single(dev->dma_device, addr, size, direction);
1521 * ib_dma_map_page - Map a physical page to DMA address
1522 * @dev: The device for which the dma_addr is to be created
1523 * @page: The page to be mapped
1524 * @offset: The offset within the page
1525 * @size: The size of the region in bytes
1526 * @direction: The direction of the DMA
1528 static inline u64 ib_dma_map_page(struct ib_device *dev,
1530 unsigned long offset,
1532 enum dma_data_direction direction)
1535 return dev->dma_ops->map_page(dev, page, offset, size, direction);
1536 return dma_map_page(dev->dma_device, page, offset, size, direction);
1540 * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page()
1541 * @dev: The device for which the DMA address was created
1542 * @addr: The DMA address
1543 * @size: The size of the region in bytes
1544 * @direction: The direction of the DMA
1546 static inline void ib_dma_unmap_page(struct ib_device *dev,
1547 u64 addr, size_t size,
1548 enum dma_data_direction direction)
1551 dev->dma_ops->unmap_page(dev, addr, size, direction);
1553 dma_unmap_page(dev->dma_device, addr, size, direction);
1557 * ib_dma_map_sg - Map a scatter/gather list to DMA addresses
1558 * @dev: The device for which the DMA addresses are to be created
1559 * @sg: The array of scatter/gather entries
1560 * @nents: The number of scatter/gather entries
1561 * @direction: The direction of the DMA
1563 static inline int ib_dma_map_sg(struct ib_device *dev,
1564 struct scatterlist *sg, int nents,
1565 enum dma_data_direction direction)
1568 return dev->dma_ops->map_sg(dev, sg, nents, direction);
1569 return dma_map_sg(dev->dma_device, sg, nents, direction);
1573 * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses
1574 * @dev: The device for which the DMA addresses were created
1575 * @sg: The array of scatter/gather entries
1576 * @nents: The number of scatter/gather entries
1577 * @direction: The direction of the DMA
1579 static inline void ib_dma_unmap_sg(struct ib_device *dev,
1580 struct scatterlist *sg, int nents,
1581 enum dma_data_direction direction)
1584 dev->dma_ops->unmap_sg(dev, sg, nents, direction);
1586 dma_unmap_sg(dev->dma_device, sg, nents, direction);
1590 * ib_sg_dma_address - Return the DMA address from a scatter/gather entry
1591 * @dev: The device for which the DMA addresses were created
1592 * @sg: The scatter/gather entry
1594 static inline u64 ib_sg_dma_address(struct ib_device *dev,
1595 struct scatterlist *sg)
1598 return dev->dma_ops->dma_address(dev, sg);
1599 return sg_dma_address(sg);
1603 * ib_sg_dma_len - Return the DMA length from a scatter/gather entry
1604 * @dev: The device for which the DMA addresses were created
1605 * @sg: The scatter/gather entry
1607 static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
1608 struct scatterlist *sg)
1611 return dev->dma_ops->dma_len(dev, sg);
1612 return sg_dma_len(sg);
1616 * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU
1617 * @dev: The device for which the DMA address was created
1618 * @addr: The DMA address
1619 * @size: The size of the region in bytes
1620 * @dir: The direction of the DMA
1622 static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
1625 enum dma_data_direction dir)
1628 dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir);
1630 dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
1634 * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device
1635 * @dev: The device for which the DMA address was created
1636 * @addr: The DMA address
1637 * @size: The size of the region in bytes
1638 * @dir: The direction of the DMA
1640 static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
1643 enum dma_data_direction dir)
1646 dev->dma_ops->sync_single_for_device(dev, addr, size, dir);
1648 dma_sync_single_for_device(dev->dma_device, addr, size, dir);
1652 * ib_dma_alloc_coherent - Allocate memory and map it for DMA
1653 * @dev: The device for which the DMA address is requested
1654 * @size: The size of the region to allocate in bytes
1655 * @dma_handle: A pointer for returning the DMA address of the region
1656 * @flag: memory allocator flags
1658 static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
1664 return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
1669 ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
1670 *dma_handle = handle;
1676 * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent()
1677 * @dev: The device for which the DMA addresses were allocated
1678 * @size: The size of the region
1679 * @cpu_addr: the address returned by ib_dma_alloc_coherent()
1680 * @dma_handle: the DMA address returned by ib_dma_alloc_coherent()
1682 static inline void ib_dma_free_coherent(struct ib_device *dev,
1683 size_t size, void *cpu_addr,
1687 dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
1689 dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
1695 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
1697 * @pd: The protection domain associated assigned to the registered region.
1698 * @phys_buf_array: Specifies a list of physical buffers to use in the
1700 * @num_phys_buf: Specifies the size of the phys_buf_array.
1701 * @mr_access_flags: Specifies the memory access rights.
1702 * @iova_start: The offset of the region's starting I/O virtual address.
1704 struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
1705 struct ib_phys_buf *phys_buf_array,
1707 int mr_access_flags,
1711 * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
1712 * Conceptually, this call performs the functions deregister memory region
1713 * followed by register physical memory region. Where possible,
1714 * resources are reused instead of deallocated and reallocated.
1715 * @mr: The memory region to modify.
1716 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1717 * properties of the memory region are being modified.
1718 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1719 * the new protection domain to associated with the memory region,
1720 * otherwise, this parameter is ignored.
1721 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1722 * field specifies a list of physical buffers to use in the new
1723 * translation, otherwise, this parameter is ignored.
1724 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1725 * field specifies the size of the phys_buf_array, otherwise, this
1726 * parameter is ignored.
1727 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1728 * field specifies the new memory access rights, otherwise, this
1729 * parameter is ignored.
1730 * @iova_start: The offset of the region's starting I/O virtual address.
1732 int ib_rereg_phys_mr(struct ib_mr *mr,
1735 struct ib_phys_buf *phys_buf_array,
1737 int mr_access_flags,
1741 * ib_query_mr - Retrieves information about a specific memory region.
1742 * @mr: The memory region to retrieve information about.
1743 * @mr_attr: The attributes of the specified memory region.
1745 int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1748 * ib_dereg_mr - Deregisters a memory region and removes it from the
1749 * HCA translation table.
1750 * @mr: The memory region to deregister.
1752 int ib_dereg_mr(struct ib_mr *mr);
1755 * ib_alloc_mw - Allocates a memory window.
1756 * @pd: The protection domain associated with the memory window.
1758 struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
1761 * ib_bind_mw - Posts a work request to the send queue of the specified
1762 * QP, which binds the memory window to the given address range and
1763 * remote access attributes.
1764 * @qp: QP to post the bind work request on.
1765 * @mw: The memory window to bind.
1766 * @mw_bind: Specifies information about the memory window, including
1767 * its address range, remote access rights, and associated memory region.
1769 static inline int ib_bind_mw(struct ib_qp *qp,
1771 struct ib_mw_bind *mw_bind)
1773 /* XXX reference counting in corresponding MR? */
1774 return mw->device->bind_mw ?
1775 mw->device->bind_mw(qp, mw, mw_bind) :
1780 * ib_dealloc_mw - Deallocates a memory window.
1781 * @mw: The memory window to deallocate.
1783 int ib_dealloc_mw(struct ib_mw *mw);
1786 * ib_alloc_fmr - Allocates a unmapped fast memory region.
1787 * @pd: The protection domain associated with the unmapped region.
1788 * @mr_access_flags: Specifies the memory access rights.
1789 * @fmr_attr: Attributes of the unmapped region.
1791 * A fast memory region must be mapped before it can be used as part of
1794 struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
1795 int mr_access_flags,
1796 struct ib_fmr_attr *fmr_attr);
1799 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1800 * @fmr: The fast memory region to associate with the pages.
1801 * @page_list: An array of physical pages to map to the fast memory region.
1802 * @list_len: The number of pages in page_list.
1803 * @iova: The I/O virtual address to use with the mapped region.
1805 static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
1806 u64 *page_list, int list_len,
1809 return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
1813 * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
1814 * @fmr_list: A linked list of fast memory regions to unmap.
1816 int ib_unmap_fmr(struct list_head *fmr_list);
1819 * ib_dealloc_fmr - Deallocates a fast memory region.
1820 * @fmr: The fast memory region to deallocate.
1822 int ib_dealloc_fmr(struct ib_fmr *fmr);
1825 * ib_attach_mcast - Attaches the specified QP to a multicast group.
1826 * @qp: QP to attach to the multicast group. The QP must be type
1828 * @gid: Multicast group GID.
1829 * @lid: Multicast group LID in host byte order.
1831 * In order to send and receive multicast packets, subnet
1832 * administration must have created the multicast group and configured
1833 * the fabric appropriately. The port associated with the specified
1834 * QP must also be a member of the multicast group.
1836 int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1839 * ib_detach_mcast - Detaches the specified QP from a multicast group.
1840 * @qp: QP to detach from the multicast group.
1841 * @gid: Multicast group GID.
1842 * @lid: Multicast group LID in host byte order.
1844 int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1846 #endif /* IB_VERBS_H */