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 1349 2004-12-16 21:09:43Z roland $
41 #if !defined(IB_VERBS_H)
44 #include <linux/types.h>
45 #include <linux/device.h>
47 #include <asm/atomic.h>
48 #include <asm/scatterlist.h>
49 #include <asm/uaccess.h>
65 enum ib_device_cap_flags {
66 IB_DEVICE_RESIZE_MAX_WR = 1,
67 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
68 IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
69 IB_DEVICE_RAW_MULTI = (1<<3),
70 IB_DEVICE_AUTO_PATH_MIG = (1<<4),
71 IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
72 IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
73 IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
74 IB_DEVICE_SHUTDOWN_PORT = (1<<8),
75 IB_DEVICE_INIT_TYPE = (1<<9),
76 IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
77 IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
78 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
79 IB_DEVICE_SRQ_RESIZE = (1<<13),
80 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
89 struct ib_device_attr {
92 __be64 sys_image_guid;
100 int device_cap_flags;
110 int max_qp_init_rd_atom;
111 int max_ee_init_rd_atom;
112 enum ib_atomic_cap atomic_cap;
119 int max_mcast_qp_attach;
120 int max_total_mcast_qp_attach;
128 u8 local_ca_ack_delay;
139 static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
142 case IB_MTU_256: return 256;
143 case IB_MTU_512: return 512;
144 case IB_MTU_1024: return 1024;
145 case IB_MTU_2048: return 2048;
146 case IB_MTU_4096: return 4096;
157 IB_PORT_ACTIVE_DEFER = 5
160 enum ib_port_cap_flags {
162 IB_PORT_NOTICE_SUP = 1 << 2,
163 IB_PORT_TRAP_SUP = 1 << 3,
164 IB_PORT_OPT_IPD_SUP = 1 << 4,
165 IB_PORT_AUTO_MIGR_SUP = 1 << 5,
166 IB_PORT_SL_MAP_SUP = 1 << 6,
167 IB_PORT_MKEY_NVRAM = 1 << 7,
168 IB_PORT_PKEY_NVRAM = 1 << 8,
169 IB_PORT_LED_INFO_SUP = 1 << 9,
170 IB_PORT_SM_DISABLED = 1 << 10,
171 IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
172 IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
173 IB_PORT_CM_SUP = 1 << 16,
174 IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
175 IB_PORT_REINIT_SUP = 1 << 18,
176 IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
177 IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
178 IB_PORT_DR_NOTICE_SUP = 1 << 21,
179 IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
180 IB_PORT_BOOT_MGMT_SUP = 1 << 23,
181 IB_PORT_LINK_LATENCY_SUP = 1 << 24,
182 IB_PORT_CLIENT_REG_SUP = 1 << 25
192 static inline int ib_width_enum_to_int(enum ib_port_width width)
195 case IB_WIDTH_1X: return 1;
196 case IB_WIDTH_4X: return 4;
197 case IB_WIDTH_8X: return 8;
198 case IB_WIDTH_12X: return 12;
203 struct ib_port_attr {
204 enum ib_port_state state;
206 enum ib_mtu active_mtu;
225 enum ib_device_modify_flags {
226 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1
229 struct ib_device_modify {
233 enum ib_port_modify_flags {
234 IB_PORT_SHUTDOWN = 1,
235 IB_PORT_INIT_TYPE = (1<<2),
236 IB_PORT_RESET_QKEY_CNTR = (1<<3)
239 struct ib_port_modify {
240 u32 set_port_cap_mask;
241 u32 clr_port_cap_mask;
249 IB_EVENT_QP_ACCESS_ERR,
253 IB_EVENT_PATH_MIG_ERR,
254 IB_EVENT_DEVICE_FATAL,
255 IB_EVENT_PORT_ACTIVE,
258 IB_EVENT_PKEY_CHANGE,
261 IB_EVENT_SRQ_LIMIT_REACHED,
262 IB_EVENT_QP_LAST_WQE_REACHED
266 struct ib_device *device;
273 enum ib_event_type event;
276 struct ib_event_handler {
277 struct ib_device *device;
278 void (*handler)(struct ib_event_handler *, struct ib_event *);
279 struct list_head list;
282 #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
284 (_ptr)->device = _device; \
285 (_ptr)->handler = _handler; \
286 INIT_LIST_HEAD(&(_ptr)->list); \
289 struct ib_global_route {
298 __be32 version_tclass_flow;
307 IB_MULTICAST_QPN = 0xffffff
310 #define IB_LID_PERMISSIVE __constant_htons(0xFFFF)
317 struct ib_global_route grh;
330 IB_WC_LOC_EEC_OP_ERR,
335 IB_WC_LOC_ACCESS_ERR,
336 IB_WC_REM_INV_REQ_ERR,
337 IB_WC_REM_ACCESS_ERR,
340 IB_WC_RNR_RETRY_EXC_ERR,
341 IB_WC_LOC_RDD_VIOL_ERR,
342 IB_WC_REM_INV_RD_REQ_ERR,
345 IB_WC_INV_EEC_STATE_ERR,
347 IB_WC_RESP_TIMEOUT_ERR,
359 * Set value of IB_WC_RECV so consumers can test if a completion is a
360 * receive by testing (opcode & IB_WC_RECV).
363 IB_WC_RECV_RDMA_WITH_IMM
368 IB_WC_WITH_IMM = (1<<1)
373 enum ib_wc_status status;
374 enum ib_wc_opcode opcode;
385 u8 port_num; /* valid only for DR SMPs on switches */
393 enum ib_srq_attr_mask {
394 IB_SRQ_MAX_WR = 1 << 0,
395 IB_SRQ_LIMIT = 1 << 1,
404 struct ib_srq_init_attr {
405 void (*event_handler)(struct ib_event *, void *);
407 struct ib_srq_attr attr;
425 * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
426 * here (and in that order) since the MAD layer uses them as
427 * indices into a 2-entry table.
439 struct ib_qp_init_attr {
440 void (*event_handler)(struct ib_event *, void *);
442 struct ib_cq *send_cq;
443 struct ib_cq *recv_cq;
445 struct ib_qp_cap cap;
446 enum ib_sig_type sq_sig_type;
447 enum ib_qp_type qp_type;
448 u8 port_num; /* special QP types only */
451 enum ib_rnr_timeout {
452 IB_RNR_TIMER_655_36 = 0,
453 IB_RNR_TIMER_000_01 = 1,
454 IB_RNR_TIMER_000_02 = 2,
455 IB_RNR_TIMER_000_03 = 3,
456 IB_RNR_TIMER_000_04 = 4,
457 IB_RNR_TIMER_000_06 = 5,
458 IB_RNR_TIMER_000_08 = 6,
459 IB_RNR_TIMER_000_12 = 7,
460 IB_RNR_TIMER_000_16 = 8,
461 IB_RNR_TIMER_000_24 = 9,
462 IB_RNR_TIMER_000_32 = 10,
463 IB_RNR_TIMER_000_48 = 11,
464 IB_RNR_TIMER_000_64 = 12,
465 IB_RNR_TIMER_000_96 = 13,
466 IB_RNR_TIMER_001_28 = 14,
467 IB_RNR_TIMER_001_92 = 15,
468 IB_RNR_TIMER_002_56 = 16,
469 IB_RNR_TIMER_003_84 = 17,
470 IB_RNR_TIMER_005_12 = 18,
471 IB_RNR_TIMER_007_68 = 19,
472 IB_RNR_TIMER_010_24 = 20,
473 IB_RNR_TIMER_015_36 = 21,
474 IB_RNR_TIMER_020_48 = 22,
475 IB_RNR_TIMER_030_72 = 23,
476 IB_RNR_TIMER_040_96 = 24,
477 IB_RNR_TIMER_061_44 = 25,
478 IB_RNR_TIMER_081_92 = 26,
479 IB_RNR_TIMER_122_88 = 27,
480 IB_RNR_TIMER_163_84 = 28,
481 IB_RNR_TIMER_245_76 = 29,
482 IB_RNR_TIMER_327_68 = 30,
483 IB_RNR_TIMER_491_52 = 31
486 enum ib_qp_attr_mask {
488 IB_QP_CUR_STATE = (1<<1),
489 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
490 IB_QP_ACCESS_FLAGS = (1<<3),
491 IB_QP_PKEY_INDEX = (1<<4),
495 IB_QP_PATH_MTU = (1<<8),
496 IB_QP_TIMEOUT = (1<<9),
497 IB_QP_RETRY_CNT = (1<<10),
498 IB_QP_RNR_RETRY = (1<<11),
499 IB_QP_RQ_PSN = (1<<12),
500 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
501 IB_QP_ALT_PATH = (1<<14),
502 IB_QP_MIN_RNR_TIMER = (1<<15),
503 IB_QP_SQ_PSN = (1<<16),
504 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
505 IB_QP_PATH_MIG_STATE = (1<<18),
507 IB_QP_DEST_QPN = (1<<20)
527 enum ib_qp_state qp_state;
528 enum ib_qp_state cur_qp_state;
529 enum ib_mtu path_mtu;
530 enum ib_mig_state path_mig_state;
536 struct ib_qp_cap cap;
537 struct ib_ah_attr ah_attr;
538 struct ib_ah_attr alt_ah_attr;
541 u8 en_sqd_async_notify;
544 u8 max_dest_rd_atomic;
556 IB_WR_RDMA_WRITE_WITH_IMM,
560 IB_WR_ATOMIC_CMP_AND_SWP,
561 IB_WR_ATOMIC_FETCH_AND_ADD
566 IB_SEND_SIGNALED = (1<<1),
567 IB_SEND_SOLICITED = (1<<2),
568 IB_SEND_INLINE = (1<<3)
578 struct ib_send_wr *next;
580 struct ib_sge *sg_list;
582 enum ib_wr_opcode opcode;
600 u16 pkey_index; /* valid for GSI only */
601 u8 port_num; /* valid for DR SMPs on switch only */
607 struct ib_recv_wr *next;
609 struct ib_sge *sg_list;
613 enum ib_access_flags {
614 IB_ACCESS_LOCAL_WRITE = 1,
615 IB_ACCESS_REMOTE_WRITE = (1<<1),
616 IB_ACCESS_REMOTE_READ = (1<<2),
617 IB_ACCESS_REMOTE_ATOMIC = (1<<3),
618 IB_ACCESS_MW_BIND = (1<<4)
628 u64 device_virt_addr;
635 enum ib_mr_rereg_flags {
636 IB_MR_REREG_TRANS = 1,
637 IB_MR_REREG_PD = (1<<1),
638 IB_MR_REREG_ACCESS = (1<<2)
657 struct ib_device *device;
658 struct list_head pd_list;
659 struct list_head mr_list;
660 struct list_head mw_list;
661 struct list_head cq_list;
662 struct list_head qp_list;
663 struct list_head srq_list;
664 struct list_head ah_list;
668 u64 user_handle; /* handle given to us by userspace */
669 struct ib_ucontext *context; /* associated user context */
670 struct list_head list; /* link to context's list */
671 u32 id; /* index into kernel idr */
675 unsigned long user_base;
676 unsigned long virt_base;
681 struct list_head chunk_list;
684 struct ib_umem_chunk {
685 struct list_head list;
688 struct scatterlist page_list[0];
698 #define IB_UMEM_MAX_PAGE_CHUNK \
699 ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
700 ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
701 (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
703 struct ib_umem_object {
704 struct ib_uobject uobject;
709 struct ib_device *device;
710 struct ib_uobject *uobject;
711 atomic_t usecnt; /* count all resources */
715 struct ib_device *device;
717 struct ib_uobject *uobject;
720 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
723 struct ib_device *device;
724 struct ib_uobject *uobject;
725 ib_comp_handler comp_handler;
726 void (*event_handler)(struct ib_event *, void *);
729 atomic_t usecnt; /* count number of work queues */
733 struct ib_device *device;
735 struct ib_uobject *uobject;
736 void (*event_handler)(struct ib_event *, void *);
742 struct ib_device *device;
744 struct ib_cq *send_cq;
745 struct ib_cq *recv_cq;
747 struct ib_uobject *uobject;
748 void (*event_handler)(struct ib_event *, void *);
751 enum ib_qp_type qp_type;
755 struct ib_device *device;
757 struct ib_uobject *uobject;
760 atomic_t usecnt; /* count number of MWs */
764 struct ib_device *device;
766 struct ib_uobject *uobject;
771 struct ib_device *device;
773 struct list_head list;
781 enum ib_process_mad_flags {
782 IB_MAD_IGNORE_MKEY = 1,
783 IB_MAD_IGNORE_BKEY = 2,
784 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
788 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
789 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
790 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
791 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
794 #define IB_DEVICE_NAME_MAX 64
798 struct ib_event_handler event_handler;
799 struct ib_pkey_cache **pkey_cache;
800 struct ib_gid_cache **gid_cache;
804 struct device *dma_device;
806 char name[IB_DEVICE_NAME_MAX];
808 struct list_head event_handler_list;
809 spinlock_t event_handler_lock;
811 struct list_head core_list;
812 struct list_head client_data_list;
813 spinlock_t client_data_lock;
815 struct ib_cache cache;
819 int (*query_device)(struct ib_device *device,
820 struct ib_device_attr *device_attr);
821 int (*query_port)(struct ib_device *device,
823 struct ib_port_attr *port_attr);
824 int (*query_gid)(struct ib_device *device,
825 u8 port_num, int index,
827 int (*query_pkey)(struct ib_device *device,
828 u8 port_num, u16 index, u16 *pkey);
829 int (*modify_device)(struct ib_device *device,
830 int device_modify_mask,
831 struct ib_device_modify *device_modify);
832 int (*modify_port)(struct ib_device *device,
833 u8 port_num, int port_modify_mask,
834 struct ib_port_modify *port_modify);
835 struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device,
836 struct ib_udata *udata);
837 int (*dealloc_ucontext)(struct ib_ucontext *context);
838 int (*mmap)(struct ib_ucontext *context,
839 struct vm_area_struct *vma);
840 struct ib_pd * (*alloc_pd)(struct ib_device *device,
841 struct ib_ucontext *context,
842 struct ib_udata *udata);
843 int (*dealloc_pd)(struct ib_pd *pd);
844 struct ib_ah * (*create_ah)(struct ib_pd *pd,
845 struct ib_ah_attr *ah_attr);
846 int (*modify_ah)(struct ib_ah *ah,
847 struct ib_ah_attr *ah_attr);
848 int (*query_ah)(struct ib_ah *ah,
849 struct ib_ah_attr *ah_attr);
850 int (*destroy_ah)(struct ib_ah *ah);
851 struct ib_srq * (*create_srq)(struct ib_pd *pd,
852 struct ib_srq_init_attr *srq_init_attr,
853 struct ib_udata *udata);
854 int (*modify_srq)(struct ib_srq *srq,
855 struct ib_srq_attr *srq_attr,
856 enum ib_srq_attr_mask srq_attr_mask);
857 int (*query_srq)(struct ib_srq *srq,
858 struct ib_srq_attr *srq_attr);
859 int (*destroy_srq)(struct ib_srq *srq);
860 int (*post_srq_recv)(struct ib_srq *srq,
861 struct ib_recv_wr *recv_wr,
862 struct ib_recv_wr **bad_recv_wr);
863 struct ib_qp * (*create_qp)(struct ib_pd *pd,
864 struct ib_qp_init_attr *qp_init_attr,
865 struct ib_udata *udata);
866 int (*modify_qp)(struct ib_qp *qp,
867 struct ib_qp_attr *qp_attr,
869 int (*query_qp)(struct ib_qp *qp,
870 struct ib_qp_attr *qp_attr,
872 struct ib_qp_init_attr *qp_init_attr);
873 int (*destroy_qp)(struct ib_qp *qp);
874 int (*post_send)(struct ib_qp *qp,
875 struct ib_send_wr *send_wr,
876 struct ib_send_wr **bad_send_wr);
877 int (*post_recv)(struct ib_qp *qp,
878 struct ib_recv_wr *recv_wr,
879 struct ib_recv_wr **bad_recv_wr);
880 struct ib_cq * (*create_cq)(struct ib_device *device, int cqe,
881 struct ib_ucontext *context,
882 struct ib_udata *udata);
883 int (*destroy_cq)(struct ib_cq *cq);
884 int (*resize_cq)(struct ib_cq *cq, int cqe);
885 int (*poll_cq)(struct ib_cq *cq, int num_entries,
887 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
888 int (*req_notify_cq)(struct ib_cq *cq,
889 enum ib_cq_notify cq_notify);
890 int (*req_ncomp_notif)(struct ib_cq *cq,
892 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
893 int mr_access_flags);
894 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
895 struct ib_phys_buf *phys_buf_array,
899 struct ib_mr * (*reg_user_mr)(struct ib_pd *pd,
900 struct ib_umem *region,
902 struct ib_udata *udata);
903 int (*query_mr)(struct ib_mr *mr,
904 struct ib_mr_attr *mr_attr);
905 int (*dereg_mr)(struct ib_mr *mr);
906 int (*rereg_phys_mr)(struct ib_mr *mr,
909 struct ib_phys_buf *phys_buf_array,
913 struct ib_mw * (*alloc_mw)(struct ib_pd *pd);
914 int (*bind_mw)(struct ib_qp *qp,
916 struct ib_mw_bind *mw_bind);
917 int (*dealloc_mw)(struct ib_mw *mw);
918 struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
920 struct ib_fmr_attr *fmr_attr);
921 int (*map_phys_fmr)(struct ib_fmr *fmr,
922 u64 *page_list, int list_len,
924 int (*unmap_fmr)(struct list_head *fmr_list);
925 int (*dealloc_fmr)(struct ib_fmr *fmr);
926 int (*attach_mcast)(struct ib_qp *qp,
929 int (*detach_mcast)(struct ib_qp *qp,
932 int (*process_mad)(struct ib_device *device,
933 int process_mad_flags,
936 struct ib_grh *in_grh,
937 struct ib_mad *in_mad,
938 struct ib_mad *out_mad);
940 struct module *owner;
941 struct class_device class_dev;
942 struct kobject ports_parent;
943 struct list_head port_list;
946 IB_DEV_UNINITIALIZED,
960 void (*add) (struct ib_device *);
961 void (*remove)(struct ib_device *);
963 struct list_head list;
966 struct ib_device *ib_alloc_device(size_t size);
967 void ib_dealloc_device(struct ib_device *device);
969 int ib_register_device (struct ib_device *device);
970 void ib_unregister_device(struct ib_device *device);
972 int ib_register_client (struct ib_client *client);
973 void ib_unregister_client(struct ib_client *client);
975 void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
976 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
979 static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
981 return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
984 static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
986 return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
989 int ib_register_event_handler (struct ib_event_handler *event_handler);
990 int ib_unregister_event_handler(struct ib_event_handler *event_handler);
991 void ib_dispatch_event(struct ib_event *event);
993 int ib_query_device(struct ib_device *device,
994 struct ib_device_attr *device_attr);
996 int ib_query_port(struct ib_device *device,
997 u8 port_num, struct ib_port_attr *port_attr);
999 int ib_query_gid(struct ib_device *device,
1000 u8 port_num, int index, union ib_gid *gid);
1002 int ib_query_pkey(struct ib_device *device,
1003 u8 port_num, u16 index, u16 *pkey);
1005 int ib_modify_device(struct ib_device *device,
1006 int device_modify_mask,
1007 struct ib_device_modify *device_modify);
1009 int ib_modify_port(struct ib_device *device,
1010 u8 port_num, int port_modify_mask,
1011 struct ib_port_modify *port_modify);
1014 * ib_alloc_pd - Allocates an unused protection domain.
1015 * @device: The device on which to allocate the protection domain.
1017 * A protection domain object provides an association between QPs, shared
1018 * receive queues, address handles, memory regions, and memory windows.
1020 struct ib_pd *ib_alloc_pd(struct ib_device *device);
1023 * ib_dealloc_pd - Deallocates a protection domain.
1024 * @pd: The protection domain to deallocate.
1026 int ib_dealloc_pd(struct ib_pd *pd);
1029 * ib_create_ah - Creates an address handle for the given address vector.
1030 * @pd: The protection domain associated with the address handle.
1031 * @ah_attr: The attributes of the address vector.
1033 * The address handle is used to reference a local or global destination
1034 * in all UD QP post sends.
1036 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
1039 * ib_create_ah_from_wc - Creates an address handle associated with the
1040 * sender of the specified work completion.
1041 * @pd: The protection domain associated with the address handle.
1042 * @wc: Work completion information associated with a received message.
1043 * @grh: References the received global route header. This parameter is
1044 * ignored unless the work completion indicates that the GRH is valid.
1045 * @port_num: The outbound port number to associate with the address.
1047 * The address handle is used to reference a local or global destination
1048 * in all UD QP post sends.
1050 struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
1051 struct ib_grh *grh, u8 port_num);
1054 * ib_modify_ah - Modifies the address vector associated with an address
1056 * @ah: The address handle to modify.
1057 * @ah_attr: The new address vector attributes to associate with the
1060 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1063 * ib_query_ah - Queries the address vector associated with an address
1065 * @ah: The address handle to query.
1066 * @ah_attr: The address vector attributes associated with the address
1069 int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
1072 * ib_destroy_ah - Destroys an address handle.
1073 * @ah: The address handle to destroy.
1075 int ib_destroy_ah(struct ib_ah *ah);
1078 * ib_create_srq - Creates a SRQ associated with the specified protection
1080 * @pd: The protection domain associated with the SRQ.
1081 * @srq_init_attr: A list of initial attributes required to create the SRQ.
1083 * srq_attr->max_wr and srq_attr->max_sge are read the determine the
1084 * requested size of the SRQ, and set to the actual values allocated
1085 * on return. If ib_create_srq() succeeds, then max_wr and max_sge
1086 * will always be at least as large as the requested values.
1088 struct ib_srq *ib_create_srq(struct ib_pd *pd,
1089 struct ib_srq_init_attr *srq_init_attr);
1092 * ib_modify_srq - Modifies the attributes for the specified SRQ.
1093 * @srq: The SRQ to modify.
1094 * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
1095 * the current values of selected SRQ attributes are returned.
1096 * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
1097 * are being modified.
1099 * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or
1100 * IB_SRQ_LIMIT to set the SRQ's limit and request notification when
1101 * the number of receives queued drops below the limit.
1103 int ib_modify_srq(struct ib_srq *srq,
1104 struct ib_srq_attr *srq_attr,
1105 enum ib_srq_attr_mask srq_attr_mask);
1108 * ib_query_srq - Returns the attribute list and current values for the
1110 * @srq: The SRQ to query.
1111 * @srq_attr: The attributes of the specified SRQ.
1113 int ib_query_srq(struct ib_srq *srq,
1114 struct ib_srq_attr *srq_attr);
1117 * ib_destroy_srq - Destroys the specified SRQ.
1118 * @srq: The SRQ to destroy.
1120 int ib_destroy_srq(struct ib_srq *srq);
1123 * ib_post_srq_recv - Posts a list of work requests to the specified SRQ.
1124 * @srq: The SRQ to post the work request on.
1125 * @recv_wr: A list of work requests to post on the receive queue.
1126 * @bad_recv_wr: On an immediate failure, this parameter will reference
1127 * the work request that failed to be posted on the QP.
1129 static inline int ib_post_srq_recv(struct ib_srq *srq,
1130 struct ib_recv_wr *recv_wr,
1131 struct ib_recv_wr **bad_recv_wr)
1133 return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr);
1137 * ib_create_qp - Creates a QP associated with the specified protection
1139 * @pd: The protection domain associated with the QP.
1140 * @qp_init_attr: A list of initial attributes required to create the QP.
1142 struct ib_qp *ib_create_qp(struct ib_pd *pd,
1143 struct ib_qp_init_attr *qp_init_attr);
1146 * ib_modify_qp - Modifies the attributes for the specified QP and then
1147 * transitions the QP to the given state.
1148 * @qp: The QP to modify.
1149 * @qp_attr: On input, specifies the QP attributes to modify. On output,
1150 * the current values of selected QP attributes are returned.
1151 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
1152 * are being modified.
1154 int ib_modify_qp(struct ib_qp *qp,
1155 struct ib_qp_attr *qp_attr,
1159 * ib_query_qp - Returns the attribute list and current values for the
1161 * @qp: The QP to query.
1162 * @qp_attr: The attributes of the specified QP.
1163 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
1164 * @qp_init_attr: Additional attributes of the selected QP.
1166 * The qp_attr_mask may be used to limit the query to gathering only the
1167 * selected attributes.
1169 int ib_query_qp(struct ib_qp *qp,
1170 struct ib_qp_attr *qp_attr,
1172 struct ib_qp_init_attr *qp_init_attr);
1175 * ib_destroy_qp - Destroys the specified QP.
1176 * @qp: The QP to destroy.
1178 int ib_destroy_qp(struct ib_qp *qp);
1181 * ib_post_send - Posts a list of work requests to the send queue of
1183 * @qp: The QP to post the work request on.
1184 * @send_wr: A list of work requests to post on the send queue.
1185 * @bad_send_wr: On an immediate failure, this parameter will reference
1186 * the work request that failed to be posted on the QP.
1188 static inline int ib_post_send(struct ib_qp *qp,
1189 struct ib_send_wr *send_wr,
1190 struct ib_send_wr **bad_send_wr)
1192 return qp->device->post_send(qp, send_wr, bad_send_wr);
1196 * ib_post_recv - Posts a list of work requests to the receive queue of
1198 * @qp: The QP to post the work request on.
1199 * @recv_wr: A list of work requests to post on the receive queue.
1200 * @bad_recv_wr: On an immediate failure, this parameter will reference
1201 * the work request that failed to be posted on the QP.
1203 static inline int ib_post_recv(struct ib_qp *qp,
1204 struct ib_recv_wr *recv_wr,
1205 struct ib_recv_wr **bad_recv_wr)
1207 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1211 * ib_create_cq - Creates a CQ on the specified device.
1212 * @device: The device on which to create the CQ.
1213 * @comp_handler: A user-specified callback that is invoked when a
1214 * completion event occurs on the CQ.
1215 * @event_handler: A user-specified callback that is invoked when an
1216 * asynchronous event not associated with a completion occurs on the CQ.
1217 * @cq_context: Context associated with the CQ returned to the user via
1218 * the associated completion and event handlers.
1219 * @cqe: The minimum size of the CQ.
1221 * Users can examine the cq structure to determine the actual CQ size.
1223 struct ib_cq *ib_create_cq(struct ib_device *device,
1224 ib_comp_handler comp_handler,
1225 void (*event_handler)(struct ib_event *, void *),
1226 void *cq_context, int cqe);
1229 * ib_resize_cq - Modifies the capacity of the CQ.
1230 * @cq: The CQ to resize.
1231 * @cqe: The minimum size of the CQ.
1233 * Users can examine the cq structure to determine the actual CQ size.
1235 int ib_resize_cq(struct ib_cq *cq, int cqe);
1238 * ib_destroy_cq - Destroys the specified CQ.
1239 * @cq: The CQ to destroy.
1241 int ib_destroy_cq(struct ib_cq *cq);
1244 * ib_poll_cq - poll a CQ for completion(s)
1245 * @cq:the CQ being polled
1246 * @num_entries:maximum number of completions to return
1247 * @wc:array of at least @num_entries &struct ib_wc where completions
1250 * Poll a CQ for (possibly multiple) completions. If the return value
1251 * is < 0, an error occurred. If the return value is >= 0, it is the
1252 * number of completions returned. If the return value is
1253 * non-negative and < num_entries, then the CQ was emptied.
1255 static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
1258 return cq->device->poll_cq(cq, num_entries, wc);
1262 * ib_peek_cq - Returns the number of unreaped completions currently
1263 * on the specified CQ.
1264 * @cq: The CQ to peek.
1265 * @wc_cnt: A minimum number of unreaped completions to check for.
1267 * If the number of unreaped completions is greater than or equal to wc_cnt,
1268 * this function returns wc_cnt, otherwise, it returns the actual number of
1269 * unreaped completions.
1271 int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1274 * ib_req_notify_cq - Request completion notification on a CQ.
1275 * @cq: The CQ to generate an event for.
1276 * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
1277 * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
1278 * notification will occur on the next completion.
1280 static inline int ib_req_notify_cq(struct ib_cq *cq,
1281 enum ib_cq_notify cq_notify)
1283 return cq->device->req_notify_cq(cq, cq_notify);
1287 * ib_req_ncomp_notif - Request completion notification when there are
1288 * at least the specified number of unreaped completions on the CQ.
1289 * @cq: The CQ to generate an event for.
1290 * @wc_cnt: The number of unreaped completions that should be on the
1291 * CQ before an event is generated.
1293 static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1295 return cq->device->req_ncomp_notif ?
1296 cq->device->req_ncomp_notif(cq, wc_cnt) :
1301 * ib_get_dma_mr - Returns a memory region for system memory that is
1303 * @pd: The protection domain associated with the memory region.
1304 * @mr_access_flags: Specifies the memory access rights.
1306 struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1309 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
1311 * @pd: The protection domain associated assigned to the registered region.
1312 * @phys_buf_array: Specifies a list of physical buffers to use in the
1314 * @num_phys_buf: Specifies the size of the phys_buf_array.
1315 * @mr_access_flags: Specifies the memory access rights.
1316 * @iova_start: The offset of the region's starting I/O virtual address.
1318 struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
1319 struct ib_phys_buf *phys_buf_array,
1321 int mr_access_flags,
1325 * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
1326 * Conceptually, this call performs the functions deregister memory region
1327 * followed by register physical memory region. Where possible,
1328 * resources are reused instead of deallocated and reallocated.
1329 * @mr: The memory region to modify.
1330 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1331 * properties of the memory region are being modified.
1332 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1333 * the new protection domain to associated with the memory region,
1334 * otherwise, this parameter is ignored.
1335 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1336 * field specifies a list of physical buffers to use in the new
1337 * translation, otherwise, this parameter is ignored.
1338 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1339 * field specifies the size of the phys_buf_array, otherwise, this
1340 * parameter is ignored.
1341 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1342 * field specifies the new memory access rights, otherwise, this
1343 * parameter is ignored.
1344 * @iova_start: The offset of the region's starting I/O virtual address.
1346 int ib_rereg_phys_mr(struct ib_mr *mr,
1349 struct ib_phys_buf *phys_buf_array,
1351 int mr_access_flags,
1355 * ib_query_mr - Retrieves information about a specific memory region.
1356 * @mr: The memory region to retrieve information about.
1357 * @mr_attr: The attributes of the specified memory region.
1359 int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1362 * ib_dereg_mr - Deregisters a memory region and removes it from the
1363 * HCA translation table.
1364 * @mr: The memory region to deregister.
1366 int ib_dereg_mr(struct ib_mr *mr);
1369 * ib_alloc_mw - Allocates a memory window.
1370 * @pd: The protection domain associated with the memory window.
1372 struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
1375 * ib_bind_mw - Posts a work request to the send queue of the specified
1376 * QP, which binds the memory window to the given address range and
1377 * remote access attributes.
1378 * @qp: QP to post the bind work request on.
1379 * @mw: The memory window to bind.
1380 * @mw_bind: Specifies information about the memory window, including
1381 * its address range, remote access rights, and associated memory region.
1383 static inline int ib_bind_mw(struct ib_qp *qp,
1385 struct ib_mw_bind *mw_bind)
1387 /* XXX reference counting in corresponding MR? */
1388 return mw->device->bind_mw ?
1389 mw->device->bind_mw(qp, mw, mw_bind) :
1394 * ib_dealloc_mw - Deallocates a memory window.
1395 * @mw: The memory window to deallocate.
1397 int ib_dealloc_mw(struct ib_mw *mw);
1400 * ib_alloc_fmr - Allocates a unmapped fast memory region.
1401 * @pd: The protection domain associated with the unmapped region.
1402 * @mr_access_flags: Specifies the memory access rights.
1403 * @fmr_attr: Attributes of the unmapped region.
1405 * A fast memory region must be mapped before it can be used as part of
1408 struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
1409 int mr_access_flags,
1410 struct ib_fmr_attr *fmr_attr);
1413 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1414 * @fmr: The fast memory region to associate with the pages.
1415 * @page_list: An array of physical pages to map to the fast memory region.
1416 * @list_len: The number of pages in page_list.
1417 * @iova: The I/O virtual address to use with the mapped region.
1419 static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
1420 u64 *page_list, int list_len,
1423 return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
1427 * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
1428 * @fmr_list: A linked list of fast memory regions to unmap.
1430 int ib_unmap_fmr(struct list_head *fmr_list);
1433 * ib_dealloc_fmr - Deallocates a fast memory region.
1434 * @fmr: The fast memory region to deallocate.
1436 int ib_dealloc_fmr(struct ib_fmr *fmr);
1439 * ib_attach_mcast - Attaches the specified QP to a multicast group.
1440 * @qp: QP to attach to the multicast group. The QP must be type
1442 * @gid: Multicast group GID.
1443 * @lid: Multicast group LID in host byte order.
1445 * In order to send and receive multicast packets, subnet
1446 * administration must have created the multicast group and configured
1447 * the fabric appropriately. The port associated with the specified
1448 * QP must also be a member of the multicast group.
1450 int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1453 * ib_detach_mcast - Detaches the specified QP from a multicast group.
1454 * @qp: QP to detach from the multicast group.
1455 * @gid: Multicast group GID.
1456 * @lid: Multicast group LID in host byte order.
1458 int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1460 #endif /* IB_VERBS_H */