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 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
41 #if !defined(IB_VERBS_H)
44 #include <iba/ib_types.h>
45 #include <iba/ib_ci.h>
62 enum ib_device_cap_flags {
63 IB_DEVICE_RESIZE_MAX_WR = 1,
64 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
65 IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
66 IB_DEVICE_RAW_MULTI = (1<<3),
67 IB_DEVICE_AUTO_PATH_MIG = (1<<4),
68 IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
69 IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
70 IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
71 IB_DEVICE_SHUTDOWN_PORT = (1<<8),
72 IB_DEVICE_INIT_TYPE = (1<<9),
73 IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
74 IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
75 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
76 IB_DEVICE_SRQ_RESIZE = (1<<13),
77 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
80 struct ib_device_attr {
82 __be64 sys_image_guid;
100 int max_qp_init_rd_atom;
101 int max_ee_init_rd_atom;
102 enum ib_atomic_cap atomic_cap;
109 int max_mcast_qp_attach;
110 int max_total_mcast_qp_attach;
118 u8 local_ca_ack_delay;
121 static inline int ib_mtu_enum_to_int(int mtu)
124 case IB_MTU_256: return 256;
125 case IB_MTU_512: return 512;
126 case IB_MTU_1024: return 1024;
127 case IB_MTU_2048: return 2048;
128 case IB_MTU_4096: return 4096;
139 IB_PORT_ACTIVE_DEFER = 5
142 enum ib_port_cap_flags {
144 IB_PORT_NOTICE_SUP = 1 << 2,
145 IB_PORT_TRAP_SUP = 1 << 3,
146 IB_PORT_OPT_IPD_SUP = 1 << 4,
147 IB_PORT_AUTO_MIGR_SUP = 1 << 5,
148 IB_PORT_SL_MAP_SUP = 1 << 6,
149 IB_PORT_MKEY_NVRAM = 1 << 7,
150 IB_PORT_PKEY_NVRAM = 1 << 8,
151 IB_PORT_LED_INFO_SUP = 1 << 9,
152 IB_PORT_SM_DISABLED = 1 << 10,
153 IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
154 IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
155 IB_PORT_CM_SUP = 1 << 16,
156 IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
157 IB_PORT_REINIT_SUP = 1 << 18,
158 IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
159 IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
160 IB_PORT_DR_NOTICE_SUP = 1 << 21,
161 IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
162 IB_PORT_BOOT_MGMT_SUP = 1 << 23,
163 IB_PORT_LINK_LATENCY_SUP = 1 << 24,
164 IB_PORT_CLIENT_REG_SUP = 1 << 25
174 static inline int ib_width_enum_to_int(enum ib_port_width width)
177 case IB_WIDTH_1X: return 1;
178 case IB_WIDTH_4X: return 4;
179 case IB_WIDTH_8X: return 8;
180 case IB_WIDTH_12X: return 12;
185 struct ib_port_attr {
186 enum ib_port_state state;
188 enum ib_mtu active_mtu;
207 enum ib_device_modify_flags {
208 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1
211 struct ib_device_modify {
215 enum ib_port_modify_flags {
216 IB_PORT_SHUTDOWN = 1,
217 IB_PORT_INIT_TYPE = (1<<2),
218 IB_PORT_RESET_QKEY_CNTR = (1<<3)
221 struct ib_port_modify {
222 u32 set_port_cap_mask;
223 u32 clr_port_cap_mask;
228 IB_EVENT_CQ_ERR = IB_AE_CQ_ERROR,
229 IB_EVENT_QP_FATAL = IB_AE_QP_FATAL,
230 IB_EVENT_QP_REQ_ERR = IB_AE_WQ_REQ_ERROR,
231 IB_EVENT_QP_ACCESS_ERR = IB_AE_WQ_ACCESS_ERROR,
232 IB_EVENT_COMM_EST = IB_AE_QP_COMM,
233 IB_EVENT_SQ_DRAINED = IB_AE_SQ_DRAINED,
234 IB_EVENT_PATH_MIG = IB_AE_QP_APM,
235 IB_EVENT_PATH_MIG_ERR = IB_AE_QP_APM_ERROR,
236 IB_EVENT_DEVICE_FATAL = IB_AE_LOCAL_FATAL,
237 IB_EVENT_PORT_ACTIVE = IB_AE_PORT_ACTIVE,
238 IB_EVENT_PORT_ERR = IB_AE_PORT_DOWN,
239 IB_EVENT_LID_CHANGE = IB_AE_UNKNOWN + 1,
240 IB_EVENT_PKEY_CHANGE,
243 IB_EVENT_SRQ_LIMIT_REACHED,
244 IB_EVENT_QP_LAST_WQE_REACHED
248 struct ib_device *device;
255 enum ib_event_type event;
256 uint64_t vendor_specific;
259 struct ib_event_handler {
260 struct ib_device *device;
261 void (*handler)(struct ib_event_handler *, struct ib_event *);
262 struct list_head list;
265 #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
266 (_ptr)->device = _device; \
267 (_ptr)->handler = _handler; \
268 INIT_LIST_HEAD(&(_ptr)->list)
270 struct ib_global_route {
279 __be32 version_tclass_flow;
288 IB_MULTICAST_QPN = 0xffffff
296 struct ib_global_route grh;
305 #ifdef WIN_TO_BE_REMOVE
306 //define in ib_types.h
311 IB_WC_LOC_EEC_OP_ERR,
316 IB_WC_LOC_ACCESS_ERR,
317 IB_WC_REM_INV_REQ_ERR,
318 IB_WC_REM_ACCESS_ERR,
321 IB_WC_RNR_RETRY_EXC_ERR,
322 IB_WC_LOC_RDD_VIOL_ERR,
323 IB_WC_REM_INV_RD_REQ_ERR,
326 IB_WC_INV_EEC_STATE_ERR,
328 IB_WC_RESP_TIMEOUT_ERR,
338 enum ib_srq_attr_mask {
339 IB_SRQ_MAX_WR = 1 << 0,
340 IB_SRQ_LIMIT = 1 << 1,
349 struct ib_srq_init_attr {
350 void (*event_handler)(struct ib_event *, void *);
352 struct ib_srq_attr attr;
368 struct ib_qp_init_attr {
369 void (*event_handler)(struct ib_event *, void *);
371 struct ib_cq *send_cq;
372 struct ib_cq *recv_cq;
374 struct ib_qp_cap cap;
375 enum ib_sig_type sq_sig_type;
376 enum ib_qp_type_t qp_type;
377 u8 port_num; /* special QP types only */
380 enum ib_rnr_timeout {
381 IB_RNR_TIMER_655_36 = 0,
382 IB_RNR_TIMER_000_01 = 1,
383 IB_RNR_TIMER_000_02 = 2,
384 IB_RNR_TIMER_000_03 = 3,
385 IB_RNR_TIMER_000_04 = 4,
386 IB_RNR_TIMER_000_06 = 5,
387 IB_RNR_TIMER_000_08 = 6,
388 IB_RNR_TIMER_000_12 = 7,
389 IB_RNR_TIMER_000_16 = 8,
390 IB_RNR_TIMER_000_24 = 9,
391 IB_RNR_TIMER_000_32 = 10,
392 IB_RNR_TIMER_000_48 = 11,
393 IB_RNR_TIMER_000_64 = 12,
394 IB_RNR_TIMER_000_96 = 13,
395 IB_RNR_TIMER_001_28 = 14,
396 IB_RNR_TIMER_001_92 = 15,
397 IB_RNR_TIMER_002_56 = 16,
398 IB_RNR_TIMER_003_84 = 17,
399 IB_RNR_TIMER_005_12 = 18,
400 IB_RNR_TIMER_007_68 = 19,
401 IB_RNR_TIMER_010_24 = 20,
402 IB_RNR_TIMER_015_36 = 21,
403 IB_RNR_TIMER_020_48 = 22,
404 IB_RNR_TIMER_030_72 = 23,
405 IB_RNR_TIMER_040_96 = 24,
406 IB_RNR_TIMER_061_44 = 25,
407 IB_RNR_TIMER_081_92 = 26,
408 IB_RNR_TIMER_122_88 = 27,
409 IB_RNR_TIMER_163_84 = 28,
410 IB_RNR_TIMER_245_76 = 29,
411 IB_RNR_TIMER_327_68 = 30,
412 IB_RNR_TIMER_491_52 = 31
415 enum ib_qp_attr_mask {
417 IB_QP_CUR_STATE = (1<<1),
418 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
419 IB_QP_ACCESS_FLAGS = (1<<3),
420 IB_QP_PKEY_INDEX = (1<<4),
424 IB_QP_PATH_MTU = (1<<8),
425 IB_QP_TIMEOUT = (1<<9),
426 IB_QP_RETRY_CNT = (1<<10),
427 IB_QP_RNR_RETRY = (1<<11),
428 IB_QP_RQ_PSN = (1<<12),
429 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
430 IB_QP_ALT_PATH = (1<<14),
431 IB_QP_MIN_RNR_TIMER = (1<<15),
432 IB_QP_SQ_PSN = (1<<16),
433 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
434 IB_QP_PATH_MIG_STATE = (1<<18),
436 IB_QP_DEST_QPN = (1<<20)
439 //TODO: these literals are also defined in ib_types.h and have there ANOTHER VALUES !!!
452 enum ib_qp_state qp_state;
453 enum ib_qp_state cur_qp_state;
454 enum ib_mtu path_mtu;
455 ib_apm_state_t path_mig_state;
461 struct ib_qp_cap cap;
462 struct ib_ah_attr ah_attr;
463 struct ib_ah_attr alt_ah_attr;
466 u8 en_sqd_async_notify;
469 u8 max_dest_rd_atomic;
486 typedef enum MTHCA_QP_ACCESS_FLAGS {
487 MTHCA_ACCESS_LOCAL_WRITE = 1,
488 MTHCA_ACCESS_REMOTE_WRITE = (1<<1),
489 MTHCA_ACCESS_REMOTE_READ = (1<<2),
490 MTHCA_ACCESS_REMOTE_ATOMIC = (1<<3),
491 MTHCA_ACCESS_MW_BIND = (1<<4)
501 u64 device_virt_addr;
503 mthca_qp_access_t mr_access_flags;
508 enum ib_mr_rereg_flags {
509 IB_MR_REREG_TRANS = 1,
510 IB_MR_REREG_PD = (1<<1),
511 IB_MR_REREG_ACCESS = (1<<2)
530 struct ib_device *device;
533 atomic_t usecnt; /* count all resources */
535 cl_list_item_t list_item; // chain of user contexts
544 u64 user_handle; /* handle given to us by userspace */
545 struct ib_ucontext *context; /* associated user context */
546 struct list_head list; /* link to context's list */
547 u32 id; /* index into kernel idr */
557 struct list_head chunk_list;
560 #pragma warning( disable : 4200 )
561 struct ib_umem_chunk {
562 struct list_head list;
565 struct scatterlist page_list[0];
567 #pragma warning( default : 4200 )
576 #define IB_UMEM_MAX_PAGE_CHUNK \
577 ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
578 ((char *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
579 (char *) &((struct ib_umem_chunk *) 0)->page_list[0]))
581 struct ib_umem_object {
582 struct ib_uobject uobject;
587 struct list_head list; /* for chaining AV MRs (for user mode only) */
588 struct ib_device *device;
589 struct ib_ucontext *ucontext;
590 atomic_t usecnt; /* count all resources */
591 KMUTEX mutex; /* for chaining AV MRs (for user mode only) */
595 struct ib_device *device;
597 struct ib_ucontext *ucontext;
600 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
603 struct ib_device *device;
604 struct ib_ucontext *ucontext;
606 ib_comp_handler comp_handler;
607 void (*event_handler)(struct ib_event *, void *);
610 atomic_t usecnt; /* count number of work queues */
614 struct ib_device *device;
616 struct ib_uobject *uobject;
617 void (*event_handler)(struct ib_event *, void *);
623 struct ib_device *device;
625 struct ib_cq *send_cq;
626 struct ib_cq *recv_cq;
628 struct ib_ucontext *ucontext;
630 void (*event_handler)(struct ib_event *, void *);
633 enum ib_qp_type_t qp_type;
637 struct list_head list; /* for chaining AV MRs (for user mode only) */
638 struct ib_device *device;
642 atomic_t usecnt; /* count number of MWs */
646 struct ib_device *device;
652 struct ib_device *device;
654 struct list_head list;
662 enum ib_process_mad_flags {
663 IB_MAD_IGNORE_MKEY = 1,
664 IB_MAD_IGNORE_BKEY = 2,
665 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
669 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
670 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
671 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
672 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
675 #define IB_DEVICE_NAME_MAX 64
679 struct ib_event_handler event_handler;
680 struct ib_pkey_cache **pkey_cache;
681 struct ib_gid_cache **gid_cache;
687 struct mthca_dev *mdev;
689 char name[IB_DEVICE_NAME_MAX];
691 struct list_head event_handler_list;
692 spinlock_t event_handler_lock;
694 struct list_head core_list;
695 struct list_head client_data_list;
696 spinlock_t client_data_lock;
698 struct ib_cache cache;
702 int (*query_device)(struct ib_device *device,
703 struct ib_device_attr *device_attr);
704 int (*query_port)(struct ib_device *device,
706 struct ib_port_attr *port_attr);
707 int (*query_gid_chunk)(struct ib_device *device,
708 u8 port_num, int index,
709 union ib_gid gid[8]);
710 int (*query_pkey_chunk)(struct ib_device *device,
711 u8 port_num, u16 index, u16 pkey[32]);
712 int (*modify_device)(struct ib_device *device,
713 int device_modify_mask,
714 struct ib_device_modify *device_modify);
715 int (*modify_port)(struct ib_device *device,
716 u8 port_num, int port_modify_mask,
717 struct ib_port_modify *port_modify);
718 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
719 ci_umv_buf_t* const p_umv_buf);
720 int (*dealloc_ucontext)(struct ib_ucontext *context);
721 struct ib_pd * (*alloc_pd)(struct ib_device *device,
722 struct ib_ucontext *context,
723 ci_umv_buf_t* const p_umv_buf);
724 int (*dealloc_pd)(struct ib_pd *pd);
725 struct ib_ah * (*create_ah)(struct ib_pd *pd,
726 struct ib_ah_attr *ah_attr);
727 int (*modify_ah)(struct ib_ah *ah,
728 struct ib_ah_attr *ah_attr);
729 int (*query_ah)(struct ib_ah *ah,
730 struct ib_ah_attr *ah_attr);
731 int (*destroy_ah)(struct ib_ah *ah);
732 struct ib_srq * (*create_srq)(struct ib_pd *pd,
733 struct ib_srq_init_attr *srq_init_attr,
734 ci_umv_buf_t* const p_umv_buf);
735 int (*modify_srq)(struct ib_srq *srq,
736 struct ib_srq_attr *srq_attr,
737 enum ib_srq_attr_mask srq_attr_mask);
738 int (*query_srq)(struct ib_srq *srq,
739 struct ib_srq_attr *srq_attr);
740 int (*destroy_srq)(struct ib_srq *srq);
741 int (*post_srq_recv)(struct ib_srq *srq,
742 struct _ib_recv_wr *recv_wr,
743 struct _ib_recv_wr **bad_recv_wr);
744 struct ib_qp * (*create_qp)(struct ib_pd *pd,
745 struct ib_qp_init_attr *qp_init_attr,
746 ci_umv_buf_t* const p_umv_buf);
747 int (*modify_qp)(struct ib_qp *qp,
748 struct ib_qp_attr *qp_attr,
750 int (*query_qp)(struct ib_qp *qp,
751 struct ib_qp_attr *qp_attr,
753 struct ib_qp_init_attr *qp_init_attr);
754 int (*destroy_qp)(struct ib_qp *qp);
755 int (*post_send)(struct ib_qp *qp,
756 struct _ib_send_wr *send_wr,
757 struct _ib_send_wr **bad_send_wr);
758 int (*post_recv)(struct ib_qp *qp,
759 struct _ib_recv_wr *recv_wr,
760 struct _ib_recv_wr **bad_recv_wr);
761 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
762 struct ib_ucontext *context,
763 ci_umv_buf_t* const p_umv_buf);
764 int (*destroy_cq)(struct ib_cq *cq);
765 int (*resize_cq)(struct ib_cq *cq, int *cqe);
766 int (*poll_cq)(struct ib_cq *cq, int num_entries,
768 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
769 int (*req_notify_cq)(struct ib_cq *cq,
770 enum ib_cq_notify cq_notify);
771 int (*req_ncomp_notif)(struct ib_cq *cq,
773 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
774 mthca_qp_access_t mr_access_flags);
775 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
776 struct ib_phys_buf *phys_buf_array,
778 mthca_qp_access_t mr_access_flags,
780 struct ib_mr * (*reg_virt_mr)(struct ib_pd *pd,
781 void* __ptr64 vaddr, uint64_t length, uint64_t hca_va,
782 mthca_qp_access_t acc, boolean_t um_call);
783 int (*query_mr)(struct ib_mr *mr,
784 struct ib_mr_attr *mr_attr);
785 int (*dereg_mr)(struct ib_mr *mr);
786 int (*rereg_phys_mr)(struct ib_mr *mr,
789 struct ib_phys_buf *phys_buf_array,
791 mthca_qp_access_t mr_access_flags,
793 struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
794 int (*bind_mw)(struct ib_qp *qp,
796 struct ib_mw_bind *mw_bind);
797 int (*dealloc_mw)(struct ib_mw *mw);
798 struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
799 mthca_qp_access_t mr_access_flags,
800 struct ib_fmr_attr *fmr_attr);
801 int (*map_phys_fmr)(struct ib_fmr *fmr,
802 u64 *page_list, int list_len,
804 int (*unmap_fmr)(struct list_head *fmr_list);
805 int (*dealloc_fmr)(struct ib_fmr *fmr);
806 int (*attach_mcast)(struct ib_qp *qp,
809 int (*detach_mcast)(struct ib_qp *qp,
812 int (*process_mad)(struct ib_device *device,
813 int process_mad_flags,
815 struct _ib_wc *in_wc,
816 struct _ib_grh *in_grh,
817 struct ib_mad *in_mad,
818 struct ib_mad *out_mad);
820 struct list_head port_list;
830 void (*add) (struct ib_device *);
831 void (*remove)(struct ib_device *);
833 struct list_head list;
836 struct ib_device *ib_alloc_device(size_t size);
837 void ib_dealloc_device(struct ib_device *device);
839 int ib_register_device (struct ib_device *device);
840 void ib_unregister_device(struct ib_device *device);
842 int ib_register_client (struct ib_client *client);
843 void ib_unregister_client(struct ib_client *client);
845 void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
846 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
849 int ib_core_init(void);
851 void ib_core_cleanup(void);
853 int ib_register_event_handler (struct ib_event_handler *event_handler);
854 int ib_unregister_event_handler(struct ib_event_handler *event_handler);
855 void ib_dispatch_event(struct ib_event *event);
857 int ib_query_device(struct ib_device *device,
858 struct ib_device_attr *device_attr);
860 int ib_query_port(struct ib_device *device,
861 u8 port_num, struct ib_port_attr *port_attr);
863 int ib_query_gid_chunk(struct ib_device *device,
864 u8 port_num, int index, union ib_gid gid[8]);
866 int ib_query_pkey_chunk(struct ib_device *device,
867 u8 port_num, u16 index, u16 pkey[32]);
869 int ib_modify_device(struct ib_device *device,
870 int device_modify_mask,
871 struct ib_device_modify *device_modify);
873 int ib_modify_port(struct ib_device *device,
874 u8 port_num, int port_modify_mask,
875 struct ib_port_modify *port_modify);
878 * ibv_alloc_pd - Allocates an unused protection domain.
879 * @device: The device on which to allocate the protection domain.
880 * @context: user process context (for application calls only)
881 * @p_umv_buf: parameters structure (for application calls only)
883 * A protection domain object provides an association between QPs, shared
884 * receive queues, address handles, memory regions, and memory windows.
886 struct ib_pd *ibv_alloc_pd(struct ib_device *device,
887 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
890 * ibv_dealloc_pd - Deallocates a protection domain.
891 * @pd: The protection domain to deallocate.
893 int ibv_dealloc_pd(struct ib_pd *pd);
896 * ibv_create_ah - Creates an address handle for the given address vector.
897 * @pd: The protection domain associated with the address handle.
898 * @ah_attr: The attributes of the address vector.
899 * @context: user process context (for application calls only)
900 * @p_umv_buf: parameters structure (for application calls only)
902 * The address handle is used to reference a local or global destination
903 * in all UD QP post sends.
905 struct ib_ah *ibv_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
906 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
909 * ibv_create_ah_from_wc - Creates an address handle associated with the
910 * sender of the specified work completion.
911 * @pd: The protection domain associated with the address handle.
912 * @wc: Work completion information associated with a received message.
913 * @grh: References the received global route header. This parameter is
914 * ignored unless the work completion indicates that the GRH is valid.
915 * @port_num: The outbound port number to associate with the address.
917 * The address handle is used to reference a local or global destination
918 * in all UD QP post sends.
920 struct ib_ah *ibv_create_ah_from_wc(struct ib_pd *pd, struct _ib_wc *wc,
921 struct ib_grh *grh, u8 port_num);
924 * ibv_modify_ah - Modifies the address vector associated with an address
926 * @ah: The address handle to modify.
927 * @ah_attr: The new address vector attributes to associate with the
930 int ibv_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
933 * ibv_query_ah - Queries the address vector associated with an address
935 * @ah: The address handle to query.
936 * @ah_attr: The address vector attributes associated with the address
939 int ibv_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
942 * ibv_destroy_ah - Destroys an address handle.
943 * @ah: The address handle to destroy.
945 int ibv_destroy_ah(struct ib_ah *ah);
948 * ibv_create_srq - Creates a SRQ associated with the specified protection
950 * @pd: The protection domain associated with the SRQ.
951 * @srq_init_attr: A list of initial attributes required to create the
952 * SRQ. If SRQ creation succeeds, then the attributes are updated to
953 * the actual capabilities of the created SRQ.
955 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
956 * requested size of the SRQ, and set to the actual values allocated
957 * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
958 * will always be at least as large as the requested values.
960 struct ib_srq *ibv_create_srq(struct ib_pd *pd,
961 struct ib_srq_init_attr *srq_init_attr);
964 * ibv_modify_srq - Modifies the attributes for the specified SRQ.
965 * @srq: The SRQ to modify.
966 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
967 * the current values of selected SRQ attributes are returned.
968 * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
969 * are being modified.
971 * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
972 * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
973 * the number of receives queued drops below the limit.
975 int ibv_modify_srq(struct ib_srq *srq,
976 struct ib_srq_attr *srq_attr,
977 enum ib_srq_attr_mask srq_attr_mask);
980 * ibv_query_srq - Returns the attribute list and current values for the
982 * @srq: The SRQ to query.
983 * @srq_attr: The attributes of the specified SRQ.
985 int ibv_query_srq(struct ib_srq *srq,
986 struct ib_srq_attr *srq_attr);
989 * ibv_destroy_srq - Destroys the specified SRQ.
990 * @srq: The SRQ to destroy.
992 int ibv_destroy_srq(struct ib_srq *srq);
995 * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ.
996 * @srq: The SRQ to post the work request on.
997 * @recv_wr: A list of work requests to post on the receive queue.
998 * @bad_recv_wr: On an immediate failure, this parameter will reference
999 * the work request that failed to be posted on the QP.
1001 static inline int ibv_post_srq_recv(struct ib_srq *srq,
1002 struct _ib_recv_wr *recv_wr,
1003 struct _ib_recv_wr **bad_recv_wr)
1005 return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
1009 * ibv_create_qp - Creates a QP associated with the specified protection
1011 * @pd: The protection domain associated with the QP.
1012 * @qp_init_attr: A list of initial attributes required to create the
1013 * QP. If QP creation succeeds, then the attributes are updated to
1014 * the actual capabilities of the created QP.
1015 * @context: user process context (for application calls only)
1016 * @p_umv_buf: parameters structure (for application calls only)
1018 struct ib_qp *ibv_create_qp(struct ib_pd *pd,
1019 struct ib_qp_init_attr *qp_init_attr,
1020 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
1023 * ibv_modify_qp - Modifies the attributes for the specified QP and then
1024 * transitions the QP to the given state.
1025 * @qp: The QP to modify.
1026 * @qp_attr: On input, specifies the QP attributes to modify. On output,
1027 * the current values of selected QP attributes are returned.
1028 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
1029 * are being modified.
1031 int ibv_modify_qp(struct ib_qp *qp,
1032 struct ib_qp_attr *qp_attr,
1036 * ibv_query_qp - Returns the attribute list and current values for the
1038 * @qp: The QP to query.
1039 * @qp_attr: The attributes of the specified QP.
1040 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
1041 * @qp_init_attr: Additional attributes of the selected QP.
1043 * The qp_attr_mask may be used to limit the query to gathering only the
1044 * selected attributes.
1046 int ibv_query_qp(struct ib_qp *qp,
1047 struct ib_qp_attr *qp_attr,
1049 struct ib_qp_init_attr *qp_init_attr);
1052 * ibv_destroy_qp - Destroys the specified QP.
1053 * @qp: The QP to destroy.
1055 int ibv_destroy_qp(struct ib_qp *qp);
1058 * ib_post_send - Posts a list of work requests to the send queue of
1060 * @qp: The QP to post the work request on.
1061 * @send_wr: A list of work requests to post on the send queue.
1062 * @bad_send_wr: On an immediate failure, this parameter will reference
1063 * the work request that failed to be posted on the QP.
1065 static inline int ib_post_send(struct ib_qp *qp,
1066 struct _ib_send_wr *send_wr,
1067 struct _ib_send_wr **bad_send_wr)
1069 return qp->device->post_send(qp, send_wr, bad_send_wr);
1073 * ib_post_recv - Posts a list of work requests to the receive queue of
1075 * @qp: The QP to post the work request on.
1076 * @recv_wr: A list of work requests to post on the receive queue.
1077 * @bad_recv_wr: On an immediate failure, this parameter will reference
1078 * the work request that failed to be posted on the QP.
1080 static inline int ib_post_recv(struct ib_qp *qp,
1081 struct _ib_recv_wr *recv_wr,
1082 struct _ib_recv_wr **bad_recv_wr)
1084 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1088 * ibv_create_cq - Creates a CQ on the specified device.
1089 * @device: The device on which to create the CQ.
1090 * @comp_handler: A user-specified callback that is invoked when a
1091 * completion event occurs on the CQ.
1092 * @event_handler: A user-specified callback that is invoked when an
1093 * asynchronous event not associated with a completion occurs on the CQ.
1094 * @cq_context: Context associated with the CQ returned to the user via
1095 * the associated completion and event handlers.
1096 * @cqe: The minimum size of the CQ.
1097 * @context: user process context (for application calls only)
1098 * @p_umv_buf: parameters structure (for application calls only)
1100 * Users can examine the cq structure to determine the actual CQ size.
1102 struct ib_cq *ibv_create_cq(struct ib_device *device,
1103 ib_comp_handler comp_handler,
1104 void (*event_handler)(struct ib_event *, void *),
1105 void *cq_context, int cqe,
1106 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
1109 * ibv_resize_cq - Modifies the capacity of the CQ.
1110 * @cq: The CQ to resize.
1111 * @cqe: The minimum size of the CQ.
1113 * Users can examine the cq structure to determine the actual CQ size.
1115 int ibv_resize_cq(struct ib_cq *cq, int cqe);
1118 * ibv_destroy_cq - Destroys the specified CQ.
1119 * @cq: The CQ to destroy.
1121 int ibv_destroy_cq(struct ib_cq *cq);
1124 * ib_poll_cq - poll a CQ for completion(s)
1125 * @cq:the CQ being polled
1126 * @num_entries:maximum number of completions to return
1127 * @wc:array of at least @num_entries &struct _ib_wc where completions
1130 * Poll a CQ for (possibly multiple) completions. If the return value
1131 * is < 0, an error occurred. If the return value is >= 0, it is the
1132 * number of completions returned. If the return value is
1133 * non-negative and < num_entries, then the CQ was emptied.
1135 static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
1138 return cq->device->poll_cq(cq, num_entries, wc);
1142 * ib_peek_cq - Returns the number of unreaped completions currently
1143 * on the specified CQ.
1144 * @cq: The CQ to peek.
1145 * @wc_cnt: A minimum number of unreaped completions to check for.
1147 * If the number of unreaped completions is greater than or equal to wc_cnt,
1148 * this function returns wc_cnt, otherwise, it returns the actual number of
1149 * unreaped completions.
1151 int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1154 * ib_req_notify_cq - Request completion notification on a CQ.
1155 * @cq: The CQ to generate an event for.
1156 * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
1157 * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
1158 * notification will occur on the next completion.
1160 static inline int ib_req_notify_cq(struct ib_cq *cq,
1161 enum ib_cq_notify cq_notify)
1163 return cq->device->req_notify_cq(cq, cq_notify);
1167 * ib_req_ncomp_notif - Request completion notification when there are
1168 * at least the specified number of unreaped completions on the CQ.
1169 * @cq: The CQ to generate an event for.
1170 * @wc_cnt: The number of unreaped completions that should be on the
1171 * CQ before an event is generated.
1173 static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1175 return cq->device->req_ncomp_notif ?
1176 cq->device->req_ncomp_notif(cq, wc_cnt) :
1181 * ibv_reg_mr - Prepares a virtually addressed memory region for use
1183 * @pd: The protection domain associated assigned to the registered region.
1184 * @vaddr: virtual address of the region
1185 * @length: Specifies the size of the region.
1186 * @hca_va: virtual address in HCA
1187 * @mr_access_flags: Specifies the memory access rights.
1188 * @um_call: call from user, when TRUE.
1190 struct ib_mr *ibv_reg_mr(struct ib_pd *pd,
1191 mthca_qp_access_t mr_access_flags,
1192 void* __ptr64 vaddr,
1199 * ibv_get_dma_mr - Returns a memory region for system memory that is
1201 * @pd: The protection domain associated with the memory region.
1202 * @mr_access_flags: Specifies the memory access rights.
1204 struct ib_mr *ibv_get_dma_mr(struct ib_pd *pd, mthca_qp_access_t mr_access_flags);
1207 * ibv_reg_phys_mr - Prepares a virtually addressed memory region for use
1209 * @pd: The protection domain associated assigned to the registered region.
1210 * @phys_buf_array: Specifies a list of physical buffers to use in the
1212 * @num_phys_buf: Specifies the size of the phys_buf_array.
1213 * @mr_access_flags: Specifies the memory access rights.
1214 * @iova_start: The offset of the region's starting I/O virtual address.
1216 struct ib_mr *ibv_reg_phys_mr(struct ib_pd *pd,
1217 struct ib_phys_buf *phys_buf_array,
1219 mthca_qp_access_t mr_access_flags,
1223 * ibv_rereg_phys_mr - Modifies the attributes of an existing memory region.
1224 * Conceptually, this call performs the functions deregister memory region
1225 * followed by register physical memory region. Where possible,
1226 * resources are reused instead of deallocated and reallocated.
1227 * @mr: The memory region to modify.
1228 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1229 * properties of the memory region are being modified.
1230 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1231 * the new protection domain to associated with the memory region,
1232 * otherwise, this parameter is ignored.
1233 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1234 * field specifies a list of physical buffers to use in the new
1235 * translation, otherwise, this parameter is ignored.
1236 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1237 * field specifies the size of the phys_buf_array, otherwise, this
1238 * parameter is ignored.
1239 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1240 * field specifies the new memory access rights, otherwise, this
1241 * parameter is ignored.
1242 * @iova_start: The offset of the region's starting I/O virtual address.
1244 int ibv_rereg_phys_mr(struct ib_mr *mr,
1247 struct ib_phys_buf *phys_buf_array,
1249 mthca_qp_access_t mr_access_flags,
1253 * ibv_query_mr - Retrieves information about a specific memory region.
1254 * @mr: The memory region to retrieve information about.
1255 * @mr_attr: The attributes of the specified memory region.
1257 int ibv_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1260 * ibv_dereg_mr - Deregisters a memory region and removes it from the
1261 * HCA translation table.
1262 * @mr: The memory region to deregister.
1264 int ibv_dereg_mr(struct ib_mr *mr);
1267 * ibv_alloc_mw - Allocates a memory window.
1268 * @pd: The protection domain associated with the memory window.
1270 struct ib_mw *ibv_alloc_mw(struct ib_pd *pd);
1273 * ib_bind_mw - Posts a work request to the send queue of the specified
1274 * QP, which binds the memory window to the given address range and
1275 * remote access attributes.
1276 * @qp: QP to post the bind work request on.
1277 * @mw: The memory window to bind.
1278 * @mw_bind: Specifies information about the memory window, including
1279 * its address range, remote access rights, and associated memory region.
1281 static inline int ib_bind_mw(struct ib_qp *qp,
1283 struct ib_mw_bind *mw_bind)
1285 /* XXX reference counting in corresponding MR? */
1286 return mw->device->bind_mw ?
1287 mw->device->bind_mw(qp, mw, mw_bind) :
1292 * ibv_dealloc_mw - Deallocates a memory window.
1293 * @mw: The memory window to deallocate.
1295 int ibv_dealloc_mw(struct ib_mw *mw);
1298 * ibv_alloc_fmr - Allocates a unmapped fast memory region.
1299 * @pd: The protection domain associated with the unmapped region.
1300 * @mr_access_flags: Specifies the memory access rights.
1301 * @fmr_attr: Attributes of the unmapped region.
1303 * A fast memory region must be mapped before it can be used as part of
1306 struct ib_fmr *ibv_alloc_fmr(struct ib_pd *pd,
1307 mthca_qp_access_t mr_access_flags,
1308 struct ib_fmr_attr *fmr_attr);
1311 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1312 * @fmr: The fast memory region to associate with the pages.
1313 * @page_list: An array of physical pages to map to the fast memory region.
1314 * @list_len: The number of pages in page_list.
1315 * @iova: The I/O virtual address to use with the mapped region.
1317 int ibv_map_phys_fmr(struct ib_fmr *fmr,
1318 u64 *page_list, int list_len,
1322 * ibv_unmap_fmr - Removes the mapping from a list of fast memory regions.
1323 * @fmr_list: A linked list of fast memory regions to unmap.
1325 int ibv_unmap_fmr(struct list_head *fmr_list);
1328 * ibv_dealloc_fmr - Deallocates a fast memory region.
1329 * @fmr: The fast memory region to deallocate.
1331 int ibv_dealloc_fmr(struct ib_fmr *fmr);
1334 * ibv_attach_mcast - Attaches the specified QP to a multicast group.
1335 * @qp: QP to attach to the multicast group. The QP must be type
1336 * IB_QPT_UNRELIABLE_DGRM.
1337 * @gid: Multicast group GID.
1338 * @lid: Multicast group LID in host byte order.
1340 * In order to send and receive multicast packets, subnet
1341 * administration must have created the multicast group and configured
1342 * the fabric appropriately. The port associated with the specified
1343 * QP must also be a member of the multicast group.
1345 int ibv_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1348 * ibv_detach_mcast - Detaches the specified QP from a multicast group.
1349 * @qp: QP to detach from the multicast group.
1350 * @gid: Multicast group GID.
1351 * @lid: Multicast group LID in host byte order.
1353 int ibv_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1356 * ibv_um_close - Releases application.
1357 * @h_um_ca: application context
1359 void ibv_um_close(struct ib_ucontext * h_um_ca);
1361 #endif /* IB_VERBS_H */