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.
8 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU
10 * General Public License (GPL) Version 2, available from the file
11 * COPYING in the main directory of this source tree, or the
12 * OpenIB.org BSD license below:
14 * Redistribution and use in source and binary forms, with or
15 * without modification, are permitted provided that the following
18 * - Redistributions of source code must retain the above
19 * copyright notice, this list of conditions and the following
22 * - Redistributions in binary form must reproduce the above
23 * copyright notice, this list of conditions and the following
24 * disclaimer in the documentation and/or other materials
25 * provided with the distribution.
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
31 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
39 #if !defined(IB_VERBS_H)
42 #include <linux/types.h>
43 #include <linux/device.h>
44 #include <asm/atomic.h>
60 enum ib_device_cap_flags {
61 IB_DEVICE_RESIZE_MAX_WR = 1,
62 IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
63 IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
64 IB_DEVICE_RAW_MULTI = (1<<3),
65 IB_DEVICE_AUTO_PATH_MIG = (1<<4),
66 IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
67 IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
68 IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
69 IB_DEVICE_SHUTDOWN_PORT = (1<<8),
70 IB_DEVICE_INIT_TYPE = (1<<9),
71 IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
72 IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
73 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
74 IB_DEVICE_SRQ_RESIZE = (1<<13),
75 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
84 struct ib_device_attr {
105 int max_qp_init_rd_atom;
106 int max_ee_init_rd_atom;
107 enum ib_atomic_cap atomic_cap;
114 int max_mcast_qp_attach;
115 int max_total_mcast_qp_attach;
123 u8 local_ca_ack_delay;
134 static inline int ib_mtu_enum_to_int(enum ib_mtu mtu)
137 case IB_MTU_256: return 256;
138 case IB_MTU_512: return 512;
139 case IB_MTU_1024: return 1024;
140 case IB_MTU_2048: return 2048;
141 case IB_MTU_4096: return 4096;
152 IB_PORT_ACTIVE_DEFER = 5
155 enum ib_port_cap_flags {
157 IB_PORT_NOTICE_SUP = 1 << 2,
158 IB_PORT_TRAP_SUP = 1 << 3,
159 IB_PORT_OPT_IPD_SUP = 1 << 4,
160 IB_PORT_AUTO_MIGR_SUP = 1 << 5,
161 IB_PORT_SL_MAP_SUP = 1 << 6,
162 IB_PORT_MKEY_NVRAM = 1 << 7,
163 IB_PORT_PKEY_NVRAM = 1 << 8,
164 IB_PORT_LED_INFO_SUP = 1 << 9,
165 IB_PORT_SM_DISABLED = 1 << 10,
166 IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
167 IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
168 IB_PORT_CM_SUP = 1 << 16,
169 IB_PORT_SNMP_TUNNEL_SUP = 1 << 17,
170 IB_PORT_REINIT_SUP = 1 << 18,
171 IB_PORT_DEVICE_MGMT_SUP = 1 << 19,
172 IB_PORT_VENDOR_CLASS_SUP = 1 << 20,
173 IB_PORT_DR_NOTICE_SUP = 1 << 21,
174 IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
175 IB_PORT_BOOT_MGMT_SUP = 1 << 23,
176 IB_PORT_LINK_LATENCY_SUP = 1 << 24,
177 IB_PORT_CLIENT_REG_SUP = 1 << 25
187 static inline int ib_width_enum_to_int(enum ib_port_width width)
190 case IB_WIDTH_1X: return 1;
191 case IB_WIDTH_4X: return 4;
192 case IB_WIDTH_8X: return 8;
193 case IB_WIDTH_12X: return 12;
198 struct ib_port_attr {
199 enum ib_port_state state;
201 enum ib_mtu active_mtu;
220 enum ib_device_modify_flags {
221 IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1
224 struct ib_device_modify {
228 enum ib_port_modify_flags {
229 IB_PORT_SHUTDOWN = 1,
230 IB_PORT_INIT_TYPE = (1<<2),
231 IB_PORT_RESET_QKEY_CNTR = (1<<3)
234 struct ib_port_modify {
235 u32 set_port_cap_mask;
236 u32 clr_port_cap_mask;
244 IB_EVENT_QP_ACCESS_ERR,
248 IB_EVENT_PATH_MIG_ERR,
249 IB_EVENT_DEVICE_FATAL,
250 IB_EVENT_PORT_ACTIVE,
253 IB_EVENT_PKEY_CHANGE,
258 struct ib_device *device;
264 enum ib_event_type event;
267 struct ib_event_handler {
268 struct ib_device *device;
269 void (*handler)(struct ib_event_handler *, struct ib_event *);
270 struct list_head list;
273 #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \
275 (_ptr)->device = _device; \
276 (_ptr)->handler = _handler; \
277 INIT_LIST_HEAD(&(_ptr)->list); \
280 struct ib_global_route {
289 IB_MULTICAST_QPN = 0xffffff
297 struct ib_global_route grh;
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,
339 * Set value of IB_WC_RECV so consumers can test if a completion is a
340 * receive by testing (opcode & IB_WC_RECV).
343 IB_WC_RECV_RDMA_WITH_IMM
348 IB_WC_WITH_IMM = (1<<1)
353 enum ib_wc_status status;
354 enum ib_wc_opcode opcode;
365 u8 port_num; /* valid only for DR SMPs on switches */
388 * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
389 * here (and in that order) since the MAD layer uses them as
390 * indices into a 2-entry table.
402 struct ib_qp_init_attr {
403 void (*event_handler)(struct ib_event *, void *);
405 struct ib_cq *send_cq;
406 struct ib_cq *recv_cq;
408 struct ib_qp_cap cap;
409 enum ib_sig_type sq_sig_type;
410 enum ib_qp_type qp_type;
411 u8 port_num; /* special QP types only */
414 enum ib_rnr_timeout {
415 IB_RNR_TIMER_655_36 = 0,
416 IB_RNR_TIMER_000_01 = 1,
417 IB_RNR_TIMER_000_02 = 2,
418 IB_RNR_TIMER_000_03 = 3,
419 IB_RNR_TIMER_000_04 = 4,
420 IB_RNR_TIMER_000_06 = 5,
421 IB_RNR_TIMER_000_08 = 6,
422 IB_RNR_TIMER_000_12 = 7,
423 IB_RNR_TIMER_000_16 = 8,
424 IB_RNR_TIMER_000_24 = 9,
425 IB_RNR_TIMER_000_32 = 10,
426 IB_RNR_TIMER_000_48 = 11,
427 IB_RNR_TIMER_000_64 = 12,
428 IB_RNR_TIMER_000_96 = 13,
429 IB_RNR_TIMER_001_28 = 14,
430 IB_RNR_TIMER_001_92 = 15,
431 IB_RNR_TIMER_002_56 = 16,
432 IB_RNR_TIMER_003_84 = 17,
433 IB_RNR_TIMER_005_12 = 18,
434 IB_RNR_TIMER_007_68 = 19,
435 IB_RNR_TIMER_010_24 = 20,
436 IB_RNR_TIMER_015_36 = 21,
437 IB_RNR_TIMER_020_48 = 22,
438 IB_RNR_TIMER_030_72 = 23,
439 IB_RNR_TIMER_040_96 = 24,
440 IB_RNR_TIMER_061_44 = 25,
441 IB_RNR_TIMER_081_92 = 26,
442 IB_RNR_TIMER_122_88 = 27,
443 IB_RNR_TIMER_163_84 = 28,
444 IB_RNR_TIMER_245_76 = 29,
445 IB_RNR_TIMER_327_68 = 30,
446 IB_RNR_TIMER_491_52 = 31
449 enum ib_qp_attr_mask {
451 IB_QP_CUR_STATE = (1<<1),
452 IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2),
453 IB_QP_ACCESS_FLAGS = (1<<3),
454 IB_QP_PKEY_INDEX = (1<<4),
458 IB_QP_PATH_MTU = (1<<8),
459 IB_QP_TIMEOUT = (1<<9),
460 IB_QP_RETRY_CNT = (1<<10),
461 IB_QP_RNR_RETRY = (1<<11),
462 IB_QP_RQ_PSN = (1<<12),
463 IB_QP_MAX_QP_RD_ATOMIC = (1<<13),
464 IB_QP_ALT_PATH = (1<<14),
465 IB_QP_MIN_RNR_TIMER = (1<<15),
466 IB_QP_SQ_PSN = (1<<16),
467 IB_QP_MAX_DEST_RD_ATOMIC = (1<<17),
468 IB_QP_PATH_MIG_STATE = (1<<18),
470 IB_QP_DEST_QPN = (1<<20)
490 enum ib_qp_state qp_state;
491 enum ib_qp_state cur_qp_state;
492 enum ib_mtu path_mtu;
493 enum ib_mig_state path_mig_state;
499 struct ib_qp_cap cap;
500 struct ib_ah_attr ah_attr;
501 struct ib_ah_attr alt_ah_attr;
504 u8 en_sqd_async_notify;
507 u8 max_dest_rd_atomic;
519 IB_WR_RDMA_WRITE_WITH_IMM,
523 IB_WR_ATOMIC_CMP_AND_SWP,
524 IB_WR_ATOMIC_FETCH_AND_ADD
529 IB_SEND_SIGNALED = (1<<1),
530 IB_SEND_SOLICITED = (1<<2),
531 IB_SEND_INLINE = (1<<3)
541 struct ib_send_wr *next;
543 struct ib_sge *sg_list;
545 enum ib_wr_opcode opcode;
561 struct ib_mad_hdr *mad_hdr;
564 int timeout_ms; /* valid for MADs only */
565 u16 pkey_index; /* valid for GSI only */
566 u8 port_num; /* valid for DR SMPs on switch only */
572 struct ib_recv_wr *next;
574 struct ib_sge *sg_list;
578 enum ib_access_flags {
579 IB_ACCESS_LOCAL_WRITE = 1,
580 IB_ACCESS_REMOTE_WRITE = (1<<1),
581 IB_ACCESS_REMOTE_READ = (1<<2),
582 IB_ACCESS_REMOTE_ATOMIC = (1<<3),
583 IB_ACCESS_MW_BIND = (1<<4)
593 u64 device_virt_addr;
600 enum ib_mr_rereg_flags {
601 IB_MR_REREG_TRANS = 1,
602 IB_MR_REREG_PD = (1<<1),
603 IB_MR_REREG_ACCESS = (1<<2)
622 struct ib_device *device;
623 atomic_t usecnt; /* count all resources */
627 struct ib_device *device;
631 typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
634 struct ib_device *device;
635 ib_comp_handler comp_handler;
636 void (*event_handler)(struct ib_event *, void *);
639 atomic_t usecnt; /* count number of work queues */
643 struct ib_device *device;
650 struct ib_device *device;
652 struct ib_cq *send_cq;
653 struct ib_cq *recv_cq;
655 void (*event_handler)(struct ib_event *, void *);
658 enum ib_qp_type qp_type;
662 struct ib_device *device;
666 atomic_t usecnt; /* count number of MWs */
670 struct ib_device *device;
676 struct ib_device *device;
678 struct list_head list;
686 enum ib_process_mad_flags {
687 IB_MAD_IGNORE_MKEY = 1,
688 IB_MAD_IGNORE_BKEY = 2,
689 IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY
693 IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */
694 IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */
695 IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */
696 IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */
699 #define IB_DEVICE_NAME_MAX 64
703 struct ib_event_handler event_handler;
704 struct ib_pkey_cache **pkey_cache;
705 struct ib_gid_cache **gid_cache;
709 struct device *dma_device;
711 char name[IB_DEVICE_NAME_MAX];
713 struct list_head event_handler_list;
714 spinlock_t event_handler_lock;
716 struct list_head core_list;
717 struct list_head client_data_list;
718 spinlock_t client_data_lock;
720 struct ib_cache cache;
724 int (*query_device)(struct ib_device *device,
725 struct ib_device_attr *device_attr);
726 int (*query_port)(struct ib_device *device,
728 struct ib_port_attr *port_attr);
729 int (*query_gid)(struct ib_device *device,
730 u8 port_num, int index,
732 int (*query_pkey)(struct ib_device *device,
733 u8 port_num, u16 index, u16 *pkey);
734 int (*modify_device)(struct ib_device *device,
735 int device_modify_mask,
736 struct ib_device_modify *device_modify);
737 int (*modify_port)(struct ib_device *device,
738 u8 port_num, int port_modify_mask,
739 struct ib_port_modify *port_modify);
740 struct ib_pd * (*alloc_pd)(struct ib_device *device);
741 int (*dealloc_pd)(struct ib_pd *pd);
742 struct ib_ah * (*create_ah)(struct ib_pd *pd,
743 struct ib_ah_attr *ah_attr);
744 int (*modify_ah)(struct ib_ah *ah,
745 struct ib_ah_attr *ah_attr);
746 int (*query_ah)(struct ib_ah *ah,
747 struct ib_ah_attr *ah_attr);
748 int (*destroy_ah)(struct ib_ah *ah);
749 struct ib_qp * (*create_qp)(struct ib_pd *pd,
750 struct ib_qp_init_attr *qp_init_attr);
751 int (*modify_qp)(struct ib_qp *qp,
752 struct ib_qp_attr *qp_attr,
754 int (*query_qp)(struct ib_qp *qp,
755 struct ib_qp_attr *qp_attr,
757 struct ib_qp_init_attr *qp_init_attr);
758 int (*destroy_qp)(struct ib_qp *qp);
759 int (*post_send)(struct ib_qp *qp,
760 struct ib_send_wr *send_wr,
761 struct ib_send_wr **bad_send_wr);
762 int (*post_recv)(struct ib_qp *qp,
763 struct ib_recv_wr *recv_wr,
764 struct ib_recv_wr **bad_recv_wr);
765 struct ib_cq * (*create_cq)(struct ib_device *device,
767 int (*destroy_cq)(struct ib_cq *cq);
768 int (*resize_cq)(struct ib_cq *cq, int *cqe);
769 int (*poll_cq)(struct ib_cq *cq, int num_entries,
771 int (*peek_cq)(struct ib_cq *cq, int wc_cnt);
772 int (*req_notify_cq)(struct ib_cq *cq,
773 enum ib_cq_notify cq_notify);
774 int (*req_ncomp_notif)(struct ib_cq *cq,
776 struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
777 int mr_access_flags);
778 struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
779 struct ib_phys_buf *phys_buf_array,
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,
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,
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,
816 struct ib_grh *in_grh,
817 struct ib_mad *in_mad,
818 struct ib_mad *out_mad);
820 struct class_device class_dev;
821 struct kobject ports_parent;
822 struct list_head port_list;
825 IB_DEV_UNINITIALIZED,
836 void (*add) (struct ib_device *);
837 void (*remove)(struct ib_device *);
839 struct list_head list;
842 struct ib_device *ib_alloc_device(size_t size);
843 void ib_dealloc_device(struct ib_device *device);
845 int ib_register_device (struct ib_device *device);
846 void ib_unregister_device(struct ib_device *device);
848 int ib_register_client (struct ib_client *client);
849 void ib_unregister_client(struct ib_client *client);
851 void *ib_get_client_data(struct ib_device *device, struct ib_client *client);
852 void ib_set_client_data(struct ib_device *device, struct ib_client *client,
855 int ib_register_event_handler (struct ib_event_handler *event_handler);
856 int ib_unregister_event_handler(struct ib_event_handler *event_handler);
857 void ib_dispatch_event(struct ib_event *event);
859 int ib_query_device(struct ib_device *device,
860 struct ib_device_attr *device_attr);
862 int ib_query_port(struct ib_device *device,
863 u8 port_num, struct ib_port_attr *port_attr);
865 int ib_query_gid(struct ib_device *device,
866 u8 port_num, int index, union ib_gid *gid);
868 int ib_query_pkey(struct ib_device *device,
869 u8 port_num, u16 index, u16 *pkey);
871 int ib_modify_device(struct ib_device *device,
872 int device_modify_mask,
873 struct ib_device_modify *device_modify);
875 int ib_modify_port(struct ib_device *device,
876 u8 port_num, int port_modify_mask,
877 struct ib_port_modify *port_modify);
880 * ib_alloc_pd - Allocates an unused protection domain.
881 * @device: The device on which to allocate the protection domain.
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 *ib_alloc_pd(struct ib_device *device);
889 * ib_dealloc_pd - Deallocates a protection domain.
890 * @pd: The protection domain to deallocate.
892 int ib_dealloc_pd(struct ib_pd *pd);
895 * ib_create_ah - Creates an address handle for the given address vector.
896 * @pd: The protection domain associated with the address handle.
897 * @ah_attr: The attributes of the address vector.
899 * The address handle is used to reference a local or global destination
900 * in all UD QP post sends.
902 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
905 * ib_modify_ah - Modifies the address vector associated with an address
907 * @ah: The address handle to modify.
908 * @ah_attr: The new address vector attributes to associate with the
911 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
914 * ib_query_ah - Queries the address vector associated with an address
916 * @ah: The address handle to query.
917 * @ah_attr: The address vector attributes associated with the address
920 int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr);
923 * ib_destroy_ah - Destroys an address handle.
924 * @ah: The address handle to destroy.
926 int ib_destroy_ah(struct ib_ah *ah);
929 * ib_create_qp - Creates a QP associated with the specified protection
931 * @pd: The protection domain associated with the QP.
932 * @qp_init_attr: A list of initial attributes required to create the QP.
934 struct ib_qp *ib_create_qp(struct ib_pd *pd,
935 struct ib_qp_init_attr *qp_init_attr);
938 * ib_modify_qp - Modifies the attributes for the specified QP and then
939 * transitions the QP to the given state.
940 * @qp: The QP to modify.
941 * @qp_attr: On input, specifies the QP attributes to modify. On output,
942 * the current values of selected QP attributes are returned.
943 * @qp_attr_mask: A bit-mask used to specify which attributes of the QP
944 * are being modified.
946 int ib_modify_qp(struct ib_qp *qp,
947 struct ib_qp_attr *qp_attr,
951 * ib_query_qp - Returns the attribute list and current values for the
953 * @qp: The QP to query.
954 * @qp_attr: The attributes of the specified QP.
955 * @qp_attr_mask: A bit-mask used to select specific attributes to query.
956 * @qp_init_attr: Additional attributes of the selected QP.
958 * The qp_attr_mask may be used to limit the query to gathering only the
959 * selected attributes.
961 int ib_query_qp(struct ib_qp *qp,
962 struct ib_qp_attr *qp_attr,
964 struct ib_qp_init_attr *qp_init_attr);
967 * ib_destroy_qp - Destroys the specified QP.
968 * @qp: The QP to destroy.
970 int ib_destroy_qp(struct ib_qp *qp);
973 * ib_post_send - Posts a list of work requests to the send queue of
975 * @qp: The QP to post the work request on.
976 * @send_wr: A list of work requests to post on the send queue.
977 * @bad_send_wr: On an immediate failure, this parameter will reference
978 * the work request that failed to be posted on the QP.
980 static inline int ib_post_send(struct ib_qp *qp,
981 struct ib_send_wr *send_wr,
982 struct ib_send_wr **bad_send_wr)
984 return qp->device->post_send(qp, send_wr, bad_send_wr);
988 * ib_post_recv - Posts a list of work requests to the receive queue of
990 * @qp: The QP to post the work request on.
991 * @recv_wr: A list of work requests to post on the receive queue.
992 * @bad_recv_wr: On an immediate failure, this parameter will reference
993 * the work request that failed to be posted on the QP.
995 static inline int ib_post_recv(struct ib_qp *qp,
996 struct ib_recv_wr *recv_wr,
997 struct ib_recv_wr **bad_recv_wr)
999 return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
1003 * ib_create_cq - Creates a CQ on the specified device.
1004 * @device: The device on which to create the CQ.
1005 * @comp_handler: A user-specified callback that is invoked when a
1006 * completion event occurs on the CQ.
1007 * @event_handler: A user-specified callback that is invoked when an
1008 * asynchronous event not associated with a completion occurs on the CQ.
1009 * @cq_context: Context associated with the CQ returned to the user via
1010 * the associated completion and event handlers.
1011 * @cqe: The minimum size of the CQ.
1013 * Users can examine the cq structure to determine the actual CQ size.
1015 struct ib_cq *ib_create_cq(struct ib_device *device,
1016 ib_comp_handler comp_handler,
1017 void (*event_handler)(struct ib_event *, void *),
1018 void *cq_context, int cqe);
1021 * ib_resize_cq - Modifies the capacity of the CQ.
1022 * @cq: The CQ to resize.
1023 * @cqe: The minimum size of the CQ.
1025 * Users can examine the cq structure to determine the actual CQ size.
1027 int ib_resize_cq(struct ib_cq *cq, int cqe);
1030 * ib_destroy_cq - Destroys the specified CQ.
1031 * @cq: The CQ to destroy.
1033 int ib_destroy_cq(struct ib_cq *cq);
1036 * ib_poll_cq - poll a CQ for completion(s)
1037 * @cq:the CQ being polled
1038 * @num_entries:maximum number of completions to return
1039 * @wc:array of at least @num_entries &struct ib_wc where completions
1042 * Poll a CQ for (possibly multiple) completions. If the return value
1043 * is < 0, an error occurred. If the return value is >= 0, it is the
1044 * number of completions returned. If the return value is
1045 * non-negative and < num_entries, then the CQ was emptied.
1047 static inline int ib_poll_cq(struct ib_cq *cq, int num_entries,
1050 return cq->device->poll_cq(cq, num_entries, wc);
1054 * ib_peek_cq - Returns the number of unreaped completions currently
1055 * on the specified CQ.
1056 * @cq: The CQ to peek.
1057 * @wc_cnt: A minimum number of unreaped completions to check for.
1059 * If the number of unreaped completions is greater than or equal to wc_cnt,
1060 * this function returns wc_cnt, otherwise, it returns the actual number of
1061 * unreaped completions.
1063 int ib_peek_cq(struct ib_cq *cq, int wc_cnt);
1066 * ib_req_notify_cq - Request completion notification on a CQ.
1067 * @cq: The CQ to generate an event for.
1068 * @cq_notify: If set to %IB_CQ_SOLICITED, completion notification will
1069 * occur on the next solicited event. If set to %IB_CQ_NEXT_COMP,
1070 * notification will occur on the next completion.
1072 static inline int ib_req_notify_cq(struct ib_cq *cq,
1073 enum ib_cq_notify cq_notify)
1075 return cq->device->req_notify_cq(cq, cq_notify);
1079 * ib_req_ncomp_notif - Request completion notification when there are
1080 * at least the specified number of unreaped completions on the CQ.
1081 * @cq: The CQ to generate an event for.
1082 * @wc_cnt: The number of unreaped completions that should be on the
1083 * CQ before an event is generated.
1085 static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
1087 return cq->device->req_ncomp_notif ?
1088 cq->device->req_ncomp_notif(cq, wc_cnt) :
1093 * ib_get_dma_mr - Returns a memory region for system memory that is
1095 * @pd: The protection domain associated with the memory region.
1096 * @mr_access_flags: Specifies the memory access rights.
1098 struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
1101 * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
1103 * @pd: The protection domain associated assigned to the registered region.
1104 * @phys_buf_array: Specifies a list of physical buffers to use in the
1106 * @num_phys_buf: Specifies the size of the phys_buf_array.
1107 * @mr_access_flags: Specifies the memory access rights.
1108 * @iova_start: The offset of the region's starting I/O virtual address.
1110 struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
1111 struct ib_phys_buf *phys_buf_array,
1113 int mr_access_flags,
1117 * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
1118 * Conceptually, this call performs the functions deregister memory region
1119 * followed by register physical memory region. Where possible,
1120 * resources are reused instead of deallocated and reallocated.
1121 * @mr: The memory region to modify.
1122 * @mr_rereg_mask: A bit-mask used to indicate which of the following
1123 * properties of the memory region are being modified.
1124 * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
1125 * the new protection domain to associated with the memory region,
1126 * otherwise, this parameter is ignored.
1127 * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1128 * field specifies a list of physical buffers to use in the new
1129 * translation, otherwise, this parameter is ignored.
1130 * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
1131 * field specifies the size of the phys_buf_array, otherwise, this
1132 * parameter is ignored.
1133 * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
1134 * field specifies the new memory access rights, otherwise, this
1135 * parameter is ignored.
1136 * @iova_start: The offset of the region's starting I/O virtual address.
1138 int ib_rereg_phys_mr(struct ib_mr *mr,
1141 struct ib_phys_buf *phys_buf_array,
1143 int mr_access_flags,
1147 * ib_query_mr - Retrieves information about a specific memory region.
1148 * @mr: The memory region to retrieve information about.
1149 * @mr_attr: The attributes of the specified memory region.
1151 int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1154 * ib_dereg_mr - Deregisters a memory region and removes it from the
1155 * HCA translation table.
1156 * @mr: The memory region to deregister.
1158 int ib_dereg_mr(struct ib_mr *mr);
1161 * ib_alloc_mw - Allocates a memory window.
1162 * @pd: The protection domain associated with the memory window.
1164 struct ib_mw *ib_alloc_mw(struct ib_pd *pd);
1167 * ib_bind_mw - Posts a work request to the send queue of the specified
1168 * QP, which binds the memory window to the given address range and
1169 * remote access attributes.
1170 * @qp: QP to post the bind work request on.
1171 * @mw: The memory window to bind.
1172 * @mw_bind: Specifies information about the memory window, including
1173 * its address range, remote access rights, and associated memory region.
1175 static inline int ib_bind_mw(struct ib_qp *qp,
1177 struct ib_mw_bind *mw_bind)
1179 /* XXX reference counting in corresponding MR? */
1180 return mw->device->bind_mw ?
1181 mw->device->bind_mw(qp, mw, mw_bind) :
1186 * ib_dealloc_mw - Deallocates a memory window.
1187 * @mw: The memory window to deallocate.
1189 int ib_dealloc_mw(struct ib_mw *mw);
1192 * ib_alloc_fmr - Allocates a unmapped fast memory region.
1193 * @pd: The protection domain associated with the unmapped region.
1194 * @mr_access_flags: Specifies the memory access rights.
1195 * @fmr_attr: Attributes of the unmapped region.
1197 * A fast memory region must be mapped before it can be used as part of
1200 struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
1201 int mr_access_flags,
1202 struct ib_fmr_attr *fmr_attr);
1205 * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region.
1206 * @fmr: The fast memory region to associate with the pages.
1207 * @page_list: An array of physical pages to map to the fast memory region.
1208 * @list_len: The number of pages in page_list.
1209 * @iova: The I/O virtual address to use with the mapped region.
1211 static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
1212 u64 *page_list, int list_len,
1215 return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova);
1219 * ib_unmap_fmr - Removes the mapping from a list of fast memory regions.
1220 * @fmr_list: A linked list of fast memory regions to unmap.
1222 int ib_unmap_fmr(struct list_head *fmr_list);
1225 * ib_dealloc_fmr - Deallocates a fast memory region.
1226 * @fmr: The fast memory region to deallocate.
1228 int ib_dealloc_fmr(struct ib_fmr *fmr);
1231 * ib_attach_mcast - Attaches the specified QP to a multicast group.
1232 * @qp: QP to attach to the multicast group. The QP must be type
1234 * @gid: Multicast group GID.
1235 * @lid: Multicast group LID in host byte order.
1237 * In order to send and receive multicast packets, subnet
1238 * administration must have created the multicast group and configured
1239 * the fabric appropriately. The port associated with the specified
1240 * QP must also be a member of the multicast group.
1242 int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1245 * ib_detach_mcast - Detaches the specified QP from a multicast group.
1246 * @qp: QP to detach from the multicast group.
1247 * @gid: Multicast group GID.
1248 * @lid: Multicast group LID in host byte order.
1250 int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid);
1252 #endif /* IB_VERBS_H */