xref: /onnv-gate/usr/src/uts/common/sys/ib/ibtl/ibci.h (revision 12965:b65a8427f8fe)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
58580SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
68580SBill.Taylor@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*12965SWilliam.Taylor@Oracle.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_SYS_IB_IBTL_IBCI_H
260Sstevel@tonic-gate #define	_SYS_IB_IBTL_IBCI_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * ibci.h
300Sstevel@tonic-gate  *
310Sstevel@tonic-gate  * Define the data structures and function prototypes that comprise
320Sstevel@tonic-gate  * the IB Channel API (API for HCA drivers).  All CI handles are opaque
330Sstevel@tonic-gate  * to the IBTF here, real data is accessed in the HCA driver by a
340Sstevel@tonic-gate  * typecast to a driver specific struct.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <sys/ib/ibtl/ibtl_types.h>
380Sstevel@tonic-gate #include <sys/ib/ibtl/ibtl_ci_types.h>
390Sstevel@tonic-gate #include <sys/modctl.h>
400Sstevel@tonic-gate 
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #ifdef	__cplusplus
430Sstevel@tonic-gate extern "C" {
440Sstevel@tonic-gate #endif
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * Define CI opaque IBTF handles.
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate typedef	struct	ibtl_qp_s	*ibtl_qp_hdl_t;		/* ibt_alloc_qp() */
500Sstevel@tonic-gate typedef struct	ibtl_eec_s	*ibtl_eec_hdl_t;	/* ibt_alloc_eec() */
510Sstevel@tonic-gate 
520Sstevel@tonic-gate /*
530Sstevel@tonic-gate  * Define IBTF opaque CI handles.
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate typedef struct ibc_hca_s	*ibc_hca_hdl_t; /* HCA/CI Handle */
560Sstevel@tonic-gate typedef struct ibc_pd_s		*ibc_pd_hdl_t;	/* Protection Domain Handle */
570Sstevel@tonic-gate typedef	struct ibc_rdd_s	*ibc_rdd_hdl_t;	/* Reliable Datagram Domain */
580Sstevel@tonic-gate typedef struct ibc_ah_s		*ibc_ah_hdl_t;	/* Address Handle */
590Sstevel@tonic-gate typedef struct ibc_qp_s		*ibc_qp_hdl_t;	/* Queue Pair Handle */
600Sstevel@tonic-gate typedef struct ibc_srq_s	*ibc_srq_hdl_t;	/* Shared Receive Queue Hdl */
610Sstevel@tonic-gate typedef struct ibc_qpn_s	*ibc_qpn_hdl_t;	/* Queue Pair Number Handle */
620Sstevel@tonic-gate typedef struct ibc_cq_s		*ibc_cq_hdl_t;	/* Completion Queue Handle */
630Sstevel@tonic-gate typedef struct ibc_eec_s	*ibc_eec_hdl_t; /* End-to-End Context Handle */
648580SBill.Taylor@Sun.COM typedef struct ibc_mem_alloc_s	*ibc_mem_alloc_hdl_t; /* Memory Handle */
650Sstevel@tonic-gate 
66*12965SWilliam.Taylor@Oracle.COM #define	ibc_sched_hdl_t		ibt_sched_hdl_t	/* CQ Sched Handle */
67929Ssrust #define	ibc_fmr_pool_hdl_t	ibt_fmr_pool_hdl_t /* FMR Pool Handle */
680Sstevel@tonic-gate #define	ibc_mr_hdl_t	ibt_mr_hdl_t	/* Memory Region Handle */
690Sstevel@tonic-gate #define	ibc_mw_hdl_t	ibt_mw_hdl_t	/* Memory Window Handle */
700Sstevel@tonic-gate #define	ibc_ma_hdl_t	ibt_ma_hdl_t	/* Memory Area Handle */
718580SBill.Taylor@Sun.COM #define	ibc_mi_hdl_t	ibt_mi_hdl_t	/* Memory IOV Handle */
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /* Handle used by CI for up calls to IBTF */
740Sstevel@tonic-gate typedef struct ibtl_hca_devinfo_s *ibc_clnt_hdl_t;	/* ibc_attach() */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /*
770Sstevel@tonic-gate  * Fields opaque to TI, but visible to CI
780Sstevel@tonic-gate  */
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * ibt_qp_alloc_attr_t
820Sstevel@tonic-gate  */
830Sstevel@tonic-gate #define	qp_ibc_scq_hdl	qp_opaque1
840Sstevel@tonic-gate #define	qp_ibc_rcq_hdl	qp_opaque2
850Sstevel@tonic-gate #define	qp_ibc_srq_hdl	qp_opaque3
860Sstevel@tonic-gate 
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate  * ibt_status_t
900Sstevel@tonic-gate  */
910Sstevel@tonic-gate #define	IBT_HCA_RAWD_CHAN_EXCEEDED	IBT_ERR_OPAQUE1	/* Requested raw QP */
920Sstevel@tonic-gate 							/* exceeds HCA max */
930Sstevel@tonic-gate 							/* limit */
940Sstevel@tonic-gate #define	IBT_CHAN_RAWD_NOT_SUPPORTED	IBT_ERR_OPAQUE2	/* Raw datagram QPs */
950Sstevel@tonic-gate 							/* not supported */
960Sstevel@tonic-gate #define	IBT_CHAN_RD_NOT_SUPPORTED	IBT_ERR_OPAQUE3	/* RD not supported */
970Sstevel@tonic-gate #define	IBT_EEC_HDL_INVALID		IBT_ERR_OPAQUE4	/* Invalid EEC handle */
980Sstevel@tonic-gate #define	IBT_EEC_STATE_INVALID		IBT_ERR_OPAQUE5	/* Invalid EEC State */
990Sstevel@tonic-gate #define	IBT_EEC_ATTR_RO			IBT_ERR_OPAQUE6	/* Can't Change EEC */
1000Sstevel@tonic-gate 							/* Attribute */
1010Sstevel@tonic-gate #define	IBT_RDD_IN_USE			IBT_ERR_OPAQUE7	/* RDD in Use */
1020Sstevel@tonic-gate #define	IBT_RDD_HDL_INVALID		IBT_ERR_OPAQUE8	/* Invalid RDD */
1030Sstevel@tonic-gate #define	IBT_RNR_NAK_TIMER_INVALID	IBT_ERR_OPAQUE9	/* Invalid RNR NAK */
1040Sstevel@tonic-gate 							/* Timer Value */
1050Sstevel@tonic-gate #define	IBT_RDD_NOT_SUPPORTED		IBT_ERR_OPAQUE10
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * ibt_wc_status_t
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate #define	IBT_WC_LOCAL_EEC_OP_ERR		12	/* Internal consistency error */
1120Sstevel@tonic-gate #define	IBT_WC_LOCAL_RDD_VIOLATION_ERR	30	/* The RDD associated with */
1130Sstevel@tonic-gate 						/* the QP does not match */
1140Sstevel@tonic-gate 						/* the RDD associated with */
1150Sstevel@tonic-gate 						/* the EE Context */
1160Sstevel@tonic-gate #define	IBT_WC_REMOTE_RD_REQ_INVALID	31	/* Detected an invalid */
1170Sstevel@tonic-gate 						/* incoming RD message */
1180Sstevel@tonic-gate #define	IBT_WC_EEC_REMOTE_ABORTED	32	/* Requester aborted the */
1190Sstevel@tonic-gate 						/* operation */
1200Sstevel@tonic-gate #define	IBT_WC_EEC_NUM_INVALID		33	/* Invalid EEC Number */
1210Sstevel@tonic-gate 						/* detected */
1220Sstevel@tonic-gate #define	IBT_WC_EEC_STATE_INVALID	34	/* Invalid EEC state */
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * ibt_async_code_t
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate #define	IBT_EVENT_PATH_MIGRATED_EEC	IBT_ASYNC_OPAQUE1
1280Sstevel@tonic-gate #define	IBT_ERROR_CATASTROPHIC_EEC	IBT_ASYNC_OPAQUE3
1290Sstevel@tonic-gate #define	IBT_ERROR_PATH_MIGRATE_REQ_EEC	IBT_ASYNC_OPAQUE4
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate /*
1320Sstevel@tonic-gate  * ibt_object_type_t
1330Sstevel@tonic-gate  */
1340Sstevel@tonic-gate #define	IBT_HDL_EEC	IBT_HDL_OPAQUE1
1350Sstevel@tonic-gate #define	IBT_HDL_RDD	IBT_HDL_OPAQUE2
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate /*
1390Sstevel@tonic-gate  * ibt_wc_t
1400Sstevel@tonic-gate  */
1418580SBill.Taylor@Sun.COM #define	wc_eecn		wc_detail	/* End-to-End Context RD's only */
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate /* Channel Interface version */
145*12965SWilliam.Taylor@Oracle.COM typedef int ibc_version_t;
146*12965SWilliam.Taylor@Oracle.COM #define	IBCI_V1	1
147*12965SWilliam.Taylor@Oracle.COM #define	IBCI_V2	2
148*12965SWilliam.Taylor@Oracle.COM #define	IBCI_V3	3
149*12965SWilliam.Taylor@Oracle.COM #define	IBCI_V4	4
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate typedef enum ibc_free_qp_flags_e {
1530Sstevel@tonic-gate 	IBC_FREE_QP_AND_QPN	= 0,	/* free all qp resources */
1540Sstevel@tonic-gate 	IBC_FREE_QP_ONLY	= 1	/* OK to free the QP, but the QPN */
1550Sstevel@tonic-gate 					/* cannot be reused until a future */
1560Sstevel@tonic-gate 					/* call to ibc_release_qpn(qpn_hdl), */
1570Sstevel@tonic-gate 					/* where qpn_hdl is a return value */
1580Sstevel@tonic-gate 					/* of ibc_free_qp() */
1590Sstevel@tonic-gate } ibc_free_qp_flags_t;
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /*
1620Sstevel@tonic-gate  * RDD alloc flags
1630Sstevel@tonic-gate  */
1640Sstevel@tonic-gate typedef enum ibc_rdd_flags_e {
1650Sstevel@tonic-gate 	IBT_RDD_NO_FLAGS	= 0,
1660Sstevel@tonic-gate 	IBT_RDD_USER_MAP	= (1 << 0),
1670Sstevel@tonic-gate 	IBT_RDD_DEFER_ALLOC	= (1 << 1)
1680Sstevel@tonic-gate } ibc_rdd_flags_t;
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate /*
1710Sstevel@tonic-gate  * EEC alloc flags
1720Sstevel@tonic-gate  */
1730Sstevel@tonic-gate typedef enum ibc_eec_flags_e {
1740Sstevel@tonic-gate 	IBT_EEC_NO_FLAGS	= 0,
1750Sstevel@tonic-gate 	IBT_EEC_USER_MAP	= (1 << 0),
1760Sstevel@tonic-gate 	IBT_EEC_DEFER_ALLOC	= (1 << 1)
1770Sstevel@tonic-gate } ibc_eec_flags_t;
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate /*
1800Sstevel@tonic-gate  * Event data for asynchronous events and errors. The QP/EEC/CQ/SRQ handle,
1810Sstevel@tonic-gate  * or port number associated with the Event/Error is passed as an argument
1820Sstevel@tonic-gate  * to the async handler.
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate typedef struct ibc_async_event_s {
1850Sstevel@tonic-gate 	uint64_t	ev_fma_ena;	/* fault management error data */
1860Sstevel@tonic-gate 	ibtl_qp_hdl_t	ev_qp_hdl;	/* IBTF QP handle. */
1870Sstevel@tonic-gate 	ibtl_eec_hdl_t	ev_eec_hdl;	/* IBTF EEC handle. */
1880Sstevel@tonic-gate 	ibt_cq_hdl_t	ev_cq_hdl;	/* IBT CQ handle. */
1890Sstevel@tonic-gate 	ibt_srq_hdl_t	ev_srq_hdl;	/* SRQ handle */
1908580SBill.Taylor@Sun.COM 	ibt_port_change_t ev_port_flags; /* Port Change flags */
1918580SBill.Taylor@Sun.COM 	uint8_t		ev_port;	/* For PORT UP/DOWN/CHANGE events */
192*12965SWilliam.Taylor@Oracle.COM 	ibt_fc_syndrome_t ev_fc;	/* FEXCH syndrome */
1930Sstevel@tonic-gate } ibc_async_event_t;
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate typedef struct ibc_operations_s {
1970Sstevel@tonic-gate 	/* HCA */
1980Sstevel@tonic-gate 	ibt_status_t (*ibc_query_hca_ports)(ibc_hca_hdl_t hca, uint8_t port,
1990Sstevel@tonic-gate 	    ibt_hca_portinfo_t *info_p);
2000Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_ports)(ibc_hca_hdl_t hca, uint8_t port,
2010Sstevel@tonic-gate 	    ibt_port_modify_flags_t flags, uint8_t init_type);
2020Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_system_image)(ibc_hca_hdl_t hca,
2030Sstevel@tonic-gate 	    ib_guid_t sys_guid);
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate 	/* Protection Domain */
2060Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_pd)(ibc_hca_hdl_t hca, ibt_pd_flags_t flags,
2070Sstevel@tonic-gate 	    ibc_pd_hdl_t *pd_p);
2080Sstevel@tonic-gate 	ibt_status_t (*ibc_free_pd)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd);
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate 	/* Reliable Datagram Domain */
2110Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_rdd)(ibc_hca_hdl_t hca, ibc_rdd_flags_t flags,
2120Sstevel@tonic-gate 	    ibc_rdd_hdl_t *rdd_p);
2130Sstevel@tonic-gate 	ibt_status_t (*ibc_free_rdd)(ibc_hca_hdl_t hca, ibc_rdd_hdl_t rdd);
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate 	/* Address Handle */
2160Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_ah)(ibc_hca_hdl_t hca, ibt_ah_flags_t flags,
2170Sstevel@tonic-gate 	    ibc_pd_hdl_t pd, ibt_adds_vect_t *attr_p, ibc_ah_hdl_t *ah_p);
2180Sstevel@tonic-gate 	ibt_status_t (*ibc_free_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah);
2190Sstevel@tonic-gate 	ibt_status_t (*ibc_query_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah,
2200Sstevel@tonic-gate 	    ibc_pd_hdl_t *pd_p, ibt_adds_vect_t *attr_p);
2210Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_ah)(ibc_hca_hdl_t hca, ibc_ah_hdl_t ah,
2220Sstevel@tonic-gate 	    ibt_adds_vect_t *attr_p);
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate 	/* Queue Pair */
2250Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_qp)(ibc_hca_hdl_t hca, ibtl_qp_hdl_t ibtl_qp,
2260Sstevel@tonic-gate 	    ibt_qp_type_t type, ibt_qp_alloc_attr_t *attr_p,
2270Sstevel@tonic-gate 	    ibt_chan_sizes_t *queue_sizes_p, ib_qpn_t *qpn, ibc_qp_hdl_t *qp_p);
2280Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_special_qp)(ibc_hca_hdl_t hca, uint8_t port,
2290Sstevel@tonic-gate 	    ibtl_qp_hdl_t ibt_qp, ibt_sqp_type_t type,
2300Sstevel@tonic-gate 	    ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p,
2310Sstevel@tonic-gate 	    ibc_qp_hdl_t *qp_p);
2328580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_alloc_qp_range)(ibc_hca_hdl_t hca, uint_t log2,
2338580SBill.Taylor@Sun.COM 	    ibtl_qp_hdl_t *ibtl_qp_p, ibt_qp_type_t type,
2348580SBill.Taylor@Sun.COM 	    ibt_qp_alloc_attr_t *attr_p, ibt_chan_sizes_t *queue_sizes_p,
2358580SBill.Taylor@Sun.COM 	    ibc_cq_hdl_t *send_cq_p, ibc_cq_hdl_t *recv_cq_p,
2368580SBill.Taylor@Sun.COM 	    ib_qpn_t *qpn_p, ibc_qp_hdl_t *qp_p);
2370Sstevel@tonic-gate 	ibt_status_t (*ibc_free_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
2380Sstevel@tonic-gate 	    ibc_free_qp_flags_t free_qp_flags, ibc_qpn_hdl_t *qpnh_p);
2390Sstevel@tonic-gate 	ibt_status_t (*ibc_release_qpn)(ibc_hca_hdl_t hca, ibc_qpn_hdl_t qpnh);
2400Sstevel@tonic-gate 	ibt_status_t (*ibc_query_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
2410Sstevel@tonic-gate 	    ibt_qp_query_attr_t *attr_p);
2420Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_qp)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
2430Sstevel@tonic-gate 	    ibt_cep_modify_flags_t flags, ibt_qp_info_t *info_p,
2440Sstevel@tonic-gate 	    ibt_queue_sizes_t *actual_sz);
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate 	/* Completion Queues */
2470Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_cq)(ibc_hca_hdl_t hca, ibt_cq_hdl_t ibt_cq,
2480Sstevel@tonic-gate 	    ibt_cq_attr_t *attr_p, ibc_cq_hdl_t *cq_p, uint_t *actual_size);
2490Sstevel@tonic-gate 	ibt_status_t (*ibc_free_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq);
2500Sstevel@tonic-gate 	ibt_status_t (*ibc_query_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
2518580SBill.Taylor@Sun.COM 	    uint_t *entries, uint_t *count_p, uint_t *usec_p,
2528580SBill.Taylor@Sun.COM 	    ibt_cq_handler_id_t *hid_p);
2530Sstevel@tonic-gate 	ibt_status_t (*ibc_resize_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
2540Sstevel@tonic-gate 	    uint_t size, uint_t *actual_size);
2558580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_modify_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
2568580SBill.Taylor@Sun.COM 	    uint_t count, uint_t usec, ibt_cq_handler_id_t hid);
2570Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_cq_sched)(ibc_hca_hdl_t hca,
258*12965SWilliam.Taylor@Oracle.COM 	    ibt_cq_sched_attr_t *attr, ibc_sched_hdl_t *sched_hdl_p);
2590Sstevel@tonic-gate 	ibt_status_t (*ibc_free_cq_sched)(ibc_hca_hdl_t hca,
260*12965SWilliam.Taylor@Oracle.COM 	    ibc_sched_hdl_t sched_hdl);
261*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_query_cq_handler_id)(ibc_hca_hdl_t hca,
262*12965SWilliam.Taylor@Oracle.COM 	    ibt_cq_handler_id_t hid, ibt_cq_handler_attr_t *attrs);
2630Sstevel@tonic-gate 
2640Sstevel@tonic-gate 	/* EE Context */
2650Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_eec)(ibc_hca_hdl_t hca, ibc_eec_flags_t flags,
2660Sstevel@tonic-gate 	    ibtl_eec_hdl_t ibtl_eec, ibc_rdd_hdl_t rdd, ibc_eec_hdl_t *eec_p);
2670Sstevel@tonic-gate 	ibt_status_t (*ibc_free_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec);
2680Sstevel@tonic-gate 	ibt_status_t (*ibc_query_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
2690Sstevel@tonic-gate 	    ibt_eec_query_attr_t *attr_p);
2700Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_eec)(ibc_hca_hdl_t hca, ibc_eec_hdl_t eec,
2710Sstevel@tonic-gate 	    ibt_cep_modify_flags_t flags, ibt_eec_info_t *info_p);
2720Sstevel@tonic-gate 
2730Sstevel@tonic-gate 	/* Memory Registration */
2740Sstevel@tonic-gate 	ibt_status_t (*ibc_register_mr)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
2750Sstevel@tonic-gate 	    ibt_mr_attr_t *attr_p, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
2760Sstevel@tonic-gate 	    ibt_mr_desc_t *mem_desc);
2770Sstevel@tonic-gate 	ibt_status_t (*ibc_register_buf)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
2780Sstevel@tonic-gate 	    ibt_smr_attr_t *attrp, struct buf *buf, void *ibtl_reserved,
2790Sstevel@tonic-gate 	    ibc_mr_hdl_t *mr_hdl_p, ibt_mr_desc_t *mem_desc);
2800Sstevel@tonic-gate 	ibt_status_t (*ibc_register_shared_mr)(ibc_hca_hdl_t hca,
2810Sstevel@tonic-gate 	    ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_smr_attr_t *attr_p,
2820Sstevel@tonic-gate 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
2830Sstevel@tonic-gate 	ibt_status_t (*ibc_deregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr);
2840Sstevel@tonic-gate 	ibt_status_t (*ibc_query_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
2850Sstevel@tonic-gate 	    ibt_mr_query_attr_t *info_p);
2860Sstevel@tonic-gate 	ibt_status_t (*ibc_reregister_mr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
2870Sstevel@tonic-gate 	    ibc_pd_hdl_t pd, ibt_mr_attr_t *attr_p, void *ibtl_reserved,
2880Sstevel@tonic-gate 	    ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
2890Sstevel@tonic-gate 	ibt_status_t (*ibc_reregister_buf)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr,
2900Sstevel@tonic-gate 	    ibc_pd_hdl_t pd, ibt_smr_attr_t *attrp, struct buf *buf,
2910Sstevel@tonic-gate 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p, ibt_mr_desc_t *mem_desc);
2920Sstevel@tonic-gate 	ibt_status_t (*ibc_sync_mr)(ibc_hca_hdl_t hca,
2930Sstevel@tonic-gate 	    ibt_mr_sync_t *mr_segments, size_t	num_segments);
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 	/* Memory Window */
2960Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_mw)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
2970Sstevel@tonic-gate 	    ibt_mw_flags_t flags, ibc_mw_hdl_t *mw_p, ibt_rkey_t *rkey_p);
2980Sstevel@tonic-gate 	ibt_status_t (*ibc_free_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw);
2990Sstevel@tonic-gate 	ibt_status_t (*ibc_query_mw)(ibc_hca_hdl_t hca, ibc_mw_hdl_t mw,
3000Sstevel@tonic-gate 	    ibt_mw_query_attr_t *mw_attr_p);
3010Sstevel@tonic-gate 
3020Sstevel@tonic-gate 	/* Multicast Group */
3030Sstevel@tonic-gate 	ibt_status_t (*ibc_attach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
3040Sstevel@tonic-gate 	    ib_gid_t gid, ib_lid_t lid);
3050Sstevel@tonic-gate 	ibt_status_t (*ibc_detach_mcg)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
3060Sstevel@tonic-gate 	    ib_gid_t gid, ib_lid_t lid);
3070Sstevel@tonic-gate 
3080Sstevel@tonic-gate 	/* WR processing */
3090Sstevel@tonic-gate 	ibt_status_t (*ibc_post_send)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
3100Sstevel@tonic-gate 	    ibt_send_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
3110Sstevel@tonic-gate 	ibt_status_t (*ibc_post_recv)(ibc_hca_hdl_t hca, ibc_qp_hdl_t qp,
3120Sstevel@tonic-gate 	    ibt_recv_wr_t *wr_p, uint_t num_wr, uint_t *num_posted);
3130Sstevel@tonic-gate 	ibt_status_t (*ibc_poll_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
3140Sstevel@tonic-gate 	    ibt_wc_t *wc_p, uint_t num_wc, uint_t *num_polled);
3150Sstevel@tonic-gate 	ibt_status_t (*ibc_notify_cq)(ibc_hca_hdl_t hca, ibc_cq_hdl_t cq,
3160Sstevel@tonic-gate 	    ibt_cq_notify_flags_t flags);
3170Sstevel@tonic-gate 
3180Sstevel@tonic-gate 	/* CI Object Private Data */
3190Sstevel@tonic-gate 	ibt_status_t (*ibc_ci_data_in)(ibc_hca_hdl_t hca,
3200Sstevel@tonic-gate 	    ibt_ci_data_flags_t flags, ibt_object_type_t object,
3210Sstevel@tonic-gate 	    void *ibc_object_handle, void *data_p, size_t data_sz);
3220Sstevel@tonic-gate 	ibt_status_t (*ibc_ci_data_out)(ibc_hca_hdl_t hca,
3230Sstevel@tonic-gate 	    ibt_ci_data_flags_t flags, ibt_object_type_t object,
3240Sstevel@tonic-gate 	    void *ibc_object_handle, void *data_p, size_t data_sz);
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate 	/* Shared Receive Queues */
3270Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_srq)(ibc_hca_hdl_t hca, ibt_srq_flags_t flags,
3280Sstevel@tonic-gate 	    ibt_srq_hdl_t ibt_srq, ibc_pd_hdl_t pd, ibt_srq_sizes_t *sizes,
3290Sstevel@tonic-gate 	    ibc_srq_hdl_t *ibc_srq_p, ibt_srq_sizes_t *real_size_p);
3300Sstevel@tonic-gate 	ibt_status_t (*ibc_free_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq);
3310Sstevel@tonic-gate 	ibt_status_t (*ibc_query_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
3320Sstevel@tonic-gate 	    ibc_pd_hdl_t *pd_p, ibt_srq_sizes_t *sizes_p, uint_t *limit);
3330Sstevel@tonic-gate 	ibt_status_t (*ibc_modify_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
3340Sstevel@tonic-gate 	    ibt_srq_modify_flags_t flags, uint_t size, uint_t limit,
3350Sstevel@tonic-gate 	    uint_t *real_size_p);
3360Sstevel@tonic-gate 	ibt_status_t (*ibc_post_srq)(ibc_hca_hdl_t hca, ibc_srq_hdl_t srq,
3370Sstevel@tonic-gate 	    ibt_recv_wr_t *wr, uint_t num_wr, uint_t *num_posted_p);
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 	/* Address translation */
3400Sstevel@tonic-gate 	ibt_status_t (*ibc_map_mem_area)(ibc_hca_hdl_t hca_hdl,
3410Sstevel@tonic-gate 	    ibt_va_attr_t *va_attrs, void *ibtl_reserved,
34211972SBill.Taylor@Sun.COM 	    uint_t paddr_list_len, ibt_reg_req_t *reg_req,
34311972SBill.Taylor@Sun.COM 	    ibc_ma_hdl_t *ma_hdl_p);
3440Sstevel@tonic-gate 	ibt_status_t (*ibc_unmap_mem_area)(ibc_hca_hdl_t hca_hdl,
3450Sstevel@tonic-gate 	    ibc_ma_hdl_t ma_hdl);
3468580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_map_mem_iov)(ibc_hca_hdl_t hca_hdl,
3478580SBill.Taylor@Sun.COM 	    ibt_iov_attr_t *iov_attr, ibt_all_wr_t *wr,
3488580SBill.Taylor@Sun.COM 	    ibc_mi_hdl_t *mi_hdl);
3498580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_unmap_mem_iov)(ibc_hca_hdl_t hca_hdl,
3508580SBill.Taylor@Sun.COM 	    ibc_mi_hdl_t mi_hdl);
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate 	/* Allocate L_Key */
3530Sstevel@tonic-gate 	ibt_status_t (*ibc_alloc_lkey)(ibc_hca_hdl_t hca_hdl, ibc_pd_hdl_t pd,
3540Sstevel@tonic-gate 	    ibt_lkey_flags_t flags, uint_t phys_buf_list_sz,
3550Sstevel@tonic-gate 	    ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p);
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 	/* Physical Register Memory Region */
3580Sstevel@tonic-gate 	ibt_status_t (*ibc_register_physical_mr)(ibc_hca_hdl_t hca,
3590Sstevel@tonic-gate 	    ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr, void *ibtl_reserved,
3600Sstevel@tonic-gate 	    ibc_mr_hdl_t *mr_p, ibt_pmr_desc_t *mem_desc_p);
3610Sstevel@tonic-gate 	ibt_status_t (*ibc_reregister_physical_mr)(ibc_hca_hdl_t hca,
3620Sstevel@tonic-gate 	    ibc_mr_hdl_t mr, ibc_pd_hdl_t pd, ibt_pmr_attr_t *mem_pattr,
3630Sstevel@tonic-gate 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
3640Sstevel@tonic-gate 	    ibt_pmr_desc_t *mem_desc_p);
365929Ssrust 
366929Ssrust 	/* Fast Memory Registration (FMR) */
367929Ssrust 	ibt_status_t (*ibc_create_fmr_pool)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
368929Ssrust 	    ibt_fmr_pool_attr_t *fmr_params, ibc_fmr_pool_hdl_t *fmr_pool_p);
369929Ssrust 	ibt_status_t (*ibc_destroy_fmr_pool)(ibc_hca_hdl_t hca,
370929Ssrust 	    ibc_fmr_pool_hdl_t fmr_pool);
371929Ssrust 	ibt_status_t (*ibc_flush_fmr_pool)(ibc_hca_hdl_t hca,
372929Ssrust 	    ibc_fmr_pool_hdl_t fmr_pool);
373929Ssrust 	ibt_status_t (*ibc_register_physical_fmr)(ibc_hca_hdl_t hca,
374929Ssrust 	    ibc_fmr_pool_hdl_t fmr_pool, ibt_pmr_attr_t *mem_pattr,
375929Ssrust 	    void *ibtl_reserved, ibc_mr_hdl_t *mr_hdl_p,
376929Ssrust 	    ibt_pmr_desc_t *mem_desc_p);
377929Ssrust 	ibt_status_t (*ibc_deregister_fmr)(ibc_hca_hdl_t hca, ibc_mr_hdl_t mr);
3788580SBill.Taylor@Sun.COM 
3798580SBill.Taylor@Sun.COM 	/* IO memory management */
3808580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_alloc_io_mem)(ibc_hca_hdl_t hca_hdl, size_t size,
3818580SBill.Taylor@Sun.COM 	    ibt_mr_flags_t mr_flag, caddr_t *kaddrp,
3828580SBill.Taylor@Sun.COM 	    ibc_mem_alloc_hdl_t *mem_alloc_hdl);
3838580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_free_io_mem)(ibc_hca_hdl_t hca_hdl,
3848580SBill.Taylor@Sun.COM 	    ibc_mem_alloc_hdl_t mem_alloc_hdl);
3858580SBill.Taylor@Sun.COM 
3868580SBill.Taylor@Sun.COM 	/* Extended RC (XRC) */
3878580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_alloc_xrc_domain)();
3888580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_free_xrc_domain)();
3898580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_alloc_xrc_srq)();
3908580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_free_xrc_srq)();
3918580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_query_xrc_srq)();
3928580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_modify_xrc_srq)();
3938580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_alloc_xrc_tgt_qp)();
3948580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_free_xrc_tgt_qp)();
3958580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_query_xrc_tgt_qp)();
3968580SBill.Taylor@Sun.COM 	ibt_status_t (*ibc_modify_xrc_tgt_qp)();
397*12965SWilliam.Taylor@Oracle.COM 
398*12965SWilliam.Taylor@Oracle.COM 	/* DMA memory region */
399*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_register_dma_mr)(ibc_hca_hdl_t hca, ibc_pd_hdl_t pd,
400*12965SWilliam.Taylor@Oracle.COM 	    ibt_dmr_attr_t *attr_p, void *ibtl_reserved, ibc_mr_hdl_t *mr_p,
401*12965SWilliam.Taylor@Oracle.COM 	    ibt_mr_desc_t *mem_desc);
402*12965SWilliam.Taylor@Oracle.COM 
403*12965SWilliam.Taylor@Oracle.COM 	/* OPS extensions for next round of enhancements */
404*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_enhancement1)();
405*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_enhancement2)();
406*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_enhancement3)();
407*12965SWilliam.Taylor@Oracle.COM 	ibt_status_t (*ibc_enhancement4)();
4080Sstevel@tonic-gate } ibc_operations_t;
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate /*
4120Sstevel@tonic-gate  * The ibc_hca_info_s structure is used for HCA drivers to communicate its
4130Sstevel@tonic-gate  * HCA specific information to IBTF when it attaches a device via ibc_attach().
4140Sstevel@tonic-gate  *
4150Sstevel@tonic-gate  * IBTF assumes that the structures pointed to by the hca_ops and hca_attr
4160Sstevel@tonic-gate  * structure members are persistent.
4170Sstevel@tonic-gate  */
4180Sstevel@tonic-gate typedef struct ibc_hca_info_s {
4190Sstevel@tonic-gate 	ibc_version_t		hca_ci_vers;	/* CI Version */
4200Sstevel@tonic-gate 	ibc_hca_hdl_t		hca_handle;	/* used for call through */
4210Sstevel@tonic-gate 						/* "hca_ops" */
4220Sstevel@tonic-gate 	ibc_operations_t	*hca_ops;
4230Sstevel@tonic-gate 	ibt_hca_attr_t		*hca_attr;
4240Sstevel@tonic-gate } ibc_hca_info_t;
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate 
4270Sstevel@tonic-gate /* Channel Interface return status */
4280Sstevel@tonic-gate typedef enum ibc_status_e {
4290Sstevel@tonic-gate 	IBC_SUCCESS = 0,
4300Sstevel@tonic-gate 	IBC_FAILURE = 1
4310Sstevel@tonic-gate } ibc_status_t;
4320Sstevel@tonic-gate 
4330Sstevel@tonic-gate /*
4340Sstevel@tonic-gate  * CI up-calls to IBTF.
4350Sstevel@tonic-gate  */
4360Sstevel@tonic-gate 
4370Sstevel@tonic-gate /*
4380Sstevel@tonic-gate  * ibc_init
4390Sstevel@tonic-gate  *	Registers CI clients with the Solaris I/O framework
4400Sstevel@tonic-gate  *
4410Sstevel@tonic-gate  * ibc_fini
4420Sstevel@tonic-gate  *	Un-Registers CI clients with the Solaris I/O framework
4430Sstevel@tonic-gate  */
4440Sstevel@tonic-gate int ibc_init(struct modlinkage *modlp);
4450Sstevel@tonic-gate void ibc_fini(struct modlinkage *modlp);
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate /*
4480Sstevel@tonic-gate  * ibc_attach
449401Shiremath  *	Register HCA device with IBTF. During this call HCA driver provides
450401Shiremath  *	driver's information neededby IBTF.
4510Sstevel@tonic-gate  *
4520Sstevel@tonic-gate  * ibc_post_attach
4530Sstevel@tonic-gate  *	After a successful ibc_attach, this must be called.
4540Sstevel@tonic-gate  *
4550Sstevel@tonic-gate  * ibc_pre_detach
4560Sstevel@tonic-gate  *	Attempt to De-Register HCA Device from IBTF.
4570Sstevel@tonic-gate  *	This requires the cooperation of IBTF clients to
4580Sstevel@tonic-gate  *	stop using this HCA.  Upon success, the HCA driver
4590Sstevel@tonic-gate  *	is committed to calling ibc_detach.
4600Sstevel@tonic-gate  *
4610Sstevel@tonic-gate  * ibc_detach
4620Sstevel@tonic-gate  *	De-Register HCA Device from IBTF.
4630Sstevel@tonic-gate  *	This function will succeed if ibc_pre_detach has previously
4640Sstevel@tonic-gate  *	succeeded for this device.
4650Sstevel@tonic-gate  */
4660Sstevel@tonic-gate ibc_status_t ibc_attach(ibc_clnt_hdl_t *ibc_hdl_p, ibc_hca_info_t *info_p);
4670Sstevel@tonic-gate void ibc_post_attach(ibc_clnt_hdl_t ibc_hdl);
4680Sstevel@tonic-gate ibc_status_t ibc_pre_detach(ibc_clnt_hdl_t ibc_hdl, ddi_detach_cmd_t cmd);
4690Sstevel@tonic-gate void ibc_detach(ibc_clnt_hdl_t ibc_hdl);
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate /*
4720Sstevel@tonic-gate  * ibc_cq_handler
4730Sstevel@tonic-gate  *	IBTF Completion Queue Notification Handler.
4740Sstevel@tonic-gate  */
4750Sstevel@tonic-gate void ibc_cq_handler(ibc_clnt_hdl_t ibc_hdl, ibt_cq_hdl_t ibt_cq);
4760Sstevel@tonic-gate 
4770Sstevel@tonic-gate /*
4780Sstevel@tonic-gate  * ibc_async_handler
4790Sstevel@tonic-gate  *	IBTF Asynchronous event/error handler.
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate void ibc_async_handler(ibc_clnt_hdl_t ibc_hdl, ibt_async_code_t code,
4820Sstevel@tonic-gate     ibc_async_event_t *event_p);
483401Shiremath 
4840Sstevel@tonic-gate /*
4850Sstevel@tonic-gate  * ibc_memory_handler
4860Sstevel@tonic-gate  *	IBTF memory event/error handler.
4870Sstevel@tonic-gate  */
4880Sstevel@tonic-gate void ibc_memory_handler(ibc_clnt_hdl_t ibc_hdl, ibt_mem_code_t code,
4890Sstevel@tonic-gate     ibt_mem_data_t *data_p, void *ibtl_reserved);
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate /*
4920Sstevel@tonic-gate  * ibc_get_ci_failure()
4930Sstevel@tonic-gate  *
4940Sstevel@tonic-gate  *	Used to obtain a special IBTF failure code for CI specific failures,
4950Sstevel@tonic-gate  *	failures other than those defined in ibt_status_t.
4960Sstevel@tonic-gate  */
4970Sstevel@tonic-gate ibt_status_t ibc_get_ci_failure(uint64_t ena);
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate #ifdef __cplusplus
5000Sstevel@tonic-gate }
5010Sstevel@tonic-gate #endif
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate #endif	/* _SYS_IB_IBTL_IBCI_H */
504