17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
54f1d42a6Spramodbg  * Common Development and Distribution License (the "License").
64f1d42a6Spramodbg  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*8e55d263SRajkumar Sivaprakasam  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_IB_MGT_IBDM_IBDM_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_IB_MGT_IBDM_IBDM_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * ibdm_impl.h
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  *	This file contains definitions of the data structures, macros etc
337c478bd9Sstevel@tonic-gate  *	related to the IBDM module.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/ib/mgt/ibdm/ibdm_ibnex.h>
377c478bd9Sstevel@tonic-gate #include <sys/ib/ibtl/impl/ibtl_util.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef __cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* values for "cb_req_type" */
447c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_INVALID		0x0
457c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_CLASSPORTINFO	0x1
467c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOUINFO		0x2
477c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOCINFO		0x4
487c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_SRVENTS		0x8
497c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOU_DIAGCODE	0x10
507c478bd9Sstevel@tonic-gate #define	IBDM_REQ_TYPE_IOC_DIAGCODE	0x20
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate typedef struct ibdm_taskq_args_s {
537c478bd9Sstevel@tonic-gate 	ibmf_handle_t		tq_ibmf_handle;
547c478bd9Sstevel@tonic-gate 	ibmf_msg_t		*tq_ibmf_msg;
557c478bd9Sstevel@tonic-gate 	void			*tq_args;
567c478bd9Sstevel@tonic-gate } ibdm_taskq_args_t;
577c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ibdm_taskq_args_t))
587c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ib_mad_hdr_t))
597c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", ibmf_msg_t))
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	IBDM_GID_PRESENT		0x1
627c478bd9Sstevel@tonic-gate #define	IBDM_GID_NOT_PRESENT		0x0
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #define	IBDM_IBMF_PKT_DUP_RESP		0x1
657c478bd9Sstevel@tonic-gate #define	IBDM_IBMF_PKT_REUSED		0x2
667c478bd9Sstevel@tonic-gate #define	IBDM_IBMF_PKT_UNEXP_RESP	0x4
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define	IBDM_MAX_SERV_ENTRIES_PER_REQ	4
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate typedef struct ibdm_gid_s {
717c478bd9Sstevel@tonic-gate 	uint64_t		gid_dgid_hi;
727c478bd9Sstevel@tonic-gate 	uint64_t		gid_dgid_lo;
737c478bd9Sstevel@tonic-gate 	struct ibdm_gid_s	*gid_next;
747c478bd9Sstevel@tonic-gate } ibdm_gid_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #define	IBDM_GID_PROBE_NOT_DONE		0x00
777c478bd9Sstevel@tonic-gate #define	IBDM_GET_CLASSPORTINFO		0x01
787c478bd9Sstevel@tonic-gate #define	IBDM_GET_IOUNITINFO		0x02
797c478bd9Sstevel@tonic-gate #define	IBDM_GET_IOC_DETAILS		0x04
807c478bd9Sstevel@tonic-gate #define	IBDM_GID_PROBING_COMPLETE	0x08
817c478bd9Sstevel@tonic-gate #define	IBDM_GID_PROBING_SKIPPED	0x10
827c478bd9Sstevel@tonic-gate #define	IBDM_GID_PROBING_FAILED		0x20
8353c1b7a3Seota #define	IBDM_SET_CLASSPORTINFO		0x40
8453c1b7a3Seota 
8553c1b7a3Seota /*
8653c1b7a3Seota  * Identifiers to distinguish a Cisco FC GW from others.
8753c1b7a3Seota  * Used to filter a setclassportinfo request.
8853c1b7a3Seota  */
8953c1b7a3Seota #define	IBDM_CISCO_COMPANY_ID		(0x5ad)
9053c1b7a3Seota #define	IBDM_CISCO_DEVICE_ID		(0xa87c)
9153c1b7a3Seota 
9253c1b7a3Seota /*
9353c1b7a3Seota  * the bit-shift value for OUI in GUID
9453c1b7a3Seota  * A 64 bit globally unique identifier (GUID) composed of a 24 bit company id
9553c1b7a3Seota  * and an 48 bit extension identifier, and this value is used to extract
9653c1b7a3Seota  * the company id from the GUID.
9753c1b7a3Seota  */
9853c1b7a3Seota #define	IBDM_OUI_GUID_SHIFT		(40)
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * The state diagram for the gl_state
1027c478bd9Sstevel@tonic-gate  *
10353c1b7a3Seota  *                          (in case of Cisco FC GW)
10453c1b7a3Seota  * IBDM_GID_PROBE_NOT_DONE  ---------- 40 -> IBDM_SET_CLASSPORTINFO
10553c1b7a3Seota  *                          ----.	        |
10653c1b7a3Seota  *    |      |			| (others)      |
10753c1b7a3Seota  *    |      |			1		|
10853c1b7a3Seota  *    |      |			|               1
10953c1b7a3Seota  *    |      |			`-------------.	|
11053c1b7a3Seota  *    |      |                                v v
11153c1b7a3Seota  *    |	     |				     IBDM_GET_CLASSPORTINFO
11253c1b7a3Seota  *    |      |
1137c478bd9Sstevel@tonic-gate  *    |      |                                  |
1147c478bd9Sstevel@tonic-gate  *    |      2                                  3
1157c478bd9Sstevel@tonic-gate  *    |      |                                  |
1167c478bd9Sstevel@tonic-gate  *    |      v                                  v
1177c478bd9Sstevel@tonic-gate  *    |     IBDM_GID_PROBING_FAILED          IBDM_GET_IOUNITINFO
1187c478bd9Sstevel@tonic-gate  *    |                                         |
1197c478bd9Sstevel@tonic-gate  *    6                                         4
1207c478bd9Sstevel@tonic-gate  *    |                                         |
1217c478bd9Sstevel@tonic-gate  *    v                                         v
1227c478bd9Sstevel@tonic-gate  *  IBDM_GID_PROBING_SKIPPLED                IBDM_GET_IOC_DETAILS
1237c478bd9Sstevel@tonic-gate  *                                              |
1247c478bd9Sstevel@tonic-gate  *                                              5
1257c478bd9Sstevel@tonic-gate  *                                              |
1267c478bd9Sstevel@tonic-gate  *                                              v
1277c478bd9Sstevel@tonic-gate  *                                           IBDM_GID_PROBE_COMPLETE
1287c478bd9Sstevel@tonic-gate  *
1297c478bd9Sstevel@tonic-gate  * Initial state : IBDM_GID_PROBE_NOT_DONE
13053c1b7a3Seota  *     40 = Port sends setClassPortInfo to activate Cisco FC GW
13153c1b7a3Seota  *	1 = Port supports DM MAD's and a request to ClassportInfo is sent
1327c478bd9Sstevel@tonic-gate  *	3 = Received ClassPortInfo and sent IOUnitInfo
1337c478bd9Sstevel@tonic-gate  *	4 = Recevied IOUunitInfo and sent IOC profile, diagcodes, and
1347c478bd9Sstevel@tonic-gate  *		service entries requests
1357c478bd9Sstevel@tonic-gate  *	5 = Received all the IOC information
1367c478bd9Sstevel@tonic-gate  *	2 = Failed to probe the GID
1377c478bd9Sstevel@tonic-gate  *		Port does not support DM MAD's
1387c478bd9Sstevel@tonic-gate  *		Port did not respond property
1397c478bd9Sstevel@tonic-gate  *	6 = A different GID for the same port, skip the probe
1407c478bd9Sstevel@tonic-gate  *
1417c478bd9Sstevel@tonic-gate  * Reprobe state transition :
1427c478bd9Sstevel@tonic-gate  *
1437c478bd9Sstevel@tonic-gate  * IBDM_GID_PROBE_COMPLETE
1447c478bd9Sstevel@tonic-gate  *	|
1457c478bd9Sstevel@tonic-gate  *	7
1467c478bd9Sstevel@tonic-gate  *	|
1477c478bd9Sstevel@tonic-gate  *	v
1487c478bd9Sstevel@tonic-gate  * IBDM_GET_IOC_DETAILS
1497c478bd9Sstevel@tonic-gate  *	|
1507c478bd9Sstevel@tonic-gate  *	8
1517c478bd9Sstevel@tonic-gate  *	|
1527c478bd9Sstevel@tonic-gate  *	v
1537c478bd9Sstevel@tonic-gate  * IBDM_GID_PROBE_COMPLETE
1547c478bd9Sstevel@tonic-gate  *
1557c478bd9Sstevel@tonic-gate  *	7 = Reprobe request for one or more IOCs initiated.
1567c478bd9Sstevel@tonic-gate  *	8 = Reprobe done(IOC COntroller Profile & Service entries)
1577c478bd9Sstevel@tonic-gate  */
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate typedef struct ibdm_dp_gidinfo_s {
1607c478bd9Sstevel@tonic-gate 	kmutex_t		gl_mutex;
1617c478bd9Sstevel@tonic-gate 	uint_t			gl_state;
1627c478bd9Sstevel@tonic-gate 	int			gl_reprobe_flag;	/* pass this to taskq */
1637c478bd9Sstevel@tonic-gate 	struct ibdm_dp_gidinfo_s *gl_next;
1647c478bd9Sstevel@tonic-gate 	struct ibdm_dp_gidinfo_s *gl_prev;
1657c478bd9Sstevel@tonic-gate 	ibdm_iou_info_t		*gl_iou;
1667c478bd9Sstevel@tonic-gate 	int			gl_pending_cmds;
1677c478bd9Sstevel@tonic-gate 	ibmf_qp_handle_t	gl_qp_hdl;
1687c478bd9Sstevel@tonic-gate 	uint64_t		gl_transactionID;
1697c478bd9Sstevel@tonic-gate 	ibdm_timeout_cb_args_t	gl_iou_cb_args;
1707c478bd9Sstevel@tonic-gate 	ib_lid_t		gl_dlid;
1717c478bd9Sstevel@tonic-gate 	ib_lid_t		gl_slid;
1727c478bd9Sstevel@tonic-gate 	uint64_t		gl_dgid_hi;
1737c478bd9Sstevel@tonic-gate 	uint64_t		gl_dgid_lo;
1747c478bd9Sstevel@tonic-gate 	uint64_t		gl_sgid_hi;
1757c478bd9Sstevel@tonic-gate 	uint64_t		gl_sgid_lo;
1767c478bd9Sstevel@tonic-gate 	ib_guid_t		gl_nodeguid;
1777c478bd9Sstevel@tonic-gate 	ib_guid_t		gl_portguid;
1787c478bd9Sstevel@tonic-gate 	ib_pkey_t		gl_p_key;
179*8e55d263SRajkumar Sivaprakasam 	boolean_t		gl_is_dm_capable;
1807c478bd9Sstevel@tonic-gate 	boolean_t		gl_redirected;
1817c478bd9Sstevel@tonic-gate 	uint32_t		gl_redirect_dlid;
1827c478bd9Sstevel@tonic-gate 	uint32_t		gl_redirect_QP;
1837c478bd9Sstevel@tonic-gate 	ib_pkey_t		gl_redirect_pkey;
1847c478bd9Sstevel@tonic-gate 	ib_qkey_t		gl_redirect_qkey;
1857c478bd9Sstevel@tonic-gate 	uint64_t		gl_redirectGID_hi;
1867c478bd9Sstevel@tonic-gate 	uint64_t		gl_redirectGID_lo;
1877c478bd9Sstevel@tonic-gate 	ibmf_handle_t		gl_ibmf_hdl;
1887c478bd9Sstevel@tonic-gate 	ibmf_saa_handle_t	gl_sa_hdl;
1897c478bd9Sstevel@tonic-gate 	timeout_id_t		gl_timeout_id;
1907c478bd9Sstevel@tonic-gate 	ibdm_timeout_cb_args_t	gl_cpi_cb_args;
1917c478bd9Sstevel@tonic-gate 	uint32_t		gl_ngids;
1927c478bd9Sstevel@tonic-gate 	ibdm_gid_t		*gl_gid;
1937c478bd9Sstevel@tonic-gate 	uint32_t		gl_resp_timeout;
1947c478bd9Sstevel@tonic-gate 	int			gl_num_iocs;
1957c478bd9Sstevel@tonic-gate 	ibdm_hca_list_t		*gl_hca_list;
1967c478bd9Sstevel@tonic-gate 	int			gl_disconnected;
1979d3d2ed0Shiremath 	uint64_t		gl_min_transactionID;
1989d3d2ed0Shiremath 	uint64_t		gl_max_transactionID;
199add2b70bSpramodbg 	ibdm_iou_info_t		*gl_prev_iou;
20053c1b7a3Seota 	uint16_t		gl_devid;	/* device ID info */
20153c1b7a3Seota 	kcondvar_t		gl_probe_cv;	/* sync for Cisco FC GW */
20253c1b7a3Seota 	uint32_t		gl_flag;
20318edb70cSeota 	uint8_t			gl_SL:4; 	/* SL from path_record */
20418edb70cSeota 	uint8_t			gl_redirectSL:4; /* SL from redirection */
2057c478bd9Sstevel@tonic-gate } ibdm_dp_gidinfo_t;
2067c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
2077c478bd9Sstevel@tonic-gate 	ibdm_dp_gidinfo_s::{gl_state gl_timeout_id gl_pending_cmds}))
2087c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_dp_gidinfo_s))
2097c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibdm_dp_gidinfo_s::{gl_ibmf_hdl gl_sa_hdl}))
21018edb70cSeota _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
21118edb70cSeota 	ibdm_ioc_info_s::{ioc_timeout_id ioc_dc_timeout_id}))
21218edb70cSeota _NOTE(MUTEX_PROTECTS_DATA(ibdm_dp_gidinfo_s::gl_mutex,
21318edb70cSeota 	ibdm_srvents_info_s::se_timeout_id))
2147c478bd9Sstevel@tonic-gate 
2159d3d2ed0Shiremath /*
2169d3d2ed0Shiremath  * The transaction ID for the GID contains of two parts :
2179d3d2ed0Shiremath  *	1. Upper 32 bits which is unique for each GID.
2189d3d2ed0Shiremath  *	2. Lower 32 bits which is unique for each MAD.
2199d3d2ed0Shiremath  * The assumptions are :
2209d3d2ed0Shiremath  *	1. At most 2 power 32 DM capable GIDs on the IB fabric
2219d3d2ed0Shiremath  *	2. IBDM sends maximum of 2 power 32 MADs to the same DM GID
2229d3d2ed0Shiremath  * The limits are sufficient for practical configurations.
2239d3d2ed0Shiremath  */
2249d3d2ed0Shiremath #define	IBDM_GID_TRANSACTIONID_SHIFT	((ulong_t)32)
2254f1d42a6Spramodbg #define	IBDM_GID_TRANSACTIONID_MASK	0xFFFFFFFF00000000ULL
2269d3d2ed0Shiremath 
2277c478bd9Sstevel@tonic-gate typedef struct ibdm_s {
2287c478bd9Sstevel@tonic-gate 	/* Protects IBDM's critical data */
2297c478bd9Sstevel@tonic-gate 	kmutex_t		ibdm_mutex;
2307c478bd9Sstevel@tonic-gate 	uint32_t		ibdm_hca_count;
2317c478bd9Sstevel@tonic-gate 	kmutex_t		ibdm_hl_mutex;
2327c478bd9Sstevel@tonic-gate 	kmutex_t		ibdm_ibnex_mutex;
2337c478bd9Sstevel@tonic-gate 	ibdm_hca_list_t		*ibdm_hca_list_head;
2347c478bd9Sstevel@tonic-gate 	ibdm_hca_list_t		*ibdm_hca_list_tail;
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate 	ibdm_dp_gidinfo_t	*ibdm_dp_gidlist_head;
2377c478bd9Sstevel@tonic-gate 	ibdm_dp_gidinfo_t	*ibdm_dp_gidlist_tail;
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 	kcondvar_t		ibdm_probe_cv;
2407c478bd9Sstevel@tonic-gate 	kcondvar_t		ibdm_busy_cv;
24100a3eaf3SRamaswamy Tummala 	kcondvar_t		ibdm_port_settle_cv;
2427c478bd9Sstevel@tonic-gate 	uint32_t		ibdm_ngid_probes_in_progress;
2439d3d2ed0Shiremath 	uint64_t		ibdm_transactionID;
2447c478bd9Sstevel@tonic-gate 	uint32_t		ibdm_ngids;
2457c478bd9Sstevel@tonic-gate 	uint32_t		ibdm_busy;
2467c478bd9Sstevel@tonic-gate 	int			ibdm_state;
2477c478bd9Sstevel@tonic-gate 	ibt_clnt_hdl_t		ibdm_ibt_clnt_hdl;
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate 	/*
2507c478bd9Sstevel@tonic-gate 	 * These are callback routines registered by the IB nexus driver.
2517c478bd9Sstevel@tonic-gate 	 * These callbacks are used to inform the IB nexus driver about
2527c478bd9Sstevel@tonic-gate 	 * the arrival/removal of HCA and IOC's
2537c478bd9Sstevel@tonic-gate 	 */
2547c478bd9Sstevel@tonic-gate 	ibdm_callback_t		ibdm_ibnex_callback;
255add2b70bSpramodbg 
256add2b70bSpramodbg 	/* Flag indicating - prev_iou during sweep */
257add2b70bSpramodbg 	int			ibdm_prev_iou;
2587c478bd9Sstevel@tonic-gate } ibdm_t;
2597c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_mutex, ibdm_s::{ibdm_ibt_clnt_hdl
2607c478bd9Sstevel@tonic-gate 	ibdm_busy ibdm_state}))
2617c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(ibdm_s::ibdm_ibt_clnt_hdl))
2627c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_hl_mutex,
2637c478bd9Sstevel@tonic-gate 	ibdm_s::{ibdm_hca_list_head ibdm_hca_list_tail}))
2647c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(ibdm_s::ibdm_ibnex_mutex,
2657c478bd9Sstevel@tonic-gate 	ibdm_s::ibdm_ibnex_callback))
2667c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("Serialized access by cv", ibdm_s))
2677c478bd9Sstevel@tonic-gate _NOTE(LOCK_ORDER(ibdm_s::ibdm_mutex ibdm_dp_gidinfo_s::gl_mutex))
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate /* valid values for ibdm_state */
2707c478bd9Sstevel@tonic-gate #define	IBDM_LOCKS_ALLOCED	0x01		/* global locks alloced */
2717c478bd9Sstevel@tonic-gate #define	IBDM_CVS_ALLOCED	0x02		/* global "cv"s alloced */
2727c478bd9Sstevel@tonic-gate #define	IBDM_IBT_ATTACHED	0x04		/* ibt_attach() called */
2737c478bd9Sstevel@tonic-gate #define	IBDM_HCA_ATTACHED	0x08		/* ibdm_handle_hca() called */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate #define	IBDM_8_BIT_MASK		0x00FF
2767c478bd9Sstevel@tonic-gate #define	IBDM_16_BIT_MASK	0xFFFF
2777c478bd9Sstevel@tonic-gate #define	IBDM_RETRY_COUNT	0x2
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate #define	IBDM_BUSY		0x1
2807c478bd9Sstevel@tonic-gate #define	IBDM_PROBE_IN_PROGRESS	0x2
28153c1b7a3Seota #define	IBDM_CISCO_PROBE	0x4
28253c1b7a3Seota #define	IBDM_CISCO_PROBE_DONE	0x8
2837c478bd9Sstevel@tonic-gate 
28453c1b7a3Seota /*
28553c1b7a3Seota  * Device Management MAD packet format
28653c1b7a3Seota  * +--------+------------+------------+------------+------------+
28753c1b7a3Seota  * | offset |   byte 0   |   byte 1   |   byte 2   |   byte 3   |
28853c1b7a3Seota  * +--------+------------+------------+------------+------------+ --
28953c1b7a3Seota  * |   0    |                                                   |  ^
29053c1b7a3Seota  * +--------+                                                   | sizeof(
29153c1b7a3Seota  * |   ...  |              Common MAD Header                    | ib_mad_hdr_t)
29253c1b7a3Seota  * +--------+                                                   |  | (A)
29353c1b7a3Seota  * |   20   |                                                   |  v
29453c1b7a3Seota  * +--------+------------+------------+------------+------------+ --
29553c1b7a3Seota  * |   24   |                                                   |  ^
29653c1b7a3Seota  * +--------+                                                   |  |
29753c1b7a3Seota  * |   ...  |              RMPP Header                          |  |
29853c1b7a3Seota  * +--------+                                                   |  |
29953c1b7a3Seota  * |   32   |                                                   |  |
30053c1b7a3Seota  * +--------+------------+------------+------------+------------+  |
30153c1b7a3Seota  * |   36   |                                                   |  |
30253c1b7a3Seota  * +--------+              Access_Key                           |
30353c1b7a3Seota  * |   40   |                                                   | IBDM_DM_MAD_
30453c1b7a3Seota  * +--------+------------+------------+------------+------------+ HDR_SZ
30553c1b7a3Seota  * |   44   |  KeyType   |              reserved                |    (B)
30653c1b7a3Seota  * +--------+------------+------------+------------+------------+  |
30753c1b7a3Seota  * |   48   |                                                   |  |
30853c1b7a3Seota  * +--------+                                                   |  |
30953c1b7a3Seota  * |   52   |              Reserved                             |  |
31053c1b7a3Seota  * +--------+                                                   |  |
31153c1b7a3Seota  * |   56   |                                                   |  |
31253c1b7a3Seota  * +--------+------------+------------+------------+------------+  |
31353c1b7a3Seota  * |   60   |       Change_ID         |     ComponentMask       |  v
31453c1b7a3Seota  * +--------+------------+------------+------------+------------+ --
31553c1b7a3Seota  * |   64   |                                                   |  ^
31653c1b7a3Seota  * +--------+                                                   | IBDM_MAD_SIZE
31753c1b7a3Seota  * |   ...  |              Device Management Data               | - (A) - (B)
31853c1b7a3Seota  * +--------+                                                   |  |
31953c1b7a3Seota  * |  252   |                                                   |  v
32053c1b7a3Seota  * +--------+------------+------------+------------+------------+ --
32153c1b7a3Seota  */
3227c478bd9Sstevel@tonic-gate #define	IBDM_MAD_SIZE		256
32353c1b7a3Seota #define	IBDM_DM_MAD_HDR_SZ	40
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate #define	IBDM_DFT_TIMEOUT	4
3267c478bd9Sstevel@tonic-gate #define	IBDM_DFT_NRETRIES	3
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate #define	IBDM_ENABLE_TASKQ_HANDLING	1
3297c478bd9Sstevel@tonic-gate #define	IBDM_DISABLE_TASKQ_HANLDING	0
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate typedef struct ibdm_saa_event_arg_s {
3327c478bd9Sstevel@tonic-gate 	ibmf_saa_handle_t ibmf_saa_handle;
3337c478bd9Sstevel@tonic-gate 	ibmf_saa_subnet_event_t ibmf_saa_event;
3347c478bd9Sstevel@tonic-gate 	ibmf_saa_event_details_t event_details;
3357c478bd9Sstevel@tonic-gate 	void *callback_arg;
3367c478bd9Sstevel@tonic-gate } ibdm_saa_event_arg_t;
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate #define	IBDM_TIMEOUT_VALUE(t)	(drv_usectohz(t * 1000000))
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate #define	IBDM_OUT_IBMFMSG_MADHDR(msg)\
3417c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_send.im_bufs_mad_hdr)
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_MADHDR(msg)\
3447c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_mad_hdr)
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_STATUS(msg)\
3477c478bd9Sstevel@tonic-gate 		b2h16(msg->im_msgbufs_recv.im_bufs_mad_hdr->Status)
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_ATTR(msg)\
3507c478bd9Sstevel@tonic-gate 		b2h16(msg->im_msgbufs_recv.im_bufs_mad_hdr->AttributeID)
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG_ATTRMOD(msg)\
3537c478bd9Sstevel@tonic-gate 		b2h32(msg->im_msgbufs_recv.im_bufs_mad_hdr->AttributeModifier)
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2IOU(msg)	(ib_dm_io_unitinfo_t *)\
3567c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2IOC(msg)	(ib_dm_ioc_ctrl_profile_t *)\
3597c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2SRVENT(msg)	(ib_dm_srv_t *)\
3627c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate #define	IBDM_IN_IBMFMSG2DIAGCODE(msg)	(uint32_t *)\
3657c478bd9Sstevel@tonic-gate 		(msg->im_msgbufs_recv.im_bufs_cl_data)
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate #define	IBDM_GIDINFO2IOCINFO(gid_info, idx) \
3687c478bd9Sstevel@tonic-gate 		(ibdm_ioc_info_t *)&gid_info->gl_iou->iou_ioc_info[idx];
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate #define	IBDM_IS_IOC_NUM_INVALID(ioc_no, gid_info)\
3717c478bd9Sstevel@tonic-gate 		((ioc_no < 1) || (ioc_no >\
3727c478bd9Sstevel@tonic-gate 			gid_info->gl_iou->iou_info.iou_num_ctrl_slots))
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate #define	IBDM_INVALID_PKEY(pkey)	\
3757c478bd9Sstevel@tonic-gate 		(((pkey) == IB_PKEY_INVALID_FULL) || \
3767c478bd9Sstevel@tonic-gate 		((pkey) == IB_PKEY_INVALID_LIMITED))
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate #ifdef DEBUG
3797c478bd9Sstevel@tonic-gate 
38053c1b7a3Seota void	ibdm_dump_mad_hdr(ib_mad_hdr_t *);
3817c478bd9Sstevel@tonic-gate void	ibdm_dump_ibmf_msg(ibmf_msg_t *, int);
3827c478bd9Sstevel@tonic-gate void	ibdm_dump_path_info(sa_path_record_t *);
38353c1b7a3Seota void	ibdm_dump_classportinfo(ib_mad_classportinfo_t *);
3847c478bd9Sstevel@tonic-gate void	ibdm_dump_iounitinfo(ib_dm_io_unitinfo_t *);
3857c478bd9Sstevel@tonic-gate void	ibdm_dump_ioc_profile(ib_dm_ioc_ctrl_profile_t *);
3867c478bd9Sstevel@tonic-gate void	ibdm_dump_service_entries(ib_dm_srv_t *);
3877c478bd9Sstevel@tonic-gate void	ibdm_dump_sweep_fabric_timestamp(int);
3887c478bd9Sstevel@tonic-gate 
38953c1b7a3Seota #define	ibdm_dump_mad_hdr(a)		ibdm_dump_mad_hdr(a)
3907c478bd9Sstevel@tonic-gate #define	ibdm_dump_ibmf_msg(a, b)	ibdm_dump_ibmf_msg(a, b)
3917c478bd9Sstevel@tonic-gate #define	ibdm_dump_path_info(a)		ibdm_dump_path_info(a)
3927c478bd9Sstevel@tonic-gate #define	ibdm_dump_classportinfo(a)	ibdm_dump_classportinfo(a)
3937c478bd9Sstevel@tonic-gate #define	ibdm_dump_iounitinfo(a)		ibdm_dump_iounitinfo(a)
3947c478bd9Sstevel@tonic-gate #define	ibdm_dump_ioc_profile(a)	ibdm_dump_ioc_profile(a)
3957c478bd9Sstevel@tonic-gate #define	ibdm_dump_service_entries(a)	ibdm_dump_service_entries(a)
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate #else
3987c478bd9Sstevel@tonic-gate 
39953c1b7a3Seota #define	ibdm_dump_mad_hdr(a)
4007c478bd9Sstevel@tonic-gate #define	ibdm_dump_ibmf_msg(a, b)
4017c478bd9Sstevel@tonic-gate #define	ibdm_dump_path_info(a)
4027c478bd9Sstevel@tonic-gate #define	ibdm_dump_classportinfo(a)
4037c478bd9Sstevel@tonic-gate #define	ibdm_dump_iounitinfo(a)
4047c478bd9Sstevel@tonic-gate #define	ibdm_dump_ioc_profile(a)
4057c478bd9Sstevel@tonic-gate #define	ibdm_dump_service_entries(a)
4067c478bd9Sstevel@tonic-gate #define	ibdm_dump_sweep_fabric_timestamp(a)
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate #endif
4097c478bd9Sstevel@tonic-gate 
4107c478bd9Sstevel@tonic-gate #ifdef __cplusplus
4117c478bd9Sstevel@tonic-gate }
4127c478bd9Sstevel@tonic-gate #endif
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate #endif	/* _SYS_IB_MGT_IBDM_IBDM_IMPL_H */
415