xref: /onnv-gate/usr/src/uts/common/sys/ib/ibtl/impl/ibtl.h (revision 12574:0d8f6d488501)
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
59879SRamaswamy.Tummala@Sun.COM  * Common Development and Distribution License (the "License").
69879SRamaswamy.Tummala@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*12574SWilliam.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_IMPL_IBTL_H
260Sstevel@tonic-gate #define	_SYS_IB_IBTL_IMPL_IBTL_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate /*
290Sstevel@tonic-gate  * ibtl.h
300Sstevel@tonic-gate  *
310Sstevel@tonic-gate  * All data structures and function prototypes that are specific to the
320Sstevel@tonic-gate  * IBTL implementation.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate #include <sys/note.h>
350Sstevel@tonic-gate #include <sys/ib/ibtl/ibvti.h>
360Sstevel@tonic-gate #include <sys/ib/ibtl/ibti.h>
370Sstevel@tonic-gate #include <sys/ib/ibtl/ibci.h>
380Sstevel@tonic-gate #include <sys/ib/ibtl/impl/ibtl_util.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #ifdef __cplusplus
410Sstevel@tonic-gate extern "C" {
420Sstevel@tonic-gate #endif
430Sstevel@tonic-gate 
440Sstevel@tonic-gate /*
450Sstevel@tonic-gate  * Define a per IBT Client state structure. Its address is returned
460Sstevel@tonic-gate  * to the IBT client as an opaque IBT Client Handle - ibt_clnt_hdl_t.
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  * ibt_attach() allocates one of these structures.
490Sstevel@tonic-gate  *
500Sstevel@tonic-gate  * For each IBT Client registered with the IBTL, we maintain a list
510Sstevel@tonic-gate  * of HCAs, clnt_hca_list, that this IBT Client is using.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * This list is updated by ibt_open_hca().
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate typedef struct ibtl_clnt_s {
560Sstevel@tonic-gate 	char			clnt_name[8];	/* (just a debugging aid) */
570Sstevel@tonic-gate 	ibt_clnt_modinfo_t	*clnt_modinfop;	/* Pointer to IBT client's */
580Sstevel@tonic-gate 						/* module information */
590Sstevel@tonic-gate 	void			*clnt_private;	/* IBT Client's private ptr */
600Sstevel@tonic-gate 	dev_info_t		*clnt_dip;	/* IBT Client's dip */
610Sstevel@tonic-gate 	struct	ibtl_clnt_s	*clnt_list_link;
620Sstevel@tonic-gate 	uint32_t		clnt_async_cnt;
630Sstevel@tonic-gate 	uint32_t		clnt_srv_cnt;	/* Service resource counter */
640Sstevel@tonic-gate 	struct	ibtl_hca_s	*clnt_hca_list;	/* HCAs this client is using. */
650Sstevel@tonic-gate 						/* link is ha_hca_link */
660Sstevel@tonic-gate 	ibt_sm_notice_handler_t	clnt_sm_trap_handler; /* may be NULL */
670Sstevel@tonic-gate 	void			*clnt_sm_trap_handler_arg;
680Sstevel@tonic-gate } ibtl_clnt_t;
690Sstevel@tonic-gate 
700Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_clnt_s::{clnt_name clnt_modinfop
710Sstevel@tonic-gate     clnt_private clnt_dip}))
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /* HCA Device State. */
740Sstevel@tonic-gate typedef enum ibtl_hca_state_e {
750Sstevel@tonic-gate 	IBTL_HCA_DEV_ATTACHED	= 1,	/* new HCA attached */
760Sstevel@tonic-gate 	IBTL_HCA_DEV_DETACHED	= 2,	/* detached */
770Sstevel@tonic-gate 	IBTL_HCA_DEV_DETACHING	= 3	/* not detached yet */
780Sstevel@tonic-gate } ibtl_hca_state_t;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /*
810Sstevel@tonic-gate  * Define a type to record hca async PORT_UP and PORT_DOWN events for
820Sstevel@tonic-gate  * processing by async thread(s). At the time an async is made by an
830Sstevel@tonic-gate  * HCA driver (presumably at interrupt level), a call is made to IBTL.
840Sstevel@tonic-gate  * IBTL marks this field, and wakes up an async thread for delivery
850Sstevel@tonic-gate  * to IBT clients as appropriate.
860Sstevel@tonic-gate  */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate typedef enum ibtl_async_port_status_e {
899891SRajkumar.Sivaprakasam@Sun.COM 	IBTL_HCA_PORT_UNKNOWN		= 0x000,	/* initial state */
909891SRajkumar.Sivaprakasam@Sun.COM 	IBTL_HCA_PORT_UP		= 0x001,
919891SRajkumar.Sivaprakasam@Sun.COM 	IBTL_HCA_PORT_DOWN		= 0x002,
929891SRajkumar.Sivaprakasam@Sun.COM 	IBTL_HCA_PORT_CHG		= 0x004,
939891SRajkumar.Sivaprakasam@Sun.COM 	IBTL_HCA_PORT_ASYNC_CLNT_REREG	= 0x008,
940Sstevel@tonic-gate } ibtl_async_port_status_t;
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
979891SRajkumar.Sivaprakasam@Sun.COM  * Define a type to record the PORT async events and port change flags.
989891SRajkumar.Sivaprakasam@Sun.COM  */
999891SRajkumar.Sivaprakasam@Sun.COM typedef struct ibtl_async_port_event_s {
1009891SRajkumar.Sivaprakasam@Sun.COM 	ibtl_async_port_status_t	status;
1019891SRajkumar.Sivaprakasam@Sun.COM 	ibt_port_change_t		flags;
1029891SRajkumar.Sivaprakasam@Sun.COM } ibtl_async_port_event_t;
1039891SRajkumar.Sivaprakasam@Sun.COM 
1049891SRajkumar.Sivaprakasam@Sun.COM /*
1050Sstevel@tonic-gate  * Bit definition(s) for {qp,cq,eec,hd,ha,srq}_async_flags.
1060Sstevel@tonic-gate  *
1070Sstevel@tonic-gate  *	IBTL_ASYNC_PENDING	This structure is known by the async_threads.
1080Sstevel@tonic-gate  *				It will be checked for additional async work
1090Sstevel@tonic-gate  *				before this bit is cleared, so new async
1100Sstevel@tonic-gate  *				events/errors do not require this structure
1110Sstevel@tonic-gate  *				to be linked onto its async list.
1120Sstevel@tonic-gate  *
1130Sstevel@tonic-gate  *	IBTL_ASYNC_FREE_OBJECT  Client has called ibt_free_*, and the
1140Sstevel@tonic-gate  *				the structure should be kmem_freed when
1150Sstevel@tonic-gate  *				the outstanding asyncs complete.
1160Sstevel@tonic-gate  */
1170Sstevel@tonic-gate typedef enum ibtl_async_flags_e {
1180Sstevel@tonic-gate 	IBTL_ASYNC_PENDING	= 0x1,
1190Sstevel@tonic-gate 	IBTL_ASYNC_FREE_OBJECT	= 0x2
1200Sstevel@tonic-gate } ibtl_async_flags_t;
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate /*
1239879SRamaswamy.Tummala@Sun.COM  * Keeps track of all data associated with HCA port kstats.
1249879SRamaswamy.Tummala@Sun.COM  */
1259879SRamaswamy.Tummala@Sun.COM typedef struct ibtl_hca_port_kstat_s {
1269879SRamaswamy.Tummala@Sun.COM 	struct ibtl_hca_devinfo_s *pks_hca_devp;
1279879SRamaswamy.Tummala@Sun.COM 	uint_t			pks_port_num;
1289879SRamaswamy.Tummala@Sun.COM 	struct kstat		*pks_stats_ksp;
1299879SRamaswamy.Tummala@Sun.COM 	struct kstat		*pks_pkeys_ksp;
1309879SRamaswamy.Tummala@Sun.COM } ibtl_hca_port_kstat_t;
1319879SRamaswamy.Tummala@Sun.COM 
1329879SRamaswamy.Tummala@Sun.COM /*
1330Sstevel@tonic-gate  * Define a per CI HCA Device structure. Its address is returned
1340Sstevel@tonic-gate  * to the CI as an opaque IBTL HCA Handle - ibc_hdl_t.
1350Sstevel@tonic-gate  *
1360Sstevel@tonic-gate  * ibc_ci_attach() allocates one of these and adds it to ibtl_hca_list.
1370Sstevel@tonic-gate  *
1380Sstevel@tonic-gate  * The hd_hca_dev_link is the link for the ibtl_hca_list. It is the
1390Sstevel@tonic-gate  * list of HCA devices registered with the IBTL.
1400Sstevel@tonic-gate  *
1410Sstevel@tonic-gate  * The hd_clnt_list is a list of IBT Clients using this HCA.
1420Sstevel@tonic-gate  * The hd_clnt_list->l_head points to the ha_clnt_link field of a client's
1430Sstevel@tonic-gate  * ibtl_hca_s structure.
1440Sstevel@tonic-gate  *
1450Sstevel@tonic-gate  * This list is updated by ibt_open_hca().
1460Sstevel@tonic-gate  */
1470Sstevel@tonic-gate typedef struct ibtl_hca_devinfo_s {
1480Sstevel@tonic-gate 	struct ibtl_hca_devinfo_s *hd_hca_dev_link; /* Next HCA Device */
1490Sstevel@tonic-gate 	ibtl_hca_state_t	hd_state;	/* HCA device state: */
1500Sstevel@tonic-gate 						/* attached/detached */
1510Sstevel@tonic-gate 	uint_t			hd_portinfo_len; /* #bytes of portinfo */
1520Sstevel@tonic-gate 	ibt_hca_portinfo_t	*hd_portinfop;	/* ptr to portinfo cache */
1530Sstevel@tonic-gate 	struct ibtl_hca_s	*hd_clnt_list;	/* IBT Client using this HCA. */
1540Sstevel@tonic-gate 	ibc_hca_hdl_t		hd_ibc_hca_hdl;	/* CI HCA handle */
1550Sstevel@tonic-gate 	ibc_operations_t	*hd_ibc_ops;	/* operations vector */
1560Sstevel@tonic-gate 	ibt_hca_attr_t		*hd_hca_attr;	/* hca attributes */
1570Sstevel@tonic-gate 	dev_info_t		*hd_hca_dip;	/* HCA devinfo pointer */
1580Sstevel@tonic-gate 	struct ibtl_hca_devinfo_s *hd_async_link; /* async list link */
1590Sstevel@tonic-gate 	kcondvar_t		hd_portinfo_cv;	/* waiting for ibc_query */
1600Sstevel@tonic-gate 	int			hd_portinfo_waiters; /* any waiters */
1610Sstevel@tonic-gate 	uint8_t			hd_portinfo_locked_port;
1620Sstevel@tonic-gate 						/* port whose info is queried */
1630Sstevel@tonic-gate 	kcondvar_t		hd_async_busy_cv; /* wakeup when #clients = 0 */
1640Sstevel@tonic-gate 	int			hd_async_busy;	/* only 1 async at a time */
1650Sstevel@tonic-gate 	ibt_async_code_t	hd_async_codes;	/* all codes for this HCA */
1660Sstevel@tonic-gate 	ibt_async_code_t	hd_async_code;	/* current code being run */
1670Sstevel@tonic-gate 	ibt_async_event_t	hd_async_event;	/* current event being run */
1680Sstevel@tonic-gate 	ibtl_async_flags_t	hd_async_flags;	/* see *_async_flags above */
1690Sstevel@tonic-gate 	uint64_t		hd_fma_ena;	/* FMA data for LOCAL CATASTR */
1700Sstevel@tonic-gate 	uint32_t		hd_async_task_cnt; /* #clients doing asyncs */
1710Sstevel@tonic-gate 	kcondvar_t		hd_async_task_cv; /* wakeup when #clients = 0 */
1720Sstevel@tonic-gate 	uint_t			hd_multism;	/* 1 - MultiSM, 0 - Single SM */
1739879SRamaswamy.Tummala@Sun.COM 	ibtl_hca_port_kstat_t	*hd_hca_port_ks_info;	/* port kstat ptr */
1749879SRamaswamy.Tummala@Sun.COM 	uint_t			hd_hca_port_ks_info_len; /* port kstat size */
1750Sstevel@tonic-gate 		/* The following must be at the end of this struct */
1769891SRajkumar.Sivaprakasam@Sun.COM 	ibtl_async_port_event_t hd_async_port[1]; /* per-port async data */
1770Sstevel@tonic-gate } ibtl_hca_devinfo_t;
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_hca_devinfo_s::hd_ibc_ops))
1800Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_hca_devinfo_s::hd_ibc_hca_hdl))
1810Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_hca_devinfo_s::hd_hca_attr))
1820Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("hd_async_busy and hd_async_busy_cv",
1830Sstevel@tonic-gate     ibtl_hca_devinfo_s::{hd_async_code hd_async_event}))
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate /*
1860Sstevel@tonic-gate  * Define a HCA info structure.
1870Sstevel@tonic-gate  *
1880Sstevel@tonic-gate  * The IBTL function ibt_open_hca() allocates one of these.
1890Sstevel@tonic-gate  *
1900Sstevel@tonic-gate  * For each client instance registered with the IBTL, we maintain a list
1910Sstevel@tonic-gate  * of HCAs that it is using.  The elements of that list include the
1920Sstevel@tonic-gate  * address of the CI HCA device structure, a pointer to the client
1930Sstevel@tonic-gate  * structure, and reference counts of HCA resources that this client
1940Sstevel@tonic-gate  * device is using.
1950Sstevel@tonic-gate  *
1960Sstevel@tonic-gate  * Note: ha_qpn_cnt is protected by a global mutex to deal with a client
1970Sstevel@tonic-gate  * trying to open the HCA while it is actively being closed.
1980Sstevel@tonic-gate  *
1990Sstevel@tonic-gate  * ha_hca_link is the link to the next HCA info struct that this client is
2000Sstevel@tonic-gate  * using.
2010Sstevel@tonic-gate  *
2020Sstevel@tonic-gate  * ha_clnt_link is the link to the next IBT client (ibtl_clnt_t) that is using
2030Sstevel@tonic-gate  * the same CI HCA (ibtl_hca_devinfo_t). The link points to that client's
2040Sstevel@tonic-gate  * ibtl_hca_t because an IBT client can use more than one CI HCA.
2050Sstevel@tonic-gate  */
2060Sstevel@tonic-gate typedef struct ibtl_hca_s {
2070Sstevel@tonic-gate 	struct ibtl_hca_s	*ha_hca_link;	/* Next HCA used by client */
2080Sstevel@tonic-gate 	struct ibtl_hca_s	*ha_clnt_link;	/* Next client using same HCA */
2090Sstevel@tonic-gate 	ibtl_hca_devinfo_t	*ha_hca_devp;	/* CI HCA device structure. */
2100Sstevel@tonic-gate 	ibtl_clnt_t		*ha_clnt_devp;	/* Client state struct */
2110Sstevel@tonic-gate 	void			*ha_clnt_private;
2120Sstevel@tonic-gate 	int			ha_flags;	/* misc. flags */
213*12574SWilliam.Taylor@Oracle.COM 
214*12574SWilliam.Taylor@Oracle.COM 	/* The following counters are accessed with atomic operations. */
2150Sstevel@tonic-gate 	uint32_t		ha_qp_cnt;	/* QP resource counter */
2160Sstevel@tonic-gate 	uint32_t		ha_eec_cnt;	/* EEC resource counter */
2170Sstevel@tonic-gate 	uint32_t		ha_cq_cnt;	/* CQ resource counter */
2180Sstevel@tonic-gate 	uint32_t		ha_pd_cnt;	/* PD resource counter */
2190Sstevel@tonic-gate 	uint32_t		ha_ah_cnt;	/* AH resource counter */
2200Sstevel@tonic-gate 	uint32_t		ha_mr_cnt;	/* Mem Region resource count */
2210Sstevel@tonic-gate 	uint32_t		ha_mw_cnt;	/* Mem Window resource count */
2220Sstevel@tonic-gate 	uint32_t		ha_qpn_cnt;	/* QPN resource counter */
2230Sstevel@tonic-gate 	uint32_t		ha_srq_cnt;	/* SRQ resource counter */
2240Sstevel@tonic-gate 	ibtl_async_flags_t	ha_async_flags;	/* see *_async_flags above */
2250Sstevel@tonic-gate 	uint32_t		ha_async_cnt;	/* #asyncs in progress */
226929Ssrust 	uint32_t		ha_fmr_pool_cnt; /* FMR Pool resource count */
2270Sstevel@tonic-gate } ibtl_hca_t;
2280Sstevel@tonic-gate 
2290Sstevel@tonic-gate /* ha_flags values */
2300Sstevel@tonic-gate #define	IBTL_HA_CLOSING	1	/* In process of closing, so don't allow open */
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_hca_s::ha_clnt_devp))
2330Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_hca_s::ha_hca_devp))
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate /*
2360Sstevel@tonic-gate  * Bit definition(s) for cq_impl_flags.
2370Sstevel@tonic-gate  *
2380Sstevel@tonic-gate  *	IBTL_CQ_PENDING		This CQ is known by the ibtl_cq_threads,
2390Sstevel@tonic-gate  *				and it will be checked for additional work
2400Sstevel@tonic-gate  *				before this bit is cleared, so new work
2410Sstevel@tonic-gate  *				will be seen without this cq being added
2420Sstevel@tonic-gate  *				to the cq list.
2430Sstevel@tonic-gate  *
2440Sstevel@tonic-gate  *	IBTL_CQ_CALL_CLIENT	Mark that the HCA driver has called
2450Sstevel@tonic-gate  *				ibc_cq_handler with new work on this CQ,
2460Sstevel@tonic-gate  *				so IBTL should call the client handler
2470Sstevel@tonic-gate  *				again before it is considered done.
2480Sstevel@tonic-gate  *
2490Sstevel@tonic-gate  *	IBTL_CQ_FREE		Mark that ibt_free_cq is sleeping until
2500Sstevel@tonic-gate  *				ibtl_cq_threads is done with this CQ.
2510Sstevel@tonic-gate  */
2520Sstevel@tonic-gate typedef enum ibtl_cq_impl_flags_e {
2530Sstevel@tonic-gate 	IBTL_CQ_PENDING		= 0x1,
2540Sstevel@tonic-gate 	IBTL_CQ_CALL_CLIENT	= 0x2,
2550Sstevel@tonic-gate 	IBTL_CQ_FREE		= 0x4
2560Sstevel@tonic-gate } ibtl_cq_impl_flags_t;
2570Sstevel@tonic-gate 
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate /*
2600Sstevel@tonic-gate  * Define a per CQ state structure.
2610Sstevel@tonic-gate  *
2620Sstevel@tonic-gate  * The ibt_alloc_cq() allocates one of these. A CQ is associated with a
2630Sstevel@tonic-gate  * particular HCA, whose handle is recorded in the cq_hca field.
2640Sstevel@tonic-gate  * The cq_ibc_cq_hdl field is initialized with the CI CQ handle returned
2650Sstevel@tonic-gate  * from the ibc_alloc_cq() call to the HCA driver.
2660Sstevel@tonic-gate  *
2670Sstevel@tonic-gate  * In order to set/get the client's private data, cq_clnt_private, clients
2680Sstevel@tonic-gate  * need to use ibt_set_cq_private() and ibt_get_cq_private() calls.
2690Sstevel@tonic-gate  *
2700Sstevel@tonic-gate  * An IBT client registers a CQ completion handler callback and private
2710Sstevel@tonic-gate  * callback argument (probably the client instance soft state structure) using
2720Sstevel@tonic-gate  * the ibt_set_cq_handler() IBT routine. The comp_handler, arg fields of the
2730Sstevel@tonic-gate  * structure are initialized with the values passed in by the IBTL client.
2740Sstevel@tonic-gate  * These two fields are the only fields protected by the cq_mutex.
2750Sstevel@tonic-gate  *
2760Sstevel@tonic-gate  * When a completion event is posted to an IBT client, the
2770Sstevel@tonic-gate  * client completion handler is called with the following arguments:
2780Sstevel@tonic-gate  *
2790Sstevel@tonic-gate  *	- The Client Handle, that is passed into the IBTL on ibt_attach call.
2800Sstevel@tonic-gate  *	- The CQ Handle upon which the completion occurred.
2810Sstevel@tonic-gate  *	- The private client argument, set during handler registration via
2820Sstevel@tonic-gate  *	  ibt_set_cq_handler() call.
2830Sstevel@tonic-gate  *
2840Sstevel@tonic-gate  * The address of the ibtl_cq_s structure is passed in as the ibt_cq_hdl_t
2850Sstevel@tonic-gate  * (callback arg) in the CI ibc_alloc_cq() function. Thus when a CI calls
2860Sstevel@tonic-gate  * the IBTL completion handler (ibc_ci_cq_handler()) we can de-mux
2870Sstevel@tonic-gate  * directly to the targeted IBT client.
2880Sstevel@tonic-gate  *
2890Sstevel@tonic-gate  */
2900Sstevel@tonic-gate typedef struct ibtl_cq_s {
2910Sstevel@tonic-gate 	ibc_cq_hdl_t		cq_ibc_cq_hdl;	/* CI CQ handle */
2920Sstevel@tonic-gate 	ibtl_hca_t		*cq_hca;	/* IBTL HCA hdl */
2930Sstevel@tonic-gate 	ibt_cq_handler_t	cq_comp_handler; /* Completion handler */
2940Sstevel@tonic-gate 	void			*cq_arg;	/* CQ handler's argument */
2950Sstevel@tonic-gate 	kmutex_t		cq_mutex;	/* Mutex. */
2960Sstevel@tonic-gate 	void			*cq_clnt_private; /* Client's Private. */
2970Sstevel@tonic-gate 	struct ibtl_cq_s	*cq_link;	/* link for queuing cq to */
2980Sstevel@tonic-gate 						/* to be handled in a thread */
2990Sstevel@tonic-gate 	struct ibtl_cq_s	*cq_async_link;	/* list link for asyncs */
3000Sstevel@tonic-gate 	ibtl_cq_impl_flags_t	cq_impl_flags;	/* dynamic bits if cq */
3010Sstevel@tonic-gate 						/* handler runs in a thread */
3020Sstevel@tonic-gate 	int			cq_in_thread;	/* mark if cq handler is to */
3030Sstevel@tonic-gate 						/* be called in a thread */
3040Sstevel@tonic-gate 	ibt_async_code_t	cq_async_codes;
3050Sstevel@tonic-gate 	ibtl_async_flags_t	cq_async_flags;	/* see *_async_flags above */
3060Sstevel@tonic-gate 	uint64_t		cq_fma_ena;	/* FMA data */
3070Sstevel@tonic-gate } ibtl_cq_t;
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibtl_cq_s::{cq_in_thread cq_hca
3100Sstevel@tonic-gate     cq_ibc_cq_hdl}))
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate /*
3130Sstevel@tonic-gate  * Define a per SRQ state structure.
3140Sstevel@tonic-gate  *
3150Sstevel@tonic-gate  * ibt_alloc_srq() allocates one of these. A SRQ is associated with a
3160Sstevel@tonic-gate  * particular HCA, whose handle is recorded in the srq_hca field.
3170Sstevel@tonic-gate  * The srq_ibc_srq_hdl field is initialized with the CI SRQ handle returned
3180Sstevel@tonic-gate  * from the ibc_alloc_srq() call to the HCA driver.
3190Sstevel@tonic-gate  *
3200Sstevel@tonic-gate  * In order to set/get the client's private data, srq_clnt_private, clients
3210Sstevel@tonic-gate  * need to use ibt_set_srq_private() and ibt_get_srq_private() calls.
3220Sstevel@tonic-gate  *
3230Sstevel@tonic-gate  * The address of the ibtl_srq_s structure is passed in as the ibt_srq_hdl_t
3240Sstevel@tonic-gate  * (callback arg) in the CI ibc_alloc_srq() function.
3250Sstevel@tonic-gate  */
3260Sstevel@tonic-gate typedef struct ibtl_srq_s {
3270Sstevel@tonic-gate 	ibc_srq_hdl_t		srq_ibc_srq_hdl;	/* CI SRQ handle */
3280Sstevel@tonic-gate 	ibtl_hca_t		*srq_hca;		/* IBTL HCA hdl */
3290Sstevel@tonic-gate 	void			*srq_clnt_private;	/* Client's Private. */
3300Sstevel@tonic-gate 	struct ibtl_srq_s	*srq_async_link;	/* Async Link list */
3310Sstevel@tonic-gate 	ibt_async_code_t	srq_async_codes;
3320Sstevel@tonic-gate 	ibtl_async_flags_t	srq_async_flags;	/* Async_flags */
3330Sstevel@tonic-gate 	uint64_t		srq_fma_ena;		/* FMA data */
3340Sstevel@tonic-gate } ibtl_srq_t;
3350Sstevel@tonic-gate 
3360Sstevel@tonic-gate /*
3370Sstevel@tonic-gate  * Define a per QP state structure.
3380Sstevel@tonic-gate  *
3390Sstevel@tonic-gate  * The qp_hca field is initialized with the ibtl_hca_hdl_t of the HCA in
3400Sstevel@tonic-gate  * which the QP was allocated. The qp_ibc_qp_hdl field is initialized with
3410Sstevel@tonic-gate  * the CI QP handle.
3420Sstevel@tonic-gate  *
3430Sstevel@tonic-gate  * The ibtl_qp_t structure also maintains a channel connection state
3440Sstevel@tonic-gate  * structure that is only valid for RC and RD QP's. The information about
3450Sstevel@tonic-gate  * the respective Send and Receive CQ, the RDD and PD Handles are also stored.
3460Sstevel@tonic-gate  *
3470Sstevel@tonic-gate  * The IBTA spec does not include the signal type or PD on a QP query
3480Sstevel@tonic-gate  * operation. In order to implement the "CLONE" feature of the alloc rc|ud
3490Sstevel@tonic-gate  * channel functions we need to cache these values.
3500Sstevel@tonic-gate  */
3510Sstevel@tonic-gate typedef struct ibtl_qp_s {
3520Sstevel@tonic-gate 	ibt_tran_srv_t		qp_type;	/* QP type */
3530Sstevel@tonic-gate 	ibt_attr_flags_t	qp_flags;
3540Sstevel@tonic-gate 	ibc_qp_hdl_t		qp_ibc_qp_hdl;	/* CI QP handle */
3550Sstevel@tonic-gate 	ibc_pd_hdl_t		qp_pd_hdl;	/* CI PD Hdl */
3560Sstevel@tonic-gate 	ibtl_hca_t		*qp_hca;	/* IBTL HCA handle */
3570Sstevel@tonic-gate 	ibtl_cq_t		*qp_send_cq;	/* IBTL CQ handle */
3580Sstevel@tonic-gate 	ibtl_cq_t		*qp_recv_cq;	/* IBTL CQ handle */
3590Sstevel@tonic-gate 	struct ibtl_qp_s	*qp_async_link;	/* async list link */
3600Sstevel@tonic-gate 	ibt_async_code_t	qp_async_codes;
3610Sstevel@tonic-gate 	ibtl_async_flags_t	qp_async_flags;	/* see *_async_flags above */
3620Sstevel@tonic-gate 	uint64_t		qp_cat_fma_ena;	/* FMA data */
3630Sstevel@tonic-gate 	uint64_t		qp_pth_fma_ena;	/* FMA data */
3640Sstevel@tonic-gate 	uint64_t		qp_inv_fma_ena;	/* FMA data */
3650Sstevel@tonic-gate 	uint64_t		qp_acc_fma_ena;	/* FMA data */
3660Sstevel@tonic-gate } ibtl_qp_t;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 
3690Sstevel@tonic-gate /*
3700Sstevel@tonic-gate  * Define a per EEC state structure.
3710Sstevel@tonic-gate  *
3720Sstevel@tonic-gate  * The ibt_alloc_eec() allocates an ibt_eec_s structure and initializes
3730Sstevel@tonic-gate  * the eec_hca field with the ibtl_hca_hdl_t of the HCA in which the EEC
3740Sstevel@tonic-gate  * was allocated. The eec_ibc_eec_hdl field is initialized with the
3750Sstevel@tonic-gate  * CI EEC handle.
3760Sstevel@tonic-gate  *
3770Sstevel@tonic-gate  * The information about CI's RDD Handle and channel connection state structure
3780Sstevel@tonic-gate  * is also maintained.
3790Sstevel@tonic-gate  */
3800Sstevel@tonic-gate typedef struct ibtl_eec_s {
3810Sstevel@tonic-gate 	ibc_eec_hdl_t		eec_ibc_eec_hdl;	/* CI EEC Handle. */
3820Sstevel@tonic-gate 	ibtl_hca_t		*eec_hca;		/* IBTL HCA Hdl */
3830Sstevel@tonic-gate 	ibc_rdd_hdl_t		eec_ibc_rdd_hdl;	/* CI RDD Handle. */
3840Sstevel@tonic-gate 	struct ibtl_channel_s	*eec_channel;
3850Sstevel@tonic-gate 	struct ibtl_eec_s	*eec_async_link;	/* async list link */
3860Sstevel@tonic-gate 	ibt_async_code_t	eec_async_codes;
3870Sstevel@tonic-gate 	ibtl_async_flags_t	eec_async_flags;
3880Sstevel@tonic-gate 	uint64_t		eec_cat_fma_ena;	/* FMA data */
3890Sstevel@tonic-gate 	uint64_t		eec_pth_fma_ena;	/* FMA data */
3900Sstevel@tonic-gate } ibtl_eec_t;
3910Sstevel@tonic-gate 
3920Sstevel@tonic-gate /*
3930Sstevel@tonic-gate  * Define an ibt RD communication channel struct. This holds information
3940Sstevel@tonic-gate  * specific to an RD QP.
3950Sstevel@tonic-gate  */
3960Sstevel@tonic-gate typedef struct ibtl_rd_chan_s {
3970Sstevel@tonic-gate 	ibtl_eec_t		*rd_eec;	/* point to the EEC */
3980Sstevel@tonic-gate } ibtl_rd_chan_t;
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate /*
4010Sstevel@tonic-gate  * Define an ibt UD communication channel struct. This holds information
4020Sstevel@tonic-gate  * specific to a UD QP.
4030Sstevel@tonic-gate  */
4040Sstevel@tonic-gate typedef struct ibtl_ud_chan_s {
4050Sstevel@tonic-gate 	uint8_t			ud_port_num;	/* track the port number for */
4060Sstevel@tonic-gate 						/* ibt_modify_reply_ud_dest() */
4070Sstevel@tonic-gate 	ib_qkey_t		ud_qkey;	/* track the qkey */
4080Sstevel@tonic-gate } ibtl_ud_chan_t;
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate /*
4110Sstevel@tonic-gate  * Define an ibt RC communication channel struct. This holds information
4120Sstevel@tonic-gate  * specific to an RC QP.
4130Sstevel@tonic-gate  */
4140Sstevel@tonic-gate typedef struct ibtl_rc_chan_s {
4150Sstevel@tonic-gate 	int			rc_free_flags;	/* Track connection state as */
4160Sstevel@tonic-gate 						/* we will need to delay for */
4170Sstevel@tonic-gate 						/* TIMEWAIT before freeing. */
4180Sstevel@tonic-gate 	ibc_qpn_hdl_t		rc_qpn_hdl;	/* Store qpn_hdl while in */
4190Sstevel@tonic-gate 						/* TIMEWAIT delay. */
4200Sstevel@tonic-gate } ibtl_rc_chan_t;
4210Sstevel@tonic-gate 
4220Sstevel@tonic-gate /* bit definitions for rc_free_flags */
4230Sstevel@tonic-gate #define	IBTL_RC_QP_CONNECTED	0x1
4240Sstevel@tonic-gate #define	IBTL_RC_QP_CLOSING	0x2
4250Sstevel@tonic-gate #define	IBTL_RC_QP_CLOSED	0x4
4260Sstevel@tonic-gate #define	IBTL_RC_QP_FREED	0x8
42711369SPramod.Gunjikar@Sun.COM #define	IBTL_RC_QP_CONNECTING	0x10
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate /*
4300Sstevel@tonic-gate  * Define a per Channel state structure.
4310Sstevel@tonic-gate  *
4320Sstevel@tonic-gate  * A ibtl_channel_s is allocated each time a TI client calls a
4330Sstevel@tonic-gate  * channel allocation routine ibt_alloc_rc_channel() or ibt_alloc_ud_channel()
4340Sstevel@tonic-gate  * or VTI client calls ibt_alloc_qp() or ibt_alloc_special_qp().
4350Sstevel@tonic-gate  *
4360Sstevel@tonic-gate  * In order to set/get the client's private data, ch_clnt_private,
4370Sstevel@tonic-gate  * TI client's need to use ibt_set_chan_private() and ibt_get_chan_private()
4380Sstevel@tonic-gate  * or VTI clients need to use ibt_set_qp_private() and ibt_get_qp_private().
4390Sstevel@tonic-gate  */
4400Sstevel@tonic-gate typedef struct ibtl_channel_s {
4410Sstevel@tonic-gate 	/* The ibtl_qp_t must be at the first of this struct */
4420Sstevel@tonic-gate 	ibtl_qp_t		ch_qp;		/* IBTL QP handle */
4430Sstevel@tonic-gate 	union {					/* transport specific */
4440Sstevel@tonic-gate 		ibtl_rc_chan_t	rc;		/* RC Channel specific */
4450Sstevel@tonic-gate 		ibtl_rd_chan_t	rd;		/* RD Channel specific */
4460Sstevel@tonic-gate 		ibtl_ud_chan_t	ud;		/* UD Channel specific */
4470Sstevel@tonic-gate 	} ch_transport;
4480Sstevel@tonic-gate 	ibt_cep_state_t		ch_current_state; /* track the current state */
4490Sstevel@tonic-gate 	void			*ch_clnt_private; /* Client's Private data */
4500Sstevel@tonic-gate 	kmutex_t		ch_cm_mutex;	/* for ch_cm_private, etc. */
4510Sstevel@tonic-gate 	kcondvar_t		ch_cm_cv;	/* for recycle_rc */
4520Sstevel@tonic-gate 	void			*ch_cm_private;	/* Ptr to CM state */
4530Sstevel@tonic-gate } ibtl_channel_t;
4540Sstevel@tonic-gate 
4550Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibtl_channel_s))
4560Sstevel@tonic-gate 
4570Sstevel@tonic-gate /*
4580Sstevel@tonic-gate  * MACROS
4590Sstevel@tonic-gate  */
4600Sstevel@tonic-gate #define	IBTL_CHAN2QP(ibt_chan)		(&(ibt_chan)->ch_qp)
4610Sstevel@tonic-gate #define	IBTL_CHAN2HCA(ibt_chan)		(ibt_chan)->ch_qp.qp_hca
4620Sstevel@tonic-gate 
4630Sstevel@tonic-gate #define	IBTL_CHAN2CIQP(ibt_chan)	(ibt_chan->ch_qp.qp_ibc_qp_hdl)
4640Sstevel@tonic-gate 
4650Sstevel@tonic-gate #define	IBTL_QP2CHAN(ibtl_qp)		(ibtl_channel_t *)(ibtl_qp)
4660Sstevel@tonic-gate #define	IBTL_EEC2CHAN(ibtl_eec)		(ibtl_eec)->eec_channel
4670Sstevel@tonic-gate 
4680Sstevel@tonic-gate /*
4690Sstevel@tonic-gate  * Get IBC HCA Handle from IBT Handles.
4700Sstevel@tonic-gate  */
4710Sstevel@tonic-gate #define	IBTL_HDIP2CIHCA(hca_devp)	(hca_devp)->hd_ibc_hca_hdl
4720Sstevel@tonic-gate #define	IBTL_HCA2CIHCA(ibtl_hca)	IBTL_HDIP2CIHCA(ibtl_hca->ha_hca_devp)
4730Sstevel@tonic-gate #define	IBTL_ECC2CIHCA(ibtl_eec)	IBTL_HCA2CIHCA((ibtl_eec)->eec_hca)
4740Sstevel@tonic-gate #define	IBTL_CQ2CIHCA(ibtl_cq)		IBTL_HCA2CIHCA((ibtl_cq)->cq_hca)
4750Sstevel@tonic-gate #define	IBTL_CHAN2CIHCA(ibt_chan)	IBTL_HCA2CIHCA((ibt_chan)->ch_qp.qp_hca)
4760Sstevel@tonic-gate #define	IBTL_SRQ2CIHCA(ibtl_srq)	IBTL_HCA2CIHCA((ibtl_srq)->srq_hca)
4770Sstevel@tonic-gate 
4780Sstevel@tonic-gate /*
4790Sstevel@tonic-gate  * Get a pointer to the HCA ops structure from IBT handles.
4800Sstevel@tonic-gate  */
4810Sstevel@tonic-gate #define	IBTL_HDIP2CIHCAOPS_P(hca_devp)	(hca_devp)->hd_ibc_ops
4820Sstevel@tonic-gate #define	IBTL_HCA2CIHCAOPS_P(ibtl_hca)	\
4830Sstevel@tonic-gate 	IBTL_HDIP2CIHCAOPS_P(ibtl_hca->ha_hca_devp)
4840Sstevel@tonic-gate #define	IBTL_CQ2CIHCAOPS_P(ibtl_cq)	IBTL_HCA2CIHCAOPS_P((ibtl_cq)->cq_hca)
4850Sstevel@tonic-gate #define	IBTL_CHAN2CIHCAOPS_P(ibt_chan)	\
4860Sstevel@tonic-gate 	IBTL_HCA2CIHCAOPS_P((ibt_chan)->ch_qp.qp_hca)
4870Sstevel@tonic-gate #define	IBTL_SRQ2CIHCAOPS_P(ibtl_srq)	\
4880Sstevel@tonic-gate 	IBTL_HCA2CIHCAOPS_P((ibtl_srq)->srq_hca)
4890Sstevel@tonic-gate 
4900Sstevel@tonic-gate /*
4910Sstevel@tonic-gate  * Get Client Handle from IBT Handles.
4920Sstevel@tonic-gate  */
4930Sstevel@tonic-gate #define	IBTL_HCA2CLNT(ibtl_hca)		(ibtl_hca)->ha_clnt_devp
4940Sstevel@tonic-gate #define	IBTL_ECC2CLNT(ibtl_eec)		IBTL_HCA2CLNT((ibtl_eec)->eec_hca)
4950Sstevel@tonic-gate #define	IBTL_CQ2CLNT(ibtl_cq)		IBTL_HCA2CLNT((ibtl_cq)->cq_hca)
4960Sstevel@tonic-gate #define	IBTL_CHAN2CLNT(ibt_chan)	IBTL_HCA2CLNT((ibt_chan)->ch_qp.qp_hca)
4970Sstevel@tonic-gate 
4980Sstevel@tonic-gate /*
4990Sstevel@tonic-gate  * Get a Pointer to the client modinfo from IBT Handles.
5000Sstevel@tonic-gate  */
5010Sstevel@tonic-gate #define	IBTL_HCA2MODI_P(ibtl_hca)	\
5020Sstevel@tonic-gate 	((IBTL_HCA2CLNT(ibtl_hca))->clnt_modinfop)
5030Sstevel@tonic-gate 
5040Sstevel@tonic-gate #define	IBTL_EEC2MODI_P(ibtl_eec)	\
5050Sstevel@tonic-gate 	((IBTL_EEC2CLNT(ibtl_eec))->clnt_modinfop)
5060Sstevel@tonic-gate 
5070Sstevel@tonic-gate #define	IBTL_CQ2MODI_P(ibtl_cq)		((IBTL_CQ2CLNT(ibtl_cq))->clnt_modinfop)
5080Sstevel@tonic-gate 
5090Sstevel@tonic-gate #define	IBTL_CHAN2MODI_P(chan)		((IBTL_CHAN2CLNT(chan))->clnt_modinfop)
5100Sstevel@tonic-gate 
5110Sstevel@tonic-gate /*
5120Sstevel@tonic-gate  * Using HCA Device Info Pointer, access HCA Attributes values for
5130Sstevel@tonic-gate  *	Max SGID Table Size, Max PKEY Table Size.
5140Sstevel@tonic-gate  */
5150Sstevel@tonic-gate #define	IBTL_HDIP2SGIDTBLSZ(hca)	\
5160Sstevel@tonic-gate 		(hca)->hd_hca_attr->hca_max_port_sgid_tbl_sz
5170Sstevel@tonic-gate #define	IBTL_HDIP2PKEYTBLSZ(hca)	\
5180Sstevel@tonic-gate 		(hca)->hd_hca_attr->hca_max_port_pkey_tbl_sz
5190Sstevel@tonic-gate 
5200Sstevel@tonic-gate /*
5210Sstevel@tonic-gate  * Using IBTL HCA Handle, access HCA Attributes values.
5220Sstevel@tonic-gate  *			viz.	HCA Node GUID,
5230Sstevel@tonic-gate  *				Number of Ports on this HCA Device,
5240Sstevel@tonic-gate  *				Max SGID Table Size
5250Sstevel@tonic-gate  *				Max PKEY Table Size
5260Sstevel@tonic-gate  */
5270Sstevel@tonic-gate #define	IBTL_HCA2HCAGUID(hca_hdl) \
5280Sstevel@tonic-gate 	(hca_hdl)->ha_hca_devp->hd_hca_attr->hca_node_guid
5290Sstevel@tonic-gate #define	IBTL_HCA2NPORTS(hca_hdl) \
5300Sstevel@tonic-gate 	(hca_hdl)->ha_hca_devp->hd_hca_attr->hca_nports
5310Sstevel@tonic-gate #define	IBTL_HCA2SGIDTBLSZ(hca_hdl) \
5320Sstevel@tonic-gate 	(hca_hdl)->ha_hca_devp->hd_hca_attr->hca_max_port_sgid_tbl_sz
5330Sstevel@tonic-gate #define	IBTL_HCA2PKEYTBLSZ(hca_hdl) \
5340Sstevel@tonic-gate 	(hca_hdl)->ha_hca_devp->hd_hca_attr->hca_max_port_pkey_tbl_sz
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate /* possible strlen of a IB driver's name */
5370Sstevel@tonic-gate #define	IBTL_DRVNAME_LEN	40
5380Sstevel@tonic-gate 
5390Sstevel@tonic-gate /* strings passed to ib_dprintfN() are this long */
5400Sstevel@tonic-gate #define	IBTL_PRINT_BUF_LEN	4096
5410Sstevel@tonic-gate 
5420Sstevel@tonic-gate /* Check if client isn't CM/DM/IBMA */
5430Sstevel@tonic-gate #define	IBTL_GENERIC_CLIENT(clntp) \
5440Sstevel@tonic-gate 	(((clntp)->clnt_modinfop->mi_clnt_class != IBT_CM) && \
5450Sstevel@tonic-gate 	    ((clntp)->clnt_modinfop->mi_clnt_class != IBT_DM) && \
5460Sstevel@tonic-gate 	    ((clntp)->clnt_modinfop->mi_clnt_class != IBT_IBMA))
5470Sstevel@tonic-gate 
5480Sstevel@tonic-gate /*
5490Sstevel@tonic-gate  * Function Prototypes that are specific to the IBTL implementation.
5500Sstevel@tonic-gate  */
5510Sstevel@tonic-gate ibtl_hca_devinfo_t *ibtl_get_hcadevinfo(ib_guid_t hca_guid);
5520Sstevel@tonic-gate ibt_status_t ibtl_init_hca_portinfo(ibtl_hca_devinfo_t *hca_devp);
5530Sstevel@tonic-gate void	ibtl_reinit_hca_portinfo(ibtl_hca_devinfo_t *hca_devp, uint8_t port);
5540Sstevel@tonic-gate 
5550Sstevel@tonic-gate void	ibtl_init_cep_states(void);
5560Sstevel@tonic-gate void	ibtl_ib2usec_init(void);
5570Sstevel@tonic-gate void	ibtl_logging_initialization(void);
5580Sstevel@tonic-gate void	ibtl_logging_destroy(void);
5590Sstevel@tonic-gate void	ibtl_thread_init(void);
5600Sstevel@tonic-gate void	ibtl_thread_init2(void);
5610Sstevel@tonic-gate void	ibtl_thread_fini(void);
5620Sstevel@tonic-gate void	ibtl_announce_new_hca(ibtl_hca_devinfo_t *hca_devp);
5630Sstevel@tonic-gate void	ibtl_another_cq_handler_in_thread(void);
5640Sstevel@tonic-gate int	ibtl_detach_all_clients(ibtl_hca_devinfo_t *hcap);
5650Sstevel@tonic-gate void	ibtl_qp_flow_control_enter(void);
5660Sstevel@tonic-gate void	ibtl_qp_flow_control_exit(void);
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate /* synchronization of asyncs when freeing an object */
5690Sstevel@tonic-gate void	ibtl_free_qp_async_check(ibtl_qp_t *ibtl_qp);
5700Sstevel@tonic-gate void	ibtl_free_cq_async_check(ibtl_cq_t *ibtl_cq);
5710Sstevel@tonic-gate void	ibtl_free_srq_async_check(ibtl_srq_t *ibtl_srq);
5720Sstevel@tonic-gate void	ibtl_free_eec_async_check(ibtl_eec_t *ibtl_eec);
5730Sstevel@tonic-gate void	ibtl_free_hca_async_check(ibt_hca_hdl_t ibt_hca);
5740Sstevel@tonic-gate void	ibtl_free_clnt_async_check(ibtl_clnt_t *clntp);
5750Sstevel@tonic-gate 
5760Sstevel@tonic-gate /* synchronization of cq_handler callbacks and free_cq */
5770Sstevel@tonic-gate void	ibtl_free_cq_check(ibtl_cq_t *ibtl_cq);
5780Sstevel@tonic-gate 
5790Sstevel@tonic-gate /* release_qpn and close_hca synchronization */
5800Sstevel@tonic-gate void	ibtl_close_hca_check(ibt_hca_hdl_t ibt_hca);
5810Sstevel@tonic-gate 
5820Sstevel@tonic-gate /* Global List of HCA devices, and associated lock. */
5830Sstevel@tonic-gate extern struct ibtl_hca_devinfo_s *ibtl_hca_list; /* link is hd_hca_dev_link */
5840Sstevel@tonic-gate 
5850Sstevel@tonic-gate /* Global List of IBT Client Instances, and associated lock. */
5860Sstevel@tonic-gate extern struct ibtl_clnt_s *ibtl_clnt_list; /* link is clnt_list_link */
5870Sstevel@tonic-gate extern kmutex_t ibtl_clnt_list_mutex;
5880Sstevel@tonic-gate 
5890Sstevel@tonic-gate /* Lock for the race between the client and CM to free QPs. */
5900Sstevel@tonic-gate extern kmutex_t ibtl_free_qp_mutex;
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate /* Lock for the race between the client closing the HCA and QPN being freed. */
5930Sstevel@tonic-gate extern kcondvar_t ibtl_close_hca_cv;
5940Sstevel@tonic-gate 
5950Sstevel@tonic-gate /* Limit the flow of QP verb calls */
5960Sstevel@tonic-gate extern kmutex_t ibtl_qp_mutex;
5970Sstevel@tonic-gate extern kcondvar_t ibtl_qp_cv;
5980Sstevel@tonic-gate 
5990Sstevel@tonic-gate /* Async handlers and client private for well known clients of IBTL */
6000Sstevel@tonic-gate extern ibt_async_handler_t ibtl_cm_async_handler;
6010Sstevel@tonic-gate extern ibt_async_handler_t ibtl_dm_async_handler;
6020Sstevel@tonic-gate extern ibt_async_handler_t ibtl_ibma_async_handler;
6030Sstevel@tonic-gate extern void *ibtl_cm_clnt_private;
6040Sstevel@tonic-gate extern void *ibtl_dm_clnt_private;
6050Sstevel@tonic-gate extern void *ibtl_ibma_clnt_private;
6060Sstevel@tonic-gate 
6070Sstevel@tonic-gate /* cache for fast GID => portinfo lookup */
6080Sstevel@tonic-gate extern boolean_t ibtl_fast_gid_cache_valid;
6090Sstevel@tonic-gate 
6100Sstevel@tonic-gate 
6110Sstevel@tonic-gate /* The following structs are used to pass info in and out of the APIs */
6120Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_rc_chan_alloc_args_s))
6130Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_rc_chan_query_attr_s))
6140Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_rc_chan_modify_attr_s))
6150Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_ud_dest_query_attr_s))
6160Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_ud_chan_alloc_args_s))
6170Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_ud_chan_query_attr_s))
6180Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_ud_chan_modify_attr_s))
6190Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_ud_dest_s))
6200Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_qp_alloc_attr_s))
6210Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_qp_info_s))
6220Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_hca_portinfo_s))
6230Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_adds_vect_s))
6240Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_cep_path_s))
6250Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("client managed", ibt_mr_desc_s))
6260Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("GIDs are transient", ib_gid_s))
6270Sstevel@tonic-gate 
6280Sstevel@tonic-gate #ifdef __cplusplus
6290Sstevel@tonic-gate }
6300Sstevel@tonic-gate #endif
6310Sstevel@tonic-gate 
6320Sstevel@tonic-gate #endif /* _SYS_IB_IBTL_IMPL_IBTL_H */
633