xref: /onnv-gate/usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_impl.h (revision 10231:d1cbfdc8cfa8)
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
52927Spramodbg  * Common Development and Distribution License (the "License").
62927Spramodbg  * 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*10231SRajkumar.Sivaprakasam@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_IB_MGT_IBDM_IBDM_IMPL_H
270Sstevel@tonic-gate #define	_SYS_IB_MGT_IBDM_IBDM_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * ibdm_impl.h
310Sstevel@tonic-gate  *
320Sstevel@tonic-gate  *	This file contains definitions of the data structures, macros etc
330Sstevel@tonic-gate  *	related to the IBDM module.
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <sys/ib/mgt/ibdm/ibdm_ibnex.h>
370Sstevel@tonic-gate #include <sys/ib/ibtl/impl/ibtl_util.h>
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifdef __cplusplus
400Sstevel@tonic-gate extern "C" {
410Sstevel@tonic-gate #endif
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /* values for "cb_req_type" */
440Sstevel@tonic-gate #define	IBDM_REQ_TYPE_INVALID		0x0
450Sstevel@tonic-gate #define	IBDM_REQ_TYPE_CLASSPORTINFO	0x1
460Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOUINFO		0x2
470Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOCINFO		0x4
480Sstevel@tonic-gate #define	IBDM_REQ_TYPE_SRVENTS		0x8
490Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOU_DIAGCODE	0x10
500Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOC_DIAGCODE	0x20
510Sstevel@tonic-gate 
520Sstevel@tonic-gate typedef struct ibdm_taskq_args_s {
530Sstevel@tonic-gate 	ibmf_handle_t		tq_ibmf_handle;
540Sstevel@tonic-gate 	ibmf_msg_t		*tq_ibmf_msg;
550Sstevel@tonic-gate 	void			*tq_args;
560Sstevel@tonic-gate } ibdm_taskq_args_t;
570Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ibdm_taskq_args_t))
580Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ib_mad_hdr_t))
590Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ibmf_msg_t))
600Sstevel@tonic-gate 
610Sstevel@tonic-gate #define	IBDM_GID_PRESENT		0x1
620Sstevel@tonic-gate #define	IBDM_GID_NOT_PRESENT		0x0
630Sstevel@tonic-gate 
640Sstevel@tonic-gate #define	IBDM_IBMF_PKT_DUP_RESP		0x1
650Sstevel@tonic-gate #define	IBDM_IBMF_PKT_REUSED		0x2
660Sstevel@tonic-gate #define	IBDM_IBMF_PKT_UNEXP_RESP	0x4
670Sstevel@tonic-gate 
680Sstevel@tonic-gate #define	IBDM_MAX_SERV_ENTRIES_PER_REQ	4
690Sstevel@tonic-gate 
700Sstevel@tonic-gate typedef struct ibdm_gid_s {
710Sstevel@tonic-gate 	uint64_t		gid_dgid_hi;
720Sstevel@tonic-gate 	uint64_t		gid_dgid_lo;
730Sstevel@tonic-gate 	struct ibdm_gid_s	*gid_next;
740Sstevel@tonic-gate } ibdm_gid_t;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #define	IBDM_GID_PROBE_NOT_DONE		0x00
770Sstevel@tonic-gate #define	IBDM_GET_CLASSPORTINFO		0x01
780Sstevel@tonic-gate #define	IBDM_GET_IOUNITINFO		0x02
790Sstevel@tonic-gate #define	IBDM_GET_IOC_DETAILS		0x04
800Sstevel@tonic-gate #define	IBDM_GID_PROBING_COMPLETE	0x08
810Sstevel@tonic-gate #define	IBDM_GID_PROBING_SKIPPED	0x10
820Sstevel@tonic-gate #define	IBDM_GID_PROBING_FAILED		0x20
836262Seota #define	IBDM_SET_CLASSPORTINFO		0x40
846262Seota 
856262Seota /*
866262Seota  * Identifiers to distinguish a Cisco FC GW from others.
876262Seota  * Used to filter a setclassportinfo request.
886262Seota  */
896262Seota #define	IBDM_CISCO_COMPANY_ID		(0x5ad)
906262Seota #define	IBDM_CISCO_DEVICE_ID		(0xa87c)
916262Seota 
926262Seota /*
936262Seota  * the bit-shift value for OUI in GUID
946262Seota  * A 64 bit globally unique identifier (GUID) composed of a 24 bit company id
956262Seota  * and an 48 bit extension identifier, and this value is used to extract
966262Seota  * the company id from the GUID.
976262Seota  */
986262Seota #define	IBDM_OUI_GUID_SHIFT		(40)
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * The state diagram for the gl_state
1020Sstevel@tonic-gate  *
1036262Seota  *                          (in case of Cisco FC GW)
1046262Seota  * IBDM_GID_PROBE_NOT_DONE  ---------- 40 -> IBDM_SET_CLASSPORTINFO
1056262Seota  *                          ----.	        |
1066262Seota  *    |      |			| (others)      |
1076262Seota  *    |      |			1		|
1086262Seota  *    |      |			|               1
1096262Seota  *    |      |			`-------------.	|
1106262Seota  *    |      |                                v v
1116262Seota  *    |	     |				     IBDM_GET_CLASSPORTINFO
1126262Seota  *    |      |
1130Sstevel@tonic-gate  *    |      |                                  |
1140Sstevel@tonic-gate  *    |      2                                  3
1150Sstevel@tonic-gate  *    |      |                                  |
1160Sstevel@tonic-gate  *    |      v                                  v
1170Sstevel@tonic-gate  *    |     IBDM_GID_PROBING_FAILED          IBDM_GET_IOUNITINFO
1180Sstevel@tonic-gate  *    |                                         |
1190Sstevel@tonic-gate  *    6                                         4
1200Sstevel@tonic-gate  *    |                                         |
1210Sstevel@tonic-gate  *    v                                         v
1220Sstevel@tonic-gate  *  IBDM_GID_PROBING_SKIPPLED                IBDM_GET_IOC_DETAILS
1230Sstevel@tonic-gate  *                                              |
1240Sstevel@tonic-gate  *                                              5
1250Sstevel@tonic-gate  *                                              |
1260Sstevel@tonic-gate  *                                              v
1270Sstevel@tonic-gate  *                                           IBDM_GID_PROBE_COMPLETE
1280Sstevel@tonic-gate  *
1290Sstevel@tonic-gate  * Initial state : IBDM_GID_PROBE_NOT_DONE
1306262Seota  *     40 = Port sends setClassPortInfo to activate Cisco FC GW
1316262Seota  *	1 = Port supports DM MAD's and a request to ClassportInfo is sent
1320Sstevel@tonic-gate  *	3 = Received ClassPortInfo and sent IOUnitInfo
1330Sstevel@tonic-gate  *	4 = Recevied IOUunitInfo and sent IOC profile, diagcodes, and
1340Sstevel@tonic-gate  *		service entries requests
1350Sstevel@tonic-gate  *	5 = Received all the IOC information
1360Sstevel@tonic-gate  *	2 = Failed to probe the GID
1370Sstevel@tonic-gate  *		Port does not support DM MAD's
1380Sstevel@tonic-gate  *		Port did not respond property
1390Sstevel@tonic-gate  *	6 = A different GID for the same port, skip the probe
1400Sstevel@tonic-gate  *
1410Sstevel@tonic-gate  * Reprobe state transition :
1420Sstevel@tonic-gate  *
1430Sstevel@tonic-gate  * IBDM_GID_PROBE_COMPLETE
1440Sstevel@tonic-gate  *	|
1450Sstevel@tonic-gate  *	7
1460Sstevel@tonic-gate  *	|
1470Sstevel@tonic-gate  *	v
1480Sstevel@tonic-gate  * IBDM_GET_IOC_DETAILS
1490Sstevel@tonic-gate  *	|
1500Sstevel@tonic-gate  *	8
1510Sstevel@tonic-gate  *	|
1520Sstevel@tonic-gate  *	v
1530Sstevel@tonic-gate  * IBDM_GID_PROBE_COMPLETE
1540Sstevel@tonic-gate  *
1550Sstevel@tonic-gate  *	7 = Reprobe request for one or more IOCs initiated.
1560Sstevel@tonic-gate  *	8 = Reprobe done(IOC COntroller Profile & Service entries)
1570Sstevel@tonic-gate  */
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate typedef struct ibdm_dp_gidinfo_s {
1600Sstevel@tonic-gate 	kmutex_t		gl_mutex;
1610Sstevel@tonic-gate 	uint_t			gl_state;
1620Sstevel@tonic-gate 	int			gl_reprobe_flag;	/* pass this to taskq */
1630Sstevel@tonic-gate 	struct ibdm_dp_gidinfo_s *gl_next;
1640Sstevel@tonic-gate 	struct ibdm_dp_gidinfo_s *gl_prev;
1650Sstevel@tonic-gate 	ibdm_iou_info_t		*gl_iou;
1660Sstevel@tonic-gate 	int			gl_pending_cmds;
1670Sstevel@tonic-gate 	ibmf_qp_handle_t	gl_qp_hdl;
1680Sstevel@tonic-gate 	uint64_t		gl_transactionID;
1690Sstevel@tonic-gate 	ibdm_timeout_cb_args_t	gl_iou_cb_args;
1700Sstevel@tonic-gate 	ib_lid_t		gl_dlid;
1710Sstevel@tonic-gate 	ib_lid_t		gl_slid;
1720Sstevel@tonic-gate 	uint64_t		gl_dgid_hi;
1730Sstevel@tonic-gate 	uint64_t		gl_dgid_lo;
1740Sstevel@tonic-gate 	uint64_t		gl_sgid_hi;
1750Sstevel@tonic-gate 	uint64_t		gl_sgid_lo;
1760Sstevel@tonic-gate 	ib_guid_t		gl_nodeguid;
1770Sstevel@tonic-gate 	ib_guid_t		gl_portguid;
1780Sstevel@tonic-gate 	ib_pkey_t		gl_p_key;
179*10231SRajkumar.Sivaprakasam@Sun.COM 	boolean_t		gl_is_dm_capable;
1800Sstevel@tonic-gate 	boolean_t		gl_redirected;
1810Sstevel@tonic-gate 	uint32_t		gl_redirect_dlid;
1820Sstevel@tonic-gate 	uint32_t		gl_redirect_QP;
1830Sstevel@tonic-gate 	ib_pkey_t		gl_redirect_pkey;
1840Sstevel@tonic-gate 	ib_qkey_t		gl_redirect_qkey;
1850Sstevel@tonic-gate 	uint64_t		gl_redirectGID_hi;
1860Sstevel@tonic-gate 	uint64_t		gl_redirectGID_lo;
1870Sstevel@tonic-gate 	ibmf_handle_t		gl_ibmf_hdl;
1880Sstevel@tonic-gate 	ibmf_saa_handle_t	gl_sa_hdl;
1890Sstevel@tonic-gate 	timeout_id_t		gl_timeout_id;
1900Sstevel@tonic-gate 	ibdm_timeout_cb_args_t	gl_cpi_cb_args;
1910Sstevel@tonic-gate 	uint32_t		gl_ngids;
1920Sstevel@tonic-gate 	ibdm_gid_t		*gl_gid;
1930Sstevel@tonic-gate 	uint32_t		gl_resp_timeout;
1940Sstevel@tonic-gate 	int			gl_num_iocs;
1950Sstevel@tonic-gate 	ibdm_hca_list_t		*gl_hca_list;
1960Sstevel@tonic-gate 	int			gl_disconnected;
1971093Shiremath 	uint64_t		gl_min_transactionID;
1981093Shiremath 	uint64_t		gl_max_transactionID;
1994024Spramodbg 	ibdm_iou_info_t		*gl_prev_iou;
2006262Seota 	uint16_t		gl_devid;	/* device ID info */
2016262Seota 	kcondvar_t		gl_probe_cv;	/* sync for Cisco FC GW */
2026262Seota 	uint32_t		gl_flag;
2036699Seota 	uint8_t			gl_SL:4; 	/* SL from path_record */
2046699Seota 	uint8_t			gl_redirectSL:4; /* SL from redirection */
2050Sstevel@tonic-gate } ibdm_dp_gidinfo_t;
2060Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
2070Sstevel@tonic-gate 	ibdm_dp_gidinfo_s::{gl_state gl_timeout_id gl_pending_cmds}))
2080Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_dp_gidinfo_s))
2090Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibdm_dp_gidinfo_s::{gl_ibmf_hdl gl_sa_hdl}))
2106699Seota _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
2116699Seota 	ibdm_ioc_info_s::{ioc_timeout_id ioc_dc_timeout_id}))
2126699Seota _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
2136699Seota 	ibdm_srvents_info_s::se_timeout_id))
2140Sstevel@tonic-gate 
2151093Shiremath /*
2161093Shiremath  * The transaction ID for the GID contains of two parts :
2171093Shiremath  *	1. Upper 32 bits which is unique for each GID.
2181093Shiremath  *	2. Lower 32 bits which is unique for each MAD.
2191093Shiremath  * The assumptions are :
2201093Shiremath  *	1. At most 2 power 32 DM capable GIDs on the IB fabric
2211093Shiremath  *	2. IBDM sends maximum of 2 power 32 MADs to the same DM GID
2221093Shiremath  * The limits are sufficient for practical configurations.
2231093Shiremath  */
2241093Shiremath #define	IBDM_GID_TRANSACTIONID_SHIFT	((ulong_t)32)
2252927Spramodbg #define	IBDM_GID_TRANSACTIONID_MASK	0xFFFFFFFF00000000ULL
2261093Shiremath 
2270Sstevel@tonic-gate typedef struct ibdm_s {
2280Sstevel@tonic-gate 	/* Protects IBDM's critical data */
2290Sstevel@tonic-gate 	kmutex_t		ibdm_mutex;
2300Sstevel@tonic-gate 	uint32_t		ibdm_hca_count;
2310Sstevel@tonic-gate 	kmutex_t		ibdm_hl_mutex;
2320Sstevel@tonic-gate 	kmutex_t		ibdm_ibnex_mutex;
2330Sstevel@tonic-gate 	ibdm_hca_list_t		*ibdm_hca_list_head;
2340Sstevel@tonic-gate 	ibdm_hca_list_t		*ibdm_hca_list_tail;
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate 	ibdm_dp_gidinfo_t	*ibdm_dp_gidlist_head;
2370Sstevel@tonic-gate 	ibdm_dp_gidinfo_t	*ibdm_dp_gidlist_tail;
2380Sstevel@tonic-gate 
2390Sstevel@tonic-gate 	kcondvar_t		ibdm_probe_cv;
2400Sstevel@tonic-gate 	kcondvar_t		ibdm_busy_cv;
2418082SRamaswamy.Tummala@Sun.COM 	kcondvar_t		ibdm_port_settle_cv;
2420Sstevel@tonic-gate 	uint32_t		ibdm_ngid_probes_in_progress;
2431093Shiremath 	uint64_t		ibdm_transactionID;
2440Sstevel@tonic-gate 	uint32_t		ibdm_ngids;
2450Sstevel@tonic-gate 	uint32_t		ibdm_busy;
2460Sstevel@tonic-gate 	int			ibdm_state;
2470Sstevel@tonic-gate 	ibt_clnt_hdl_t		ibdm_ibt_clnt_hdl;
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate 	/*
2500Sstevel@tonic-gate 	 * These are callback routines registered by the IB nexus driver.
2510Sstevel@tonic-gate 	 * These callbacks are used to inform the IB nexus driver about
2520Sstevel@tonic-gate 	 * the arrival/removal of HCA and IOC's
2530Sstevel@tonic-gate 	 */
2540Sstevel@tonic-gate 	ibdm_callback_t		ibdm_ibnex_callback;
2554024Spramodbg 
2564024Spramodbg 	/* Flag indicating - prev_iou during sweep */
2574024Spramodbg 	int			ibdm_prev_iou;
2580Sstevel@tonic-gate } ibdm_t;
2590Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_mutex, ibdm_s::{ibdm_ibt_clnt_hdl
2600Sstevel@tonic-gate 	ibdm_busy ibdm_state}))
2610Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibdm_s::ibdm_ibt_clnt_hdl))
2620Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_hl_mutex,
2630Sstevel@tonic-gate 	ibdm_s::{ibdm_hca_list_head ibdm_hca_list_tail}))
2640Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_ibnex_mutex,
2650Sstevel@tonic-gate 	ibdm_s::ibdm_ibnex_callback))
2660Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_s))
2670Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibdm_s::ibdm_mutex ibdm_dp_gidinfo_s::gl_mutex))
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate /* valid values for ibdm_state */
2700Sstevel@tonic-gate #define	IBDM_LOCKS_ALLOCED	0x01		/* global locks alloced */
2710Sstevel@tonic-gate #define	IBDM_CVS_ALLOCED	0x02		/* global "cv"s alloced */
2720Sstevel@tonic-gate #define	IBDM_IBT_ATTACHED	0x04		/* ibt_attach() called */
2730Sstevel@tonic-gate #define	IBDM_HCA_ATTACHED	0x08		/* ibdm_handle_hca() called */
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate #define	IBDM_8_BIT_MASK		0x00FF
2760Sstevel@tonic-gate #define	IBDM_16_BIT_MASK	0xFFFF
2770Sstevel@tonic-gate #define	IBDM_RETRY_COUNT	0x2
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate #define	IBDM_BUSY		0x1
2800Sstevel@tonic-gate #define	IBDM_PROBE_IN_PROGRESS	0x2
2816262Seota #define	IBDM_CISCO_PROBE	0x4
2826262Seota #define	IBDM_CISCO_PROBE_DONE	0x8
2830Sstevel@tonic-gate 
2846262Seota /*
2856262Seota  * Device Management MAD packet format
2866262Seota  * +--------+------------+------------+------------+------------+
2876262Seota  * | offset |   byte 0   |   byte 1   |   byte 2   |   byte 3   |
2886262Seota  * +--------+------------+------------+------------+------------+ --
2896262Seota  * |   0    |                                                   |  ^
2906262Seota  * +--------+                                                   | sizeof(
2916262Seota  * |   ...  |              Common MAD Header                    | ib_mad_hdr_t)
2926262Seota  * +--------+                                                   |  | (A)
2936262Seota  * |   20   |                                                   |  v
2946262Seota  * +--------+------------+------------+------------+------------+ --
2956262Seota  * |   24   |                                                   |  ^
2966262Seota  * +--------+                                                   |  |
2976262Seota  * |   ...  |              RMPP Header                          |  |
2986262Seota  * +--------+                                                   |  |
2996262Seota  * |   32   |                                                   |  |
3006262Seota  * +--------+------------+------------+------------+------------+  |
3016262Seota  * |   36   |                                                   |  |
3026262Seota  * +--------+              Access_Key                           |
3036262Seota  * |   40   |                                                   | IBDM_DM_MAD_
3046262Seota  * +--------+------------+------------+------------+------------+ HDR_SZ
3056262Seota  * |   44   |  KeyType   |              reserved                |    (B)
3066262Seota  * +--------+------------+------------+------------+------------+  |
3076262Seota  * |   48   |                                                   |  |
3086262Seota  * +--------+                                                   |  |
3096262Seota  * |   52   |              Reserved                             |  |
3106262Seota  * +--------+                                                   |  |
3116262Seota  * |   56   |                                                   |  |
3126262Seota  * +--------+------------+------------+------------+------------+  |
3136262Seota  * |   60   |       Change_ID         |     ComponentMask       |  v
3146262Seota  * +--------+------------+------------+------------+------------+ --
3156262Seota  * |   64   |                                                   |  ^
3166262Seota  * +--------+                                                   | IBDM_MAD_SIZE
3176262Seota  * |   ...  |              Device Management Data               | - (A) - (B)
3186262Seota  * +--------+                                                   |  |
3196262Seota  * |  252   |                                                   |  v
3206262Seota  * +--------+------------+------------+------------+------------+ --
3216262Seota  */
3220Sstevel@tonic-gate #define	IBDM_MAD_SIZE		256
3236262Seota #define	IBDM_DM_MAD_HDR_SZ	40
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate #define	IBDM_DFT_TIMEOUT	4
3260Sstevel@tonic-gate #define	IBDM_DFT_NRETRIES	3
3270Sstevel@tonic-gate 
3280Sstevel@tonic-gate #define	IBDM_ENABLE_TASKQ_HANDLING	1
3290Sstevel@tonic-gate #define	IBDM_DISABLE_TASKQ_HANLDING	0
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate typedef struct ibdm_saa_event_arg_s {
3320Sstevel@tonic-gate 	ibmf_saa_handle_t ibmf_saa_handle;
3330Sstevel@tonic-gate 	ibmf_saa_subnet_event_t ibmf_saa_event;
3340Sstevel@tonic-gate 	ibmf_saa_event_details_t event_details;
3350Sstevel@tonic-gate 	void *callback_arg;
3360Sstevel@tonic-gate } ibdm_saa_event_arg_t;
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate #define	IBDM_TIMEOUT_VALUE(t)	(drv_usectohz(t * 1000000))
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate #define	IBDM_OUT_IBMFMSG_MADHDR(msg)\
3410Sstevel@tonic-gate 		(msg->im_msgbufs_send.im_bufs_mad_hdr)
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_MADHDR(msg)\
3440Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_mad_hdr)
3450Sstevel@tonic-gate 
3460Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_STATUS(msg)\
3470Sstevel@tonic-gate 		b2h16(msg->im_msgbufs_recv.im_bufs_mad_hdr->Status)
3480Sstevel@tonic-gate 
3490Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_ATTR(msg)\
3500Sstevel@tonic-gate 		b2h16(msg->im_msgbufs_recv.im_bufs_mad_hdr->AttributeID)
3510Sstevel@tonic-gate 
3520Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_ATTRMOD(msg)\
3530Sstevel@tonic-gate 		b2h32(msg->im_msgbufs_recv.im_bufs_mad_hdr->AttributeModifier)
3540Sstevel@tonic-gate 
3550Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2IOU(msg)	(ib_dm_io_unitinfo_t *)\
3560Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2IOC(msg)	(ib_dm_ioc_ctrl_profile_t *)\
3590Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2SRVENT(msg)	(ib_dm_srv_t *)\
3620Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3630Sstevel@tonic-gate 
3640Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2DIAGCODE(msg)	(uint32_t *)\
3650Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate #define	IBDM_GIDINFO2IOCINFO(gid_info, idx) \
3680Sstevel@tonic-gate 		(ibdm_ioc_info_t *)&gid_info->gl_iou->iou_ioc_info[idx];
3690Sstevel@tonic-gate 
3700Sstevel@tonic-gate #define	IBDM_IS_IOC_NUM_INVALID(ioc_no, gid_info)\
3710Sstevel@tonic-gate 		((ioc_no < 1) || (ioc_no >\
3720Sstevel@tonic-gate 			gid_info->gl_iou->iou_info.iou_num_ctrl_slots))
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate #define	IBDM_INVALID_PKEY(pkey)	\
3750Sstevel@tonic-gate 		(((pkey) == IB_PKEY_INVALID_FULL) || \
3760Sstevel@tonic-gate 		((pkey) == IB_PKEY_INVALID_LIMITED))
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate #ifdef DEBUG
3790Sstevel@tonic-gate 
3806262Seota void	ibdm_dump_mad_hdr(ib_mad_hdr_t *);
3810Sstevel@tonic-gate void	ibdm_dump_ibmf_msg(ibmf_msg_t *, int);
3820Sstevel@tonic-gate void	ibdm_dump_path_info(sa_path_record_t *);
3836262Seota void	ibdm_dump_classportinfo(ib_mad_classportinfo_t *);
3840Sstevel@tonic-gate void	ibdm_dump_iounitinfo(ib_dm_io_unitinfo_t *);
3850Sstevel@tonic-gate void	ibdm_dump_ioc_profile(ib_dm_ioc_ctrl_profile_t *);
3860Sstevel@tonic-gate void	ibdm_dump_service_entries(ib_dm_srv_t *);
3870Sstevel@tonic-gate void	ibdm_dump_sweep_fabric_timestamp(int);
3880Sstevel@tonic-gate 
3896262Seota #define	ibdm_dump_mad_hdr(a)		ibdm_dump_mad_hdr(a)
3900Sstevel@tonic-gate #define	ibdm_dump_ibmf_msg(a, b)	ibdm_dump_ibmf_msg(a, b)
3910Sstevel@tonic-gate #define	ibdm_dump_path_info(a)		ibdm_dump_path_info(a)
3920Sstevel@tonic-gate #define	ibdm_dump_classportinfo(a)	ibdm_dump_classportinfo(a)
3930Sstevel@tonic-gate #define	ibdm_dump_iounitinfo(a)		ibdm_dump_iounitinfo(a)
3940Sstevel@tonic-gate #define	ibdm_dump_ioc_profile(a)	ibdm_dump_ioc_profile(a)
3950Sstevel@tonic-gate #define	ibdm_dump_service_entries(a)	ibdm_dump_service_entries(a)
3960Sstevel@tonic-gate 
3970Sstevel@tonic-gate #else
3980Sstevel@tonic-gate 
3996262Seota #define	ibdm_dump_mad_hdr(a)
4000Sstevel@tonic-gate #define	ibdm_dump_ibmf_msg(a, b)
4010Sstevel@tonic-gate #define	ibdm_dump_path_info(a)
4020Sstevel@tonic-gate #define	ibdm_dump_classportinfo(a)
4030Sstevel@tonic-gate #define	ibdm_dump_iounitinfo(a)
4040Sstevel@tonic-gate #define	ibdm_dump_ioc_profile(a)
4050Sstevel@tonic-gate #define	ibdm_dump_service_entries(a)
4060Sstevel@tonic-gate #define	ibdm_dump_sweep_fabric_timestamp(a)
4070Sstevel@tonic-gate 
4080Sstevel@tonic-gate #endif
4090Sstevel@tonic-gate 
4100Sstevel@tonic-gate #ifdef __cplusplus
4110Sstevel@tonic-gate }
4120Sstevel@tonic-gate #endif
4130Sstevel@tonic-gate 
4140Sstevel@tonic-gate #endif	/* _SYS_IB_MGT_IBDM_IBDM_IMPL_H */
415