xref: /onnv-gate/usr/src/lib/mpapi/libmpscsi_vhci/common/mp_utils.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM #ifndef _MP_UTILS_H
26*7836SJohn.Forte@Sun.COM #define	_MP_UTILS_H
27*7836SJohn.Forte@Sun.COM 
28*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
29*7836SJohn.Forte@Sun.COM extern "C" {
30*7836SJohn.Forte@Sun.COM #endif
31*7836SJohn.Forte@Sun.COM 
32*7836SJohn.Forte@Sun.COM #include <mpapi.h>
33*7836SJohn.Forte@Sun.COM #include <sys/scsi/adapters/mpapi_impl.h>
34*7836SJohn.Forte@Sun.COM 
35*7836SJohn.Forte@Sun.COM #include <sys/types.h>
36*7836SJohn.Forte@Sun.COM #include <libsysevent.h>
37*7836SJohn.Forte@Sun.COM #include <syslog.h>
38*7836SJohn.Forte@Sun.COM #include <pthread.h>
39*7836SJohn.Forte@Sun.COM 
40*7836SJohn.Forte@Sun.COM /* Default bytes */
41*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_LU_LIST		4096
42*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_INIT_PORT_LIST	1024
43*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_PATH_LIST		1024
44*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_DEV_PROD		1024
45*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_TPG			1024
46*7836SJohn.Forte@Sun.COM #define	DEFAULT_BUFFER_SIZE_LOADBALANCE		1024
47*7836SJohn.Forte@Sun.COM 
48*7836SJohn.Forte@Sun.COM 
49*7836SJohn.Forte@Sun.COM /* Node to hold pointer to client callback */
50*7836SJohn.Forte@Sun.COM typedef struct _property_node
51*7836SJohn.Forte@Sun.COM {
52*7836SJohn.Forte@Sun.COM 	MP_OBJECT_PROPERTY_FN 	pClientFn;
53*7836SJohn.Forte@Sun.COM 	void 			*pCallerData;
54*7836SJohn.Forte@Sun.COM 
55*7836SJohn.Forte@Sun.COM } PROPERTY_CALLBACK_NODE;
56*7836SJohn.Forte@Sun.COM 
57*7836SJohn.Forte@Sun.COM 
58*7836SJohn.Forte@Sun.COM /* Node to hold pointer to client callback */
59*7836SJohn.Forte@Sun.COM typedef struct _visibility_node
60*7836SJohn.Forte@Sun.COM {
61*7836SJohn.Forte@Sun.COM 	MP_OBJECT_VISIBILITY_FN 	pClientFn;
62*7836SJohn.Forte@Sun.COM 	void 				*pCallerData;
63*7836SJohn.Forte@Sun.COM 
64*7836SJohn.Forte@Sun.COM } VISIBILITY_CALLBACK_NODE;
65*7836SJohn.Forte@Sun.COM 
66*7836SJohn.Forte@Sun.COM 
67*7836SJohn.Forte@Sun.COM /* Global array to hold client callbacks */
68*7836SJohn.Forte@Sun.COM extern
69*7836SJohn.Forte@Sun.COM PROPERTY_CALLBACK_NODE   g_Property_Callback_List[MP_OBJECT_TYPE_MAX + 1];
70*7836SJohn.Forte@Sun.COM 
71*7836SJohn.Forte@Sun.COM /* Global array to hold client callbacks */
72*7836SJohn.Forte@Sun.COM extern
73*7836SJohn.Forte@Sun.COM VISIBILITY_CALLBACK_NODE g_Visibility_Callback_List[MP_OBJECT_TYPE_MAX + 1];
74*7836SJohn.Forte@Sun.COM 
75*7836SJohn.Forte@Sun.COM 
76*7836SJohn.Forte@Sun.COM /* Global variable to hold this pligin's ID */
77*7836SJohn.Forte@Sun.COM extern MP_UINT32	g_pluginOwnerID;
78*7836SJohn.Forte@Sun.COM 
79*7836SJohn.Forte@Sun.COM /* Global variable to hold scsi_vhci file descriptor */
80*7836SJohn.Forte@Sun.COM extern int		g_scsi_vhci_fd;
81*7836SJohn.Forte@Sun.COM 
82*7836SJohn.Forte@Sun.COM /* Global variable to hold sysevent handle */
83*7836SJohn.Forte@Sun.COM extern sysevent_handle_t *g_SysEventHandle;
84*7836SJohn.Forte@Sun.COM 
85*7836SJohn.Forte@Sun.COM /* Mutexes to make array modify/read thread safe */
86*7836SJohn.Forte@Sun.COM extern pthread_mutex_t g_visa_mutex;
87*7836SJohn.Forte@Sun.COM extern pthread_mutex_t g_prop_mutex;
88*7836SJohn.Forte@Sun.COM 
89*7836SJohn.Forte@Sun.COM 
90*7836SJohn.Forte@Sun.COM 
91*7836SJohn.Forte@Sun.COM /* Used to add debug (log) info */
92*7836SJohn.Forte@Sun.COM void log(int priority, const char *routine, char *msg, ...);
93*7836SJohn.Forte@Sun.COM 
94*7836SJohn.Forte@Sun.COM /* Returns an MP_STATUS code for an mp_iocdata_t.mp_errno code */
95*7836SJohn.Forte@Sun.COM MP_STATUS getStatus4ErrorCode(int driverError);
96*7836SJohn.Forte@Sun.COM 
97*7836SJohn.Forte@Sun.COM /* Returns an MP_OID_LIST that will hold "size" MP_OID elements */
98*7836SJohn.Forte@Sun.COM MP_OID_LIST *createOidList(int size);
99*7836SJohn.Forte@Sun.COM 
100*7836SJohn.Forte@Sun.COM /* Initializes the sysevent framework */
101*7836SJohn.Forte@Sun.COM MP_STATUS init_sysevents();
102*7836SJohn.Forte@Sun.COM 
103*7836SJohn.Forte@Sun.COM /* Implementation function for MP_GetAssociatedTPGOidList() */
104*7836SJohn.Forte@Sun.COM MP_STATUS getAssociatedTPGOidList(MP_OID oid, MP_OID_LIST **ppList);
105*7836SJohn.Forte@Sun.COM 
106*7836SJohn.Forte@Sun.COM /* Implementation function for MP_GetTargetPortGroupProperties() */
107*7836SJohn.Forte@Sun.COM MP_STATUS getTargetPortGroupProperties(MP_OID oid,
108*7836SJohn.Forte@Sun.COM 	MP_TARGET_PORT_GROUP_PROPERTIES *pProps);
109*7836SJohn.Forte@Sun.COM 
110*7836SJohn.Forte@Sun.COM /* Implementation function for MP_GetTargetPortOidList() */
111*7836SJohn.Forte@Sun.COM MP_STATUS getTargetPortOidList(MP_OID oid, MP_OID_LIST **ppList);
112*7836SJohn.Forte@Sun.COM 
113*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
114*7836SJohn.Forte@Sun.COM }
115*7836SJohn.Forte@Sun.COM #endif
116*7836SJohn.Forte@Sun.COM 
117*7836SJohn.Forte@Sun.COM #endif	/* _MP_UTILS_H */
118