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