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
38 * $Id: ib_verbs.h 2975 2005-08-04 04:59:37Z roland $
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;
258 struct ib_event_handler {
259 struct ib_device *device;
260 void (*handler)(struct ib_event_handler *, struct ib_event *);
261 struct list_head list;
264 #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
265 (_ptr)->device = _device; \
266 (_ptr)->handler = _handler; \
267 INIT_LIST_HEAD(&(_ptr)->list)
269 struct ib_global_route {
278 __be32 version_tclass_flow;
287 IB_MULTICAST_QPN = 0xffffff
295 struct ib_global_route grh;
304 #ifdef WIN_TO_BE_REMOVE
305 //define in ib_types.h
310 IB_WC_LOC_EEC_OP_ERR,
315 IB_WC_LOC_ACCESS_ERR,
316 IB_WC_REM_INV_REQ_ERR,
317 IB_WC_REM_ACCESS_ERR,
320 IB_WC_RNR_RETRY_EXC_ERR,
321 IB_WC_LOC_RDD_VIOL_ERR,
322 IB_WC_REM_INV_RD_REQ_ERR,
325 IB_WC_INV_EEC_STATE_ERR,
327 IB_WC_RESP_TIMEOUT_ERR,
337 enum ib_srq_attr_mask {
338 IB_SRQ_MAX_WR = 1 << 0,
339 IB_SRQ_LIMIT = 1 << 1,
348 struct ib_srq_init_attr {
349 void (*event_handler)(struct ib_event *, void *);
351 struct ib_srq_attr attr;
367 struct ib_qp_init_attr {
368 void (*event_handler)(struct ib_event *, void *);
370 struct ib_cq *send_cq;
371 struct ib_cq *recv_cq;
373 struct ib_qp_cap cap;
374 enum ib_sig_type sq_sig_type;
375 enum ib_qp_type_t qp_type;
376 u8 port_num; /* special QP types only */
379 enum ib_rnr_timeout {
380 IB_RNR_TIMER_655_36 = 0,
381 IB_RNR_TIMER_000_01 = 1,
382 IB_RNR_TIMER_000_02 = 2,
383 IB_RNR_TIMER_000_03 = 3,
384 IB_RNR_TIMER_000_04 = 4,
385 IB_RNR_TIMER_000_06 = 5,
386 IB_RNR_TIMER_000_08 = 6,
387 IB_RNR_TIMER_000_12 = 7,
388 IB_RNR_TIMER_000_16 = 8,
389 IB_RNR_TIMER_000_24 = 9,
390 IB_RNR_TIMER_000_32 = 10,
391 IB_RNR_TIMER_000_48 = 11,
392 IB_RNR_TIMER_000_64 = 12,
393 IB_RNR_TIMER_000_96 = 13,
394 IB_RNR_TIMER_001_28 = 14,
395 IB_RNR_TIMER_001_92 = 15,
396 IB_RNR_TIMER_002_56 = 16,
397 IB_RNR_TIMER_003_84 = 17,
398 IB_RNR_TIMER_005_12 = 18,
399 IB_RNR_TIMER_007_68 = 19,
400 IB_RNR_TIMER_010_24 = 20,
401 IB_RNR_TIMER_015_36 = 21,
402 IB_RNR_TIMER_020_48 = 22,
403 IB_RNR_TIMER_030_72 = 23,
404 IB_RNR_TIMER_040_96 = 24,
405 IB_RNR_TIMER_061_44 = 25,
406 IB_RNR_TIMER_081_92 = 26,
407 IB_RNR_TIMER_122_88 = 27,
408 IB_RNR_TIMER_163_84 = 28,
409 IB_RNR_TIMER_245_76 = 29,
410 IB_RNR_TIMER_327_68 = 30,
411 IB_RNR_TIMER_491_52 = 31
414 enum ib_qp_attr_mask {
416 IB_QP_CUR_STATE = (1<<1),
417 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
418 IB_QP_ACCESS_FLAGS = (1<<3),
419 IB_QP_PKEY_INDEX = (1<<4),
423 IB_QP_PATH_MTU = (1<<8),
424 IB_QP_TIMEOUT = (1<<9),
425 IB_QP_RETRY_CNT = (1<<10),
426 IB_QP_RNR_RETRY = (1<<11),
427 IB_QP_RQ_PSN = (1<<12),
428 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
429 IB_QP_ALT_PATH = (1<<14),
430 IB_QP_MIN_RNR_TIMER = (1<<15),
431 IB_QP_SQ_PSN = (1<<16),
432 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
433 IB_QP_PATH_MIG_STATE = (1<<18),
435 IB_QP_DEST_QPN = (1<<20)
438 //TODO: these literals are also defined in ib_types.h and have there ANOTHER VALUES !!!
451 enum ib_qp_state qp_state;
452 enum ib_qp_state cur_qp_state;
453 enum ib_mtu path_mtu;
454 ib_apm_state_t path_mig_state;
460 struct ib_qp_cap cap;
461 struct ib_ah_attr ah_attr;
462 struct ib_ah_attr alt_ah_attr;
465 u8 en_sqd_async_notify;
468 u8 max_dest_rd_atomic;
485 typedef enum MTHCA_QP_ACCESS_FLAGS {
486 MTHCA_ACCESS_LOCAL_WRITE = 1,
487 MTHCA_ACCESS_REMOTE_WRITE = (1<<1),
488 MTHCA_ACCESS_REMOTE_READ = (1<<2),
489 MTHCA_ACCESS_REMOTE_ATOMIC = (1<<3),
490 MTHCA_ACCESS_MW_BIND = (1<<4)
500 u64 device_virt_addr;
502 mthca_qp_access_t mr_access_flags;
507 enum ib_mr_rereg_flags {
508 IB_MR_REREG_TRANS = 1,
509 IB_MR_REREG_PD = (1<<1),
510 IB_MR_REREG_ACCESS = (1<<2)
529 struct ib_device *device;
532 atomic_t usecnt; /* count all resources */
542 u64 user_handle; /* handle given to us by userspace */
543 struct ib_ucontext *context; /* associated user context */
544 struct list_head list; /* link to context's list */
545 u32 id; /* index into kernel idr */
555 struct list_head chunk_list;
558 #pragma warning( disable : 4200 )
559 struct ib_umem_chunk {
560 struct list_head list;
563 struct scatterlist page_list[0];
565 #pragma warning( default : 4200 )
574 #define IB_UMEM_MAX_PAGE_CHUNK \
575 ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
576 ((char *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
577 (char *) &((struct ib_umem_chunk *) 0)->page_list[0]))
579 struct ib_umem_object {
580 struct ib_uobject uobject;
585 struct ib_device *device;
586 struct ib_ucontext *ucontext;
587 atomic_t usecnt; /* count all resources */
591 struct ib_device *device;
593 struct ib_ucontext *ucontext;
597 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
600 struct ib_device *device;
601 struct ib_ucontext *ucontext;
603 ib_comp_handler comp_handler;
604 void (*event_handler)(struct ib_event *, void *);
607 atomic_t usecnt; /* count number of work queues */
611 struct ib_device *device;
613 struct ib_uobject *uobject;
614 void (*event_handler)(struct ib_event *, void *);
620 struct ib_device *device;
622 struct ib_cq *send_cq;
623 struct ib_cq *recv_cq;
625 struct ib_ucontext *ucontext;
627 void (*event_handler)(struct ib_event *, void *);
630 enum ib_qp_type_t qp_type;
634 struct ib_device *device;
638 atomic_t usecnt; /* count number of MWs */
642 struct ib_device *device;
648 struct ib_device *device;
650 struct list_head list;
658 enum ib_process_mad_flags {
659 IB_MAD_IGNORE_MKEY = 1,
660 IB_MAD_IGNORE_BKEY = 2,
661 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
665 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
666 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
667 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
668 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
671 #define IB_DEVICE_NAME_MAX 64
675 struct ib_event_handler event_handler;
676 struct ib_pkey_cache **pkey_cache;
677 struct ib_gid_cache **gid_cache;
683 struct mthca_dev *mdev;
685 char name[IB_DEVICE_NAME_MAX];
687 struct list_head event_handler_list;
688 spinlock_t event_handler_lock;
690 struct list_head core_list;
691 struct list_head client_data_list;
692 spinlock_t client_data_lock;
694 struct ib_cache cache;
698 int (*query_device)(struct ib_device *device,
699 struct ib_device_attr *device_attr);
700 int (*query_port)(struct ib_device *device,
702 struct ib_port_attr *port_attr);
703 int (*query_gid)(struct ib_device *device,
704 u8 port_num, int index,
706 int (*query_pkey)(struct ib_device *device,
707 u8 port_num, u16 index, u16 *pkey);
708 int (*modify_device)(struct ib_device *device,
709 int device_modify_mask,
710 struct ib_device_modify *device_modify);
711 int (*modify_port)(struct ib_device *device,
712 u8 port_num, int port_modify_mask,
713 struct ib_port_modify *port_modify);
714 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
715 ci_umv_buf_t* const p_umv_buf);
716 int (*dealloc_ucontext)(struct ib_ucontext *context);
717 struct ib_pd * (*alloc_pd)(struct ib_device *device,
718 struct ib_ucontext *context,
719 ci_umv_buf_t* const p_umv_buf);
720 int (*dealloc_pd)(struct ib_pd *pd);
721 struct ib_ah * (*create_ah)(struct ib_pd *pd,
722 struct ib_ah_attr *ah_attr);
723 int (*modify_ah)(struct ib_ah *ah,
724 struct ib_ah_attr *ah_attr);
725 int (*query_ah)(struct ib_ah *ah,
726 struct ib_ah_attr *ah_attr);
727 int (*destroy_ah)(struct ib_ah *ah);
728 struct ib_srq * (*create_srq)(struct ib_pd *pd,
729 struct ib_srq_init_attr *srq_init_attr,
730 ci_umv_buf_t* const p_umv_buf);
731 int (*modify_srq)(struct ib_srq *srq,
732 struct ib_srq_attr *srq_attr,
733 enum ib_srq_attr_mask srq_attr_mask);
734 int (*query_srq)(struct ib_srq *srq,
735 struct ib_srq_attr *srq_attr);
736 int (*destroy_srq)(struct ib_srq *srq);
737 int (*post_srq_recv)(struct ib_srq *srq,
738 struct _ib_recv_wr *recv_wr,
739 struct _ib_recv_wr **bad_recv_wr);
740 struct ib_qp * (*create_qp)(struct ib_pd *pd,
741 struct ib_qp_init_attr *qp_init_attr,
742 ci_umv_buf_t* const p_umv_buf);
743 int (*modify_qp)(struct ib_qp *qp,
744 struct ib_qp_attr *qp_attr,
746 int (*query_qp)(struct ib_qp *qp,
747 struct ib_qp_attr *qp_attr,
749 struct ib_qp_init_attr *qp_init_attr);
750 int (*destroy_qp)(struct ib_qp *qp);
751 int (*post_send)(struct ib_qp *qp,
752 struct _ib_send_wr *send_wr,
753 struct _ib_send_wr **bad_send_wr);
754 int (*post_recv)(struct ib_qp *qp,
755 struct _ib_recv_wr *recv_wr,
756 struct _ib_recv_wr **bad_recv_wr);
757 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
758 struct ib_ucontext *context,
759 ci_umv_buf_t* const p_umv_buf);
760 int (*destroy_cq)(struct ib_cq *cq);
761 int (*resize_cq)(struct ib_cq *cq, int *cqe);
762 int (*poll_cq)(struct ib_cq *cq, int num_entries,
764 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
765 int (*req_notify_cq)(struct ib_cq *cq,
766 enum ib_cq_notify cq_notify);
767 int (*req_ncomp_notif)(struct ib_cq *cq,
769 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
770 mthca_qp_access_t mr_access_flags);
771 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
772 struct ib_phys_buf *phys_buf_array,
774 mthca_qp_access_t mr_access_flags,
776 struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
777 void* __ptr64 vaddr, uint64_t length, uint64_t hca_va, mthca_qp_access_t acc);
778 int (*query_mr)(struct ib_mr *mr,
779 struct ib_mr_attr *mr_attr);
780 int (*dereg_mr)(struct ib_mr *mr);
781 int (*rereg_phys_mr)(struct ib_mr *mr,
784 struct ib_phys_buf *phys_buf_array,
786 mthca_qp_access_t mr_access_flags,
788 struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
789 int (*bind_mw)(struct ib_qp *qp,
791 struct ib_mw_bind *mw_bind);
792 int (*dealloc_mw)(struct ib_mw *mw);
793 struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
794 mthca_qp_access_t mr_access_flags,
795 struct ib_fmr_attr *fmr_attr);
796 int (*map_phys_fmr)(struct ib_fmr *fmr,
797 u64 *page_list, int list_len,
799 int (*unmap_fmr)(struct list_head *fmr_list);
800 int (*dealloc_fmr)(struct ib_fmr *fmr);
801 int (*attach_mcast)(struct ib_qp *qp,
804 int (*detach_mcast)(struct ib_qp *qp,
807 int (*process_mad)(struct ib_device *device,
808 int process_mad_flags,
810 struct _ib_wc *in_wc,
811 struct ib_grh *in_grh,
812 struct ib_mad *in_mad,
813 struct ib_mad *out_mad);
815 struct list_head port_list;
825 void (*add) (struct ib_device *);
826 void (*remove)(struct ib_device *);
828 struct list_head list;
831 struct ib_device *ib_alloc_device(size_t size);
832 void ib_dealloc_device(struct ib_device *device);
834 int ib_register_device (struct ib_device *device);
835 void ib_unregister_device(struct ib_device *device);
837 int ib_register_client (struct ib_client *client);
838 void ib_unregister_client(struct ib_client *client);
840 void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
841 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
844 int ib_core_init(void);
846 void ib_core_cleanup(void);
848 int ib_register_event_handler (struct ib_event_handler *event_handler);
849 int ib_unregister_event_handler(struct ib_event_handler *event_handler);
850 void ib_dispatch_event(struct ib_event *event);
852 int ib_query_device(struct ib_device *device,
853 struct ib_device_attr *device_attr);
855 int ib_query_port(struct ib_device *device,
856 u8 port_num, struct ib_port_attr *port_attr);
858 int ib_query_gid(struct ib_device *device,
859 u8 port_num, int index, union ib_gid *gid);
861 int ib_query_pkey(struct ib_device *device,
862 u8 port_num, u16 index, u16 *pkey);
864 int ib_modify_device(struct ib_device *device,
865 int device_modify_mask,
866 struct ib_device_modify *device_modify);
868 int ib_modify_port(struct ib_device *device,
869 u8 port_num, int port_modify_mask,
870 struct ib_port_modify *port_modify);
873 * ibv_alloc_pd - Allocates an unused protection domain.
874 * @device: The device on which to allocate the protection domain.
875 * @context: user process context (for application calls only)
876 * @p_umv_buf: parameters structure (for application calls only)
878 * A protection domain object provides an association between QPs, shared
879 * receive queues, address handles, memory regions, and memory windows.
881 struct ib_pd *ibv_alloc_pd(struct ib_device *device,
882 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
885 * ibv_dealloc_pd - Deallocates a protection domain.
886 * @pd: The protection domain to deallocate.
888 int ibv_dealloc_pd(struct ib_pd *pd);
891 * ibv_create_ah - Creates an address handle for the given address vector.
892 * @pd: The protection domain associated with the address handle.
893 * @ah_attr: The attributes of the address vector.
894 * @context: user process context (for application calls only)
895 * @p_umv_buf: parameters structure (for application calls only)
897 * The address handle is used to reference a local or global destination
898 * in all UD QP post sends.
900 struct ib_ah *ibv_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
901 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
904 * ibv_create_ah_from_wc - Creates an address handle associated with the
905 * sender of the specified work completion.
906 * @pd: The protection domain associated with the address handle.
907 * @wc: Work completion information associated with a received message.
908 * @grh: References the received global route header. This parameter is
909 * ignored unless the work completion indicates that the GRH is valid.
910 * @port_num: The outbound port number to associate with the address.
912 * The address handle is used to reference a local or global destination
913 * in all UD QP post sends.
915 struct ib_ah *ibv_create_ah_from_wc(struct ib_pd *pd, struct _ib_wc *wc,
916 struct ib_grh *grh, u8 port_num);
919 * ibv_modify_ah - Modifies the address vector associated with an address
921 * @ah: The address handle to modify.
922 * @ah_attr: The new address vector attributes to associate with the
925 int ibv_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
928 * ibv_query_ah - Queries the address vector associated with an address
930 * @ah: The address handle to query.
931 * @ah_attr: The address vector attributes associated with the address
934 int ibv_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
937 * ibv_destroy_ah - Destroys an address handle.
938 * @ah: The address handle to destroy.
940 int ibv_destroy_ah(struct ib_ah *ah);
943 * ibv_create_srq - Creates a SRQ associated with the specified protection
945 * @pd: The protection domain associated with the SRQ.
946 * @srq_init_attr: A list of initial attributes required to create the
947 * SRQ. If SRQ creation succeeds, then the attributes are updated to
948 * the actual capabilities of the created SRQ.
950 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
951 * requested size of the SRQ, and set to the actual values allocated
952 * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
953 * will always be at least as large as the requested values.
955 struct ib_srq *ibv_create_srq(struct ib_pd *pd,
956 struct ib_srq_init_attr *srq_init_attr);
959 * ibv_modify_srq - Modifies the attributes for the specified SRQ.
960 * @srq: The SRQ to modify.
961 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
962 * the current values of selected SRQ attributes are returned.
963 * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
964 * are being modified.
966 * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
967 * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
968 * the number of receives queued drops below the limit.
970 int ibv_modify_srq(struct ib_srq *srq,
971 struct ib_srq_attr *srq_attr,
972 enum ib_srq_attr_mask srq_attr_mask);
975 * ibv_query_srq - Returns the attribute list and current values for the
977 * @srq: The SRQ to query.
978 * @srq_attr: The attributes of the specified SRQ.
980 int ibv_query_srq(struct ib_srq *srq,
981 struct ib_srq_attr *srq_attr);
984 * ibv_destroy_srq - Destroys the specified SRQ.
985 * @srq: The SRQ to destroy.
987 int ibv_destroy_srq(struct ib_srq *srq);
990 * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ.
991 * @srq: The SRQ to post the work request on.
992 * @recv_wr: A list of work requests to post on the receive queue.
993 * @bad_recv_wr: On an immediate failure, this parameter will reference
994 * the work request that failed to be posted on the QP.
996 static inline int ibv_post_srq_recv(struct ib_srq *srq,
997 struct _ib_recv_wr *recv_wr,
998 struct _ib_recv_wr **bad_recv_wr)
1000 return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
1004 * ibv_create_qp - Creates a QP associated with the specified protection
1006 * @pd: The protection domain associated with the QP.
1007 * @qp_init_attr: A list of initial attributes required to create the
1008 * QP. If QP creation succeeds, then the attributes are updated to
1009 * the actual capabilities of the created QP.
1010 * @context: user process context (for application calls only)
1011 * @p_umv_buf: parameters structure (for application calls only)
1013 struct ib_qp *ibv_create_qp(struct ib_pd *pd,
1014 struct ib_qp_init_attr *qp_init_attr,
1015 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
1018 * ibv_modify_qp - Modifies the attributes for the specified QP and then
1019 * transitions the QP to the given state.
1020 * @qp: The QP to modify.
1021 * @qp_attr: On input, specifies the QP attributes to modify. On output,
1022 * the current values of selected QP attributes are returned.
1023 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
1024 * are being modified.
1026 int ibv_modify_qp(struct ib_qp *qp,
1027 struct ib_qp_attr *qp_attr,
1031 * ibv_query_qp - Returns the attribute list and current values for the
1033 * @qp: The QP to query.
1034 * @qp_attr: The attributes of the specified QP.
1035 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
1036 * @qp_init_attr: Additional attributes of the selected QP.
1038 * The qp_attr_mask may be used to limit the query to gathering only the
1039 * selected attributes.
1041 int ibv_query_qp(struct ib_qp *qp,
1042 struct ib_qp_attr *qp_attr,
1044 struct ib_qp_init_attr *qp_init_attr);
1047 * ibv_destroy_qp - Destroys the specified QP.
1048 * @qp: The QP to destroy.
1050 int ibv_destroy_qp(struct ib_qp *qp);
1053 * ib_post_send - Posts a list of work requests to the send queue of
1055 * @qp: The QP to post the work request on.
1056 * @send_wr: A list of work requests to post on the send queue.
1057 * @bad_send_wr: On an immediate failure, this parameter will reference
1058 * the work request that failed to be posted on the QP.
1060 static inline int ib_post_send(struct ib_qp *qp,
1061 struct _ib_send_wr *send_wr,
1062 struct _ib_send_wr **bad_send_wr)
1064 return qp->device->post_send(qp, send_wr, bad_send_wr);
1068 * ib_post_recv - Posts a list of work requests to the receive queue of
1070 * @qp: The QP to post the work request on.
1071 * @recv_wr: A list of work requests to post on the receive queue.
1072 * @bad_recv_wr: On an immediate failure, this parameter will reference
1073 * the work request that failed to be posted on the QP.
1075 static inline int ib_post_recv(struct ib_qp *qp,
1076 struct _ib_recv_wr *recv_wr,
1077 struct _ib_recv_wr **bad_recv_wr)
1079 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1083 * ibv_create_cq - Creates a CQ on the specified device.
1084 * @device: The device on which to create the CQ.
1085 * @comp_handler: A user-specified callback that is invoked when a
1086 * completion event occurs on the CQ.
1087 * @event_handler: A user-specified callback that is invoked when an
1088 * asynchronous event not associated with a completion occurs on the CQ.
1089 * @cq_context: Context associated with the CQ returned to the user via
1090 * the associated completion and event handlers.
1091 * @cqe: The minimum size of the CQ.
1092 * @context: user process context (for application calls only)
1093 * @p_umv_buf: parameters structure (for application calls only)
1095 * Users can examine the cq structure to determine the actual CQ size.
1097 struct ib_cq *ibv_create_cq(struct ib_device *device,
1098 ib_comp_handler comp_handler,
1099 void (*event_handler)(struct ib_event *, void *),
1100 void *cq_context, int cqe,
1101 struct ib_ucontext *context, ci_umv_buf_t* const p_umv_buf);
1104 * ibv_resize_cq - Modifies the capacity of the CQ.
1105 * @cq: The CQ to resize.
1106 * @cqe: The minimum size of the CQ.
1108 * Users can examine the cq structure to determine the actual CQ size.
1110 int ibv_resize_cq(struct ib_cq *cq, int cqe);
1113 * ibv_destroy_cq - Destroys the specified CQ.
1114 * @cq: The CQ to destroy.
1116 int ibv_destroy_cq(struct ib_cq *cq);
1119 * ib_poll_cq - poll a CQ for completion(s)
1120 * @cq:the CQ being polled
1121 * @num_entries:maximum number of completions to return
1122 * @wc:array of at least @num_entries &struct _ib_wc where completions
1125 * Poll a CQ for (possibly multiple) completions. If the return value
1126 * is < 0, an error occurred. If the return value is >= 0, it is the
1127 * number of completions returned. If the return value is
1128 * non-negative and < num_entries, then the CQ was emptied.
1130 static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
1133 return cq->device->poll_cq(cq, num_entries, wc);
1137 * ib_peek_cq - Returns the number of unreaped completions currently
1138 * on the specified CQ.
1139 * @cq: The CQ to peek.
1140 * @wc_cnt: A minimum number of unreaped completions to check for.
1142 * If the number of unreaped completions is greater than or equal to wc_cnt,
1143 * this function returns wc_cnt, otherwise, it returns the actual number of
1144 * unreaped completions.
1146 int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1149 * ib_req_notify_cq - Request completion notification on a CQ.
1150 * @cq: The CQ to generate an event for.
1151 * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
1152 * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
1153 * notification will occur on the next completion.
1155 static inline int ib_req_notify_cq(struct ib_cq *cq,
1156 enum ib_cq_notify cq_notify)
1158 return cq->device->req_notify_cq(cq, cq_notify);
1162 * ib_req_ncomp_notif - Request completion notification when there are
1163 * at least the specified number of unreaped completions on the CQ.
1164 * @cq: The CQ to generate an event for.
1165 * @wc_cnt: The number of unreaped completions that should be on the
1166 * CQ before an event is generated.
1168 static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1170 return cq->device->req_ncomp_notif ?
1171 cq->device->req_ncomp_notif(cq, wc_cnt) :
1176 * ibv_reg_mr - Prepares a virtually addressed memory region for use
1178 * @pd: The protection domain associated assigned to the registered region.
1179 * @vaddr: virtual address of the region
1180 * @length: Specifies the size of the region.
1181 * @hca_va: virtual address in HCA
1182 * @mr_access_flags: Specifies the memory access rights.
1183 * @um_call: call from user, when TRUE.
1185 struct ib_mr *ibv_reg_mr(struct ib_pd *pd,
1186 mthca_qp_access_t mr_access_flags,
1187 void* __ptr64 vaddr,
1194 * ibv_get_dma_mr - Returns a memory region for system memory that is
1196 * @pd: The protection domain associated with the memory region.
1197 * @mr_access_flags: Specifies the memory access rights.
1199 struct ib_mr *ibv_get_dma_mr(struct ib_pd *pd, mthca_qp_access_t mr_access_flags);
1202 * ibv_reg_phys_mr - Prepares a virtually addressed memory region for use
1204 * @pd: The protection domain associated assigned to the registered region.
1205 * @phys_buf_array: Specifies a list of physical buffers to use in the
1207 * @num_phys_buf: Specifies the size of the phys_buf_array.
1208 * @mr_access_flags: Specifies the memory access rights.
1209 * @iova_start: The offset of the region's starting I/O virtual address.
1211 struct ib_mr *ibv_reg_phys_mr(struct ib_pd *pd,
1212 struct ib_phys_buf *phys_buf_array,
1214 mthca_qp_access_t mr_access_flags,
1218 * ibv_rereg_phys_mr - Modifies the attributes of an existing memory region.
1219 * Conceptually, this call performs the functions deregister memory region
1220 * followed by register physical memory region. Where possible,
1221 * resources are reused instead of deallocated and reallocated.
1222 * @mr: The memory region to modify.
1223 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1224 * properties of the memory region are being modified.
1225 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1226 * the new protection domain to associated with the memory region,
1227 * otherwise, this parameter is ignored.
1228 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1229 * field specifies a list of physical buffers to use in the new
1230 * translation, otherwise, this parameter is ignored.
1231 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1232 * field specifies the size of the phys_buf_array, otherwise, this
1233 * parameter is ignored.
1234 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1235 * field specifies the new memory access rights, otherwise, this
1236 * parameter is ignored.
1237 * @iova_start: The offset of the region's starting I/O virtual address.
1239 int ibv_rereg_phys_mr(struct ib_mr *mr,
1242 struct ib_phys_buf *phys_buf_array,
1244 mthca_qp_access_t mr_access_flags,
1248 * ibv_query_mr - Retrieves information about a specific memory region.
1249 * @mr: The memory region to retrieve information about.
1250 * @mr_attr: The attributes of the specified memory region.
1252 int ibv_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1255 * ibv_dereg_mr - Deregisters a memory region and removes it from the
1256 * HCA translation table.
1257 * @mr: The memory region to deregister.
1259 int ibv_dereg_mr(struct ib_mr *mr);
1262 * ibv_alloc_mw - Allocates a memory window.
1263 * @pd: The protection domain associated with the memory window.
1265 struct ib_mw *ibv_alloc_mw(struct ib_pd *pd);
1268 * ib_bind_mw - Posts a work request to the send queue of the specified
1269 * QP, which binds the memory window to the given address range and
1270 * remote access attributes.
1271 * @qp: QP to post the bind work request on.
1272 * @mw: The memory window to bind.
1273 * @mw_bind: Specifies information about the memory window, including
1274 * its address range, remote access rights, and associated memory region.
1276 static inline int ib_bind_mw(struct ib_qp *qp,
1278 struct ib_mw_bind *mw_bind)
1280 /* XXX reference counting in corresponding MR? */
1281 return mw->device->bind_mw ?
1282 mw->device->bind_mw(qp, mw, mw_bind) :
1287 * ibv_dealloc_mw - Deallocates a memory window.
1288 * @mw: The memory window to deallocate.
1290 int ibv_dealloc_mw(struct ib_mw *mw);
1293 * ibv_alloc_fmr - Allocates a unmapped fast memory region.
1294 * @pd: The protection domain associated with the unmapped region.
1295 * @mr_access_flags: Specifies the memory access rights.
1296 * @fmr_attr: Attributes of the unmapped region.
1298 * A fast memory region must be mapped before it can be used as part of
1301 struct ib_fmr *ibv_alloc_fmr(struct ib_pd *pd,
1302 mthca_qp_access_t mr_access_flags,
1303 struct ib_fmr_attr *fmr_attr);
1306 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1307 * @fmr: The fast memory region to associate with the pages.
1308 * @page_list: An array of physical pages to map to the fast memory region.
1309 * @list_len: The number of pages in page_list.
1310 * @iova: The I/O virtual address to use with the mapped region.
1312 static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
1313 u64 *page_list, int list_len,
1316 return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
1320 * ibv_unmap_fmr - Removes the mapping from a list of fast memory regions.
1321 * @fmr_list: A linked list of fast memory regions to unmap.
1323 int ibv_unmap_fmr(struct list_head *fmr_list);
1326 * ibv_dealloc_fmr - Deallocates a fast memory region.
1327 * @fmr: The fast memory region to deallocate.
1329 int ibv_dealloc_fmr(struct ib_fmr *fmr);
1332 * ibv_attach_mcast - Attaches the specified QP to a multicast group.
1333 * @qp: QP to attach to the multicast group. The QP must be type
1334 * IB_QPT_UNRELIABLE_DGRM.
1335 * @gid: Multicast group GID.
1336 * @lid: Multicast group LID in host byte order.
1338 * In order to send and receive multicast packets, subnet
1339 * administration must have created the multicast group and configured
1340 * the fabric appropriately. The port associated with the specified
1341 * QP must also be a member of the multicast group.
1343 int ibv_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1346 * ibv_detach_mcast - Detaches the specified QP from a multicast group.
1347 * @qp: QP to detach from the multicast group.
1348 * @gid: Multicast group GID.
1349 * @lid: Multicast group LID in host byte order.
1351 int ibv_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1354 * ibv_um_close - Releases application.
1355 * @h_um_ca: application context
1357 void ibv_um_close(struct ib_ucontext * h_um_ca);
1359 #endif /* IB_VERBS_H */