1*10652SHyon.Kim@Sun.COM /*
2*10652SHyon.Kim@Sun.COM * ************************************************************************
3*10652SHyon.Kim@Sun.COM * Description
4*10652SHyon.Kim@Sun.COM * HBAAPILIB.c - Implements a sample common (wrapper) HBA API library
5*10652SHyon.Kim@Sun.COM *
6*10652SHyon.Kim@Sun.COM * License:
7*10652SHyon.Kim@Sun.COM * The contents of this file are subject to the SNIA Public License
8*10652SHyon.Kim@Sun.COM * Version 1.0 (the "License"); you may not use this file except in
9*10652SHyon.Kim@Sun.COM * compliance with the License. You may obtain a copy of the License at
10*10652SHyon.Kim@Sun.COM *
11*10652SHyon.Kim@Sun.COM * /http://www.snia.org/English/Resources/Code/OpenSource.html
12*10652SHyon.Kim@Sun.COM *
13*10652SHyon.Kim@Sun.COM * Software distributed under the License is distributed on an "AS IS"
14*10652SHyon.Kim@Sun.COM * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15*10652SHyon.Kim@Sun.COM * the License for the specific language governing rights and limitations
16*10652SHyon.Kim@Sun.COM * under the License.
17*10652SHyon.Kim@Sun.COM *
18*10652SHyon.Kim@Sun.COM * The Original Code is SNIA HBA API Wrapper Library
19*10652SHyon.Kim@Sun.COM *
20*10652SHyon.Kim@Sun.COM * The Initial Developer of the Original Code is:
21*10652SHyon.Kim@Sun.COM * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
22*10652SHyon.Kim@Sun.COM *
23*10652SHyon.Kim@Sun.COM * Contributor(s):
24*10652SHyon.Kim@Sun.COM * Tuan Lam, QLogic Corp. (t_lam@qlc.com)
25*10652SHyon.Kim@Sun.COM * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com)
26*10652SHyon.Kim@Sun.COM * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com)
27*10652SHyon.Kim@Sun.COM * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
28*10652SHyon.Kim@Sun.COM *
29*10652SHyon.Kim@Sun.COM * ************************************************************************
30*10652SHyon.Kim@Sun.COM *
31*10652SHyon.Kim@Sun.COM * Adding on SM-HBA support
32*10652SHyon.Kim@Sun.COM *
33*10652SHyon.Kim@Sun.COM * The implementation includes Three different categories functions to support
34*10652SHyon.Kim@Sun.COM * both HBAAPI and SM-HBA through the same library.
35*10652SHyon.Kim@Sun.COM *
36*10652SHyon.Kim@Sun.COM * SM-HBA unique interface:
37*10652SHyon.Kim@Sun.COM * 1. CHECKLIBRARYANDVERSION(SMHBA) : match SMHBA VSL
38*10652SHyon.Kim@Sun.COM * Or checking specifically if version is SMHBA beforehand.
39*10652SHyon.Kim@Sun.COM * 2. resolved to ftable.smhbafunctiontable.{interface}
40*10652SHyon.Kim@Sun.COM * HBAAPIV2 unique functions
41*10652SHyon.Kim@Sun.COM * 1. CHECKLIBRARYANDVERSION(HBAAPIV2) : validate and match HBAAPI V2 VSL.
42*10652SHyon.Kim@Sun.COM * Or checking specifically if version is HBAAPIV2 beforehand.
43*10652SHyon.Kim@Sun.COM * 2. resolved to ftable.functiontable.{interface}
44*10652SHyon.Kim@Sun.COM * Common interface between SM-HBA and HBAAPIV2.
45*10652SHyon.Kim@Sun.COM * 1. CHECKLIBRARY() : to validate the VSL.
46*10652SHyon.Kim@Sun.COM * 2. FUNCCOMMON macro to map the appropriate entry point table
47*10652SHyon.Kim@Sun.COM * (union ftable).
48*10652SHyon.Kim@Sun.COM * 3. If the interface is not supported by HBAAPI(Version 1)
49*10652SHyon.Kim@Sun.COM * the funtiion ptr will be set to NULL.
50*10652SHyon.Kim@Sun.COM * Common interface between HBAAPI and HBAAPIV2.
51*10652SHyon.Kim@Sun.COM * 1. Check if version is not SMHBA).
52*10652SHyon.Kim@Sun.COM * 2. ftable.functiontalbe.(interface)
53*10652SHyon.Kim@Sun.COM *
54*10652SHyon.Kim@Sun.COM * ************************************************************************
55*10652SHyon.Kim@Sun.COM */
56*10652SHyon.Kim@Sun.COM /*
57*10652SHyon.Kim@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
58*10652SHyon.Kim@Sun.COM * Use is subject to license terms.
59*10652SHyon.Kim@Sun.COM */
60*10652SHyon.Kim@Sun.COM
61*10652SHyon.Kim@Sun.COM #ifdef WIN32
62*10652SHyon.Kim@Sun.COM #include <windows.h>
63*10652SHyon.Kim@Sun.COM #include <string.h>
64*10652SHyon.Kim@Sun.COM /*
65*10652SHyon.Kim@Sun.COM * Next define forces entry points in the dll to be exported
66*10652SHyon.Kim@Sun.COM * See hbaapi.h to see what it does.
67*10652SHyon.Kim@Sun.COM */
68*10652SHyon.Kim@Sun.COM #define HBAAPI_EXPORTS
69*10652SHyon.Kim@Sun.COM #else
70*10652SHyon.Kim@Sun.COM #include <dlfcn.h>
71*10652SHyon.Kim@Sun.COM #include <strings.h>
72*10652SHyon.Kim@Sun.COM #endif
73*10652SHyon.Kim@Sun.COM #include <stdio.h>
74*10652SHyon.Kim@Sun.COM #include <time.h>
75*10652SHyon.Kim@Sun.COM #include "smhbaapi.h"
76*10652SHyon.Kim@Sun.COM #include "vendorsmhbaapi.h"
77*10652SHyon.Kim@Sun.COM #include <stdlib.h>
78*10652SHyon.Kim@Sun.COM #ifdef USESYSLOG
79*10652SHyon.Kim@Sun.COM #include <syslog.h>
80*10652SHyon.Kim@Sun.COM #endif
81*10652SHyon.Kim@Sun.COM #ifdef SOLARIS
82*10652SHyon.Kim@Sun.COM #include <link.h>
83*10652SHyon.Kim@Sun.COM #include <limits.h>
84*10652SHyon.Kim@Sun.COM static int *handle;
85*10652SHyon.Kim@Sun.COM static Link_map *map, *mp;
86*10652SHyon.Kim@Sun.COM #endif
87*10652SHyon.Kim@Sun.COM
88*10652SHyon.Kim@Sun.COM /*
89*10652SHyon.Kim@Sun.COM * LIBRARY_NUM is a shortcut to figure out which library we need to call.
90*10652SHyon.Kim@Sun.COM * The top 16 bits of handle are the library index
91*10652SHyon.Kim@Sun.COM */
92*10652SHyon.Kim@Sun.COM #define LIBRARY_NUM(handle) ((handle)>>16)
93*10652SHyon.Kim@Sun.COM
94*10652SHyon.Kim@Sun.COM /*
95*10652SHyon.Kim@Sun.COM * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
96*10652SHyon.Kim@Sun.COM * with all upper 16 bits set to 0
97*10652SHyon.Kim@Sun.COM */
98*10652SHyon.Kim@Sun.COM #define VENDOR_HANDLE(handle) ((handle)&0xFFFF)
99*10652SHyon.Kim@Sun.COM
100*10652SHyon.Kim@Sun.COM #define HBA_HANDLE_FROM_LOCAL(library, vendor) \
101*10652SHyon.Kim@Sun.COM (((library)<<16) | ((vendor)&0x0000FFFF))
102*10652SHyon.Kim@Sun.COM
103*10652SHyon.Kim@Sun.COM int _hbaapi_debuglevel = 0;
104*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3)
105*10652SHyon.Kim@Sun.COM
106*10652SHyon.Kim@Sun.COM #if defined(USESYSLOG) && defined(USELOGFILE)
107*10652SHyon.Kim@Sun.COM FILE *_hbaapi_debug_fd = NULL;
108*10652SHyon.Kim@Sun.COM int _hbaapi_sysloginit = 0;
109*10652SHyon.Kim@Sun.COM #undef DEBUG
110*10652SHyon.Kim@Sun.COM #ifdef WIN32
111*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3)\
112*10652SHyon.Kim@Sun.COM if ((L) <= _hbaapi_debuglevel) {\
113*10652SHyon.Kim@Sun.COM if (_hbaapi_sysloginit == 0) {\
114*10652SHyon.Kim@Sun.COM openlog("HBAAPI", LOG_PID|LOG_ODELAY, LOG_USER);\
115*10652SHyon.Kim@Sun.COM _hbaapi_sysloginit = 1;\
116*10652SHyon.Kim@Sun.COM }\
117*10652SHyon.Kim@Sun.COM syslog(LOG_INFO, (STR), (A1), (A2), (A3));\
118*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd == NULL) {\
119*10652SHyon.Kim@Sun.COM char _logFile[MAX_PATH]; \
120*10652SHyon.Kim@Sun.COM GetTempPath(MAX_PATH, _logFile); \
121*10652SHyon.Kim@Sun.COM strcat(_logFile, "HBAAPI.log"); \
122*10652SHyon.Kim@Sun.COM _hbaapi_debug_fd = fopen(_logFile, "a");\
123*10652SHyon.Kim@Sun.COM }\
124*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd != NULL) {\
125*10652SHyon.Kim@Sun.COM fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
126*10652SHyon.Kim@Sun.COM }\
127*10652SHyon.Kim@Sun.COM }
128*10652SHyon.Kim@Sun.COM #else /* WIN32 */
129*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3)\
130*10652SHyon.Kim@Sun.COM if ((L) <= _hbaapi_debuglevel) {\
131*10652SHyon.Kim@Sun.COM if (_hbaapi_sysloginit == 0) {\
132*10652SHyon.Kim@Sun.COM openlog("HBAAPI", LOG_PID|LOG_ODELAY, LOG_USER);\
133*10652SHyon.Kim@Sun.COM _hbaapi_sysloginit = 1;\
134*10652SHyon.Kim@Sun.COM }\
135*10652SHyon.Kim@Sun.COM syslog(LOG_INFO, (STR), (A1), (A2), (A3));\
136*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd == NULL) {\
137*10652SHyon.Kim@Sun.COM _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
138*10652SHyon.Kim@Sun.COM }\
139*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd != NULL) {\
140*10652SHyon.Kim@Sun.COM fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
141*10652SHyon.Kim@Sun.COM }\
142*10652SHyon.Kim@Sun.COM }
143*10652SHyon.Kim@Sun.COM #endif /* WIN32 */
144*10652SHyon.Kim@Sun.COM
145*10652SHyon.Kim@Sun.COM #else /* Not both USESYSLOG and USELOGFILE */
146*10652SHyon.Kim@Sun.COM #if defined(USESYSLOG)
147*10652SHyon.Kim@Sun.COM int _hbaapi_sysloginit = 0;
148*10652SHyon.Kim@Sun.COM #undef DEBUG
149*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3) \
150*10652SHyon.Kim@Sun.COM if ((L) <= _hbaapi_debuglevel) {\
151*10652SHyon.Kim@Sun.COM if (_hbaapi_sysloginit == 0) {\
152*10652SHyon.Kim@Sun.COM openlog("HBAAPI", LOG_PID|LOG_ODELAY, LOG_USER);\
153*10652SHyon.Kim@Sun.COM _hbaapi_sysloginit = 1;\
154*10652SHyon.Kim@Sun.COM }\
155*10652SHyon.Kim@Sun.COM syslog(LOG_DEBUG, (STR), (A1), (A2), (A3));\
156*10652SHyon.Kim@Sun.COM }
157*10652SHyon.Kim@Sun.COM #endif /* USESYSLOG */
158*10652SHyon.Kim@Sun.COM #if defined(USELOGFILE)
159*10652SHyon.Kim@Sun.COM FILE *_hbaapi_debug_fd = NULL;
160*10652SHyon.Kim@Sun.COM #undef DEBUG
161*10652SHyon.Kim@Sun.COM #ifdef WIN32
162*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3) \
163*10652SHyon.Kim@Sun.COM if ((L) <= _hbaapi_debuglevel) {\
164*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd == NULL) {\
165*10652SHyon.Kim@Sun.COM char _logFile[MAX_PATH]; \
166*10652SHyon.Kim@Sun.COM GetTempPath(MAX_PATH, _logFile); \
167*10652SHyon.Kim@Sun.COM strcat(_logFile, "HBAAPI.log"); \
168*10652SHyon.Kim@Sun.COM _hbaapi_debug_fd = fopen(_logFile, "a");\
169*10652SHyon.Kim@Sun.COM }\
170*10652SHyon.Kim@Sun.COM }
171*10652SHyon.Kim@Sun.COM #else /* WIN32 */
172*10652SHyon.Kim@Sun.COM #define DEBUG(L, STR, A1, A2, A3) \
173*10652SHyon.Kim@Sun.COM if ((L) <= _hbaapi_debuglevel) {\
174*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd == NULL) {\
175*10652SHyon.Kim@Sun.COM _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
176*10652SHyon.Kim@Sun.COM }\
177*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd != NULL) { \
178*10652SHyon.Kim@Sun.COM fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
179*10652SHyon.Kim@Sun.COM }\
180*10652SHyon.Kim@Sun.COM }
181*10652SHyon.Kim@Sun.COM #endif /* WIN32 */
182*10652SHyon.Kim@Sun.COM #endif /* USELOGFILE */
183*10652SHyon.Kim@Sun.COM #endif /* Not both USELOGFILE and USESYSLOG */
184*10652SHyon.Kim@Sun.COM
185*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
186*10652SHyon.Kim@Sun.COM #include <pthread.h>
187*10652SHyon.Kim@Sun.COM /*
188*10652SHyon.Kim@Sun.COM * When multiple mutex's are grabed, they must be always be grabbed in
189*10652SHyon.Kim@Sun.COM * the same order, or deadlock can result. There are three levels
190*10652SHyon.Kim@Sun.COM * of mutex's involved in this API. If LL_mutex is grabbed, always grap
191*10652SHyon.Kim@Sun.COM * it first. If AL_mutex is grabbed, it may not be grabbed before
192*10652SHyon.Kim@Sun.COM * LL_mutex. If grabbed in a multi grab sequence, the mutex's protecting
193*10652SHyon.Kim@Sun.COM * the callback lists must always be grabbed last and release before calling
194*10652SHyon.Kim@Sun.COM * a vendor specific library function that might invoke a callback function
195*10652SHyon.Kim@Sun.COM * on the same thread.
196*10652SHyon.Kim@Sun.COM */
197*10652SHyon.Kim@Sun.COM #define GRAB_MUTEX(M) grab_mutex(M)
198*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX(M) release_mutex(M)
199*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX_RETURN(M, RET) release_mutex(M); return (RET)
200*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
201*10652SHyon.Kim@Sun.COM #define GRAB_MUTEX(m) EnterCriticalSection(m)
202*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX(m) LeaveCriticalSection(m)
203*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX_RETURN(m, RET) LeaveCriticalSection(m); return (RET)
204*10652SHyon.Kim@Sun.COM #else
205*10652SHyon.Kim@Sun.COM #define GRAB_MUTEX(M)
206*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX(M)
207*10652SHyon.Kim@Sun.COM #define RELEASE_MUTEX_RETURN(M, RET) return (RET)
208*10652SHyon.Kim@Sun.COM #endif
209*10652SHyon.Kim@Sun.COM
210*10652SHyon.Kim@Sun.COM /*
211*10652SHyon.Kim@Sun.COM * Vendor library information
212*10652SHyon.Kim@Sun.COM */
213*10652SHyon.Kim@Sun.COM typedef enum {
214*10652SHyon.Kim@Sun.COM HBA_LIBRARY_UNKNOWN,
215*10652SHyon.Kim@Sun.COM HBA_LIBRARY_LOADED,
216*10652SHyon.Kim@Sun.COM HBA_LIBRARY_NOT_LOADED
217*10652SHyon.Kim@Sun.COM } HBA_LIBRARY_STATUS;
218*10652SHyon.Kim@Sun.COM
219*10652SHyon.Kim@Sun.COM typedef enum {
220*10652SHyon.Kim@Sun.COM UNKNOWN = 1,
221*10652SHyon.Kim@Sun.COM SMHBA,
222*10652SHyon.Kim@Sun.COM HBAAPIV2,
223*10652SHyon.Kim@Sun.COM HBAAPI
224*10652SHyon.Kim@Sun.COM } LIBRARY_VERSION;
225*10652SHyon.Kim@Sun.COM
226*10652SHyon.Kim@Sun.COM typedef struct hba_library_info {
227*10652SHyon.Kim@Sun.COM struct hba_library_info
228*10652SHyon.Kim@Sun.COM *next;
229*10652SHyon.Kim@Sun.COM #ifdef WIN32
230*10652SHyon.Kim@Sun.COM HINSTANCE hLibrary; /* Handle to a loaded DLL */
231*10652SHyon.Kim@Sun.COM #else
232*10652SHyon.Kim@Sun.COM char *LibraryName;
233*10652SHyon.Kim@Sun.COM void* hLibrary; /* Handle to a loaded DLL */
234*10652SHyon.Kim@Sun.COM #endif
235*10652SHyon.Kim@Sun.COM char *LibraryPath;
236*10652SHyon.Kim@Sun.COM LIBRARY_VERSION version; /* resolve union */
237*10652SHyon.Kim@Sun.COM HBA_UINT32 numOfAdapters;
238*10652SHyon.Kim@Sun.COM union {
239*10652SHyon.Kim@Sun.COM SMHBA_ENTRYPOINTS smhbafunctionTable; /* smhba function pointers */
240*10652SHyon.Kim@Sun.COM HBA_ENTRYPOINTSV2 functionTable; /* hba api function pointers */
241*10652SHyon.Kim@Sun.COM } ftable;
242*10652SHyon.Kim@Sun.COM HBA_LIBRARY_STATUS status; /* info on this library */
243*10652SHyon.Kim@Sun.COM HBA_UINT32 index;
244*10652SHyon.Kim@Sun.COM } HBA_LIBRARY_INFO, *PHBA_LIBRARY_INFO;
245*10652SHyon.Kim@Sun.COM
246*10652SHyon.Kim@Sun.COM #define ARE_WE_INITED() \
247*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) { \
248*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_NOT_LOADED); \
249*10652SHyon.Kim@Sun.COM }
250*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *_hbaapi_librarylist = NULL;
251*10652SHyon.Kim@Sun.COM HBA_UINT32 _hbaapi_total_library_count = 0;
252*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
253*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_LL_mutex = PTHREAD_MUTEX_INITIALIZER;
254*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
255*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_LL_mutex;
256*10652SHyon.Kim@Sun.COM #endif
257*10652SHyon.Kim@Sun.COM
258*10652SHyon.Kim@Sun.COM /*
259*10652SHyon.Kim@Sun.COM * Macro to use the right function table between smhba and hbaapi.
260*10652SHyon.Kim@Sun.COM */
261*10652SHyon.Kim@Sun.COM #define FUNCTABLE(lib_infop) \
262*10652SHyon.Kim@Sun.COM ((lib_infop->version == SMHBA) ? \
263*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable : \
264*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable);
265*10652SHyon.Kim@Sun.COM
266*10652SHyon.Kim@Sun.COM /*
267*10652SHyon.Kim@Sun.COM * Macro to use the right function ptr between smhba and hbaapi function table.
268*10652SHyon.Kim@Sun.COM * Should be used for an interface common to SM-HBA and HBAAPIV2.
269*10652SHyon.Kim@Sun.COM */
270*10652SHyon.Kim@Sun.COM #define FUNCCOMMON(lib_infop, func) \
271*10652SHyon.Kim@Sun.COM ((lib_infop->version == SMHBA) ? \
272*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.func : \
273*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.func)
274*10652SHyon.Kim@Sun.COM
275*10652SHyon.Kim@Sun.COM /*
276*10652SHyon.Kim@Sun.COM * Macro to use the hbaapi function ptr.
277*10652SHyon.Kim@Sun.COM * Should be used for an interface applicable only HBAAPIV2.
278*10652SHyon.Kim@Sun.COM */
279*10652SHyon.Kim@Sun.COM #define FUNCHBAAPIV2(lib_infop, func) \
280*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.func
281*10652SHyon.Kim@Sun.COM
282*10652SHyon.Kim@Sun.COM /*
283*10652SHyon.Kim@Sun.COM * Macro to use the hbaapi function ptr.
284*10652SHyon.Kim@Sun.COM * Should be used for an interface applicable only HBAAPIV2.
285*10652SHyon.Kim@Sun.COM */
286*10652SHyon.Kim@Sun.COM #define FUNCSMHBA(lib_infop, func) \
287*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.func
288*10652SHyon.Kim@Sun.COM
289*10652SHyon.Kim@Sun.COM /*
290*10652SHyon.Kim@Sun.COM * Individual adapter (hba) information
291*10652SHyon.Kim@Sun.COM */
292*10652SHyon.Kim@Sun.COM typedef struct hba_adapter_info {
293*10652SHyon.Kim@Sun.COM struct hba_adapter_info
294*10652SHyon.Kim@Sun.COM *next;
295*10652SHyon.Kim@Sun.COM HBA_STATUS GNstatus; /* status from GetAdapterNameFunc */
296*10652SHyon.Kim@Sun.COM char *name;
297*10652SHyon.Kim@Sun.COM HBA_WWN nodeWWN;
298*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *library;
299*10652SHyon.Kim@Sun.COM HBA_UINT32 index;
300*10652SHyon.Kim@Sun.COM } HBA_ADAPTER_INFO;
301*10652SHyon.Kim@Sun.COM
302*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *_hbaapi_adapterlist = NULL;
303*10652SHyon.Kim@Sun.COM HBA_UINT32 _hbaapi_total_adapter_count = 0;
304*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
305*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_AL_mutex = PTHREAD_MUTEX_INITIALIZER;
306*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
307*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_AL_mutex;
308*10652SHyon.Kim@Sun.COM #endif
309*10652SHyon.Kim@Sun.COM
310*10652SHyon.Kim@Sun.COM /*
311*10652SHyon.Kim@Sun.COM * Call back registration
312*10652SHyon.Kim@Sun.COM */
313*10652SHyon.Kim@Sun.COM typedef struct hba_vendorcallback_elem {
314*10652SHyon.Kim@Sun.COM struct hba_vendorcallback_elem
315*10652SHyon.Kim@Sun.COM *next;
316*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE vendorcbhandle;
317*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_info;
318*10652SHyon.Kim@Sun.COM } HBA_VENDORCALLBACK_ELEM;
319*10652SHyon.Kim@Sun.COM
320*10652SHyon.Kim@Sun.COM /*
321*10652SHyon.Kim@Sun.COM * Each instance of HBA_ADAPTERCALLBACK_ELEM represents a call to one of
322*10652SHyon.Kim@Sun.COM * "register" functions that apply to a particular adapter.
323*10652SHyon.Kim@Sun.COM * HBA_ALLADAPTERSCALLBACK_ELEM is used just for HBA_RegisterForAdapterAddEvents
324*10652SHyon.Kim@Sun.COM */
325*10652SHyon.Kim@Sun.COM typedef struct hba_adaptercallback_elem {
326*10652SHyon.Kim@Sun.COM struct hba_adaptercallback_elem
327*10652SHyon.Kim@Sun.COM *next;
328*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_info;
329*10652SHyon.Kim@Sun.COM void *userdata;
330*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE vendorcbhandle;
331*10652SHyon.Kim@Sun.COM void (*callback)();
332*10652SHyon.Kim@Sun.COM } HBA_ADAPTERCALLBACK_ELEM;
333*10652SHyon.Kim@Sun.COM
334*10652SHyon.Kim@Sun.COM typedef struct hba_alladapterscallback_elem {
335*10652SHyon.Kim@Sun.COM struct hba_alladapterscallback_elem
336*10652SHyon.Kim@Sun.COM *next;
337*10652SHyon.Kim@Sun.COM void *userdata;
338*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
339*10652SHyon.Kim@Sun.COM void (*callback)();
340*10652SHyon.Kim@Sun.COM } HBA_ALLADAPTERSCALLBACK_ELEM;
341*10652SHyon.Kim@Sun.COM
342*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *_hbaapi_adapteraddevents_callback_list = NULL;
343*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterevents_callback_list = NULL;
344*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportevents_callback_list = NULL;
345*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportstatevents_callback_list = NULL;
346*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_hbaapi_targetevents_callback_list = NULL;
347*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_hbaapi_linkevents_callback_list = NULL;
348*10652SHyon.Kim@Sun.COM
349*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *_smhba_adapteraddevents_callback_list = NULL;
350*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_smhba_adapterevents_callback_list = NULL;
351*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_smhba_adapterportevents_callback_list = NULL;
352*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_smhba_adapterportstatevents_callback_list = NULL;
353*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_smhba_adapterphystatevents_callback_list = NULL;
354*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *_smhba_targetevents_callback_list = NULL;
355*10652SHyon.Kim@Sun.COM
356*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
357*10652SHyon.Kim@Sun.COM /* mutex's to protect each list */
358*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
359*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
360*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
361*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
362*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
363*10652SHyon.Kim@Sun.COM pthread_mutex_t _hbaapi_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
364*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
365*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
366*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
367*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
368*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_APHYSE_mutex = PTHREAD_MUTEX_INITIALIZER;
369*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
370*10652SHyon.Kim@Sun.COM pthread_mutex_t _smhba_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
371*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
372*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_AAE_mutex;
373*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_AE_mutex;
374*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_APE_mutex;
375*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_APSE_mutex;
376*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_TE_mutex;
377*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_AAE_mutex;
378*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_AE_mutex;
379*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_APE_mutex;
380*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_APSE_mutex;
381*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_APHYSE_mutex;
382*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _smhba_TE_mutex;
383*10652SHyon.Kim@Sun.COM CRITICAL_SECTION _hbaapi_LE_mutex;
384*10652SHyon.Kim@Sun.COM #endif
385*10652SHyon.Kim@Sun.COM
386*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM **cb_lists_array[] = {
387*10652SHyon.Kim@Sun.COM &_hbaapi_adapterevents_callback_list,
388*10652SHyon.Kim@Sun.COM &_hbaapi_adapterportevents_callback_list,
389*10652SHyon.Kim@Sun.COM &_hbaapi_adapterportstatevents_callback_list,
390*10652SHyon.Kim@Sun.COM &_hbaapi_targetevents_callback_list,
391*10652SHyon.Kim@Sun.COM &_hbaapi_linkevents_callback_list,
392*10652SHyon.Kim@Sun.COM &_smhba_adapterevents_callback_list,
393*10652SHyon.Kim@Sun.COM &_smhba_adapterportevents_callback_list,
394*10652SHyon.Kim@Sun.COM &_smhba_adapterportstatevents_callback_list,
395*10652SHyon.Kim@Sun.COM &_smhba_adapterphystatevents_callback_list,
396*10652SHyon.Kim@Sun.COM &_smhba_targetevents_callback_list,
397*10652SHyon.Kim@Sun.COM NULL};
398*10652SHyon.Kim@Sun.COM
399*10652SHyon.Kim@Sun.COM /*
400*10652SHyon.Kim@Sun.COM * Common library internal. Mutex handling
401*10652SHyon.Kim@Sun.COM */
402*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
403*10652SHyon.Kim@Sun.COM static void
grab_mutex(pthread_mutex_t * mp)404*10652SHyon.Kim@Sun.COM grab_mutex(pthread_mutex_t *mp) {
405*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_SET_NOT_USED */
406*10652SHyon.Kim@Sun.COM int ret;
407*10652SHyon.Kim@Sun.COM if ((ret = pthread_mutex_lock(mp)) != 0) {
408*10652SHyon.Kim@Sun.COM perror("pthread_mutex_lock - HBAAPI:");
409*10652SHyon.Kim@Sun.COM DEBUG(1, "pthread_mutex_lock returned %d", ret, 0, 0);
410*10652SHyon.Kim@Sun.COM }
411*10652SHyon.Kim@Sun.COM }
412*10652SHyon.Kim@Sun.COM
413*10652SHyon.Kim@Sun.COM static void
release_mutex(pthread_mutex_t * mp)414*10652SHyon.Kim@Sun.COM release_mutex(pthread_mutex_t *mp) {
415*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_SET_NOT_USED */
416*10652SHyon.Kim@Sun.COM int ret;
417*10652SHyon.Kim@Sun.COM if ((ret = pthread_mutex_unlock(mp)) != 0) {
418*10652SHyon.Kim@Sun.COM perror("pthread_mutex_unlock - HBAAPI:");
419*10652SHyon.Kim@Sun.COM DEBUG(1, "pthread_mutex_unlock returned %d", ret, 0, 0);
420*10652SHyon.Kim@Sun.COM }
421*10652SHyon.Kim@Sun.COM }
422*10652SHyon.Kim@Sun.COM #endif
423*10652SHyon.Kim@Sun.COM
424*10652SHyon.Kim@Sun.COM /*
425*10652SHyon.Kim@Sun.COM * Common library internal. Check library and return vendorhandle
426*10652SHyon.Kim@Sun.COM */
427*10652SHyon.Kim@Sun.COM static HBA_STATUS
HBA_CheckLibrary(HBA_HANDLE handle,HBA_LIBRARY_INFO ** lib_infopp,HBA_HANDLE * vendorhandle)428*10652SHyon.Kim@Sun.COM HBA_CheckLibrary(HBA_HANDLE handle,
429*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO **lib_infopp,
430*10652SHyon.Kim@Sun.COM HBA_HANDLE *vendorhandle) {
431*10652SHyon.Kim@Sun.COM
432*10652SHyon.Kim@Sun.COM HBA_UINT32 libraryIndex;
433*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
434*10652SHyon.Kim@Sun.COM
435*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
436*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
437*10652SHyon.Kim@Sun.COM }
438*10652SHyon.Kim@Sun.COM libraryIndex = LIBRARY_NUM(handle);
439*10652SHyon.Kim@Sun.COM
440*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
441*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist;
442*10652SHyon.Kim@Sun.COM lib_infop != NULL;
443*10652SHyon.Kim@Sun.COM lib_infop = lib_infop->next) {
444*10652SHyon.Kim@Sun.COM if (lib_infop->index == libraryIndex) {
445*10652SHyon.Kim@Sun.COM if (lib_infop->status != HBA_LIBRARY_LOADED) {
446*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
447*10652SHyon.Kim@Sun.COM }
448*10652SHyon.Kim@Sun.COM *lib_infopp = lib_infop;
449*10652SHyon.Kim@Sun.COM *vendorhandle = VENDOR_HANDLE(handle);
450*10652SHyon.Kim@Sun.COM /* caller will release the mutex */
451*10652SHyon.Kim@Sun.COM return (HBA_STATUS_OK);
452*10652SHyon.Kim@Sun.COM }
453*10652SHyon.Kim@Sun.COM }
454*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INVALID_HANDLE);
455*10652SHyon.Kim@Sun.COM }
456*10652SHyon.Kim@Sun.COM #define CHECKLIBRARY() \
457*10652SHyon.Kim@Sun.COM status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);\
458*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) { \
459*10652SHyon.Kim@Sun.COM return (status); \
460*10652SHyon.Kim@Sun.COM }
461*10652SHyon.Kim@Sun.COM
462*10652SHyon.Kim@Sun.COM #define CHECKLIBRARYANDVERSION(ver) \
463*10652SHyon.Kim@Sun.COM status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle); \
464*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) { \
465*10652SHyon.Kim@Sun.COM return (status); \
466*10652SHyon.Kim@Sun.COM } else { \
467*10652SHyon.Kim@Sun.COM if (ver != lib_infop->version) { \
468*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, \
469*10652SHyon.Kim@Sun.COM HBA_STATUS_ERROR_INCOMPATIBLE); \
470*10652SHyon.Kim@Sun.COM } \
471*10652SHyon.Kim@Sun.COM }
472*10652SHyon.Kim@Sun.COM
473*10652SHyon.Kim@Sun.COM /*
474*10652SHyon.Kim@Sun.COM * freevendorhandlelist is called with _hbaapi_LL_mutex already held
475*10652SHyon.Kim@Sun.COM */
476*10652SHyon.Kim@Sun.COM static void
freevendorhandlelist(HBA_VENDORCALLBACK_ELEM * vhlist)477*10652SHyon.Kim@Sun.COM freevendorhandlelist(HBA_VENDORCALLBACK_ELEM *vhlist) {
478*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vhlp;
479*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vnext;
480*10652SHyon.Kim@Sun.COM HBARemoveCallbackFunc registeredfunc;
481*10652SHyon.Kim@Sun.COM
482*10652SHyon.Kim@Sun.COM for (vhlp = vhlist; vhlp != NULL; vhlp = vnext) {
483*10652SHyon.Kim@Sun.COM vnext = vhlp->next;
484*10652SHyon.Kim@Sun.COM registeredfunc =
485*10652SHyon.Kim@Sun.COM FUNCCOMMON(vhlp->lib_info, RemoveCallbackHandler);
486*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
487*10652SHyon.Kim@Sun.COM continue;
488*10652SHyon.Kim@Sun.COM }
489*10652SHyon.Kim@Sun.COM (registeredfunc)(vhlp->vendorcbhandle);
490*10652SHyon.Kim@Sun.COM free(vhlp);
491*10652SHyon.Kim@Sun.COM }
492*10652SHyon.Kim@Sun.COM }
493*10652SHyon.Kim@Sun.COM
494*10652SHyon.Kim@Sun.COM static
495*10652SHyon.Kim@Sun.COM HBA_STATUS
local_remove_callback(HBA_CALLBACKHANDLE cbhandle)496*10652SHyon.Kim@Sun.COM local_remove_callback(HBA_CALLBACKHANDLE cbhandle) {
497*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM ***listp;
498*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM **lastp;
499*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM **lap;
500*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *allcbp;
501*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *cbp;
502*10652SHyon.Kim@Sun.COM HBARemoveCallbackFunc registeredfunc;
503*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vhlp;
504*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vnext;
505*10652SHyon.Kim@Sun.COM int found;
506*10652SHyon.Kim@Sun.COM HBA_STATUS status = HBA_STATUS_ERROR_INVALID_HANDLE;
507*10652SHyon.Kim@Sun.COM
508*10652SHyon.Kim@Sun.COM
509*10652SHyon.Kim@Sun.COM /* search through the simple lists first */
510*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AAE_mutex);
511*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AE_mutex);
512*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APE_mutex);
513*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APSE_mutex);
514*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_TE_mutex);
515*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LE_mutex);
516*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AAE_mutex);
517*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AE_mutex);
518*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APE_mutex);
519*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APSE_mutex);
520*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_TE_mutex);
521*10652SHyon.Kim@Sun.COM for (listp = cb_lists_array, found = 0;
522*10652SHyon.Kim@Sun.COM (found == 0 && *listp != NULL); listp++) {
523*10652SHyon.Kim@Sun.COM lastp = *listp;
524*10652SHyon.Kim@Sun.COM for (cbp = **listp; cbp != NULL; cbp = cbp->next) {
525*10652SHyon.Kim@Sun.COM if (cbhandle != (HBA_CALLBACKHANDLE)cbp) {
526*10652SHyon.Kim@Sun.COM lastp = &(cbp->next);
527*10652SHyon.Kim@Sun.COM continue;
528*10652SHyon.Kim@Sun.COM }
529*10652SHyon.Kim@Sun.COM found = 1;
530*10652SHyon.Kim@Sun.COM registeredfunc =
531*10652SHyon.Kim@Sun.COM FUNCCOMMON(cbp->lib_info, RemoveCallbackHandler);
532*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
533*10652SHyon.Kim@Sun.COM break;
534*10652SHyon.Kim@Sun.COM }
535*10652SHyon.Kim@Sun.COM (registeredfunc)(cbp->vendorcbhandle);
536*10652SHyon.Kim@Sun.COM *lastp = cbp->next;
537*10652SHyon.Kim@Sun.COM free(cbp);
538*10652SHyon.Kim@Sun.COM break;
539*10652SHyon.Kim@Sun.COM }
540*10652SHyon.Kim@Sun.COM }
541*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LE_mutex);
542*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_TE_mutex);
543*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APSE_mutex);
544*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APE_mutex);
545*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AE_mutex);
546*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AAE_mutex);
547*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AAE_mutex);
548*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AE_mutex);
549*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APE_mutex);
550*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APSE_mutex);
551*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_TE_mutex);
552*10652SHyon.Kim@Sun.COM
553*10652SHyon.Kim@Sun.COM if (found != 0) {
554*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
555*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_NOT_SUPPORTED);
556*10652SHyon.Kim@Sun.COM }
557*10652SHyon.Kim@Sun.COM return (HBA_STATUS_OK);
558*10652SHyon.Kim@Sun.COM }
559*10652SHyon.Kim@Sun.COM
560*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AAE_mutex);
561*10652SHyon.Kim@Sun.COM /*
562*10652SHyon.Kim@Sun.COM * if it wasnt in the simple lists,
563*10652SHyon.Kim@Sun.COM * look in the list for adapteraddevents
564*10652SHyon.Kim@Sun.COM */
565*10652SHyon.Kim@Sun.COM lap = &_hbaapi_adapteraddevents_callback_list;
566*10652SHyon.Kim@Sun.COM for (allcbp = _hbaapi_adapteraddevents_callback_list;
567*10652SHyon.Kim@Sun.COM allcbp != NULL;
568*10652SHyon.Kim@Sun.COM allcbp = allcbp->next) {
569*10652SHyon.Kim@Sun.COM if (cbhandle != (HBA_CALLBACKHANDLE)allcbp) {
570*10652SHyon.Kim@Sun.COM lap = &allcbp->next;
571*10652SHyon.Kim@Sun.COM continue;
572*10652SHyon.Kim@Sun.COM }
573*10652SHyon.Kim@Sun.COM for (vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
574*10652SHyon.Kim@Sun.COM vnext = vhlp->next;
575*10652SHyon.Kim@Sun.COM /* should be HBAAPIV2 VSL to get to here */
576*10652SHyon.Kim@Sun.COM registeredfunc =
577*10652SHyon.Kim@Sun.COM vhlp->lib_info->ftable.functionTable.RemoveCallbackHandler;
578*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
579*10652SHyon.Kim@Sun.COM continue;
580*10652SHyon.Kim@Sun.COM }
581*10652SHyon.Kim@Sun.COM (registeredfunc)(vhlp->vendorcbhandle);
582*10652SHyon.Kim@Sun.COM free(vhlp);
583*10652SHyon.Kim@Sun.COM }
584*10652SHyon.Kim@Sun.COM *lap = allcbp->next;
585*10652SHyon.Kim@Sun.COM free(allcbp);
586*10652SHyon.Kim@Sun.COM status = HBA_STATUS_OK;
587*10652SHyon.Kim@Sun.COM break;
588*10652SHyon.Kim@Sun.COM }
589*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AAE_mutex);
590*10652SHyon.Kim@Sun.COM
591*10652SHyon.Kim@Sun.COM /* now search smhba adapteradd events. */
592*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AAE_mutex);
593*10652SHyon.Kim@Sun.COM lap = &_smhba_adapteraddevents_callback_list;
594*10652SHyon.Kim@Sun.COM for (allcbp = _smhba_adapteraddevents_callback_list;
595*10652SHyon.Kim@Sun.COM allcbp != NULL;
596*10652SHyon.Kim@Sun.COM allcbp = allcbp->next) {
597*10652SHyon.Kim@Sun.COM if (cbhandle != (HBA_CALLBACKHANDLE)allcbp) {
598*10652SHyon.Kim@Sun.COM lap = &allcbp->next;
599*10652SHyon.Kim@Sun.COM continue;
600*10652SHyon.Kim@Sun.COM }
601*10652SHyon.Kim@Sun.COM for (vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
602*10652SHyon.Kim@Sun.COM vnext = vhlp->next;
603*10652SHyon.Kim@Sun.COM /* should be SMHBA VSL to get to here */
604*10652SHyon.Kim@Sun.COM registeredfunc =
605*10652SHyon.Kim@Sun.COM vhlp->lib_info->
606*10652SHyon.Kim@Sun.COM ftable.smhbafunctionTable.RemoveCallbackHandler;
607*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
608*10652SHyon.Kim@Sun.COM continue;
609*10652SHyon.Kim@Sun.COM }
610*10652SHyon.Kim@Sun.COM (registeredfunc)(vhlp->vendorcbhandle);
611*10652SHyon.Kim@Sun.COM free(vhlp);
612*10652SHyon.Kim@Sun.COM }
613*10652SHyon.Kim@Sun.COM *lap = allcbp->next;
614*10652SHyon.Kim@Sun.COM free(allcbp);
615*10652SHyon.Kim@Sun.COM status = HBA_STATUS_OK;
616*10652SHyon.Kim@Sun.COM break;
617*10652SHyon.Kim@Sun.COM }
618*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AAE_mutex);
619*10652SHyon.Kim@Sun.COM
620*10652SHyon.Kim@Sun.COM return (status);
621*10652SHyon.Kim@Sun.COM }
622*10652SHyon.Kim@Sun.COM
623*10652SHyon.Kim@Sun.COM /* LINTED E_STATIC_UE_STATIC_UNUSED */
624*10652SHyon.Kim@Sun.COM static char wwn_str1[17];
625*10652SHyon.Kim@Sun.COM /* LINTED E_STATIC_UE_STATIC_UNUSED */
626*10652SHyon.Kim@Sun.COM static char wwn_str2[17];
627*10652SHyon.Kim@Sun.COM /* LINTED E_STATIC_UE_STATIC_UNUSED */
628*10652SHyon.Kim@Sun.COM static char wwn_str3[17];
629*10652SHyon.Kim@Sun.COM #define WWN2STR1(wwn) WWN2str(wwn_str1, (wwn))
630*10652SHyon.Kim@Sun.COM #define WWN2STR2(wwn) WWN2str(wwn_str2, (wwn))
631*10652SHyon.Kim@Sun.COM #define WWN2STR3(wwn) WWN2str(wwn_str3, (wwn))
632*10652SHyon.Kim@Sun.COM static char *
633*10652SHyon.Kim@Sun.COM /* LINTED E_STATIC_UE_STATIC_UNUSED */
WWN2str(char * buf,HBA_WWN * wwn)634*10652SHyon.Kim@Sun.COM WWN2str(char *buf, HBA_WWN *wwn) {
635*10652SHyon.Kim@Sun.COM int j;
636*10652SHyon.Kim@Sun.COM unsigned char *pc = (unsigned char *)&(wwn->wwn[0]);
637*10652SHyon.Kim@Sun.COM buf[0] = '\0';
638*10652SHyon.Kim@Sun.COM for (j = 0; j < 16; j += 2) {
639*10652SHyon.Kim@Sun.COM (void) sprintf(&buf[j], "%02X", (int)*pc++);
640*10652SHyon.Kim@Sun.COM }
641*10652SHyon.Kim@Sun.COM return (buf);
642*10652SHyon.Kim@Sun.COM }
643*10652SHyon.Kim@Sun.COM
644*10652SHyon.Kim@Sun.COM #ifdef WIN32
645*10652SHyon.Kim@Sun.COM BOOL APIENTRY
DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)646*10652SHyon.Kim@Sun.COM DllMain(HANDLE hModule,
647*10652SHyon.Kim@Sun.COM DWORD ul_reason_for_call,
648*10652SHyon.Kim@Sun.COM LPVOID lpReserved)
649*10652SHyon.Kim@Sun.COM {
650*10652SHyon.Kim@Sun.COM switch (ul_reason_for_call) {
651*10652SHyon.Kim@Sun.COM case DLL_PROCESS_ATTACH:
652*10652SHyon.Kim@Sun.COM break;
653*10652SHyon.Kim@Sun.COM case DLL_PROCESS_DETACH:
654*10652SHyon.Kim@Sun.COM break;
655*10652SHyon.Kim@Sun.COM case DLL_THREAD_ATTACH:
656*10652SHyon.Kim@Sun.COM case DLL_THREAD_DETACH:
657*10652SHyon.Kim@Sun.COM break;
658*10652SHyon.Kim@Sun.COM }
659*10652SHyon.Kim@Sun.COM return (TRUE);
660*10652SHyon.Kim@Sun.COM }
661*10652SHyon.Kim@Sun.COM #endif
662*10652SHyon.Kim@Sun.COM
663*10652SHyon.Kim@Sun.COM /*
664*10652SHyon.Kim@Sun.COM * Read in the config file and load all the specified vendor specific
665*10652SHyon.Kim@Sun.COM * libraries and perform the function registration exercise
666*10652SHyon.Kim@Sun.COM */
667*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_LoadLibrary()668*10652SHyon.Kim@Sun.COM HBA_LoadLibrary()
669*10652SHyon.Kim@Sun.COM {
670*10652SHyon.Kim@Sun.COM HBARegisterLibraryFunc RegisterFunc;
671*10652SHyon.Kim@Sun.COM HBARegisterLibraryV2Func RegisterV2Func;
672*10652SHyon.Kim@Sun.COM SMHBARegisterLibraryFunc RegisterSMHBAFunc;
673*10652SHyon.Kim@Sun.COM HBALoadLibraryFunc LoadLibraryFunc;
674*10652SHyon.Kim@Sun.COM HBAGetVersionFunc GetVersionFunc;
675*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
676*10652SHyon.Kim@Sun.COM int ret;
677*10652SHyon.Kim@Sun.COM #endif
678*10652SHyon.Kim@Sun.COM HBA_STATUS status;
679*10652SHyon.Kim@Sun.COM HBA_UINT32 libversion;
680*10652SHyon.Kim@Sun.COM
681*10652SHyon.Kim@Sun.COM /* Open configuration file from known location */
682*10652SHyon.Kim@Sun.COM #ifdef WIN32
683*10652SHyon.Kim@Sun.COM LONG lStatus;
684*10652SHyon.Kim@Sun.COM HKEY hkSniaHba, hkVendorLib;
685*10652SHyon.Kim@Sun.COM FILETIME ftLastWriteTime;
686*10652SHyon.Kim@Sun.COM TCHAR cSubKeyName[256];
687*10652SHyon.Kim@Sun.COM DWORD i, dwSize, dwType;
688*10652SHyon.Kim@Sun.COM BYTE byFileName[MAX_PATH];
689*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
690*10652SHyon.Kim@Sun.COM
691*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist != NULL) {
692*10652SHyon.Kim@Sun.COM /* this is an app programming error */
693*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
694*10652SHyon.Kim@Sun.COM }
695*10652SHyon.Kim@Sun.COM
696*10652SHyon.Kim@Sun.COM lStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\SNIA\\HBA",
697*10652SHyon.Kim@Sun.COM 0, KEY_READ, &hkSniaHba);
698*10652SHyon.Kim@Sun.COM if (lStatus != ERROR_SUCCESS) {
699*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, configuration error */
700*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
701*10652SHyon.Kim@Sun.COM }
702*10652SHyon.Kim@Sun.COM /*
703*10652SHyon.Kim@Sun.COM * Enumerate all the subkeys. These have the form:
704*10652SHyon.Kim@Sun.COM * HKLM\Software\SNIA\HBA\<Vendor id> - note that we don't care
705*10652SHyon.Kim@Sun.COM * what the vendor id is
706*10652SHyon.Kim@Sun.COM */
707*10652SHyon.Kim@Sun.COM for (i = 0; ; i++) {
708*10652SHyon.Kim@Sun.COM dwSize = 255; /* how big the buffer is */
709*10652SHyon.Kim@Sun.COM lStatus = RegEnumKeyEx(hkSniaHba, i,
710*10652SHyon.Kim@Sun.COM (char *)&cSubKeyName, &dwSize, NULL,
711*10652SHyon.Kim@Sun.COM NULL, NULL, &ftLastWriteTime);
712*10652SHyon.Kim@Sun.COM if (lStatus == ERROR_NO_MORE_ITEMS) {
713*10652SHyon.Kim@Sun.COM break; /* we're done */
714*10652SHyon.Kim@Sun.COM } else if (lStatus == ERROR_MORE_DATA) { /* buffer not big enough */
715*10652SHyon.Kim@Sun.COM /* do whatever */
716*10652SHyon.Kim@Sun.COM ;
717*10652SHyon.Kim@Sun.COM }
718*10652SHyon.Kim@Sun.COM /* Now open the subkey that pertains to this vendor's library */
719*10652SHyon.Kim@Sun.COM lStatus = RegOpenKeyEx(hkSniaHba, cSubKeyName, 0, KEY_READ,
720*10652SHyon.Kim@Sun.COM &hkVendorLib);
721*10652SHyon.Kim@Sun.COM if (lStatus != ERROR_SUCCESS) {
722*10652SHyon.Kim@Sun.COM RegCloseKey(hkSniaHba);
723*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, installation error */
724*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
725*10652SHyon.Kim@Sun.COM /*
726*10652SHyon.Kim@Sun.COM * you may want to return something
727*10652SHyon.Kim@Sun.COM * else or keep trying
728*10652SHyon.Kim@Sun.COM */
729*10652SHyon.Kim@Sun.COM }
730*10652SHyon.Kim@Sun.COM /*
731*10652SHyon.Kim@Sun.COM * The name of the library is contained in a REG_SZ Value
732*10652SHyon.Kim@Sun.COM * keyed to "LibraryFile"
733*10652SHyon.Kim@Sun.COM */
734*10652SHyon.Kim@Sun.COM dwSize = MAX_PATH;
735*10652SHyon.Kim@Sun.COM lStatus = RegQueryValueEx(hkVendorLib, "LibraryFile", NULL, &dwType,
736*10652SHyon.Kim@Sun.COM byFileName, &dwSize);
737*10652SHyon.Kim@Sun.COM if (lStatus != ERROR_SUCCESS) {
738*10652SHyon.Kim@Sun.COM RegCloseKey(hkVendorLib);
739*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, installation error */
740*10652SHyon.Kim@Sun.COM continue;
741*10652SHyon.Kim@Sun.COM }
742*10652SHyon.Kim@Sun.COM lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof (HBA_LIBRARY_INFO));
743*10652SHyon.Kim@Sun.COM if (lib_infop == NULL) {
744*10652SHyon.Kim@Sun.COM /* what is the right thing to do in MS land??? */
745*10652SHyon.Kim@Sun.COM RegCloseKey(hkVendorLib);
746*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, installation error */
747*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
748*10652SHyon.Kim@Sun.COM }
749*10652SHyon.Kim@Sun.COM lib_infop->status = HBA_LIBRARY_NOT_LOADED;
750*10652SHyon.Kim@Sun.COM lib_infop->next = _hbaapi_librarylist;
751*10652SHyon.Kim@Sun.COM lib_infop->index = _hbaapi_total_library_count;
752*10652SHyon.Kim@Sun.COM _hbaapi_total_library_count++;
753*10652SHyon.Kim@Sun.COM _hbaapi_librarylist = lib_infop;
754*10652SHyon.Kim@Sun.COM
755*10652SHyon.Kim@Sun.COM /* Now I can try to load the library */
756*10652SHyon.Kim@Sun.COM lib_infop->hLibrary = LoadLibrary(byFileName);
757*10652SHyon.Kim@Sun.COM if (lib_infop->hLibrary == NULL) {
758*10652SHyon.Kim@Sun.COM /* printf("unable to load library %s\n", librarypath); */
759*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, installation error */
760*10652SHyon.Kim@Sun.COM goto dud_library;
761*10652SHyon.Kim@Sun.COM }
762*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath = strdup(byFileName);
763*10652SHyon.Kim@Sun.COM DEBUG(1, "HBAAPI loading: %s\n", byFileName, 0, 0);
764*10652SHyon.Kim@Sun.COM
765*10652SHyon.Kim@Sun.COM RegisterSMHBAFunc = (SMHBARegisterLibraryFunc)
766*10652SHyon.Kim@Sun.COM GetProcAddress(lib_infop->hLibrary, "SMHBA_RegisterLibrary");
767*10652SHyon.Kim@Sun.COM if (RegisterSMHBAFunc != NULL) {
768*10652SHyon.Kim@Sun.COM status = ((RegisterSMHBAFunc)(SMHBA_ENTRYPOINTS *)
769*10652SHyon.Kim@Sun.COM (&lib_infop->ftable.smhbafunctionTable));
770*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
771*10652SHyon.Kim@Sun.COM /* library not loaded */
772*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
773*10652SHyon.Kim@Sun.COM goto dud_library;
774*10652SHyon.Kim@Sun.COM } else {
775*10652SHyon.Kim@Sun.COM lib_infop->version = SMHBA;
776*10652SHyon.Kim@Sun.COM }
777*10652SHyon.Kim@Sun.COM } else {
778*10652SHyon.Kim@Sun.COM /* Call the registration function to get the list of pointers */
779*10652SHyon.Kim@Sun.COM RegisterV2Func = (HBARegisterLibraryV2Func)GetProcAddress(
780*10652SHyon.Kim@Sun.COM lib_infop->hLibrary, "HBA_RegisterLibraryV2");
781*10652SHyon.Kim@Sun.COM if (RegisterV2Func != NULL) {
782*10652SHyon.Kim@Sun.COM /*
783*10652SHyon.Kim@Sun.COM * Load the function pointers directly into
784*10652SHyon.Kim@Sun.COM * the table of functions
785*10652SHyon.Kim@Sun.COM */
786*10652SHyon.Kim@Sun.COM status = ((RegisterV2Func)
787*10652SHyon.Kim@Sun.COM (HBA_ENTRYPOINTSV2 *)(&lib_infop->ftable.functionTable));
788*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
789*10652SHyon.Kim@Sun.COM /* library not loaded */
790*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
791*10652SHyon.Kim@Sun.COM goto dud_library;
792*10652SHyon.Kim@Sun.COM } else {
793*10652SHyon.Kim@Sun.COM lib_infop->version = HBAAPIV2;
794*10652SHyon.Kim@Sun.COM }
795*10652SHyon.Kim@Sun.COM } else {
796*10652SHyon.Kim@Sun.COM /* Maybe the vendor library is only Rev1 */
797*10652SHyon.Kim@Sun.COM RegisterFunc = (HBARegisterLibraryFunc)
798*10652SHyon.Kim@Sun.COM GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibrary");
799*10652SHyon.Kim@Sun.COM if (RegisterFunc == NULL) {
800*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
801*10652SHyon.Kim@Sun.COM goto dud_library;
802*10652SHyon.Kim@Sun.COM }
803*10652SHyon.Kim@Sun.COM /*
804*10652SHyon.Kim@Sun.COM * Load the function points directly into
805*10652SHyon.Kim@Sun.COM * the Rev 2 table of functions
806*10652SHyon.Kim@Sun.COM */
807*10652SHyon.Kim@Sun.COM status = ((RegisterFunc)(
808*10652SHyon.Kim@Sun.COM (HBA_ENTRYPOINTS *)(&lib_infop->ftable.functionTable)));
809*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
810*10652SHyon.Kim@Sun.COM /* library not loaded */
811*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
812*10652SHyon.Kim@Sun.COM goto dud_library;
813*10652SHyon.Kim@Sun.COM } else {
814*10652SHyon.Kim@Sun.COM lib_infop->version = HBAAPI;
815*10652SHyon.Kim@Sun.COM }
816*10652SHyon.Kim@Sun.COM }
817*10652SHyon.Kim@Sun.COM }
818*10652SHyon.Kim@Sun.COM
819*10652SHyon.Kim@Sun.COM /* successfully loaded library */
820*10652SHyon.Kim@Sun.COM /*
821*10652SHyon.Kim@Sun.COM * SM-HBA and HBAAPI has a seperate handler for GetVersion but
822*10652SHyon.Kim@Sun.COM * they have the same function signature so use the same variable here.
823*10652SHyon.Kim@Sun.COM */
824*10652SHyon.Kim@Sun.COM GetVersionFunc = FUNCCOMMON(lib_infop, GetVersionHandler);
825*10652SHyon.Kim@Sun.COM if (GetVersionFunc != NULL) {
826*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
827*10652SHyon.Kim@Sun.COM /* Check the version of this library before loading */
828*10652SHyon.Kim@Sun.COM libversion = ((GetVersionFunc)());
829*10652SHyon.Kim@Sun.COM #ifdef NOTDEF /* save for a later time... when it matters */
830*10652SHyon.Kim@Sun.COM if (libversion < SMHBA_LIBVERSION) {
831*10652SHyon.Kim@Sun.COM goto dud_library;
832*10652SHyon.Kim@Sun.COM }
833*10652SHyon.Kim@Sun.COM #endif
834*10652SHyon.Kim@Sun.COM } else {
835*10652SHyon.Kim@Sun.COM /* Check the version of this library before loading */
836*10652SHyon.Kim@Sun.COM /* Actually... This wrapper is compatible with version 1 */
837*10652SHyon.Kim@Sun.COM libversion = ((GetVersionFunc)());
838*10652SHyon.Kim@Sun.COM #ifdef NOTDEF /* save for a later time... when it matters */
839*10652SHyon.Kim@Sun.COM if (libversion < HBA_LIBVERSION) {
840*10652SHyon.Kim@Sun.COM goto dud_library;
841*10652SHyon.Kim@Sun.COM }
842*10652SHyon.Kim@Sun.COM #endif
843*10652SHyon.Kim@Sun.COM }
844*10652SHyon.Kim@Sun.COM } else {
845*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
846*10652SHyon.Kim@Sun.COM goto dud_library;
847*10652SHyon.Kim@Sun.COM }
848*10652SHyon.Kim@Sun.COM
849*10652SHyon.Kim@Sun.COM LoadLibraryFunc = FUNCCOMMON(lib_infop, LoadLibraryHandler);
850*10652SHyon.Kim@Sun.COM if (LoadLibraryFunc == NULL) {
851*10652SHyon.Kim@Sun.COM /* Hmmm, dont we need to flag this in a realy big way??? */
852*10652SHyon.Kim@Sun.COM /* How about messages to the system event logger ??? */
853*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
854*10652SHyon.Kim@Sun.COM goto dud_library;
855*10652SHyon.Kim@Sun.COM }
856*10652SHyon.Kim@Sun.COM /* Initialize this library */
857*10652SHyon.Kim@Sun.COM status = ((LoadLibraryFunc)());
858*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
859*10652SHyon.Kim@Sun.COM /* ???Opportunity to send error msg, library error? */
860*10652SHyon.Kim@Sun.COM continue;
861*10652SHyon.Kim@Sun.COM }
862*10652SHyon.Kim@Sun.COM /* successfully loaded library */
863*10652SHyon.Kim@Sun.COM lib_infop->status = HBA_LIBRARY_LOADED;
864*10652SHyon.Kim@Sun.COM
865*10652SHyon.Kim@Sun.COM dud_library: /* its also just the end of the loop */
866*10652SHyon.Kim@Sun.COM RegCloseKey(hkVendorLib);
867*10652SHyon.Kim@Sun.COM }
868*10652SHyon.Kim@Sun.COM RegCloseKey(hkSniaHba);
869*10652SHyon.Kim@Sun.COM
870*10652SHyon.Kim@Sun.COM #else /* Unix as opposed to Win32 */
871*10652SHyon.Kim@Sun.COM FILE *hbaconf;
872*10652SHyon.Kim@Sun.COM char fullline[512]; /* line read from HBA.conf */
873*10652SHyon.Kim@Sun.COM char *libraryname; /* Read in from file HBA.conf */
874*10652SHyon.Kim@Sun.COM char *librarypath; /* Read in from file HBA.conf */
875*10652SHyon.Kim@Sun.COM char hbaConfFilePath[256];
876*10652SHyon.Kim@Sun.COM char *charPtr;
877*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
878*10652SHyon.Kim@Sun.COM
879*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
880*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist != NULL) {
881*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
882*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: previously unfreed "
883*10652SHyon.Kim@Sun.COM "libraries exist, call HBA_FreeLibrary().\n");
884*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
885*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
886*10652SHyon.Kim@Sun.COM }
887*10652SHyon.Kim@Sun.COM
888*10652SHyon.Kim@Sun.COM (void) strcpy(hbaConfFilePath, "/etc/smhba.conf");
889*10652SHyon.Kim@Sun.COM
890*10652SHyon.Kim@Sun.COM if ((hbaconf = fopen(hbaConfFilePath, "r")) == NULL) {
891*10652SHyon.Kim@Sun.COM (void) printf("Cannot open %s\n", hbaConfFilePath);
892*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
893*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
894*10652SHyon.Kim@Sun.COM }
895*10652SHyon.Kim@Sun.COM
896*10652SHyon.Kim@Sun.COM /* Read in each line and load library */
897*10652SHyon.Kim@Sun.COM while ((hbaconf != NULL) &&
898*10652SHyon.Kim@Sun.COM (fgets(fullline, sizeof (fullline), hbaconf))) {
899*10652SHyon.Kim@Sun.COM /* Skip the comments... */
900*10652SHyon.Kim@Sun.COM if ((fullline[0] == '#') || (fullline[0] == '\n')) {
901*10652SHyon.Kim@Sun.COM continue;
902*10652SHyon.Kim@Sun.COM }
903*10652SHyon.Kim@Sun.COM
904*10652SHyon.Kim@Sun.COM /* grab first 'thing' in line (if its there) */
905*10652SHyon.Kim@Sun.COM if ((libraryname = strtok(fullline, " \t\n")) != NULL) {
906*10652SHyon.Kim@Sun.COM if (strlen(libraryname) >= 64) {
907*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
908*10652SHyon.Kim@Sun.COM "Library name(%s) in %s is > 64 characters\n",
909*10652SHyon.Kim@Sun.COM libraryname, hbaConfFilePath);
910*10652SHyon.Kim@Sun.COM }
911*10652SHyon.Kim@Sun.COM }
912*10652SHyon.Kim@Sun.COM /* grab second 'thing' in line (if its there) */
913*10652SHyon.Kim@Sun.COM if ((librarypath = strtok(NULL, " \t\n")) != NULL) {
914*10652SHyon.Kim@Sun.COM if (strlen(librarypath) >= 256) {
915*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
916*10652SHyon.Kim@Sun.COM "Library path(%s) in %s is > 256 characters\n",
917*10652SHyon.Kim@Sun.COM librarypath, hbaConfFilePath);
918*10652SHyon.Kim@Sun.COM }
919*10652SHyon.Kim@Sun.COM }
920*10652SHyon.Kim@Sun.COM
921*10652SHyon.Kim@Sun.COM /* there should be no more 'things' in the line */
922*10652SHyon.Kim@Sun.COM if ((charPtr = strtok(NULL, " \n\t")) != NULL) {
923*10652SHyon.Kim@Sun.COM (void) fprintf(stderr, "Extraneous characters (\"%s\") in %s\n",
924*10652SHyon.Kim@Sun.COM charPtr, hbaConfFilePath);
925*10652SHyon.Kim@Sun.COM }
926*10652SHyon.Kim@Sun.COM
927*10652SHyon.Kim@Sun.COM /* Continue to the next line if library name or path is invalid */
928*10652SHyon.Kim@Sun.COM if (libraryname == NULL ||
929*10652SHyon.Kim@Sun.COM strlen(libraryname) == 0 ||
930*10652SHyon.Kim@Sun.COM librarypath == NULL ||
931*10652SHyon.Kim@Sun.COM (strlen(librarypath) == 0)) {
932*10652SHyon.Kim@Sun.COM continue;
933*10652SHyon.Kim@Sun.COM }
934*10652SHyon.Kim@Sun.COM
935*10652SHyon.Kim@Sun.COM /*
936*10652SHyon.Kim@Sun.COM * Special case....
937*10652SHyon.Kim@Sun.COM * Look for loglevel
938*10652SHyon.Kim@Sun.COM */
939*10652SHyon.Kim@Sun.COM if (strcmp(libraryname, "debuglevel") == 0) {
940*10652SHyon.Kim@Sun.COM _hbaapi_debuglevel = strtol(librarypath, NULL, 10);
941*10652SHyon.Kim@Sun.COM /* error handling does the right thing automagically */
942*10652SHyon.Kim@Sun.COM continue;
943*10652SHyon.Kim@Sun.COM }
944*10652SHyon.Kim@Sun.COM
945*10652SHyon.Kim@Sun.COM lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof (HBA_LIBRARY_INFO));
946*10652SHyon.Kim@Sun.COM if (lib_infop == NULL) {
947*10652SHyon.Kim@Sun.COM (void) fprintf(stderr, "HBA_LoadLibrary: out of memeory\n");
948*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
949*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
950*10652SHyon.Kim@Sun.COM }
951*10652SHyon.Kim@Sun.COM lib_infop->status = HBA_LIBRARY_NOT_LOADED;
952*10652SHyon.Kim@Sun.COM lib_infop->LibraryName = strdup(libraryname);
953*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath = strdup(librarypath);
954*10652SHyon.Kim@Sun.COM lib_infop->numOfAdapters = 0;
955*10652SHyon.Kim@Sun.COM lib_infop->version = UNKNOWN;
956*10652SHyon.Kim@Sun.COM lib_infop->index = _hbaapi_total_library_count;
957*10652SHyon.Kim@Sun.COM _hbaapi_total_library_count++;
958*10652SHyon.Kim@Sun.COM lib_infop->next = _hbaapi_librarylist;
959*10652SHyon.Kim@Sun.COM _hbaapi_librarylist = lib_infop;
960*10652SHyon.Kim@Sun.COM
961*10652SHyon.Kim@Sun.COM /* Load the DLL now */
962*10652SHyon.Kim@Sun.COM if ((lib_infop->hLibrary = dlopen(librarypath, RTLD_LAZY)) == NULL) {
963*10652SHyon.Kim@Sun.COM /* printf("unable to load library %s\n", librarypath); */
964*10652SHyon.Kim@Sun.COM continue;
965*10652SHyon.Kim@Sun.COM }
966*10652SHyon.Kim@Sun.COM /* Call the registration function to get the list of pointers */
967*10652SHyon.Kim@Sun.COM RegisterSMHBAFunc = (SMHBARegisterLibraryFunc)
968*10652SHyon.Kim@Sun.COM dlsym(lib_infop->hLibrary, "SMHBA_RegisterLibrary");
969*10652SHyon.Kim@Sun.COM if (RegisterSMHBAFunc != NULL) {
970*10652SHyon.Kim@Sun.COM /*
971*10652SHyon.Kim@Sun.COM * Load the function points directly into
972*10652SHyon.Kim@Sun.COM * the table of functions
973*10652SHyon.Kim@Sun.COM */
974*10652SHyon.Kim@Sun.COM status = ((RegisterSMHBAFunc)
975*10652SHyon.Kim@Sun.COM (&lib_infop->ftable.smhbafunctionTable));
976*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
977*10652SHyon.Kim@Sun.COM /* library not loaded */
978*10652SHyon.Kim@Sun.COM continue;
979*10652SHyon.Kim@Sun.COM } else {
980*10652SHyon.Kim@Sun.COM lib_infop->version = SMHBA;
981*10652SHyon.Kim@Sun.COM }
982*10652SHyon.Kim@Sun.COM } else {
983*10652SHyon.Kim@Sun.COM RegisterV2Func = (HBARegisterLibraryV2Func)
984*10652SHyon.Kim@Sun.COM dlsym(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
985*10652SHyon.Kim@Sun.COM if (RegisterV2Func != NULL) {
986*10652SHyon.Kim@Sun.COM /*
987*10652SHyon.Kim@Sun.COM * Load the function points directly into
988*10652SHyon.Kim@Sun.COM * the table of functions
989*10652SHyon.Kim@Sun.COM */
990*10652SHyon.Kim@Sun.COM status = ((RegisterV2Func)((HBA_ENTRYPOINTSV2 *)
991*10652SHyon.Kim@Sun.COM (&lib_infop->ftable.functionTable)));
992*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
993*10652SHyon.Kim@Sun.COM /* library not loaded */
994*10652SHyon.Kim@Sun.COM continue;
995*10652SHyon.Kim@Sun.COM } else {
996*10652SHyon.Kim@Sun.COM lib_infop->version = HBAAPIV2;
997*10652SHyon.Kim@Sun.COM }
998*10652SHyon.Kim@Sun.COM } else {
999*10652SHyon.Kim@Sun.COM /* Maybe the vendor library is only Rev1 */
1000*10652SHyon.Kim@Sun.COM RegisterFunc = (HBARegisterLibraryFunc)
1001*10652SHyon.Kim@Sun.COM dlsym(lib_infop->hLibrary, "HBA_RegisterLibrary");
1002*10652SHyon.Kim@Sun.COM if (RegisterFunc == NULL) {
1003*10652SHyon.Kim@Sun.COM /* This function is required */
1004*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1005*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: vendor specific RegisterLibrary "
1006*10652SHyon.Kim@Sun.COM "function not found. lib: %s\n", librarypath);
1007*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_LoadLibrary: vendor specific "
1008*10652SHyon.Kim@Sun.COM "RegisterLibrary function not found. lib: %s\n",
1009*10652SHyon.Kim@Sun.COM librarypath, 0, 0);
1010*10652SHyon.Kim@Sun.COM continue;
1011*10652SHyon.Kim@Sun.COM }
1012*10652SHyon.Kim@Sun.COM /*
1013*10652SHyon.Kim@Sun.COM * Load the function points directly into
1014*10652SHyon.Kim@Sun.COM * the table of functions
1015*10652SHyon.Kim@Sun.COM */
1016*10652SHyon.Kim@Sun.COM status = ((RegisterFunc)
1017*10652SHyon.Kim@Sun.COM ((HBA_ENTRYPOINTS *)(&lib_infop->ftable.functionTable)));
1018*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
1019*10652SHyon.Kim@Sun.COM /* library not loaded */
1020*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1021*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: vendor specific RegisterLibrary "
1022*10652SHyon.Kim@Sun.COM "function encountered an error. lib: %s\n",
1023*10652SHyon.Kim@Sun.COM librarypath);
1024*10652SHyon.Kim@Sun.COM DEBUG(1,
1025*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: vendor specific RegisterLibrary "
1026*10652SHyon.Kim@Sun.COM "function encountered an error. lib: %s\n",
1027*10652SHyon.Kim@Sun.COM librarypath, 0, 0);
1028*10652SHyon.Kim@Sun.COM continue;
1029*10652SHyon.Kim@Sun.COM } else {
1030*10652SHyon.Kim@Sun.COM lib_infop->version = HBAAPI;
1031*10652SHyon.Kim@Sun.COM }
1032*10652SHyon.Kim@Sun.COM }
1033*10652SHyon.Kim@Sun.COM }
1034*10652SHyon.Kim@Sun.COM
1035*10652SHyon.Kim@Sun.COM /* successfully loaded library */
1036*10652SHyon.Kim@Sun.COM /*
1037*10652SHyon.Kim@Sun.COM * SM-HBA and HBAAPI has a seperate handler for GetVersion but
1038*10652SHyon.Kim@Sun.COM * they have the same function signature so use the same variable here.
1039*10652SHyon.Kim@Sun.COM */
1040*10652SHyon.Kim@Sun.COM if ((GetVersionFunc = FUNCCOMMON(lib_infop, GetVersionHandler))
1041*10652SHyon.Kim@Sun.COM == NULL) {
1042*10652SHyon.Kim@Sun.COM continue;
1043*10652SHyon.Kim@Sun.COM }
1044*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
1045*10652SHyon.Kim@Sun.COM libversion = ((GetVersionFunc)());
1046*10652SHyon.Kim@Sun.COM if (libversion < SMHBA_LIBVERSION) {
1047*10652SHyon.Kim@Sun.COM (void) printf("Library version mismatch."
1048*10652SHyon.Kim@Sun.COM "Got %d expected %d.\n",
1049*10652SHyon.Kim@Sun.COM libversion, SMHBA_LIBVERSION);
1050*10652SHyon.Kim@Sun.COM continue;
1051*10652SHyon.Kim@Sun.COM }
1052*10652SHyon.Kim@Sun.COM } else {
1053*10652SHyon.Kim@Sun.COM libversion = ((GetVersionFunc)());
1054*10652SHyon.Kim@Sun.COM /* Check the version of this library before loading */
1055*10652SHyon.Kim@Sun.COM /* Actually... This wrapper is compatible with version 1 */
1056*10652SHyon.Kim@Sun.COM if (libversion < HBA_LIBVERSION) {
1057*10652SHyon.Kim@Sun.COM (void) printf("Library version mismatch."
1058*10652SHyon.Kim@Sun.COM "Got %d expected %d.\n",
1059*10652SHyon.Kim@Sun.COM libversion, HBA_LIBVERSION);
1060*10652SHyon.Kim@Sun.COM continue;
1061*10652SHyon.Kim@Sun.COM }
1062*10652SHyon.Kim@Sun.COM }
1063*10652SHyon.Kim@Sun.COM
1064*10652SHyon.Kim@Sun.COM DEBUG(1, "%s libversion = %d", librarypath, libversion, 0);
1065*10652SHyon.Kim@Sun.COM LoadLibraryFunc = FUNCCOMMON(lib_infop, LoadLibraryHandler);
1066*10652SHyon.Kim@Sun.COM if (LoadLibraryFunc == NULL) {
1067*10652SHyon.Kim@Sun.COM /* this function is required */
1068*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1069*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: vendor specific LoadLibrary "
1070*10652SHyon.Kim@Sun.COM "function not found. lib: %s\n", librarypath);
1071*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_LoadLibrary: vendor specific LoadLibrary "
1072*10652SHyon.Kim@Sun.COM "function not found. lib: %s\n", librarypath, 0, 0);
1073*10652SHyon.Kim@Sun.COM continue;
1074*10652SHyon.Kim@Sun.COM }
1075*10652SHyon.Kim@Sun.COM /* Initialize this library */
1076*10652SHyon.Kim@Sun.COM if ((status = ((LoadLibraryFunc)())) != HBA_STATUS_OK) {
1077*10652SHyon.Kim@Sun.COM /* maybe this should be a printf so that we CANNOT miss it */
1078*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1079*10652SHyon.Kim@Sun.COM "HBA_LoadLibrary: Encounterd and error loading: %s",
1080*10652SHyon.Kim@Sun.COM librarypath);
1081*10652SHyon.Kim@Sun.COM DEBUG(1, "Encounterd and error loading: %s", librarypath, 0, 0);
1082*10652SHyon.Kim@Sun.COM DEBUG(1, " HBA_STATUS: %d", status, 0, 0);
1083*10652SHyon.Kim@Sun.COM continue;
1084*10652SHyon.Kim@Sun.COM }
1085*10652SHyon.Kim@Sun.COM /* successfully loaded library */
1086*10652SHyon.Kim@Sun.COM lib_infop->status = HBA_LIBRARY_LOADED;
1087*10652SHyon.Kim@Sun.COM }
1088*10652SHyon.Kim@Sun.COM #endif /* WIN32 or UNIX */
1089*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
1090*10652SHyon.Kim@Sun.COM /*
1091*10652SHyon.Kim@Sun.COM * The _hbaapi_LL_mutex is already grabbed to proctect the caller of
1092*10652SHyon.Kim@Sun.COM * HBA_FreeLibrary() during loading.
1093*10652SHyon.Kim@Sun.COM * The mutexes are already initialized
1094*10652SHyon.Kim@Sun.COM * with PTHREAD_MUTEX_INITIALIZER. Do we need to init again?
1095*10652SHyon.Kim@Sun.COM * Keeping the code from HBAAPI source...
1096*10652SHyon.Kim@Sun.COM */
1097*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_AL_mutex, NULL);
1098*10652SHyon.Kim@Sun.COM if (ret == 0) {
1099*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_AAE_mutex, NULL);
1100*10652SHyon.Kim@Sun.COM }
1101*10652SHyon.Kim@Sun.COM if (ret == 0) {
1102*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_AE_mutex, NULL);
1103*10652SHyon.Kim@Sun.COM }
1104*10652SHyon.Kim@Sun.COM if (ret == 0) {
1105*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_APE_mutex, NULL);
1106*10652SHyon.Kim@Sun.COM }
1107*10652SHyon.Kim@Sun.COM if (ret == 0) {
1108*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_APSE_mutex, NULL);
1109*10652SHyon.Kim@Sun.COM }
1110*10652SHyon.Kim@Sun.COM if (ret == 0) {
1111*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_TE_mutex, NULL);
1112*10652SHyon.Kim@Sun.COM }
1113*10652SHyon.Kim@Sun.COM if (ret == 0) {
1114*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_smhba_AAE_mutex, NULL);
1115*10652SHyon.Kim@Sun.COM }
1116*10652SHyon.Kim@Sun.COM if (ret == 0) {
1117*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_smhba_AE_mutex, NULL);
1118*10652SHyon.Kim@Sun.COM }
1119*10652SHyon.Kim@Sun.COM if (ret == 0) {
1120*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_smhba_APE_mutex, NULL);
1121*10652SHyon.Kim@Sun.COM }
1122*10652SHyon.Kim@Sun.COM if (ret == 0) {
1123*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_smhba_APSE_mutex, NULL);
1124*10652SHyon.Kim@Sun.COM }
1125*10652SHyon.Kim@Sun.COM if (ret == 0) {
1126*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_smhba_TE_mutex, NULL);
1127*10652SHyon.Kim@Sun.COM }
1128*10652SHyon.Kim@Sun.COM if (ret == 0) {
1129*10652SHyon.Kim@Sun.COM ret = pthread_mutex_init(&_hbaapi_LE_mutex, NULL);
1130*10652SHyon.Kim@Sun.COM }
1131*10652SHyon.Kim@Sun.COM if (ret != 0) {
1132*10652SHyon.Kim@Sun.COM perror("pthread_mutex_init - HBA_LoadLibrary");
1133*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
1134*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
1135*10652SHyon.Kim@Sun.COM }
1136*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
1137*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
1138*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_LL_mutex);
1139*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_AL_mutex);
1140*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_AAE_mutex);
1141*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_AE_mutex);
1142*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_APE_mutex);
1143*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_APSE_mutex);
1144*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_TE_mutex);
1145*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_hbaapi_LE_mutex);
1146*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_smhba_AAE_mutex);
1147*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_smhba_AE_mutex);
1148*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_smhba_APE_mutex);
1149*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_smhba_APSE_mutex);
1150*10652SHyon.Kim@Sun.COM InitializeCriticalSection(&_smhba_TE_mutex);
1151*10652SHyon.Kim@Sun.COM #endif
1152*10652SHyon.Kim@Sun.COM
1153*10652SHyon.Kim@Sun.COM return (HBA_STATUS_OK);
1154*10652SHyon.Kim@Sun.COM }
1155*10652SHyon.Kim@Sun.COM
1156*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_FreeLibrary()1157*10652SHyon.Kim@Sun.COM HBA_FreeLibrary() {
1158*10652SHyon.Kim@Sun.COM HBAFreeLibraryFunc FreeLibraryFunc;
1159*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_SET_NOT_USED */
1160*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1161*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1162*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_next;
1163*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM
1164*10652SHyon.Kim@Sun.COM ***listp;
1165*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
1166*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_next;
1167*10652SHyon.Kim@Sun.COM
1168*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
1169*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
1170*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
1171*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_NOT_LOADED);
1172*10652SHyon.Kim@Sun.COM }
1173*10652SHyon.Kim@Sun.COM
1174*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
1175*10652SHyon.Kim@Sun.COM
1176*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_FreeLibrary()", 0, 0, 0);
1177*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist; lib_infop != NULL;
1178*10652SHyon.Kim@Sun.COM lib_infop = lib_next) {
1179*10652SHyon.Kim@Sun.COM lib_next = lib_infop->next;
1180*10652SHyon.Kim@Sun.COM if (lib_infop->status == HBA_LIBRARY_LOADED) {
1181*10652SHyon.Kim@Sun.COM FreeLibraryFunc = FUNCCOMMON(lib_infop, FreeLibraryHandler);
1182*10652SHyon.Kim@Sun.COM if (FreeLibraryFunc != NULL) {
1183*10652SHyon.Kim@Sun.COM /* Free this library */
1184*10652SHyon.Kim@Sun.COM status = ((FreeLibraryFunc)());
1185*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_FreeLibrary() Failed %d", status, 0, 0);
1186*10652SHyon.Kim@Sun.COM }
1187*10652SHyon.Kim@Sun.COM #ifdef WIN32
1188*10652SHyon.Kim@Sun.COM FreeLibrary(lib_infop->hLibrary); /* Unload DLL from memory */
1189*10652SHyon.Kim@Sun.COM #else
1190*10652SHyon.Kim@Sun.COM (void) dlclose(lib_infop->hLibrary); /* Unload DLL from memory */
1191*10652SHyon.Kim@Sun.COM #endif
1192*10652SHyon.Kim@Sun.COM }
1193*10652SHyon.Kim@Sun.COM #ifndef WIN32
1194*10652SHyon.Kim@Sun.COM free(lib_infop->LibraryName);
1195*10652SHyon.Kim@Sun.COM #endif
1196*10652SHyon.Kim@Sun.COM free(lib_infop->LibraryPath);
1197*10652SHyon.Kim@Sun.COM free(lib_infop);
1198*10652SHyon.Kim@Sun.COM
1199*10652SHyon.Kim@Sun.COM }
1200*10652SHyon.Kim@Sun.COM _hbaapi_librarylist = NULL;
1201*10652SHyon.Kim@Sun.COM /*
1202*10652SHyon.Kim@Sun.COM * OK, now all functions are disabled except for LoadLibrary,
1203*10652SHyon.Kim@Sun.COM * Hope no other thread calls it before we have returned
1204*10652SHyon.Kim@Sun.COM */
1205*10652SHyon.Kim@Sun.COM _hbaapi_total_library_count = 0;
1206*10652SHyon.Kim@Sun.COM
1207*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
1208*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
1209*10652SHyon.Kim@Sun.COM adapt_infop = adapt_next) {
1210*10652SHyon.Kim@Sun.COM adapt_next = adapt_infop->next;
1211*10652SHyon.Kim@Sun.COM free(adapt_infop->name);
1212*10652SHyon.Kim@Sun.COM free(adapt_infop);
1213*10652SHyon.Kim@Sun.COM }
1214*10652SHyon.Kim@Sun.COM _hbaapi_adapterlist = NULL;
1215*10652SHyon.Kim@Sun.COM _hbaapi_total_adapter_count = 0;
1216*10652SHyon.Kim@Sun.COM
1217*10652SHyon.Kim@Sun.COM /*
1218*10652SHyon.Kim@Sun.COM * Free up the callbacks, this is not the most efficient, but it works
1219*10652SHyon.Kim@Sun.COM */
1220*10652SHyon.Kim@Sun.COM while ((volatile HBA_ADAPTERCALLBACK_ELEM *)
1221*10652SHyon.Kim@Sun.COM _hbaapi_adapteraddevents_callback_list
1222*10652SHyon.Kim@Sun.COM != NULL) {
1223*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE)
1224*10652SHyon.Kim@Sun.COM _hbaapi_adapteraddevents_callback_list);
1225*10652SHyon.Kim@Sun.COM }
1226*10652SHyon.Kim@Sun.COM while ((volatile HBA_ADAPTERCALLBACK_ELEM *)
1227*10652SHyon.Kim@Sun.COM _smhba_adapteraddevents_callback_list
1228*10652SHyon.Kim@Sun.COM != NULL) {
1229*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE)
1230*10652SHyon.Kim@Sun.COM _smhba_adapteraddevents_callback_list);
1231*10652SHyon.Kim@Sun.COM }
1232*10652SHyon.Kim@Sun.COM for (listp = cb_lists_array; *listp != NULL; listp++) {
1233*10652SHyon.Kim@Sun.COM while ((volatile HBA_ADAPTERCALLBACK_ELEM ***)**listp != NULL) {
1234*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE)**listp);
1235*10652SHyon.Kim@Sun.COM }
1236*10652SHyon.Kim@Sun.COM }
1237*10652SHyon.Kim@Sun.COM
1238*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
1239*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
1240*10652SHyon.Kim@Sun.COM
1241*10652SHyon.Kim@Sun.COM #ifdef USESYSLOG
1242*10652SHyon.Kim@Sun.COM closelog();
1243*10652SHyon.Kim@Sun.COM #endif
1244*10652SHyon.Kim@Sun.COM #ifdef USELOGFILE
1245*10652SHyon.Kim@Sun.COM if (_hbaapi_debug_fd != NULL) {
1246*10652SHyon.Kim@Sun.COM fclose(_hbaapi_debug_fd);
1247*10652SHyon.Kim@Sun.COM }
1248*10652SHyon.Kim@Sun.COM _hbaapi_debug_fd = NULL;
1249*10652SHyon.Kim@Sun.COM #endif
1250*10652SHyon.Kim@Sun.COM #ifdef POSIX_THREADS
1251*10652SHyon.Kim@Sun.COM /* this will unlock them as well, but who cares */
1252*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_LE_mutex);
1253*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_TE_mutex);
1254*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_APSE_mutex);
1255*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_APE_mutex);
1256*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_AE_mutex);
1257*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_AAE_mutex);
1258*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_smhba_TE_mutex);
1259*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_smhba_APSE_mutex);
1260*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_smhba_APE_mutex);
1261*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_smhba_AE_mutex);
1262*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_smhba_AAE_mutex);
1263*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_AL_mutex);
1264*10652SHyon.Kim@Sun.COM (void) pthread_mutex_destroy(&_hbaapi_LL_mutex);
1265*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
1266*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_LL_mutex);
1267*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_AL_mutex);
1268*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_AAE_mutex);
1269*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_AE_mutex);
1270*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_APE_mutex);
1271*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_APSE_mutex);
1272*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_TE_mutex);
1273*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_hbaapi_LE_mutex);
1274*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_smhba_TE_mutex);
1275*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_smhba_APSE_mutex);
1276*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_smhba_APE_mutex);
1277*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_smhba_AE_mutex);
1278*10652SHyon.Kim@Sun.COM DeleteCriticalSection(&_smhba_AAE_mutex);
1279*10652SHyon.Kim@Sun.COM #endif
1280*10652SHyon.Kim@Sun.COM
1281*10652SHyon.Kim@Sun.COM return (HBA_STATUS_OK);
1282*10652SHyon.Kim@Sun.COM }
1283*10652SHyon.Kim@Sun.COM
1284*10652SHyon.Kim@Sun.COM /*
1285*10652SHyon.Kim@Sun.COM * The API used to use fixed size tables as its primary data structure.
1286*10652SHyon.Kim@Sun.COM * Indexing from 1 to N identified each adapters. Now the adapters are
1287*10652SHyon.Kim@Sun.COM * on a linked list. There is a unique "index" foreach each adapter.
1288*10652SHyon.Kim@Sun.COM * Adapters always keep their index, even if they are removed from the
1289*10652SHyon.Kim@Sun.COM * hardware. The only time the indexing is reset is on HBA_FreeLibrary
1290*10652SHyon.Kim@Sun.COM */
1291*10652SHyon.Kim@Sun.COM HBA_UINT32
HBA_GetNumberOfAdapters()1292*10652SHyon.Kim@Sun.COM HBA_GetNumberOfAdapters()
1293*10652SHyon.Kim@Sun.COM {
1294*10652SHyon.Kim@Sun.COM int j = 0;
1295*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1296*10652SHyon.Kim@Sun.COM HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersFunc;
1297*10652SHyon.Kim@Sun.COM HBAGetAdapterNameFunc GetAdapterNameFunc;
1298*10652SHyon.Kim@Sun.COM HBA_BOOLEAN found_name;
1299*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
1300*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1301*10652SHyon.Kim@Sun.COM
1302*10652SHyon.Kim@Sun.COM char adaptername[256];
1303*10652SHyon.Kim@Sun.COM int num_adapters; /* local */
1304*10652SHyon.Kim@Sun.COM
1305*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
1306*10652SHyon.Kim@Sun.COM return (0);
1307*10652SHyon.Kim@Sun.COM }
1308*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex); /* pay attention to order */
1309*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
1310*10652SHyon.Kim@Sun.COM
1311*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist;
1312*10652SHyon.Kim@Sun.COM lib_infop != NULL;
1313*10652SHyon.Kim@Sun.COM lib_infop = lib_infop->next) {
1314*10652SHyon.Kim@Sun.COM
1315*10652SHyon.Kim@Sun.COM if (lib_infop->status != HBA_LIBRARY_LOADED) {
1316*10652SHyon.Kim@Sun.COM continue;
1317*10652SHyon.Kim@Sun.COM }
1318*10652SHyon.Kim@Sun.COM
1319*10652SHyon.Kim@Sun.COM GetNumberOfAdaptersFunc =
1320*10652SHyon.Kim@Sun.COM FUNCCOMMON(lib_infop, GetNumberOfAdaptersHandler);
1321*10652SHyon.Kim@Sun.COM if (GetNumberOfAdaptersFunc == NULL) {
1322*10652SHyon.Kim@Sun.COM continue;
1323*10652SHyon.Kim@Sun.COM }
1324*10652SHyon.Kim@Sun.COM num_adapters = ((GetNumberOfAdaptersFunc)());
1325*10652SHyon.Kim@Sun.COM #ifndef WIN32
1326*10652SHyon.Kim@Sun.COM DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
1327*10652SHyon.Kim@Sun.COM lib_infop->LibraryName, num_adapters, 0);
1328*10652SHyon.Kim@Sun.COM #else
1329*10652SHyon.Kim@Sun.COM DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
1330*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath, num_adapters, 0);
1331*10652SHyon.Kim@Sun.COM #endif
1332*10652SHyon.Kim@Sun.COM
1333*10652SHyon.Kim@Sun.COM /* Also get the names of all the adapters here and cache */
1334*10652SHyon.Kim@Sun.COM GetAdapterNameFunc = FUNCCOMMON(lib_infop, GetAdapterNameHandler);
1335*10652SHyon.Kim@Sun.COM if (GetAdapterNameFunc == NULL) {
1336*10652SHyon.Kim@Sun.COM continue;
1337*10652SHyon.Kim@Sun.COM }
1338*10652SHyon.Kim@Sun.COM
1339*10652SHyon.Kim@Sun.COM for (j = 0; j < num_adapters; j++) {
1340*10652SHyon.Kim@Sun.COM found_name = 0;
1341*10652SHyon.Kim@Sun.COM status = (GetAdapterNameFunc)(j, (char *)&adaptername);
1342*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_OK) {
1343*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
1344*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
1345*10652SHyon.Kim@Sun.COM adapt_infop = adapt_infop->next) {
1346*10652SHyon.Kim@Sun.COM /*
1347*10652SHyon.Kim@Sun.COM * check for duplicates, really,
1348*10652SHyon.Kim@Sun.COM * this may just be a second
1349*10652SHyon.Kim@Sun.COM * call to this function
1350*10652SHyon.Kim@Sun.COM * ??? how do we know when a name becomes stale?
1351*10652SHyon.Kim@Sun.COM */
1352*10652SHyon.Kim@Sun.COM if (strcmp(adaptername, adapt_infop->name) == 0) {
1353*10652SHyon.Kim@Sun.COM /* already got this one */
1354*10652SHyon.Kim@Sun.COM found_name++;
1355*10652SHyon.Kim@Sun.COM break;
1356*10652SHyon.Kim@Sun.COM }
1357*10652SHyon.Kim@Sun.COM }
1358*10652SHyon.Kim@Sun.COM if (found_name != 0) {
1359*10652SHyon.Kim@Sun.COM continue;
1360*10652SHyon.Kim@Sun.COM }
1361*10652SHyon.Kim@Sun.COM }
1362*10652SHyon.Kim@Sun.COM
1363*10652SHyon.Kim@Sun.COM adapt_infop = (HBA_ADAPTER_INFO *)
1364*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTER_INFO));
1365*10652SHyon.Kim@Sun.COM if (adapt_infop == NULL) {
1366*10652SHyon.Kim@Sun.COM #ifndef WIN32
1367*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1368*10652SHyon.Kim@Sun.COM "HBA_GetNumberOfAdapters: calloc failed"
1369*10652SHyon.Kim@Sun.COM " on sizeof:%lu\n",
1370*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTER_INFO)));
1371*10652SHyon.Kim@Sun.COM #endif
1372*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
1373*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
1374*10652SHyon.Kim@Sun.COM _hbaapi_total_adapter_count);
1375*10652SHyon.Kim@Sun.COM }
1376*10652SHyon.Kim@Sun.COM if ((adapt_infop->GNstatus = status) == HBA_STATUS_OK) {
1377*10652SHyon.Kim@Sun.COM adapt_infop->name = strdup(adaptername);
1378*10652SHyon.Kim@Sun.COM } else {
1379*10652SHyon.Kim@Sun.COM char dummyname[512];
1380*10652SHyon.Kim@Sun.COM (void) sprintf(dummyname, "NULLADAPTER-%255s-%03d",
1381*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath, _hbaapi_total_adapter_count);
1382*10652SHyon.Kim@Sun.COM dummyname[511] = '\0';
1383*10652SHyon.Kim@Sun.COM adapt_infop->name = strdup(dummyname);
1384*10652SHyon.Kim@Sun.COM }
1385*10652SHyon.Kim@Sun.COM lib_infop->numOfAdapters++;
1386*10652SHyon.Kim@Sun.COM adapt_infop->library = lib_infop;
1387*10652SHyon.Kim@Sun.COM adapt_infop->next = _hbaapi_adapterlist;
1388*10652SHyon.Kim@Sun.COM adapt_infop->index = _hbaapi_total_adapter_count;
1389*10652SHyon.Kim@Sun.COM _hbaapi_adapterlist = adapt_infop;
1390*10652SHyon.Kim@Sun.COM _hbaapi_total_adapter_count++;
1391*10652SHyon.Kim@Sun.COM }
1392*10652SHyon.Kim@Sun.COM }
1393*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
1394*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
1395*10652SHyon.Kim@Sun.COM }
1396*10652SHyon.Kim@Sun.COM
1397*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetAdapterName(HBA_UINT32 adapterindex,char * adaptername)1398*10652SHyon.Kim@Sun.COM HBA_GetAdapterName(
1399*10652SHyon.Kim@Sun.COM HBA_UINT32 adapterindex,
1400*10652SHyon.Kim@Sun.COM char *adaptername)
1401*10652SHyon.Kim@Sun.COM {
1402*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
1403*10652SHyon.Kim@Sun.COM HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
1404*10652SHyon.Kim@Sun.COM
1405*10652SHyon.Kim@Sun.COM if (adaptername == NULL) {
1406*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_GetAdapterName: NULL pointer adatpername",
1407*10652SHyon.Kim@Sun.COM 0, 0, 0);
1408*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_ARG);
1409*10652SHyon.Kim@Sun.COM }
1410*10652SHyon.Kim@Sun.COM
1411*10652SHyon.Kim@Sun.COM /*
1412*10652SHyon.Kim@Sun.COM * The adapter index is from old code, but we have
1413*10652SHyon.Kim@Sun.COM * to support it. Go down the list looking for
1414*10652SHyon.Kim@Sun.COM * the adapter
1415*10652SHyon.Kim@Sun.COM */
1416*10652SHyon.Kim@Sun.COM ARE_WE_INITED();
1417*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
1418*10652SHyon.Kim@Sun.COM *adaptername = '\0';
1419*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
1420*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
1421*10652SHyon.Kim@Sun.COM adapt_infop = adapt_infop->next) {
1422*10652SHyon.Kim@Sun.COM
1423*10652SHyon.Kim@Sun.COM if (adapt_infop->index == adapterindex) {
1424*10652SHyon.Kim@Sun.COM if (adapt_infop->name != NULL &&
1425*10652SHyon.Kim@Sun.COM adapt_infop->GNstatus == HBA_STATUS_OK) {
1426*10652SHyon.Kim@Sun.COM (void) strcpy(adaptername, adapt_infop->name);
1427*10652SHyon.Kim@Sun.COM } else {
1428*10652SHyon.Kim@Sun.COM *adaptername = '\0';
1429*10652SHyon.Kim@Sun.COM }
1430*10652SHyon.Kim@Sun.COM ret = adapt_infop->GNstatus;
1431*10652SHyon.Kim@Sun.COM break;
1432*10652SHyon.Kim@Sun.COM }
1433*10652SHyon.Kim@Sun.COM }
1434*10652SHyon.Kim@Sun.COM DEBUG(2, "GetAdapterName for index:%d ->%s",
1435*10652SHyon.Kim@Sun.COM adapterindex, adaptername, 0);
1436*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret);
1437*10652SHyon.Kim@Sun.COM }
1438*10652SHyon.Kim@Sun.COM
1439*10652SHyon.Kim@Sun.COM HBA_HANDLE
HBA_OpenAdapter(char * adaptername)1440*10652SHyon.Kim@Sun.COM HBA_OpenAdapter(char *adaptername)
1441*10652SHyon.Kim@Sun.COM {
1442*10652SHyon.Kim@Sun.COM HBA_HANDLE handle;
1443*10652SHyon.Kim@Sun.COM HBAOpenAdapterFunc OpenAdapterFunc;
1444*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
1445*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1446*10652SHyon.Kim@Sun.COM
1447*10652SHyon.Kim@Sun.COM DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0);
1448*10652SHyon.Kim@Sun.COM
1449*10652SHyon.Kim@Sun.COM handle = HBA_HANDLE_INVALID;
1450*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
1451*10652SHyon.Kim@Sun.COM return (handle);
1452*10652SHyon.Kim@Sun.COM }
1453*10652SHyon.Kim@Sun.COM if (adaptername == NULL) {
1454*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_OpenAdapter: NULL pointer adatpername",
1455*10652SHyon.Kim@Sun.COM 0, 0, 0);
1456*10652SHyon.Kim@Sun.COM return (handle);
1457*10652SHyon.Kim@Sun.COM }
1458*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
1459*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
1460*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
1461*10652SHyon.Kim@Sun.COM adapt_infop = adapt_infop->next) {
1462*10652SHyon.Kim@Sun.COM if (strcmp(adaptername, adapt_infop->name) != 0) {
1463*10652SHyon.Kim@Sun.COM continue;
1464*10652SHyon.Kim@Sun.COM }
1465*10652SHyon.Kim@Sun.COM lib_infop = adapt_infop->library;
1466*10652SHyon.Kim@Sun.COM OpenAdapterFunc = FUNCCOMMON(lib_infop, OpenAdapterHandler);
1467*10652SHyon.Kim@Sun.COM
1468*10652SHyon.Kim@Sun.COM if (OpenAdapterFunc != NULL) {
1469*10652SHyon.Kim@Sun.COM /* retrieve the vendor handle */
1470*10652SHyon.Kim@Sun.COM handle = (OpenAdapterFunc)(adaptername);
1471*10652SHyon.Kim@Sun.COM if (handle != 0) {
1472*10652SHyon.Kim@Sun.COM /* or this with the library index to get the common handle */
1473*10652SHyon.Kim@Sun.COM handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1474*10652SHyon.Kim@Sun.COM }
1475*10652SHyon.Kim@Sun.COM }
1476*10652SHyon.Kim@Sun.COM break;
1477*10652SHyon.Kim@Sun.COM }
1478*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, handle);
1479*10652SHyon.Kim@Sun.COM }
1480*10652SHyon.Kim@Sun.COM
1481*10652SHyon.Kim@Sun.COM /*
1482*10652SHyon.Kim@Sun.COM * Finding an adapter with matching WWN.
1483*10652SHyon.Kim@Sun.COM */
1484*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_OpenAdapterByWWN(HBA_HANDLE * phandle,HBA_WWN nodeWWN)1485*10652SHyon.Kim@Sun.COM HBA_OpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN) {
1486*10652SHyon.Kim@Sun.COM HBA_HANDLE handle;
1487*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1488*10652SHyon.Kim@Sun.COM HBAGetNumberOfAdaptersFunc
1489*10652SHyon.Kim@Sun.COM GetNumberOfAdaptersFunc;
1490*10652SHyon.Kim@Sun.COM HBAOpenAdapterByWWNFunc
1491*10652SHyon.Kim@Sun.COM OpenAdapterFunc;
1492*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1493*10652SHyon.Kim@Sun.COM
1494*10652SHyon.Kim@Sun.COM DEBUG(2, "OpenAdapterByWWN: %s", WWN2STR1(&nodeWWN), 0, 0);
1495*10652SHyon.Kim@Sun.COM ARE_WE_INITED();
1496*10652SHyon.Kim@Sun.COM
1497*10652SHyon.Kim@Sun.COM *phandle = HBA_HANDLE_INVALID;
1498*10652SHyon.Kim@Sun.COM
1499*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
1500*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist;
1501*10652SHyon.Kim@Sun.COM lib_infop != NULL;
1502*10652SHyon.Kim@Sun.COM lib_infop = lib_infop->next) {
1503*10652SHyon.Kim@Sun.COM
1504*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_ILLEGAL_WWN;
1505*10652SHyon.Kim@Sun.COM
1506*10652SHyon.Kim@Sun.COM if (lib_infop->status != HBA_LIBRARY_LOADED) {
1507*10652SHyon.Kim@Sun.COM continue;
1508*10652SHyon.Kim@Sun.COM }
1509*10652SHyon.Kim@Sun.COM
1510*10652SHyon.Kim@Sun.COM /* only for HBAAPIV2 */
1511*10652SHyon.Kim@Sun.COM if (lib_infop->version != HBAAPIV2) {
1512*10652SHyon.Kim@Sun.COM continue;
1513*10652SHyon.Kim@Sun.COM }
1514*10652SHyon.Kim@Sun.COM
1515*10652SHyon.Kim@Sun.COM GetNumberOfAdaptersFunc =
1516*10652SHyon.Kim@Sun.COM FUNCCOMMON(lib_infop, GetNumberOfAdaptersHandler);
1517*10652SHyon.Kim@Sun.COM if (GetNumberOfAdaptersFunc == NULL) {
1518*10652SHyon.Kim@Sun.COM continue;
1519*10652SHyon.Kim@Sun.COM }
1520*10652SHyon.Kim@Sun.COM
1521*10652SHyon.Kim@Sun.COM /* look for new hardware */
1522*10652SHyon.Kim@Sun.COM (void) ((GetNumberOfAdaptersFunc)());
1523*10652SHyon.Kim@Sun.COM
1524*10652SHyon.Kim@Sun.COM OpenAdapterFunc =
1525*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.OpenAdapterByWWNHandler;
1526*10652SHyon.Kim@Sun.COM if (OpenAdapterFunc == NULL) {
1527*10652SHyon.Kim@Sun.COM continue;
1528*10652SHyon.Kim@Sun.COM }
1529*10652SHyon.Kim@Sun.COM /*
1530*10652SHyon.Kim@Sun.COM * We do not know if the WWN is known by this vendor,
1531*10652SHyon.Kim@Sun.COM * just try it
1532*10652SHyon.Kim@Sun.COM */
1533*10652SHyon.Kim@Sun.COM if ((status = (OpenAdapterFunc)(&handle, nodeWWN)) != HBA_STATUS_OK) {
1534*10652SHyon.Kim@Sun.COM continue;
1535*10652SHyon.Kim@Sun.COM }
1536*10652SHyon.Kim@Sun.COM /* OK, make a vendor non-specific handle */
1537*10652SHyon.Kim@Sun.COM *phandle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1538*10652SHyon.Kim@Sun.COM status = HBA_STATUS_OK;
1539*10652SHyon.Kim@Sun.COM break;
1540*10652SHyon.Kim@Sun.COM }
1541*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1542*10652SHyon.Kim@Sun.COM }
1543*10652SHyon.Kim@Sun.COM
1544*10652SHyon.Kim@Sun.COM void
HBA_RefreshAdapterConfiguration()1545*10652SHyon.Kim@Sun.COM HBA_RefreshAdapterConfiguration() {
1546*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RefreshAdapterConfiguration", 0, 0, 0);
1547*10652SHyon.Kim@Sun.COM (void) HBA_GetNumberOfAdapters();
1548*10652SHyon.Kim@Sun.COM }
1549*10652SHyon.Kim@Sun.COM
1550*10652SHyon.Kim@Sun.COM HBA_UINT32
HBA_GetVersion()1551*10652SHyon.Kim@Sun.COM HBA_GetVersion() {
1552*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetVersion", 0, 0, 0);
1553*10652SHyon.Kim@Sun.COM return (HBA_LIBVERSION);
1554*10652SHyon.Kim@Sun.COM }
1555*10652SHyon.Kim@Sun.COM
1556*10652SHyon.Kim@Sun.COM /*
1557*10652SHyon.Kim@Sun.COM * This function is VERY OS dependent. Wing it as best you can.
1558*10652SHyon.Kim@Sun.COM */
1559*10652SHyon.Kim@Sun.COM HBA_UINT32
HBA_GetWrapperLibraryAttributes(HBA_LIBRARYATTRIBUTES * attributes)1560*10652SHyon.Kim@Sun.COM HBA_GetWrapperLibraryAttributes(
1561*10652SHyon.Kim@Sun.COM HBA_LIBRARYATTRIBUTES *attributes)
1562*10652SHyon.Kim@Sun.COM {
1563*10652SHyon.Kim@Sun.COM
1564*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetWrapperLibraryAttributes", 0, 0, 0);
1565*10652SHyon.Kim@Sun.COM
1566*10652SHyon.Kim@Sun.COM if (attributes == NULL) {
1567*10652SHyon.Kim@Sun.COM DEBUG(1, "HBA_GetWrapperLibraryAttributes:"
1568*10652SHyon.Kim@Sun.COM "NULL pointer attributes",
1569*10652SHyon.Kim@Sun.COM 0, 0, 0);
1570*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_ARG);
1571*10652SHyon.Kim@Sun.COM }
1572*10652SHyon.Kim@Sun.COM
1573*10652SHyon.Kim@Sun.COM (void) memset(attributes, 0, sizeof (HBA_LIBRARYATTRIBUTES));
1574*10652SHyon.Kim@Sun.COM
1575*10652SHyon.Kim@Sun.COM #if defined(SOLARIS)
1576*10652SHyon.Kim@Sun.COM if ((handle = dlopen("libHBAAPI.so", RTLD_NOW)) != NULL) {
1577*10652SHyon.Kim@Sun.COM if (dlinfo(handle, RTLD_DI_LINKMAP, &map) >= 0) {
1578*10652SHyon.Kim@Sun.COM for (mp = map; mp != NULL; mp = mp->l_next) {
1579*10652SHyon.Kim@Sun.COM if (strlen(map->l_name) < 256) {
1580*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->LibPath, map->l_name);
1581*10652SHyon.Kim@Sun.COM }
1582*10652SHyon.Kim@Sun.COM }
1583*10652SHyon.Kim@Sun.COM }
1584*10652SHyon.Kim@Sun.COM }
1585*10652SHyon.Kim@Sun.COM #elif defined(WIN32)
1586*10652SHyon.Kim@Sun.COM HMODULE module;
1587*10652SHyon.Kim@Sun.COM
1588*10652SHyon.Kim@Sun.COM /* No need to do anything with the module handle */
1589*10652SHyon.Kim@Sun.COM /* It wasn't alloocated so it doesn't need to be freed */
1590*10652SHyon.Kim@Sun.COM module = GetModuleHandle("HBAAPI");
1591*10652SHyon.Kim@Sun.COM if (module != NULL) {
1592*10652SHyon.Kim@Sun.COM if (GetModuleFileName(module, attributes->LibPath,
1593*10652SHyon.Kim@Sun.COM sizeof (attributes->LibPath)) == 0) {
1594*10652SHyon.Kim@Sun.COM attributes->LibPath[0] = '\0';
1595*10652SHyon.Kim@Sun.COM }
1596*10652SHyon.Kim@Sun.COM }
1597*10652SHyon.Kim@Sun.COM #endif
1598*10652SHyon.Kim@Sun.COM #if defined(VENDOR)
1599*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->VName, VENDOR);
1600*10652SHyon.Kim@Sun.COM #else
1601*10652SHyon.Kim@Sun.COM attributes->VName[0] = '\0';
1602*10652SHyon.Kim@Sun.COM #endif
1603*10652SHyon.Kim@Sun.COM #if defined(VERSION)
1604*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->VVersion, VERSION);
1605*10652SHyon.Kim@Sun.COM #else
1606*10652SHyon.Kim@Sun.COM attributes->VVersion[0] = '\0';
1607*10652SHyon.Kim@Sun.COM #endif
1608*10652SHyon.Kim@Sun.COM #if defined(BUILD_DATE)
1609*10652SHyon.Kim@Sun.COM #if defined(WIN32)
1610*10652SHyon.Kim@Sun.COM int matchCount;
1611*10652SHyon.Kim@Sun.COM matchCount = sscanf(BUILD_DATE, "%u/%u/%u %u:%u:%u",
1612*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_year,
1613*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_mon,
1614*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_mday,
1615*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_hour,
1616*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_min,
1617*10652SHyon.Kim@Sun.COM &attributes->build_date.tm_sec);
1618*10652SHyon.Kim@Sun.COM
1619*10652SHyon.Kim@Sun.COM if (matchCount != 6) {
1620*10652SHyon.Kim@Sun.COM memset(&attributes->build_date, 0, sizeof (struct tm));
1621*10652SHyon.Kim@Sun.COM } else {
1622*10652SHyon.Kim@Sun.COM attributes->build_date.tm_year -= 1900;
1623*10652SHyon.Kim@Sun.COM attributes->build_date.tm_isdst = -1;
1624*10652SHyon.Kim@Sun.COM }
1625*10652SHyon.Kim@Sun.COM #else
1626*10652SHyon.Kim@Sun.COM if (strptime(BUILD_DATE,
1627*10652SHyon.Kim@Sun.COM "%Y/%m/%d %T %Z", &(attributes->build_date)) == NULL) {
1628*10652SHyon.Kim@Sun.COM (void) memset(&attributes->build_date, 0, sizeof (struct tm));
1629*10652SHyon.Kim@Sun.COM }
1630*10652SHyon.Kim@Sun.COM #endif
1631*10652SHyon.Kim@Sun.COM #else
1632*10652SHyon.Kim@Sun.COM (void) memset(&attributes->build_date, 0, sizeof (struct tm));
1633*10652SHyon.Kim@Sun.COM #endif
1634*10652SHyon.Kim@Sun.COM return (2);
1635*10652SHyon.Kim@Sun.COM }
1636*10652SHyon.Kim@Sun.COM
1637*10652SHyon.Kim@Sun.COM /*
1638*10652SHyon.Kim@Sun.COM * Callback registation and handling
1639*10652SHyon.Kim@Sun.COM */
1640*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RemoveCallback(HBA_CALLBACKHANDLE cbhandle)1641*10652SHyon.Kim@Sun.COM HBA_RemoveCallback(HBA_CALLBACKHANDLE cbhandle) {
1642*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1643*10652SHyon.Kim@Sun.COM
1644*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RemoveCallback", 0, 0, 0);
1645*10652SHyon.Kim@Sun.COM ARE_WE_INITED();
1646*10652SHyon.Kim@Sun.COM
1647*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
1648*10652SHyon.Kim@Sun.COM status = local_remove_callback(cbhandle);
1649*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1650*10652SHyon.Kim@Sun.COM }
1651*10652SHyon.Kim@Sun.COM
1652*10652SHyon.Kim@Sun.COM /* Adapter Add Events ************************************************* */
1653*10652SHyon.Kim@Sun.COM static void
1654*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_ARG_UNUSED */
adapteraddevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType)1655*10652SHyon.Kim@Sun.COM adapteraddevents_callback(void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) {
1656*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
1657*10652SHyon.Kim@Sun.COM
1658*10652SHyon.Kim@Sun.COM DEBUG(3, "AddAdapterEvent, port: %s", WWN2STR1(&PortWWN), 0, 0);
1659*10652SHyon.Kim@Sun.COM
1660*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AAE_mutex);
1661*10652SHyon.Kim@Sun.COM for (cbp = _hbaapi_adapteraddevents_callback_list;
1662*10652SHyon.Kim@Sun.COM cbp != NULL;
1663*10652SHyon.Kim@Sun.COM cbp = cbp->next) {
1664*10652SHyon.Kim@Sun.COM (*cbp->callback)(data, PortWWN, HBA_EVENT_ADAPTER_ADD);
1665*10652SHyon.Kim@Sun.COM }
1666*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1667*10652SHyon.Kim@Sun.COM
1668*10652SHyon.Kim@Sun.COM }
1669*10652SHyon.Kim@Sun.COM
1670*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForAdapterAddEvents(void (* callback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType),void * userData,HBA_CALLBACKHANDLE * callbackHandle)1671*10652SHyon.Kim@Sun.COM HBA_RegisterForAdapterAddEvents(
1672*10652SHyon.Kim@Sun.COM void (*callback)(
1673*10652SHyon.Kim@Sun.COM void *data,
1674*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1675*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
1676*10652SHyon.Kim@Sun.COM void *userData,
1677*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle) {
1678*10652SHyon.Kim@Sun.COM
1679*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
1680*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vcbp;
1681*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
1682*10652SHyon.Kim@Sun.COM HBARegisterForAdapterAddEventsFunc registeredfunc;
1683*10652SHyon.Kim@Sun.COM HBA_STATUS status = HBA_STATUS_OK;
1684*10652SHyon.Kim@Sun.COM HBA_STATUS failure = HBA_STATUS_OK;
1685*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1686*10652SHyon.Kim@Sun.COM int registered_cnt = 0;
1687*10652SHyon.Kim@Sun.COM int vendor_cnt = 0;
1688*10652SHyon.Kim@Sun.COM int not_supported_cnt = 0;
1689*10652SHyon.Kim@Sun.COM int status_OK_bar_cnt = 0;
1690*10652SHyon.Kim@Sun.COM int status_OK_cnt = 0;
1691*10652SHyon.Kim@Sun.COM
1692*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForAdapterAddEvents", 0, 0, 0);
1693*10652SHyon.Kim@Sun.COM ARE_WE_INITED();
1694*10652SHyon.Kim@Sun.COM
1695*10652SHyon.Kim@Sun.COM cbp = (HBA_ALLADAPTERSCALLBACK_ELEM *)
1696*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ALLADAPTERSCALLBACK_ELEM));
1697*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) cbp;
1698*10652SHyon.Kim@Sun.COM if (cbp == NULL) {
1699*10652SHyon.Kim@Sun.COM #ifndef WIN32
1700*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1701*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: calloc failed "
1702*10652SHyon.Kim@Sun.COM "for %lu bytes\n",
1703*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ALLADAPTERSCALLBACK_ELEM)));
1704*10652SHyon.Kim@Sun.COM #endif
1705*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
1706*10652SHyon.Kim@Sun.COM }
1707*10652SHyon.Kim@Sun.COM
1708*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
1709*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AAE_mutex);
1710*10652SHyon.Kim@Sun.COM cbp->callback = callback;
1711*10652SHyon.Kim@Sun.COM cbp->next = _hbaapi_adapteraddevents_callback_list;
1712*10652SHyon.Kim@Sun.COM _hbaapi_adapteraddevents_callback_list = cbp;
1713*10652SHyon.Kim@Sun.COM /*
1714*10652SHyon.Kim@Sun.COM * Need to release the mutex now incase the vendor function invokes the
1715*10652SHyon.Kim@Sun.COM * callback. We will grap the mutex later to attach the vendor handle
1716*10652SHyon.Kim@Sun.COM * list to the callback structure
1717*10652SHyon.Kim@Sun.COM */
1718*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1719*10652SHyon.Kim@Sun.COM
1720*10652SHyon.Kim@Sun.COM /*
1721*10652SHyon.Kim@Sun.COM * now create a list of vendors (vendor libraryies, NOT ADAPTERS)
1722*10652SHyon.Kim@Sun.COM * that have successfully registerred
1723*10652SHyon.Kim@Sun.COM */
1724*10652SHyon.Kim@Sun.COM vendorhandlelist = NULL;
1725*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist;
1726*10652SHyon.Kim@Sun.COM lib_infop != NULL;
1727*10652SHyon.Kim@Sun.COM lib_infop = lib_infop->next) {
1728*10652SHyon.Kim@Sun.COM
1729*10652SHyon.Kim@Sun.COM /* only for HBAAPI V2 */
1730*10652SHyon.Kim@Sun.COM if ((lib_infop->version != HBAAPIV2)) {
1731*10652SHyon.Kim@Sun.COM continue;
1732*10652SHyon.Kim@Sun.COM } else {
1733*10652SHyon.Kim@Sun.COM vendor_cnt++;
1734*10652SHyon.Kim@Sun.COM }
1735*10652SHyon.Kim@Sun.COM
1736*10652SHyon.Kim@Sun.COM registeredfunc =
1737*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RegisterForAdapterAddEventsHandler;
1738*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
1739*10652SHyon.Kim@Sun.COM continue;
1740*10652SHyon.Kim@Sun.COM }
1741*10652SHyon.Kim@Sun.COM
1742*10652SHyon.Kim@Sun.COM vcbp = (HBA_VENDORCALLBACK_ELEM *)
1743*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_VENDORCALLBACK_ELEM));
1744*10652SHyon.Kim@Sun.COM if (vcbp == NULL) {
1745*10652SHyon.Kim@Sun.COM #ifndef WIN32
1746*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1747*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: "
1748*10652SHyon.Kim@Sun.COM "calloc failed for %lu bytes\n",
1749*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_VENDORCALLBACK_ELEM)));
1750*10652SHyon.Kim@Sun.COM #endif
1751*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
1752*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
1753*10652SHyon.Kim@Sun.COM break;
1754*10652SHyon.Kim@Sun.COM }
1755*10652SHyon.Kim@Sun.COM
1756*10652SHyon.Kim@Sun.COM registered_cnt++;
1757*10652SHyon.Kim@Sun.COM status = (registeredfunc)(adapteraddevents_callback,
1758*10652SHyon.Kim@Sun.COM userData, &vcbp->vendorcbhandle);
1759*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_ERROR_NOT_SUPPORTED) {
1760*10652SHyon.Kim@Sun.COM not_supported_cnt++;
1761*10652SHyon.Kim@Sun.COM free(vcbp);
1762*10652SHyon.Kim@Sun.COM continue;
1763*10652SHyon.Kim@Sun.COM } else if (status != HBA_STATUS_OK) {
1764*10652SHyon.Kim@Sun.COM status_OK_bar_cnt++;
1765*10652SHyon.Kim@Sun.COM DEBUG(1,
1766*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
1767*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath, status, 0);
1768*10652SHyon.Kim@Sun.COM #ifndef WIN32
1769*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1770*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
1771*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath, status);
1772*10652SHyon.Kim@Sun.COM #endif
1773*10652SHyon.Kim@Sun.COM failure = status;
1774*10652SHyon.Kim@Sun.COM free(vcbp);
1775*10652SHyon.Kim@Sun.COM continue;
1776*10652SHyon.Kim@Sun.COM } else {
1777*10652SHyon.Kim@Sun.COM status_OK_cnt++;
1778*10652SHyon.Kim@Sun.COM }
1779*10652SHyon.Kim@Sun.COM vcbp->lib_info = lib_infop;
1780*10652SHyon.Kim@Sun.COM vcbp->next = vendorhandlelist;
1781*10652SHyon.Kim@Sun.COM vendorhandlelist = vcbp;
1782*10652SHyon.Kim@Sun.COM }
1783*10652SHyon.Kim@Sun.COM if (vendor_cnt == 0) {
1784*10652SHyon.Kim@Sun.COM /* no HBAAPIV2 is deteced. should be okay? */
1785*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
1786*10652SHyon.Kim@Sun.COM } else if (registered_cnt == 0) {
1787*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
1788*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
1789*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
1790*10652SHyon.Kim@Sun.COM } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
1791*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
1792*10652SHyon.Kim@Sun.COM } else if (status_OK_cnt == 0) {
1793*10652SHyon.Kim@Sun.COM /*
1794*10652SHyon.Kim@Sun.COM * At least one vendor library registered this function, but no
1795*10652SHyon.Kim@Sun.COM * vendor call succeeded
1796*10652SHyon.Kim@Sun.COM */
1797*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
1798*10652SHyon.Kim@Sun.COM status = failure;
1799*10652SHyon.Kim@Sun.COM } else {
1800*10652SHyon.Kim@Sun.COM /* we have had atleast some success, now finish up */
1801*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AAE_mutex);
1802*10652SHyon.Kim@Sun.COM /*
1803*10652SHyon.Kim@Sun.COM * this seems silly, but what if another thread called
1804*10652SHyon.Kim@Sun.COM * the callback remove
1805*10652SHyon.Kim@Sun.COM */
1806*10652SHyon.Kim@Sun.COM for (cbp = _hbaapi_adapteraddevents_callback_list;
1807*10652SHyon.Kim@Sun.COM cbp != NULL; cbp = cbp->next) {
1808*10652SHyon.Kim@Sun.COM if ((HBA_CALLBACKHANDLE)cbp == *callbackHandle) {
1809*10652SHyon.Kim@Sun.COM /* yup, its still there, hooray */
1810*10652SHyon.Kim@Sun.COM cbp->vendorhandlelist = vendorhandlelist;
1811*10652SHyon.Kim@Sun.COM vendorhandlelist = NULL;
1812*10652SHyon.Kim@Sun.COM break;
1813*10652SHyon.Kim@Sun.COM }
1814*10652SHyon.Kim@Sun.COM }
1815*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1816*10652SHyon.Kim@Sun.COM if (vendorhandlelist != NULL) {
1817*10652SHyon.Kim@Sun.COM /*
1818*10652SHyon.Kim@Sun.COM * bummer, somebody removed the callback before we finished
1819*10652SHyon.Kim@Sun.COM * registration, probably will never happen
1820*10652SHyon.Kim@Sun.COM */
1821*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
1822*10652SHyon.Kim@Sun.COM DEBUG(1,
1823*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
1824*10652SHyon.Kim@Sun.COM "called for a handle before registration was finished.",
1825*10652SHyon.Kim@Sun.COM 0, 0, 0);
1826*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
1827*10652SHyon.Kim@Sun.COM } else {
1828*10652SHyon.Kim@Sun.COM status = HBA_STATUS_OK;
1829*10652SHyon.Kim@Sun.COM }
1830*10652SHyon.Kim@Sun.COM }
1831*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1832*10652SHyon.Kim@Sun.COM }
1833*10652SHyon.Kim@Sun.COM
1834*10652SHyon.Kim@Sun.COM /* Adapter Events (other than add) ************************************** */
1835*10652SHyon.Kim@Sun.COM static void
adapterevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType)1836*10652SHyon.Kim@Sun.COM adapterevents_callback(void *data,
1837*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1838*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType) {
1839*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
1840*10652SHyon.Kim@Sun.COM
1841*10652SHyon.Kim@Sun.COM DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
1842*10652SHyon.Kim@Sun.COM eventType, 0);
1843*10652SHyon.Kim@Sun.COM
1844*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AE_mutex);
1845*10652SHyon.Kim@Sun.COM for (acbp = _hbaapi_adapterevents_callback_list;
1846*10652SHyon.Kim@Sun.COM acbp != NULL;
1847*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
1848*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
1849*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, PortWWN, eventType);
1850*10652SHyon.Kim@Sun.COM break;
1851*10652SHyon.Kim@Sun.COM }
1852*10652SHyon.Kim@Sun.COM }
1853*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AE_mutex);
1854*10652SHyon.Kim@Sun.COM }
1855*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForAdapterEvents(void (* callback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType),void * userData,HBA_HANDLE handle,HBA_CALLBACKHANDLE * callbackHandle)1856*10652SHyon.Kim@Sun.COM HBA_RegisterForAdapterEvents(
1857*10652SHyon.Kim@Sun.COM void (*callback) (
1858*10652SHyon.Kim@Sun.COM void *data,
1859*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1860*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
1861*10652SHyon.Kim@Sun.COM void *userData,
1862*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
1863*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle) {
1864*10652SHyon.Kim@Sun.COM
1865*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
1866*10652SHyon.Kim@Sun.COM HBARegisterForAdapterEventsFunc registeredfunc;
1867*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1868*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1869*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
1870*10652SHyon.Kim@Sun.COM
1871*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForAdapterEvents", 0, 0, 0);
1872*10652SHyon.Kim@Sun.COM
1873*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
1874*10652SHyon.Kim@Sun.COM
1875*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
1876*10652SHyon.Kim@Sun.COM
1877*10652SHyon.Kim@Sun.COM registeredfunc =
1878*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RegisterForAdapterEventsHandler;
1879*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
1880*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1881*10652SHyon.Kim@Sun.COM }
1882*10652SHyon.Kim@Sun.COM
1883*10652SHyon.Kim@Sun.COM /*
1884*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
1885*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
1886*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
1887*10652SHyon.Kim@Sun.COM */
1888*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1889*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
1890*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
1891*10652SHyon.Kim@Sun.COM #ifndef WIN32
1892*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1893*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterEvents: calloc failed for %lu bytes\n",
1894*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
1895*10652SHyon.Kim@Sun.COM #endif
1896*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1897*10652SHyon.Kim@Sun.COM }
1898*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1899*10652SHyon.Kim@Sun.COM acbp->callback = callback;
1900*10652SHyon.Kim@Sun.COM acbp->userdata = userData;
1901*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
1902*10652SHyon.Kim@Sun.COM
1903*10652SHyon.Kim@Sun.COM status = (registeredfunc)(adapterevents_callback,
1904*10652SHyon.Kim@Sun.COM (void *)acbp,
1905*10652SHyon.Kim@Sun.COM vendorHandle,
1906*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
1907*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
1908*10652SHyon.Kim@Sun.COM free(acbp);
1909*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1910*10652SHyon.Kim@Sun.COM }
1911*10652SHyon.Kim@Sun.COM
1912*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AE_mutex);
1913*10652SHyon.Kim@Sun.COM acbp->next = _hbaapi_adapterevents_callback_list;
1914*10652SHyon.Kim@Sun.COM _hbaapi_adapterevents_callback_list = acbp;
1915*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AE_mutex);
1916*10652SHyon.Kim@Sun.COM
1917*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1918*10652SHyon.Kim@Sun.COM }
1919*10652SHyon.Kim@Sun.COM
1920*10652SHyon.Kim@Sun.COM /* Adapter Port Events ************************************************** */
1921*10652SHyon.Kim@Sun.COM static void
adapterportevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType,HBA_UINT32 fabricPortID)1922*10652SHyon.Kim@Sun.COM adapterportevents_callback(void *data,
1923*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1924*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
1925*10652SHyon.Kim@Sun.COM HBA_UINT32 fabricPortID) {
1926*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
1927*10652SHyon.Kim@Sun.COM
1928*10652SHyon.Kim@Sun.COM DEBUG(3, "AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
1929*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN), eventType, fabricPortID);
1930*10652SHyon.Kim@Sun.COM
1931*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APE_mutex);
1932*10652SHyon.Kim@Sun.COM
1933*10652SHyon.Kim@Sun.COM for (acbp = _hbaapi_adapterportevents_callback_list;
1934*10652SHyon.Kim@Sun.COM acbp != NULL;
1935*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
1936*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
1937*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, PortWWN, eventType, fabricPortID);
1938*10652SHyon.Kim@Sun.COM break;
1939*10652SHyon.Kim@Sun.COM }
1940*10652SHyon.Kim@Sun.COM }
1941*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APE_mutex);
1942*10652SHyon.Kim@Sun.COM }
1943*10652SHyon.Kim@Sun.COM
1944*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForAdapterPortEvents(void (* callback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType,HBA_UINT32 fabricPortID),void * userData,HBA_HANDLE handle,HBA_WWN PortWWN,HBA_CALLBACKHANDLE * callbackHandle)1945*10652SHyon.Kim@Sun.COM HBA_RegisterForAdapterPortEvents(
1946*10652SHyon.Kim@Sun.COM void (*callback) (
1947*10652SHyon.Kim@Sun.COM void *data,
1948*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1949*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
1950*10652SHyon.Kim@Sun.COM HBA_UINT32 fabricPortID),
1951*10652SHyon.Kim@Sun.COM void *userData,
1952*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
1953*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
1954*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle) {
1955*10652SHyon.Kim@Sun.COM
1956*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
1957*10652SHyon.Kim@Sun.COM HBARegisterForAdapterPortEventsFunc registeredfunc;
1958*10652SHyon.Kim@Sun.COM HBA_STATUS status;
1959*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
1960*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
1961*10652SHyon.Kim@Sun.COM
1962*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForAdapterPortEvents for port: %s",
1963*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN), 0, 0);
1964*10652SHyon.Kim@Sun.COM
1965*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
1966*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
1967*10652SHyon.Kim@Sun.COM
1968*10652SHyon.Kim@Sun.COM registeredfunc =
1969*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RegisterForAdapterPortEventsHandler;
1970*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
1971*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1972*10652SHyon.Kim@Sun.COM }
1973*10652SHyon.Kim@Sun.COM
1974*10652SHyon.Kim@Sun.COM /*
1975*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
1976*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
1977*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
1978*10652SHyon.Kim@Sun.COM */
1979*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1980*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
1981*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
1982*10652SHyon.Kim@Sun.COM #ifndef WIN32
1983*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
1984*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterPortEvents: "
1985*10652SHyon.Kim@Sun.COM "calloc failed for %lu bytes\n",
1986*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
1987*10652SHyon.Kim@Sun.COM #endif
1988*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1989*10652SHyon.Kim@Sun.COM
1990*10652SHyon.Kim@Sun.COM }
1991*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1992*10652SHyon.Kim@Sun.COM acbp->callback = callback;
1993*10652SHyon.Kim@Sun.COM acbp->userdata = userData;
1994*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
1995*10652SHyon.Kim@Sun.COM
1996*10652SHyon.Kim@Sun.COM status = (registeredfunc)(adapterportevents_callback,
1997*10652SHyon.Kim@Sun.COM (void *)acbp,
1998*10652SHyon.Kim@Sun.COM vendorHandle,
1999*10652SHyon.Kim@Sun.COM PortWWN,
2000*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
2001*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
2002*10652SHyon.Kim@Sun.COM free(acbp);
2003*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2004*10652SHyon.Kim@Sun.COM }
2005*10652SHyon.Kim@Sun.COM
2006*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APE_mutex);
2007*10652SHyon.Kim@Sun.COM acbp->next = _hbaapi_adapterportevents_callback_list;
2008*10652SHyon.Kim@Sun.COM _hbaapi_adapterportevents_callback_list = acbp;
2009*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APE_mutex);
2010*10652SHyon.Kim@Sun.COM
2011*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
2012*10652SHyon.Kim@Sun.COM }
2013*10652SHyon.Kim@Sun.COM
2014*10652SHyon.Kim@Sun.COM /* Adapter State Events ************************************************ */
2015*10652SHyon.Kim@Sun.COM static void
adapterportstatevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType)2016*10652SHyon.Kim@Sun.COM adapterportstatevents_callback(void *data,
2017*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
2018*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType) {
2019*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
2020*10652SHyon.Kim@Sun.COM
2021*10652SHyon.Kim@Sun.COM DEBUG(3, "AdapterPortStatEvent, port:%s, eventType:%d",
2022*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN),
2023*10652SHyon.Kim@Sun.COM eventType, 0);
2024*10652SHyon.Kim@Sun.COM
2025*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APSE_mutex);
2026*10652SHyon.Kim@Sun.COM for (acbp = _hbaapi_adapterportstatevents_callback_list;
2027*10652SHyon.Kim@Sun.COM acbp != NULL;
2028*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
2029*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
2030*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, PortWWN, eventType);
2031*10652SHyon.Kim@Sun.COM return;
2032*10652SHyon.Kim@Sun.COM }
2033*10652SHyon.Kim@Sun.COM }
2034*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APSE_mutex);
2035*10652SHyon.Kim@Sun.COM }
2036*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForAdapterPortStatEvents(void (* callback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType),void * userData,HBA_HANDLE handle,HBA_WWN PortWWN,HBA_PORTSTATISTICS stats,HBA_UINT32 statType,HBA_CALLBACKHANDLE * callbackHandle)2037*10652SHyon.Kim@Sun.COM HBA_RegisterForAdapterPortStatEvents(
2038*10652SHyon.Kim@Sun.COM void (*callback) (
2039*10652SHyon.Kim@Sun.COM void *data,
2040*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
2041*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
2042*10652SHyon.Kim@Sun.COM void *userData,
2043*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2044*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
2045*10652SHyon.Kim@Sun.COM HBA_PORTSTATISTICS stats,
2046*10652SHyon.Kim@Sun.COM HBA_UINT32 statType,
2047*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle) {
2048*10652SHyon.Kim@Sun.COM
2049*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
2050*10652SHyon.Kim@Sun.COM HBARegisterForAdapterPortStatEventsFunc
2051*10652SHyon.Kim@Sun.COM registeredfunc;
2052*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2053*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2054*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2055*10652SHyon.Kim@Sun.COM
2056*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForAdapterPortStatEvents for port: %s",
2057*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN), 0, 0);
2058*10652SHyon.Kim@Sun.COM
2059*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2060*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
2061*10652SHyon.Kim@Sun.COM
2062*10652SHyon.Kim@Sun.COM registeredfunc =
2063*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RegisterForAdapterPortStatEventsHandler;
2064*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
2065*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
2066*10652SHyon.Kim@Sun.COM }
2067*10652SHyon.Kim@Sun.COM
2068*10652SHyon.Kim@Sun.COM /*
2069*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
2070*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
2071*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
2072*10652SHyon.Kim@Sun.COM */
2073*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
2074*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
2075*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
2076*10652SHyon.Kim@Sun.COM #ifndef WIN32
2077*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
2078*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterPortStatEvents: "
2079*10652SHyon.Kim@Sun.COM "calloc failed for %lu bytes\n",
2080*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
2081*10652SHyon.Kim@Sun.COM #endif
2082*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
2083*10652SHyon.Kim@Sun.COM }
2084*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
2085*10652SHyon.Kim@Sun.COM acbp->callback = callback;
2086*10652SHyon.Kim@Sun.COM acbp->userdata = userData;
2087*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
2088*10652SHyon.Kim@Sun.COM
2089*10652SHyon.Kim@Sun.COM status = (registeredfunc)(adapterportstatevents_callback,
2090*10652SHyon.Kim@Sun.COM (void *)acbp,
2091*10652SHyon.Kim@Sun.COM vendorHandle,
2092*10652SHyon.Kim@Sun.COM PortWWN,
2093*10652SHyon.Kim@Sun.COM stats,
2094*10652SHyon.Kim@Sun.COM statType,
2095*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
2096*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
2097*10652SHyon.Kim@Sun.COM free(acbp);
2098*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2099*10652SHyon.Kim@Sun.COM }
2100*10652SHyon.Kim@Sun.COM
2101*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_APSE_mutex);
2102*10652SHyon.Kim@Sun.COM acbp->next = _hbaapi_adapterportstatevents_callback_list;
2103*10652SHyon.Kim@Sun.COM _hbaapi_adapterportstatevents_callback_list = acbp;
2104*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_APSE_mutex);
2105*10652SHyon.Kim@Sun.COM
2106*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
2107*10652SHyon.Kim@Sun.COM }
2108*10652SHyon.Kim@Sun.COM
2109*10652SHyon.Kim@Sun.COM /* Target Events ******************************************************* */
2110*10652SHyon.Kim@Sun.COM static void
targetevents_callback(void * data,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_UINT32 eventType)2111*10652SHyon.Kim@Sun.COM targetevents_callback(void *data,
2112*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2113*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2114*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType) {
2115*10652SHyon.Kim@Sun.COM
2116*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
2117*10652SHyon.Kim@Sun.COM
2118*10652SHyon.Kim@Sun.COM DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
2119*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
2120*10652SHyon.Kim@Sun.COM
2121*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_TE_mutex);
2122*10652SHyon.Kim@Sun.COM for (acbp = _hbaapi_targetevents_callback_list;
2123*10652SHyon.Kim@Sun.COM acbp != NULL;
2124*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
2125*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
2126*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, hbaPortWWN,
2127*10652SHyon.Kim@Sun.COM discoveredPortWWN, eventType);
2128*10652SHyon.Kim@Sun.COM break;
2129*10652SHyon.Kim@Sun.COM }
2130*10652SHyon.Kim@Sun.COM }
2131*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_TE_mutex);
2132*10652SHyon.Kim@Sun.COM }
2133*10652SHyon.Kim@Sun.COM
2134*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForTargetEvents(void (* callback)(void * data,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_UINT32 eventType),void * userData,HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_CALLBACKHANDLE * callbackHandle,HBA_UINT32 allTargets)2135*10652SHyon.Kim@Sun.COM HBA_RegisterForTargetEvents(
2136*10652SHyon.Kim@Sun.COM void (*callback) (
2137*10652SHyon.Kim@Sun.COM void *data,
2138*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2139*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2140*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
2141*10652SHyon.Kim@Sun.COM void *userData,
2142*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2143*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2144*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2145*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle,
2146*10652SHyon.Kim@Sun.COM HBA_UINT32 allTargets) {
2147*10652SHyon.Kim@Sun.COM
2148*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM
2149*10652SHyon.Kim@Sun.COM *acbp;
2150*10652SHyon.Kim@Sun.COM HBARegisterForTargetEventsFunc
2151*10652SHyon.Kim@Sun.COM registeredfunc;
2152*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2153*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2154*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2155*10652SHyon.Kim@Sun.COM
2156*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForTargetEvents, hbaPort: %s, discoveredPort: %s",
2157*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
2158*10652SHyon.Kim@Sun.COM
2159*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2160*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
2161*10652SHyon.Kim@Sun.COM
2162*10652SHyon.Kim@Sun.COM registeredfunc =
2163*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RegisterForTargetEventsHandler;
2164*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
2165*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
2166*10652SHyon.Kim@Sun.COM }
2167*10652SHyon.Kim@Sun.COM
2168*10652SHyon.Kim@Sun.COM /*
2169*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
2170*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
2171*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
2172*10652SHyon.Kim@Sun.COM */
2173*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
2174*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
2175*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
2176*10652SHyon.Kim@Sun.COM #ifndef WIN32
2177*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
2178*10652SHyon.Kim@Sun.COM "HBA_RegisterForTargetEvents: calloc failed for %lu bytes\n",
2179*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
2180*10652SHyon.Kim@Sun.COM #endif
2181*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
2182*10652SHyon.Kim@Sun.COM }
2183*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
2184*10652SHyon.Kim@Sun.COM acbp->callback = callback;
2185*10652SHyon.Kim@Sun.COM acbp->userdata = userData;
2186*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
2187*10652SHyon.Kim@Sun.COM
2188*10652SHyon.Kim@Sun.COM status = (registeredfunc)(targetevents_callback,
2189*10652SHyon.Kim@Sun.COM (void *)acbp,
2190*10652SHyon.Kim@Sun.COM vendorHandle,
2191*10652SHyon.Kim@Sun.COM hbaPortWWN,
2192*10652SHyon.Kim@Sun.COM discoveredPortWWN,
2193*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle,
2194*10652SHyon.Kim@Sun.COM allTargets);
2195*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
2196*10652SHyon.Kim@Sun.COM free(acbp);
2197*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2198*10652SHyon.Kim@Sun.COM }
2199*10652SHyon.Kim@Sun.COM
2200*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_TE_mutex);
2201*10652SHyon.Kim@Sun.COM acbp->next = _hbaapi_targetevents_callback_list;
2202*10652SHyon.Kim@Sun.COM _hbaapi_targetevents_callback_list = acbp;
2203*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_TE_mutex);
2204*10652SHyon.Kim@Sun.COM
2205*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
2206*10652SHyon.Kim@Sun.COM }
2207*10652SHyon.Kim@Sun.COM
2208*10652SHyon.Kim@Sun.COM /* Link Events ********************************************************* */
2209*10652SHyon.Kim@Sun.COM static void
linkevents_callback(void * data,HBA_WWN adapterWWN,HBA_UINT32 eventType,void * pRLIRBuffer,HBA_UINT32 RLIRBufferSize)2210*10652SHyon.Kim@Sun.COM linkevents_callback(void *data,
2211*10652SHyon.Kim@Sun.COM HBA_WWN adapterWWN,
2212*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
2213*10652SHyon.Kim@Sun.COM void *pRLIRBuffer,
2214*10652SHyon.Kim@Sun.COM HBA_UINT32 RLIRBufferSize) {
2215*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
2216*10652SHyon.Kim@Sun.COM
2217*10652SHyon.Kim@Sun.COM DEBUG(3, "LinkEvent, hbaWWN:%s, eventType:%d",
2218*10652SHyon.Kim@Sun.COM WWN2STR1(&adapterWWN), eventType, 0);
2219*10652SHyon.Kim@Sun.COM
2220*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LE_mutex);
2221*10652SHyon.Kim@Sun.COM for (acbp = _hbaapi_linkevents_callback_list;
2222*10652SHyon.Kim@Sun.COM acbp != NULL;
2223*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
2224*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
2225*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, adapterWWN,
2226*10652SHyon.Kim@Sun.COM eventType, pRLIRBuffer, RLIRBufferSize);
2227*10652SHyon.Kim@Sun.COM break;
2228*10652SHyon.Kim@Sun.COM }
2229*10652SHyon.Kim@Sun.COM }
2230*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LE_mutex);
2231*10652SHyon.Kim@Sun.COM }
2232*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RegisterForLinkEvents(void (* callback)(void * data,HBA_WWN adapterWWN,HBA_UINT32 eventType,void * pRLIRBuffer,HBA_UINT32 RLIRBufferSize),void * userData,void * pRLIRBuffer,HBA_UINT32 RLIRBufferSize,HBA_HANDLE handle,HBA_CALLBACKHANDLE * callbackHandle)2233*10652SHyon.Kim@Sun.COM HBA_RegisterForLinkEvents(
2234*10652SHyon.Kim@Sun.COM void (*callback) (
2235*10652SHyon.Kim@Sun.COM void *data,
2236*10652SHyon.Kim@Sun.COM HBA_WWN adapterWWN,
2237*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
2238*10652SHyon.Kim@Sun.COM void *pRLIRBuffer,
2239*10652SHyon.Kim@Sun.COM HBA_UINT32 RLIRBufferSize),
2240*10652SHyon.Kim@Sun.COM void *userData,
2241*10652SHyon.Kim@Sun.COM void *pRLIRBuffer,
2242*10652SHyon.Kim@Sun.COM HBA_UINT32 RLIRBufferSize,
2243*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2244*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *callbackHandle) {
2245*10652SHyon.Kim@Sun.COM
2246*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
2247*10652SHyon.Kim@Sun.COM HBARegisterForLinkEventsFunc
2248*10652SHyon.Kim@Sun.COM registeredfunc;
2249*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2250*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2251*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2252*10652SHyon.Kim@Sun.COM
2253*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RegisterForLinkEvents", 0, 0, 0);
2254*10652SHyon.Kim@Sun.COM
2255*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2256*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
2257*10652SHyon.Kim@Sun.COM
2258*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, RegisterForLinkEventsHandler);
2259*10652SHyon.Kim@Sun.COM
2260*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
2261*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
2262*10652SHyon.Kim@Sun.COM }
2263*10652SHyon.Kim@Sun.COM
2264*10652SHyon.Kim@Sun.COM /*
2265*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
2266*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
2267*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
2268*10652SHyon.Kim@Sun.COM */
2269*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
2270*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
2271*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
2272*10652SHyon.Kim@Sun.COM #ifndef WIN32
2273*10652SHyon.Kim@Sun.COM (void) fprintf(stderr,
2274*10652SHyon.Kim@Sun.COM "HBA_RegisterForLinkEvents: calloc failed for %lu bytes\n",
2275*10652SHyon.Kim@Sun.COM (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
2276*10652SHyon.Kim@Sun.COM #endif
2277*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
2278*10652SHyon.Kim@Sun.COM }
2279*10652SHyon.Kim@Sun.COM *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
2280*10652SHyon.Kim@Sun.COM acbp->callback = callback;
2281*10652SHyon.Kim@Sun.COM acbp->userdata = userData;
2282*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
2283*10652SHyon.Kim@Sun.COM
2284*10652SHyon.Kim@Sun.COM status = (registeredfunc)(linkevents_callback,
2285*10652SHyon.Kim@Sun.COM (void *)acbp,
2286*10652SHyon.Kim@Sun.COM pRLIRBuffer,
2287*10652SHyon.Kim@Sun.COM RLIRBufferSize,
2288*10652SHyon.Kim@Sun.COM vendorHandle,
2289*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
2290*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
2291*10652SHyon.Kim@Sun.COM free(acbp);
2292*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2293*10652SHyon.Kim@Sun.COM }
2294*10652SHyon.Kim@Sun.COM
2295*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LE_mutex);
2296*10652SHyon.Kim@Sun.COM acbp->next = _hbaapi_linkevents_callback_list;
2297*10652SHyon.Kim@Sun.COM _hbaapi_linkevents_callback_list = acbp;
2298*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LE_mutex);
2299*10652SHyon.Kim@Sun.COM
2300*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
2301*10652SHyon.Kim@Sun.COM }
2302*10652SHyon.Kim@Sun.COM
2303*10652SHyon.Kim@Sun.COM /*
2304*10652SHyon.Kim@Sun.COM * All of the functions below are almost passthru functions to the
2305*10652SHyon.Kim@Sun.COM * vendor specific function
2306*10652SHyon.Kim@Sun.COM */
2307*10652SHyon.Kim@Sun.COM
2308*10652SHyon.Kim@Sun.COM void
HBA_CloseAdapter(HBA_HANDLE handle)2309*10652SHyon.Kim@Sun.COM HBA_CloseAdapter(HBA_HANDLE handle) {
2310*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2311*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2312*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2313*10652SHyon.Kim@Sun.COM HBACloseAdapterFunc CloseAdapterFunc;
2314*10652SHyon.Kim@Sun.COM
2315*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_CloseAdapter", 0, 0, 0);
2316*10652SHyon.Kim@Sun.COM
2317*10652SHyon.Kim@Sun.COM status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2318*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_OK) {
2319*10652SHyon.Kim@Sun.COM CloseAdapterFunc = FUNCCOMMON(lib_infop, CloseAdapterHandler);
2320*10652SHyon.Kim@Sun.COM if (CloseAdapterFunc != NULL) {
2321*10652SHyon.Kim@Sun.COM ((CloseAdapterFunc)(vendorHandle));
2322*10652SHyon.Kim@Sun.COM }
2323*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
2324*10652SHyon.Kim@Sun.COM }
2325*10652SHyon.Kim@Sun.COM }
2326*10652SHyon.Kim@Sun.COM
2327*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetAdapterAttributes(HBA_HANDLE handle,HBA_ADAPTERATTRIBUTES * hbaattributes)2328*10652SHyon.Kim@Sun.COM HBA_GetAdapterAttributes(
2329*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2330*10652SHyon.Kim@Sun.COM HBA_ADAPTERATTRIBUTES
2331*10652SHyon.Kim@Sun.COM *hbaattributes)
2332*10652SHyon.Kim@Sun.COM {
2333*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2334*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2335*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2336*10652SHyon.Kim@Sun.COM HBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
2337*10652SHyon.Kim@Sun.COM
2338*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetAdapterAttributes", 0, 0, 0);
2339*10652SHyon.Kim@Sun.COM
2340*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2341*10652SHyon.Kim@Sun.COM
2342*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2343*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2344*10652SHyon.Kim@Sun.COM }
2345*10652SHyon.Kim@Sun.COM
2346*10652SHyon.Kim@Sun.COM GetAdapterAttributesFunc =
2347*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetAdapterAttributesHandler;
2348*10652SHyon.Kim@Sun.COM if (GetAdapterAttributesFunc != NULL) {
2349*10652SHyon.Kim@Sun.COM status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
2350*10652SHyon.Kim@Sun.COM } else {
2351*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2352*10652SHyon.Kim@Sun.COM }
2353*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2354*10652SHyon.Kim@Sun.COM }
2355*10652SHyon.Kim@Sun.COM
2356*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetAdapterPortAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_PORTATTRIBUTES * portattributes)2357*10652SHyon.Kim@Sun.COM HBA_GetAdapterPortAttributes(
2358*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2359*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
2360*10652SHyon.Kim@Sun.COM HBA_PORTATTRIBUTES *portattributes)
2361*10652SHyon.Kim@Sun.COM {
2362*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2363*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2364*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2365*10652SHyon.Kim@Sun.COM HBAGetAdapterPortAttributesFunc
2366*10652SHyon.Kim@Sun.COM GetAdapterPortAttributesFunc;
2367*10652SHyon.Kim@Sun.COM
2368*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetAdapterPortAttributes", 0, 0, 0);
2369*10652SHyon.Kim@Sun.COM
2370*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2371*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2372*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2373*10652SHyon.Kim@Sun.COM }
2374*10652SHyon.Kim@Sun.COM
2375*10652SHyon.Kim@Sun.COM GetAdapterPortAttributesFunc =
2376*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetAdapterPortAttributesHandler;
2377*10652SHyon.Kim@Sun.COM if (GetAdapterPortAttributesFunc != NULL) {
2378*10652SHyon.Kim@Sun.COM status = ((GetAdapterPortAttributesFunc)
2379*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, portattributes));
2380*10652SHyon.Kim@Sun.COM } else {
2381*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2382*10652SHyon.Kim@Sun.COM }
2383*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2384*10652SHyon.Kim@Sun.COM }
2385*10652SHyon.Kim@Sun.COM
2386*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetPortStatistics(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_PORTSTATISTICS * portstatistics)2387*10652SHyon.Kim@Sun.COM HBA_GetPortStatistics(
2388*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2389*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
2390*10652SHyon.Kim@Sun.COM HBA_PORTSTATISTICS *portstatistics)
2391*10652SHyon.Kim@Sun.COM {
2392*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2393*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2394*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2395*10652SHyon.Kim@Sun.COM HBAGetPortStatisticsFunc
2396*10652SHyon.Kim@Sun.COM GetPortStatisticsFunc;
2397*10652SHyon.Kim@Sun.COM
2398*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetPortStatistics", 0, 0, 0);
2399*10652SHyon.Kim@Sun.COM
2400*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2401*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2402*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2403*10652SHyon.Kim@Sun.COM }
2404*10652SHyon.Kim@Sun.COM
2405*10652SHyon.Kim@Sun.COM GetPortStatisticsFunc =
2406*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetPortStatisticsHandler;
2407*10652SHyon.Kim@Sun.COM if (GetPortStatisticsFunc != NULL) {
2408*10652SHyon.Kim@Sun.COM status = ((GetPortStatisticsFunc)
2409*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, portstatistics));
2410*10652SHyon.Kim@Sun.COM } else {
2411*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2412*10652SHyon.Kim@Sun.COM }
2413*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2414*10652SHyon.Kim@Sun.COM }
2415*10652SHyon.Kim@Sun.COM
2416*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetDiscoveredPortAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 discoveredportindex,HBA_PORTATTRIBUTES * portattributes)2417*10652SHyon.Kim@Sun.COM HBA_GetDiscoveredPortAttributes(
2418*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2419*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
2420*10652SHyon.Kim@Sun.COM HBA_UINT32 discoveredportindex,
2421*10652SHyon.Kim@Sun.COM HBA_PORTATTRIBUTES *portattributes)
2422*10652SHyon.Kim@Sun.COM {
2423*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2424*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2425*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2426*10652SHyon.Kim@Sun.COM HBAGetDiscoveredPortAttributesFunc
2427*10652SHyon.Kim@Sun.COM GetDiscoveredPortAttributesFunc;
2428*10652SHyon.Kim@Sun.COM
2429*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetDiscoveredPortAttributes", 0, 0, 0);
2430*10652SHyon.Kim@Sun.COM
2431*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2432*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2433*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2434*10652SHyon.Kim@Sun.COM }
2435*10652SHyon.Kim@Sun.COM
2436*10652SHyon.Kim@Sun.COM GetDiscoveredPortAttributesFunc =
2437*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetDiscoveredPortAttributesHandler;
2438*10652SHyon.Kim@Sun.COM if (GetDiscoveredPortAttributesFunc != NULL) {
2439*10652SHyon.Kim@Sun.COM status = ((GetDiscoveredPortAttributesFunc)
2440*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, discoveredportindex,
2441*10652SHyon.Kim@Sun.COM portattributes));
2442*10652SHyon.Kim@Sun.COM } else {
2443*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2444*10652SHyon.Kim@Sun.COM }
2445*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2446*10652SHyon.Kim@Sun.COM }
2447*10652SHyon.Kim@Sun.COM
2448*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetPortAttributesByWWN(HBA_HANDLE handle,HBA_WWN PortWWN,HBA_PORTATTRIBUTES * portattributes)2449*10652SHyon.Kim@Sun.COM HBA_GetPortAttributesByWWN(
2450*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2451*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
2452*10652SHyon.Kim@Sun.COM HBA_PORTATTRIBUTES *portattributes)
2453*10652SHyon.Kim@Sun.COM {
2454*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2455*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2456*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2457*10652SHyon.Kim@Sun.COM HBAGetPortAttributesByWWNFunc
2458*10652SHyon.Kim@Sun.COM GetPortAttributesByWWNFunc;
2459*10652SHyon.Kim@Sun.COM
2460*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetPortAttributesByWWN: %s", WWN2STR1(&PortWWN), 0, 0);
2461*10652SHyon.Kim@Sun.COM
2462*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2463*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2464*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2465*10652SHyon.Kim@Sun.COM }
2466*10652SHyon.Kim@Sun.COM
2467*10652SHyon.Kim@Sun.COM GetPortAttributesByWWNFunc =
2468*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetPortAttributesByWWNHandler;
2469*10652SHyon.Kim@Sun.COM if (GetPortAttributesByWWNFunc != NULL) {
2470*10652SHyon.Kim@Sun.COM status = ((GetPortAttributesByWWNFunc)
2471*10652SHyon.Kim@Sun.COM (vendorHandle, PortWWN, portattributes));
2472*10652SHyon.Kim@Sun.COM } else {
2473*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2474*10652SHyon.Kim@Sun.COM }
2475*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2476*10652SHyon.Kim@Sun.COM }
2477*10652SHyon.Kim@Sun.COM
2478*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendCTPassThru(HBA_HANDLE handle,void * pReqBuffer,HBA_UINT32 ReqBufferSize,void * pRspBuffer,HBA_UINT32 RspBufferSize)2479*10652SHyon.Kim@Sun.COM HBA_SendCTPassThru(
2480*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2481*10652SHyon.Kim@Sun.COM void *pReqBuffer,
2482*10652SHyon.Kim@Sun.COM HBA_UINT32 ReqBufferSize,
2483*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2484*10652SHyon.Kim@Sun.COM HBA_UINT32 RspBufferSize)
2485*10652SHyon.Kim@Sun.COM {
2486*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2487*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2488*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2489*10652SHyon.Kim@Sun.COM HBASendCTPassThruFunc
2490*10652SHyon.Kim@Sun.COM SendCTPassThruFunc;
2491*10652SHyon.Kim@Sun.COM
2492*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendCTPassThru", 0, 0, 0);
2493*10652SHyon.Kim@Sun.COM
2494*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2495*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2496*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2497*10652SHyon.Kim@Sun.COM }
2498*10652SHyon.Kim@Sun.COM
2499*10652SHyon.Kim@Sun.COM SendCTPassThruFunc =
2500*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.SendCTPassThruHandler;
2501*10652SHyon.Kim@Sun.COM if (SendCTPassThruFunc != NULL) {
2502*10652SHyon.Kim@Sun.COM status = (SendCTPassThruFunc)
2503*10652SHyon.Kim@Sun.COM (vendorHandle,
2504*10652SHyon.Kim@Sun.COM pReqBuffer, ReqBufferSize,
2505*10652SHyon.Kim@Sun.COM pRspBuffer, RspBufferSize);
2506*10652SHyon.Kim@Sun.COM } else {
2507*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2508*10652SHyon.Kim@Sun.COM }
2509*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2510*10652SHyon.Kim@Sun.COM }
2511*10652SHyon.Kim@Sun.COM
2512*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendCTPassThruV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,void * pReqBuffer,HBA_UINT32 ReqBufferSize,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)2513*10652SHyon.Kim@Sun.COM HBA_SendCTPassThruV2(
2514*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2515*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2516*10652SHyon.Kim@Sun.COM void *pReqBuffer,
2517*10652SHyon.Kim@Sun.COM HBA_UINT32 ReqBufferSize,
2518*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2519*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
2520*10652SHyon.Kim@Sun.COM {
2521*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2522*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2523*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2524*10652SHyon.Kim@Sun.COM HBASendCTPassThruV2Func
2525*10652SHyon.Kim@Sun.COM registeredfunc;
2526*10652SHyon.Kim@Sun.COM
2527*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendCTPassThruV2m hbaPortWWN: %s",
2528*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
2529*10652SHyon.Kim@Sun.COM
2530*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2531*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendCTPassThruV2Handler);
2532*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
2533*10652SHyon.Kim@Sun.COM status = (registeredfunc)
2534*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN,
2535*10652SHyon.Kim@Sun.COM pReqBuffer, ReqBufferSize,
2536*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
2537*10652SHyon.Kim@Sun.COM } else {
2538*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2539*10652SHyon.Kim@Sun.COM }
2540*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2541*10652SHyon.Kim@Sun.COM }
2542*10652SHyon.Kim@Sun.COM
2543*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetEventBuffer(HBA_HANDLE handle,PHBA_EVENTINFO EventBuffer,HBA_UINT32 * EventBufferCount)2544*10652SHyon.Kim@Sun.COM HBA_GetEventBuffer(
2545*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2546*10652SHyon.Kim@Sun.COM PHBA_EVENTINFO EventBuffer,
2547*10652SHyon.Kim@Sun.COM HBA_UINT32 *EventBufferCount)
2548*10652SHyon.Kim@Sun.COM {
2549*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2550*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2551*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2552*10652SHyon.Kim@Sun.COM HBAGetEventBufferFunc
2553*10652SHyon.Kim@Sun.COM GetEventBufferFunc;
2554*10652SHyon.Kim@Sun.COM
2555*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetEventBuffer", 0, 0, 0);
2556*10652SHyon.Kim@Sun.COM
2557*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2558*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2559*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2560*10652SHyon.Kim@Sun.COM }
2561*10652SHyon.Kim@Sun.COM
2562*10652SHyon.Kim@Sun.COM GetEventBufferFunc =
2563*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetEventBufferHandler;
2564*10652SHyon.Kim@Sun.COM if (GetEventBufferFunc != NULL) {
2565*10652SHyon.Kim@Sun.COM status = (GetEventBufferFunc)
2566*10652SHyon.Kim@Sun.COM (vendorHandle, EventBuffer, EventBufferCount);
2567*10652SHyon.Kim@Sun.COM } else {
2568*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2569*10652SHyon.Kim@Sun.COM }
2570*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2571*10652SHyon.Kim@Sun.COM }
2572*10652SHyon.Kim@Sun.COM
2573*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SetRNIDMgmtInfo(HBA_HANDLE handle,HBA_MGMTINFO Info)2574*10652SHyon.Kim@Sun.COM HBA_SetRNIDMgmtInfo(HBA_HANDLE handle, HBA_MGMTINFO Info) {
2575*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2576*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2577*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2578*10652SHyon.Kim@Sun.COM HBASetRNIDMgmtInfoFunc
2579*10652SHyon.Kim@Sun.COM SetRNIDMgmtInfoFunc;
2580*10652SHyon.Kim@Sun.COM
2581*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SetRNIDMgmtInfo", 0, 0, 0);
2582*10652SHyon.Kim@Sun.COM
2583*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2584*10652SHyon.Kim@Sun.COM SetRNIDMgmtInfoFunc = FUNCCOMMON(lib_infop, SetRNIDMgmtInfoHandler);
2585*10652SHyon.Kim@Sun.COM if (SetRNIDMgmtInfoFunc != NULL) {
2586*10652SHyon.Kim@Sun.COM status = (SetRNIDMgmtInfoFunc)(vendorHandle, Info);
2587*10652SHyon.Kim@Sun.COM } else {
2588*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2589*10652SHyon.Kim@Sun.COM }
2590*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2591*10652SHyon.Kim@Sun.COM }
2592*10652SHyon.Kim@Sun.COM
2593*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetRNIDMgmtInfo(HBA_HANDLE handle,HBA_MGMTINFO * pInfo)2594*10652SHyon.Kim@Sun.COM HBA_GetRNIDMgmtInfo(HBA_HANDLE handle, HBA_MGMTINFO *pInfo) {
2595*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2596*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2597*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2598*10652SHyon.Kim@Sun.COM HBAGetRNIDMgmtInfoFunc
2599*10652SHyon.Kim@Sun.COM GetRNIDMgmtInfoFunc;
2600*10652SHyon.Kim@Sun.COM
2601*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetRNIDMgmtInfo", 0, 0, 0);
2602*10652SHyon.Kim@Sun.COM
2603*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2604*10652SHyon.Kim@Sun.COM GetRNIDMgmtInfoFunc = FUNCCOMMON(lib_infop, GetRNIDMgmtInfoHandler);
2605*10652SHyon.Kim@Sun.COM if (GetRNIDMgmtInfoFunc != NULL) {
2606*10652SHyon.Kim@Sun.COM status = (GetRNIDMgmtInfoFunc)(vendorHandle, pInfo);
2607*10652SHyon.Kim@Sun.COM } else {
2608*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2609*10652SHyon.Kim@Sun.COM }
2610*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2611*10652SHyon.Kim@Sun.COM }
2612*10652SHyon.Kim@Sun.COM
2613*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendRNID(HBA_HANDLE handle,HBA_WWN wwn,HBA_WWNTYPE wwntype,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)2614*10652SHyon.Kim@Sun.COM HBA_SendRNID(
2615*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2616*10652SHyon.Kim@Sun.COM HBA_WWN wwn,
2617*10652SHyon.Kim@Sun.COM HBA_WWNTYPE wwntype,
2618*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2619*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
2620*10652SHyon.Kim@Sun.COM {
2621*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2622*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2623*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2624*10652SHyon.Kim@Sun.COM HBASendRNIDFunc SendRNIDFunc;
2625*10652SHyon.Kim@Sun.COM
2626*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendRNID for wwn: %s", WWN2STR1(&wwn), 0, 0);
2627*10652SHyon.Kim@Sun.COM
2628*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2629*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2630*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2631*10652SHyon.Kim@Sun.COM }
2632*10652SHyon.Kim@Sun.COM
2633*10652SHyon.Kim@Sun.COM SendRNIDFunc = lib_infop->ftable.functionTable.SendRNIDHandler;
2634*10652SHyon.Kim@Sun.COM if (SendRNIDFunc != NULL) {
2635*10652SHyon.Kim@Sun.COM status = ((SendRNIDFunc)(vendorHandle, wwn, wwntype,
2636*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize));
2637*10652SHyon.Kim@Sun.COM } else {
2638*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2639*10652SHyon.Kim@Sun.COM }
2640*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2641*10652SHyon.Kim@Sun.COM }
2642*10652SHyon.Kim@Sun.COM
2643*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendRNIDV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN destWWN,HBA_UINT32 destFCID,HBA_UINT32 NodeIdDataFormat,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)2644*10652SHyon.Kim@Sun.COM HBA_SendRNIDV2(
2645*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2646*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2647*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
2648*10652SHyon.Kim@Sun.COM HBA_UINT32 destFCID,
2649*10652SHyon.Kim@Sun.COM HBA_UINT32 NodeIdDataFormat,
2650*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2651*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
2652*10652SHyon.Kim@Sun.COM {
2653*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2654*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2655*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2656*10652SHyon.Kim@Sun.COM HBASendRNIDV2Func registeredfunc;
2657*10652SHyon.Kim@Sun.COM
2658*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendRNIDV2, hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
2659*10652SHyon.Kim@Sun.COM
2660*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2661*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendRNIDV2Handler);
2662*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
2663*10652SHyon.Kim@Sun.COM status = (registeredfunc)
2664*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN, destWWN, destFCID, NodeIdDataFormat,
2665*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
2666*10652SHyon.Kim@Sun.COM } else {
2667*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2668*10652SHyon.Kim@Sun.COM }
2669*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2670*10652SHyon.Kim@Sun.COM }
2671*10652SHyon.Kim@Sun.COM
2672*10652SHyon.Kim@Sun.COM void
HBA_RefreshInformation(HBA_HANDLE handle)2673*10652SHyon.Kim@Sun.COM HBA_RefreshInformation(HBA_HANDLE handle) {
2674*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2675*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2676*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2677*10652SHyon.Kim@Sun.COM HBARefreshInformationFunc
2678*10652SHyon.Kim@Sun.COM RefreshInformationFunc;
2679*10652SHyon.Kim@Sun.COM
2680*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RefreshInformation", 0, 0, 0);
2681*10652SHyon.Kim@Sun.COM
2682*10652SHyon.Kim@Sun.COM status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2683*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_OK) {
2684*10652SHyon.Kim@Sun.COM RefreshInformationFunc =
2685*10652SHyon.Kim@Sun.COM FUNCCOMMON(lib_infop, RefreshInformationHandler);
2686*10652SHyon.Kim@Sun.COM if (RefreshInformationFunc != NULL) {
2687*10652SHyon.Kim@Sun.COM ((RefreshInformationFunc)(vendorHandle));
2688*10652SHyon.Kim@Sun.COM }
2689*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
2690*10652SHyon.Kim@Sun.COM }
2691*10652SHyon.Kim@Sun.COM }
2692*10652SHyon.Kim@Sun.COM
2693*10652SHyon.Kim@Sun.COM void
HBA_ResetStatistics(HBA_HANDLE handle,HBA_UINT32 portindex)2694*10652SHyon.Kim@Sun.COM HBA_ResetStatistics(HBA_HANDLE handle, HBA_UINT32 portindex) {
2695*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2696*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2697*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2698*10652SHyon.Kim@Sun.COM HBAResetStatisticsFunc
2699*10652SHyon.Kim@Sun.COM ResetStatisticsFunc;
2700*10652SHyon.Kim@Sun.COM
2701*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_ResetStatistics", 0, 0, 0);
2702*10652SHyon.Kim@Sun.COM
2703*10652SHyon.Kim@Sun.COM status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2704*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_OK) {
2705*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2706*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
2707*10652SHyon.Kim@Sun.COM }
2708*10652SHyon.Kim@Sun.COM
2709*10652SHyon.Kim@Sun.COM ResetStatisticsFunc =
2710*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ResetStatisticsHandler;
2711*10652SHyon.Kim@Sun.COM if (ResetStatisticsFunc != NULL) {
2712*10652SHyon.Kim@Sun.COM ((ResetStatisticsFunc)(vendorHandle, portindex));
2713*10652SHyon.Kim@Sun.COM }
2714*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_LL_mutex);
2715*10652SHyon.Kim@Sun.COM }
2716*10652SHyon.Kim@Sun.COM }
2717*10652SHyon.Kim@Sun.COM
2718*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetFcpTargetMapping(HBA_HANDLE handle,PHBA_FCPTARGETMAPPING mapping)2719*10652SHyon.Kim@Sun.COM HBA_GetFcpTargetMapping(HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) {
2720*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2721*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2722*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2723*10652SHyon.Kim@Sun.COM HBAGetFcpTargetMappingFunc GetFcpTargetMappingFunc;
2724*10652SHyon.Kim@Sun.COM
2725*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
2726*10652SHyon.Kim@Sun.COM
2727*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2728*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2729*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2730*10652SHyon.Kim@Sun.COM }
2731*10652SHyon.Kim@Sun.COM
2732*10652SHyon.Kim@Sun.COM GetFcpTargetMappingFunc =
2733*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetFcpTargetMappingHandler;
2734*10652SHyon.Kim@Sun.COM if (GetFcpTargetMappingFunc != NULL) {
2735*10652SHyon.Kim@Sun.COM status = ((GetFcpTargetMappingFunc)(vendorHandle, mapping));
2736*10652SHyon.Kim@Sun.COM } else {
2737*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2738*10652SHyon.Kim@Sun.COM }
2739*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2740*10652SHyon.Kim@Sun.COM }
2741*10652SHyon.Kim@Sun.COM
2742*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetFcpTargetMappingV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_FCPTARGETMAPPINGV2 * pmapping)2743*10652SHyon.Kim@Sun.COM HBA_GetFcpTargetMappingV2(
2744*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2745*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2746*10652SHyon.Kim@Sun.COM HBA_FCPTARGETMAPPINGV2 *pmapping)
2747*10652SHyon.Kim@Sun.COM {
2748*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2749*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2750*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2751*10652SHyon.Kim@Sun.COM HBAGetFcpTargetMappingV2Func
2752*10652SHyon.Kim@Sun.COM registeredfunc;
2753*10652SHyon.Kim@Sun.COM
2754*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
2755*10652SHyon.Kim@Sun.COM
2756*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2757*10652SHyon.Kim@Sun.COM
2758*10652SHyon.Kim@Sun.COM registeredfunc =
2759*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetFcpTargetMappingV2Handler;
2760*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
2761*10652SHyon.Kim@Sun.COM status = ((registeredfunc)(vendorHandle, hbaPortWWN, pmapping));
2762*10652SHyon.Kim@Sun.COM } else {
2763*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2764*10652SHyon.Kim@Sun.COM }
2765*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2766*10652SHyon.Kim@Sun.COM }
2767*10652SHyon.Kim@Sun.COM
2768*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetFcpPersistentBinding(HBA_HANDLE handle,PHBA_FCPBINDING binding)2769*10652SHyon.Kim@Sun.COM HBA_GetFcpPersistentBinding(HBA_HANDLE handle, PHBA_FCPBINDING binding) {
2770*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2771*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2772*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2773*10652SHyon.Kim@Sun.COM HBAGetFcpPersistentBindingFunc
2774*10652SHyon.Kim@Sun.COM GetFcpPersistentBindingFunc;
2775*10652SHyon.Kim@Sun.COM
2776*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetFcpPersistentBinding", 0, 0, 0);
2777*10652SHyon.Kim@Sun.COM
2778*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2779*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2780*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2781*10652SHyon.Kim@Sun.COM }
2782*10652SHyon.Kim@Sun.COM
2783*10652SHyon.Kim@Sun.COM GetFcpPersistentBindingFunc =
2784*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetFcpPersistentBindingHandler;
2785*10652SHyon.Kim@Sun.COM if (GetFcpPersistentBindingFunc != NULL) {
2786*10652SHyon.Kim@Sun.COM status = ((GetFcpPersistentBindingFunc)(vendorHandle, binding));
2787*10652SHyon.Kim@Sun.COM } else {
2788*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2789*10652SHyon.Kim@Sun.COM }
2790*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2791*10652SHyon.Kim@Sun.COM }
2792*10652SHyon.Kim@Sun.COM
2793*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_ScsiInquiryV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_UINT64 fcLUN,HBA_UINT8 CDB_Byte1,HBA_UINT8 CDB_Byte2,void * pRspBuffer,HBA_UINT32 * pRspBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * pSenseBufferSize)2794*10652SHyon.Kim@Sun.COM HBA_ScsiInquiryV2(
2795*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2796*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2797*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2798*10652SHyon.Kim@Sun.COM HBA_UINT64 fcLUN,
2799*10652SHyon.Kim@Sun.COM HBA_UINT8 CDB_Byte1,
2800*10652SHyon.Kim@Sun.COM HBA_UINT8 CDB_Byte2,
2801*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2802*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize,
2803*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
2804*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2805*10652SHyon.Kim@Sun.COM HBA_UINT32 *pSenseBufferSize)
2806*10652SHyon.Kim@Sun.COM {
2807*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2808*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2809*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2810*10652SHyon.Kim@Sun.COM HBAScsiInquiryV2Func ScsiInquiryV2Func;
2811*10652SHyon.Kim@Sun.COM
2812*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_ScsiInquiryV2 to discoveredPortWWN: %s",
2813*10652SHyon.Kim@Sun.COM WWN2STR1(&discoveredPortWWN), 0, 0);
2814*10652SHyon.Kim@Sun.COM
2815*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2816*10652SHyon.Kim@Sun.COM
2817*10652SHyon.Kim@Sun.COM ScsiInquiryV2Func =
2818*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ScsiInquiryV2Handler;
2819*10652SHyon.Kim@Sun.COM if (ScsiInquiryV2Func != NULL) {
2820*10652SHyon.Kim@Sun.COM status = ((ScsiInquiryV2Func)(
2821*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, CDB_Byte1,
2822*10652SHyon.Kim@Sun.COM CDB_Byte2, pRspBuffer, pRspBufferSize, pScsiStatus,
2823*10652SHyon.Kim@Sun.COM pSenseBuffer, pSenseBufferSize));
2824*10652SHyon.Kim@Sun.COM } else {
2825*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2826*10652SHyon.Kim@Sun.COM }
2827*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2828*10652SHyon.Kim@Sun.COM }
2829*10652SHyon.Kim@Sun.COM
2830*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendScsiInquiry(HBA_HANDLE handle,HBA_WWN PortWWN,HBA_UINT64 fcLUN,HBA_UINT8 EVPD,HBA_UINT32 PageCode,void * pRspBuffer,HBA_UINT32 RspBufferSize,void * pSenseBuffer,HBA_UINT32 SenseBufferSize)2831*10652SHyon.Kim@Sun.COM HBA_SendScsiInquiry(
2832*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2833*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
2834*10652SHyon.Kim@Sun.COM HBA_UINT64 fcLUN,
2835*10652SHyon.Kim@Sun.COM HBA_UINT8 EVPD,
2836*10652SHyon.Kim@Sun.COM HBA_UINT32 PageCode,
2837*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2838*10652SHyon.Kim@Sun.COM HBA_UINT32 RspBufferSize,
2839*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2840*10652SHyon.Kim@Sun.COM HBA_UINT32 SenseBufferSize)
2841*10652SHyon.Kim@Sun.COM {
2842*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2843*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2844*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2845*10652SHyon.Kim@Sun.COM HBASendScsiInquiryFunc SendScsiInquiryFunc;
2846*10652SHyon.Kim@Sun.COM
2847*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendScsiInquiry to PortWWN: %s",
2848*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN), 0, 0);
2849*10652SHyon.Kim@Sun.COM
2850*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2851*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2852*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2853*10652SHyon.Kim@Sun.COM }
2854*10652SHyon.Kim@Sun.COM
2855*10652SHyon.Kim@Sun.COM SendScsiInquiryFunc =
2856*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ScsiInquiryHandler;
2857*10652SHyon.Kim@Sun.COM if (SendScsiInquiryFunc != NULL) {
2858*10652SHyon.Kim@Sun.COM status = ((SendScsiInquiryFunc)(
2859*10652SHyon.Kim@Sun.COM vendorHandle, PortWWN, fcLUN, EVPD, PageCode, pRspBuffer,
2860*10652SHyon.Kim@Sun.COM RspBufferSize, pSenseBuffer, SenseBufferSize));
2861*10652SHyon.Kim@Sun.COM } else {
2862*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2863*10652SHyon.Kim@Sun.COM }
2864*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2865*10652SHyon.Kim@Sun.COM }
2866*10652SHyon.Kim@Sun.COM
2867*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_ScsiReportLUNsV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,void * pRespBuffer,HBA_UINT32 * pRespBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * pSenseBufferSize)2868*10652SHyon.Kim@Sun.COM HBA_ScsiReportLUNsV2(
2869*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2870*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2871*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2872*10652SHyon.Kim@Sun.COM void *pRespBuffer,
2873*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRespBufferSize,
2874*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
2875*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2876*10652SHyon.Kim@Sun.COM HBA_UINT32 *pSenseBufferSize)
2877*10652SHyon.Kim@Sun.COM {
2878*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2879*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2880*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2881*10652SHyon.Kim@Sun.COM HBAScsiReportLUNsV2Func ScsiReportLUNsV2Func;
2882*10652SHyon.Kim@Sun.COM
2883*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_ScsiReportLUNsV2 to discoveredPortWWN: %s",
2884*10652SHyon.Kim@Sun.COM WWN2STR1(&discoveredPortWWN), 0, 0);
2885*10652SHyon.Kim@Sun.COM
2886*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2887*10652SHyon.Kim@Sun.COM
2888*10652SHyon.Kim@Sun.COM ScsiReportLUNsV2Func =
2889*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ScsiReportLUNsV2Handler;
2890*10652SHyon.Kim@Sun.COM if (ScsiReportLUNsV2Func != NULL) {
2891*10652SHyon.Kim@Sun.COM status = ((ScsiReportLUNsV2Func)(
2892*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN,
2893*10652SHyon.Kim@Sun.COM pRespBuffer, pRespBufferSize,
2894*10652SHyon.Kim@Sun.COM pScsiStatus,
2895*10652SHyon.Kim@Sun.COM pSenseBuffer, pSenseBufferSize));
2896*10652SHyon.Kim@Sun.COM } else {
2897*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2898*10652SHyon.Kim@Sun.COM }
2899*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2900*10652SHyon.Kim@Sun.COM }
2901*10652SHyon.Kim@Sun.COM
2902*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendReportLUNs(HBA_HANDLE handle,HBA_WWN portWWN,void * pRspBuffer,HBA_UINT32 RspBufferSize,void * pSenseBuffer,HBA_UINT32 SenseBufferSize)2903*10652SHyon.Kim@Sun.COM HBA_SendReportLUNs(
2904*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2905*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
2906*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2907*10652SHyon.Kim@Sun.COM HBA_UINT32 RspBufferSize,
2908*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2909*10652SHyon.Kim@Sun.COM HBA_UINT32 SenseBufferSize)
2910*10652SHyon.Kim@Sun.COM {
2911*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2912*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2913*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2914*10652SHyon.Kim@Sun.COM HBASendReportLUNsFunc SendReportLUNsFunc;
2915*10652SHyon.Kim@Sun.COM
2916*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendReportLUNs to PortWWN: %s", WWN2STR1(&portWWN), 0, 0);
2917*10652SHyon.Kim@Sun.COM
2918*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2919*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2920*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2921*10652SHyon.Kim@Sun.COM }
2922*10652SHyon.Kim@Sun.COM
2923*10652SHyon.Kim@Sun.COM SendReportLUNsFunc = lib_infop->ftable.functionTable.ReportLUNsHandler;
2924*10652SHyon.Kim@Sun.COM if (SendReportLUNsFunc != NULL) {
2925*10652SHyon.Kim@Sun.COM status = ((SendReportLUNsFunc)(
2926*10652SHyon.Kim@Sun.COM vendorHandle, portWWN, pRspBuffer,
2927*10652SHyon.Kim@Sun.COM RspBufferSize, pSenseBuffer, SenseBufferSize));
2928*10652SHyon.Kim@Sun.COM } else {
2929*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2930*10652SHyon.Kim@Sun.COM }
2931*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2932*10652SHyon.Kim@Sun.COM }
2933*10652SHyon.Kim@Sun.COM
2934*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_ScsiReadCapacityV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_UINT64 fcLUN,void * pRspBuffer,HBA_UINT32 * pRspBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * SenseBufferSize)2935*10652SHyon.Kim@Sun.COM HBA_ScsiReadCapacityV2(
2936*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2937*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
2938*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
2939*10652SHyon.Kim@Sun.COM HBA_UINT64 fcLUN,
2940*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2941*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize,
2942*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
2943*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2944*10652SHyon.Kim@Sun.COM HBA_UINT32 *SenseBufferSize)
2945*10652SHyon.Kim@Sun.COM {
2946*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2947*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2948*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2949*10652SHyon.Kim@Sun.COM HBAScsiReadCapacityV2Func ScsiReadCapacityV2Func;
2950*10652SHyon.Kim@Sun.COM
2951*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_ScsiReadCapacityV2 to discoveredPortWWN: %s",
2952*10652SHyon.Kim@Sun.COM WWN2STR1(&discoveredPortWWN), 0, 0);
2953*10652SHyon.Kim@Sun.COM
2954*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
2955*10652SHyon.Kim@Sun.COM
2956*10652SHyon.Kim@Sun.COM ScsiReadCapacityV2Func =
2957*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ScsiReadCapacityV2Handler;
2958*10652SHyon.Kim@Sun.COM if (ScsiReadCapacityV2Func != NULL) {
2959*10652SHyon.Kim@Sun.COM status = ((ScsiReadCapacityV2Func)(
2960*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN,
2961*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize,
2962*10652SHyon.Kim@Sun.COM pScsiStatus,
2963*10652SHyon.Kim@Sun.COM pSenseBuffer, SenseBufferSize));
2964*10652SHyon.Kim@Sun.COM } else {
2965*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2966*10652SHyon.Kim@Sun.COM }
2967*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2968*10652SHyon.Kim@Sun.COM }
2969*10652SHyon.Kim@Sun.COM
2970*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendReadCapacity(HBA_HANDLE handle,HBA_WWN portWWN,HBA_UINT64 fcLUN,void * pRspBuffer,HBA_UINT32 RspBufferSize,void * pSenseBuffer,HBA_UINT32 SenseBufferSize)2971*10652SHyon.Kim@Sun.COM HBA_SendReadCapacity(
2972*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
2973*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
2974*10652SHyon.Kim@Sun.COM HBA_UINT64 fcLUN,
2975*10652SHyon.Kim@Sun.COM void *pRspBuffer,
2976*10652SHyon.Kim@Sun.COM HBA_UINT32 RspBufferSize,
2977*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
2978*10652SHyon.Kim@Sun.COM HBA_UINT32 SenseBufferSize)
2979*10652SHyon.Kim@Sun.COM {
2980*10652SHyon.Kim@Sun.COM HBA_STATUS status;
2981*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
2982*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
2983*10652SHyon.Kim@Sun.COM HBASendReadCapacityFunc SendReadCapacityFunc;
2984*10652SHyon.Kim@Sun.COM
2985*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendReadCapacity to portWWN: %s",
2986*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), 0, 0);
2987*10652SHyon.Kim@Sun.COM
2988*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
2989*10652SHyon.Kim@Sun.COM if (lib_infop->version == SMHBA) {
2990*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
2991*10652SHyon.Kim@Sun.COM }
2992*10652SHyon.Kim@Sun.COM
2993*10652SHyon.Kim@Sun.COM SendReadCapacityFunc =
2994*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.ReadCapacityHandler;
2995*10652SHyon.Kim@Sun.COM if (SendReadCapacityFunc != NULL) {
2996*10652SHyon.Kim@Sun.COM status = ((SendReadCapacityFunc)
2997*10652SHyon.Kim@Sun.COM (vendorHandle, portWWN, fcLUN, pRspBuffer,
2998*10652SHyon.Kim@Sun.COM RspBufferSize, pSenseBuffer, SenseBufferSize));
2999*10652SHyon.Kim@Sun.COM } else {
3000*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3001*10652SHyon.Kim@Sun.COM }
3002*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3003*10652SHyon.Kim@Sun.COM }
3004*10652SHyon.Kim@Sun.COM
3005*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendRPL(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN agent_wwn,HBA_UINT32 agent_domain,HBA_UINT32 portindex,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)3006*10652SHyon.Kim@Sun.COM HBA_SendRPL(
3007*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3008*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3009*10652SHyon.Kim@Sun.COM HBA_WWN agent_wwn,
3010*10652SHyon.Kim@Sun.COM HBA_UINT32 agent_domain,
3011*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3012*10652SHyon.Kim@Sun.COM void *pRspBuffer,
3013*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
3014*10652SHyon.Kim@Sun.COM {
3015*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3016*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3017*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3018*10652SHyon.Kim@Sun.COM HBASendRPLFunc registeredfunc;
3019*10652SHyon.Kim@Sun.COM
3020*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendRPL to agent_wwn: %s:%d",
3021*10652SHyon.Kim@Sun.COM WWN2STR1(&agent_wwn), agent_domain, 0);
3022*10652SHyon.Kim@Sun.COM
3023*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
3024*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendRPLHandler);
3025*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3026*10652SHyon.Kim@Sun.COM status = (registeredfunc)(
3027*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, agent_wwn, agent_domain, portindex,
3028*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
3029*10652SHyon.Kim@Sun.COM } else {
3030*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3031*10652SHyon.Kim@Sun.COM }
3032*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3033*10652SHyon.Kim@Sun.COM }
3034*10652SHyon.Kim@Sun.COM
3035*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendRPS(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN agent_wwn,HBA_UINT32 agent_domain,HBA_WWN object_wwn,HBA_UINT32 object_port_number,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)3036*10652SHyon.Kim@Sun.COM HBA_SendRPS(
3037*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3038*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3039*10652SHyon.Kim@Sun.COM HBA_WWN agent_wwn,
3040*10652SHyon.Kim@Sun.COM HBA_UINT32 agent_domain,
3041*10652SHyon.Kim@Sun.COM HBA_WWN object_wwn,
3042*10652SHyon.Kim@Sun.COM HBA_UINT32 object_port_number,
3043*10652SHyon.Kim@Sun.COM void *pRspBuffer,
3044*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
3045*10652SHyon.Kim@Sun.COM {
3046*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3047*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3048*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3049*10652SHyon.Kim@Sun.COM HBASendRPSFunc registeredfunc;
3050*10652SHyon.Kim@Sun.COM
3051*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendRPS to agent_wwn: %s:%d",
3052*10652SHyon.Kim@Sun.COM WWN2STR1(&agent_wwn), agent_domain, 0);
3053*10652SHyon.Kim@Sun.COM
3054*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
3055*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendRPSHandler);
3056*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3057*10652SHyon.Kim@Sun.COM status = (registeredfunc)(
3058*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, agent_wwn, agent_domain,
3059*10652SHyon.Kim@Sun.COM object_wwn, object_port_number,
3060*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
3061*10652SHyon.Kim@Sun.COM } else {
3062*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3063*10652SHyon.Kim@Sun.COM }
3064*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3065*10652SHyon.Kim@Sun.COM }
3066*10652SHyon.Kim@Sun.COM
3067*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendSRL(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN wwn,HBA_UINT32 domain,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)3068*10652SHyon.Kim@Sun.COM HBA_SendSRL(
3069*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3070*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3071*10652SHyon.Kim@Sun.COM HBA_WWN wwn,
3072*10652SHyon.Kim@Sun.COM HBA_UINT32 domain,
3073*10652SHyon.Kim@Sun.COM void *pRspBuffer,
3074*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
3075*10652SHyon.Kim@Sun.COM {
3076*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3077*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3078*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3079*10652SHyon.Kim@Sun.COM HBASendSRLFunc registeredfunc;
3080*10652SHyon.Kim@Sun.COM
3081*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendSRL to wwn:%s domain:%d", WWN2STR1(&wwn), domain, 0);
3082*10652SHyon.Kim@Sun.COM
3083*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
3084*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendSRLHandler);
3085*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3086*10652SHyon.Kim@Sun.COM status = (registeredfunc)(
3087*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, wwn, domain,
3088*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
3089*10652SHyon.Kim@Sun.COM } else {
3090*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3091*10652SHyon.Kim@Sun.COM }
3092*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3093*10652SHyon.Kim@Sun.COM }
3094*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendRLS(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN destWWN,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)3095*10652SHyon.Kim@Sun.COM HBA_SendRLS(
3096*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3097*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3098*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
3099*10652SHyon.Kim@Sun.COM void *pRspBuffer,
3100*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
3101*10652SHyon.Kim@Sun.COM {
3102*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3103*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3104*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3105*10652SHyon.Kim@Sun.COM HBASendRLSFunc registeredfunc;
3106*10652SHyon.Kim@Sun.COM
3107*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendRLS dest_wwn: %s",
3108*10652SHyon.Kim@Sun.COM WWN2STR1(&destWWN), 0, 0);
3109*10652SHyon.Kim@Sun.COM
3110*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
3111*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendRLSHandler);
3112*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3113*10652SHyon.Kim@Sun.COM status = (registeredfunc)(
3114*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, destWWN,
3115*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
3116*10652SHyon.Kim@Sun.COM } else {
3117*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3118*10652SHyon.Kim@Sun.COM }
3119*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3120*10652SHyon.Kim@Sun.COM }
3121*10652SHyon.Kim@Sun.COM
3122*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SendLIRR(HBA_HANDLE handle,HBA_WWN sourceWWN,HBA_WWN destWWN,HBA_UINT8 function,HBA_UINT8 type,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)3123*10652SHyon.Kim@Sun.COM HBA_SendLIRR(
3124*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3125*10652SHyon.Kim@Sun.COM HBA_WWN sourceWWN,
3126*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
3127*10652SHyon.Kim@Sun.COM HBA_UINT8 function,
3128*10652SHyon.Kim@Sun.COM HBA_UINT8 type,
3129*10652SHyon.Kim@Sun.COM void *pRspBuffer,
3130*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
3131*10652SHyon.Kim@Sun.COM {
3132*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3133*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3134*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3135*10652SHyon.Kim@Sun.COM HBASendLIRRFunc registeredfunc;
3136*10652SHyon.Kim@Sun.COM
3137*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SendLIRR destWWN:%s", WWN2STR1(&destWWN), 0, 0);
3138*10652SHyon.Kim@Sun.COM
3139*10652SHyon.Kim@Sun.COM CHECKLIBRARY();
3140*10652SHyon.Kim@Sun.COM registeredfunc = FUNCCOMMON(lib_infop, SendLIRRHandler);
3141*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3142*10652SHyon.Kim@Sun.COM status = (registeredfunc)(
3143*10652SHyon.Kim@Sun.COM vendorHandle, sourceWWN, destWWN, function, type,
3144*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
3145*10652SHyon.Kim@Sun.COM } else {
3146*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3147*10652SHyon.Kim@Sun.COM }
3148*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3149*10652SHyon.Kim@Sun.COM }
3150*10652SHyon.Kim@Sun.COM
3151*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetBindingCapability(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_BIND_CAPABILITY * pcapability)3152*10652SHyon.Kim@Sun.COM HBA_GetBindingCapability(
3153*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3154*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3155*10652SHyon.Kim@Sun.COM HBA_BIND_CAPABILITY *pcapability)
3156*10652SHyon.Kim@Sun.COM {
3157*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3158*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3159*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3160*10652SHyon.Kim@Sun.COM HBAGetBindingCapabilityFunc
3161*10652SHyon.Kim@Sun.COM registeredfunc;
3162*10652SHyon.Kim@Sun.COM
3163*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetBindingCapability", 0, 0, 0);
3164*10652SHyon.Kim@Sun.COM
3165*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3166*10652SHyon.Kim@Sun.COM
3167*10652SHyon.Kim@Sun.COM registeredfunc =
3168*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetBindingCapabilityHandler;
3169*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3170*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
3171*10652SHyon.Kim@Sun.COM } else {
3172*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3173*10652SHyon.Kim@Sun.COM }
3174*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3175*10652SHyon.Kim@Sun.COM }
3176*10652SHyon.Kim@Sun.COM
3177*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetBindingSupport(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_BIND_CAPABILITY * pcapability)3178*10652SHyon.Kim@Sun.COM HBA_GetBindingSupport(
3179*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3180*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3181*10652SHyon.Kim@Sun.COM HBA_BIND_CAPABILITY *pcapability)
3182*10652SHyon.Kim@Sun.COM {
3183*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3184*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3185*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3186*10652SHyon.Kim@Sun.COM HBAGetBindingSupportFunc
3187*10652SHyon.Kim@Sun.COM registeredfunc;
3188*10652SHyon.Kim@Sun.COM
3189*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetBindingSupport", 0, 0, 0);
3190*10652SHyon.Kim@Sun.COM
3191*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3192*10652SHyon.Kim@Sun.COM
3193*10652SHyon.Kim@Sun.COM registeredfunc =
3194*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetBindingSupportHandler;
3195*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3196*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
3197*10652SHyon.Kim@Sun.COM } else {
3198*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3199*10652SHyon.Kim@Sun.COM }
3200*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3201*10652SHyon.Kim@Sun.COM }
3202*10652SHyon.Kim@Sun.COM
3203*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SetBindingSupport(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_BIND_CAPABILITY capability)3204*10652SHyon.Kim@Sun.COM HBA_SetBindingSupport(
3205*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3206*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3207*10652SHyon.Kim@Sun.COM HBA_BIND_CAPABILITY capability)
3208*10652SHyon.Kim@Sun.COM {
3209*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3210*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3211*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3212*10652SHyon.Kim@Sun.COM HBASetBindingSupportFunc
3213*10652SHyon.Kim@Sun.COM registeredfunc;
3214*10652SHyon.Kim@Sun.COM
3215*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SetBindingSupport", 0, 0, 0);
3216*10652SHyon.Kim@Sun.COM
3217*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3218*10652SHyon.Kim@Sun.COM
3219*10652SHyon.Kim@Sun.COM registeredfunc =
3220*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.SetBindingSupportHandler;
3221*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3222*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, capability);
3223*10652SHyon.Kim@Sun.COM } else {
3224*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3225*10652SHyon.Kim@Sun.COM }
3226*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3227*10652SHyon.Kim@Sun.COM }
3228*10652SHyon.Kim@Sun.COM
3229*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_SetPersistentBindingV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,const HBA_FCPBINDING2 * pbinding)3230*10652SHyon.Kim@Sun.COM HBA_SetPersistentBindingV2(
3231*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3232*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3233*10652SHyon.Kim@Sun.COM const HBA_FCPBINDING2 *pbinding)
3234*10652SHyon.Kim@Sun.COM {
3235*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3236*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3237*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3238*10652SHyon.Kim@Sun.COM HBASetPersistentBindingV2Func
3239*10652SHyon.Kim@Sun.COM registeredfunc;
3240*10652SHyon.Kim@Sun.COM
3241*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_SetPersistentBindingV2 port: %s",
3242*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3243*10652SHyon.Kim@Sun.COM
3244*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3245*10652SHyon.Kim@Sun.COM
3246*10652SHyon.Kim@Sun.COM registeredfunc =
3247*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.SetPersistentBindingV2Handler;
3248*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3249*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
3250*10652SHyon.Kim@Sun.COM } else {
3251*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3252*10652SHyon.Kim@Sun.COM }
3253*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3254*10652SHyon.Kim@Sun.COM }
3255*10652SHyon.Kim@Sun.COM
3256*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetPersistentBindingV2(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_FCPBINDING2 * pbinding)3257*10652SHyon.Kim@Sun.COM HBA_GetPersistentBindingV2(
3258*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3259*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3260*10652SHyon.Kim@Sun.COM HBA_FCPBINDING2 *pbinding)
3261*10652SHyon.Kim@Sun.COM {
3262*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3263*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3264*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3265*10652SHyon.Kim@Sun.COM HBAGetPersistentBindingV2Func
3266*10652SHyon.Kim@Sun.COM registeredfunc;
3267*10652SHyon.Kim@Sun.COM
3268*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetPersistentBindingV2 port: %s",
3269*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3270*10652SHyon.Kim@Sun.COM
3271*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3272*10652SHyon.Kim@Sun.COM
3273*10652SHyon.Kim@Sun.COM registeredfunc =
3274*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetPersistentBindingV2Handler;
3275*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3276*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
3277*10652SHyon.Kim@Sun.COM } else {
3278*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3279*10652SHyon.Kim@Sun.COM }
3280*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3281*10652SHyon.Kim@Sun.COM }
3282*10652SHyon.Kim@Sun.COM
3283*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RemovePersistentBinding(HBA_HANDLE handle,HBA_WWN hbaPortWWN,const HBA_FCPBINDING2 * pbinding)3284*10652SHyon.Kim@Sun.COM HBA_RemovePersistentBinding(
3285*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3286*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3287*10652SHyon.Kim@Sun.COM const HBA_FCPBINDING2
3288*10652SHyon.Kim@Sun.COM *pbinding)
3289*10652SHyon.Kim@Sun.COM {
3290*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3291*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3292*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3293*10652SHyon.Kim@Sun.COM HBARemovePersistentBindingFunc
3294*10652SHyon.Kim@Sun.COM registeredfunc;
3295*10652SHyon.Kim@Sun.COM
3296*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RemovePersistentBinding", 0, 0, 0);
3297*10652SHyon.Kim@Sun.COM
3298*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3299*10652SHyon.Kim@Sun.COM
3300*10652SHyon.Kim@Sun.COM registeredfunc =
3301*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RemovePersistentBindingHandler;
3302*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3303*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
3304*10652SHyon.Kim@Sun.COM } else {
3305*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3306*10652SHyon.Kim@Sun.COM }
3307*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3308*10652SHyon.Kim@Sun.COM }
3309*10652SHyon.Kim@Sun.COM
3310*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_RemoveAllPersistentBindings(HBA_HANDLE handle,HBA_WWN hbaPortWWN)3311*10652SHyon.Kim@Sun.COM HBA_RemoveAllPersistentBindings(
3312*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3313*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN)
3314*10652SHyon.Kim@Sun.COM {
3315*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3316*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3317*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3318*10652SHyon.Kim@Sun.COM HBARemoveAllPersistentBindingsFunc
3319*10652SHyon.Kim@Sun.COM registeredfunc;
3320*10652SHyon.Kim@Sun.COM
3321*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_RemoveAllPersistentBindings", 0, 0, 0);
3322*10652SHyon.Kim@Sun.COM
3323*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3324*10652SHyon.Kim@Sun.COM
3325*10652SHyon.Kim@Sun.COM registeredfunc =
3326*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.RemoveAllPersistentBindingsHandler;
3327*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3328*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, hbaPortWWN);
3329*10652SHyon.Kim@Sun.COM } else {
3330*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3331*10652SHyon.Kim@Sun.COM }
3332*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3333*10652SHyon.Kim@Sun.COM }
3334*10652SHyon.Kim@Sun.COM
3335*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetFC4Statistics(HBA_HANDLE handle,HBA_WWN portWWN,HBA_UINT8 FC4type,HBA_FC4STATISTICS * pstatistics)3336*10652SHyon.Kim@Sun.COM HBA_GetFC4Statistics(
3337*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3338*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
3339*10652SHyon.Kim@Sun.COM HBA_UINT8 FC4type,
3340*10652SHyon.Kim@Sun.COM HBA_FC4STATISTICS *pstatistics)
3341*10652SHyon.Kim@Sun.COM {
3342*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3343*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3344*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3345*10652SHyon.Kim@Sun.COM HBAGetFC4StatisticsFunc
3346*10652SHyon.Kim@Sun.COM registeredfunc;
3347*10652SHyon.Kim@Sun.COM
3348*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetFC4Statistics port: %s", WWN2STR1(&portWWN), 0, 0);
3349*10652SHyon.Kim@Sun.COM
3350*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3351*10652SHyon.Kim@Sun.COM
3352*10652SHyon.Kim@Sun.COM registeredfunc =
3353*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetFC4StatisticsHandler;
3354*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3355*10652SHyon.Kim@Sun.COM status = (registeredfunc)
3356*10652SHyon.Kim@Sun.COM (vendorHandle, portWWN, FC4type, pstatistics);
3357*10652SHyon.Kim@Sun.COM } else {
3358*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3359*10652SHyon.Kim@Sun.COM }
3360*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3361*10652SHyon.Kim@Sun.COM }
3362*10652SHyon.Kim@Sun.COM
3363*10652SHyon.Kim@Sun.COM HBA_STATUS
HBA_GetFCPStatistics(HBA_HANDLE handle,const HBA_SCSIID * lunit,HBA_FC4STATISTICS * pstatistics)3364*10652SHyon.Kim@Sun.COM HBA_GetFCPStatistics(
3365*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3366*10652SHyon.Kim@Sun.COM const HBA_SCSIID *lunit,
3367*10652SHyon.Kim@Sun.COM HBA_FC4STATISTICS *pstatistics)
3368*10652SHyon.Kim@Sun.COM {
3369*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3370*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3371*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3372*10652SHyon.Kim@Sun.COM HBAGetFCPStatisticsFunc
3373*10652SHyon.Kim@Sun.COM registeredfunc;
3374*10652SHyon.Kim@Sun.COM
3375*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetFCPStatistics", 0, 0, 0);
3376*10652SHyon.Kim@Sun.COM
3377*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3378*10652SHyon.Kim@Sun.COM
3379*10652SHyon.Kim@Sun.COM registeredfunc =
3380*10652SHyon.Kim@Sun.COM lib_infop->ftable.functionTable.GetFCPStatisticsHandler;
3381*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3382*10652SHyon.Kim@Sun.COM status = (registeredfunc)(vendorHandle, lunit, pstatistics);
3383*10652SHyon.Kim@Sun.COM } else {
3384*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3385*10652SHyon.Kim@Sun.COM }
3386*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3387*10652SHyon.Kim@Sun.COM }
3388*10652SHyon.Kim@Sun.COM
3389*10652SHyon.Kim@Sun.COM HBA_UINT32
HBA_GetVendorLibraryAttributes(HBA_UINT32 adapter_index,HBA_LIBRARYATTRIBUTES * attributes)3390*10652SHyon.Kim@Sun.COM HBA_GetVendorLibraryAttributes(
3391*10652SHyon.Kim@Sun.COM HBA_UINT32 adapter_index,
3392*10652SHyon.Kim@Sun.COM HBA_LIBRARYATTRIBUTES *attributes)
3393*10652SHyon.Kim@Sun.COM {
3394*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
3395*10652SHyon.Kim@Sun.COM HBAGetVendorLibraryAttributesFunc
3396*10652SHyon.Kim@Sun.COM registeredfunc;
3397*10652SHyon.Kim@Sun.COM HBA_UINT32 ret = 0;
3398*10652SHyon.Kim@Sun.COM
3399*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetVendorLibraryAttributes adapterindex:%d",
3400*10652SHyon.Kim@Sun.COM adapter_index, 0, 0);
3401*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
3402*10652SHyon.Kim@Sun.COM DEBUG(1, "HBAAPI not loaded yet.", 0, 0, 0);
3403*10652SHyon.Kim@Sun.COM return (0);
3404*10652SHyon.Kim@Sun.COM }
3405*10652SHyon.Kim@Sun.COM
3406*10652SHyon.Kim@Sun.COM if (attributes == NULL) {
3407*10652SHyon.Kim@Sun.COM DEBUG(1,
3408*10652SHyon.Kim@Sun.COM "HBA_GetVendorLibraryAttributes: NULL pointer attributes",
3409*10652SHyon.Kim@Sun.COM 0, 0, 0);
3410*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_ARG);
3411*10652SHyon.Kim@Sun.COM }
3412*10652SHyon.Kim@Sun.COM
3413*10652SHyon.Kim@Sun.COM (void) memset(attributes, 0, sizeof (HBA_LIBRARYATTRIBUTES));
3414*10652SHyon.Kim@Sun.COM
3415*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
3416*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
3417*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
3418*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
3419*10652SHyon.Kim@Sun.COM adapt_infop = adapt_infop->next) {
3420*10652SHyon.Kim@Sun.COM
3421*10652SHyon.Kim@Sun.COM if (adapt_infop->index == adapter_index) {
3422*10652SHyon.Kim@Sun.COM
3423*10652SHyon.Kim@Sun.COM if (adapt_infop->library->version == SMHBA) {
3424*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
3425*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
3426*10652SHyon.Kim@Sun.COM HBA_STATUS_ERROR_INCOMPATIBLE);
3427*10652SHyon.Kim@Sun.COM }
3428*10652SHyon.Kim@Sun.COM
3429*10652SHyon.Kim@Sun.COM registeredfunc = adapt_infop->library->
3430*10652SHyon.Kim@Sun.COM ftable.functionTable.GetVendorLibraryAttributesHandler;
3431*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3432*10652SHyon.Kim@Sun.COM ret = (registeredfunc)(attributes);
3433*10652SHyon.Kim@Sun.COM } else {
3434*10652SHyon.Kim@Sun.COM /* Version 1 libary? */
3435*10652SHyon.Kim@Sun.COM HBAGetVersionFunc GetVersionFunc;
3436*10652SHyon.Kim@Sun.COM GetVersionFunc = adapt_infop->library->
3437*10652SHyon.Kim@Sun.COM ftable.functionTable.GetVersionHandler;
3438*10652SHyon.Kim@Sun.COM if (GetVersionFunc != NULL) {
3439*10652SHyon.Kim@Sun.COM ret = ((GetVersionFunc)());
3440*10652SHyon.Kim@Sun.COM }
3441*10652SHyon.Kim@Sun.COM #ifdef NOTDEF
3442*10652SHyon.Kim@Sun.COM else {
3443*10652SHyon.Kim@Sun.COM /* This should not happen, dont think its going to */
3444*10652SHyon.Kim@Sun.COM }
3445*10652SHyon.Kim@Sun.COM #endif
3446*10652SHyon.Kim@Sun.COM }
3447*10652SHyon.Kim@Sun.COM if (attributes->LibPath[0] == '\0') {
3448*10652SHyon.Kim@Sun.COM if (strlen(adapt_infop->library->LibraryPath) < 256) {
3449*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->LibPath,
3450*10652SHyon.Kim@Sun.COM adapt_infop->library->LibraryPath);
3451*10652SHyon.Kim@Sun.COM }
3452*10652SHyon.Kim@Sun.COM }
3453*10652SHyon.Kim@Sun.COM break;
3454*10652SHyon.Kim@Sun.COM }
3455*10652SHyon.Kim@Sun.COM }
3456*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
3457*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, ret);
3458*10652SHyon.Kim@Sun.COM }
3459*10652SHyon.Kim@Sun.COM
3460*10652SHyon.Kim@Sun.COM
3461*10652SHyon.Kim@Sun.COM /*
3462*10652SHyon.Kim@Sun.COM * This function returns SM-HBA version that the warpper library implemented.
3463*10652SHyon.Kim@Sun.COM */
3464*10652SHyon.Kim@Sun.COM HBA_UINT32
SMHBA_GetVersion()3465*10652SHyon.Kim@Sun.COM SMHBA_GetVersion() {
3466*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetVersion", 0, 0, 0);
3467*10652SHyon.Kim@Sun.COM return (SMHBA_LIBVERSION);
3468*10652SHyon.Kim@Sun.COM }
3469*10652SHyon.Kim@Sun.COM
3470*10652SHyon.Kim@Sun.COM /*
3471*10652SHyon.Kim@Sun.COM * This function returns the attributes for the warpper library.
3472*10652SHyon.Kim@Sun.COM */
3473*10652SHyon.Kim@Sun.COM HBA_UINT32
SMHBA_GetWrapperLibraryAttributes(SMHBA_LIBRARYATTRIBUTES * attributes)3474*10652SHyon.Kim@Sun.COM SMHBA_GetWrapperLibraryAttributes(
3475*10652SHyon.Kim@Sun.COM SMHBA_LIBRARYATTRIBUTES *attributes)
3476*10652SHyon.Kim@Sun.COM {
3477*10652SHyon.Kim@Sun.COM
3478*10652SHyon.Kim@Sun.COM struct timeval tv;
3479*10652SHyon.Kim@Sun.COM struct tm tp;
3480*10652SHyon.Kim@Sun.COM
3481*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetWrapperLibraryAttributes", 0, 0, 0);
3482*10652SHyon.Kim@Sun.COM
3483*10652SHyon.Kim@Sun.COM if (attributes == NULL) {
3484*10652SHyon.Kim@Sun.COM DEBUG(1, "SMHBA_GetWrapperLibraryAttributes: "
3485*10652SHyon.Kim@Sun.COM "NULL pointer attributes",
3486*10652SHyon.Kim@Sun.COM 0, 0, 0);
3487*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_ARG);
3488*10652SHyon.Kim@Sun.COM }
3489*10652SHyon.Kim@Sun.COM
3490*10652SHyon.Kim@Sun.COM (void) memset(attributes, 0, sizeof (SMHBA_LIBRARYATTRIBUTES));
3491*10652SHyon.Kim@Sun.COM
3492*10652SHyon.Kim@Sun.COM #if defined(SOLARIS)
3493*10652SHyon.Kim@Sun.COM if ((handle = dlopen("libSMHBAAPI.so", RTLD_NOW)) != NULL) {
3494*10652SHyon.Kim@Sun.COM if (dlinfo(handle, RTLD_DI_LINKMAP, &map) >= 0) {
3495*10652SHyon.Kim@Sun.COM for (mp = map; mp != NULL; mp = mp->l_next) {
3496*10652SHyon.Kim@Sun.COM if (strlen(map->l_name) < 256) {
3497*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->LibPath, map->l_name);
3498*10652SHyon.Kim@Sun.COM }
3499*10652SHyon.Kim@Sun.COM }
3500*10652SHyon.Kim@Sun.COM }
3501*10652SHyon.Kim@Sun.COM }
3502*10652SHyon.Kim@Sun.COM
3503*10652SHyon.Kim@Sun.COM #endif
3504*10652SHyon.Kim@Sun.COM
3505*10652SHyon.Kim@Sun.COM #if defined(VENDOR)
3506*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->VName, VENDOR);
3507*10652SHyon.Kim@Sun.COM #else
3508*10652SHyon.Kim@Sun.COM attributes->VName[0] = '\0';
3509*10652SHyon.Kim@Sun.COM #endif
3510*10652SHyon.Kim@Sun.COM #if defined(VERSION)
3511*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->VVersion, VERSION);
3512*10652SHyon.Kim@Sun.COM #else
3513*10652SHyon.Kim@Sun.COM attributes->VVersion[0] = '\0';
3514*10652SHyon.Kim@Sun.COM #endif
3515*10652SHyon.Kim@Sun.COM
3516*10652SHyon.Kim@Sun.COM if (gettimeofday(&tv, (void *)0) == 0) {
3517*10652SHyon.Kim@Sun.COM if (localtime_r(&tv.tv_sec, &tp) != NULL) {
3518*10652SHyon.Kim@Sun.COM attributes->build_date.tm_mday = tp.tm_mday;
3519*10652SHyon.Kim@Sun.COM attributes->build_date.tm_mon = tp.tm_mon;
3520*10652SHyon.Kim@Sun.COM attributes->build_date.tm_year = tp.tm_year;
3521*10652SHyon.Kim@Sun.COM } else {
3522*10652SHyon.Kim@Sun.COM (void) memset(&attributes->build_date, 0,
3523*10652SHyon.Kim@Sun.COM sizeof (attributes->build_date));
3524*10652SHyon.Kim@Sun.COM }
3525*10652SHyon.Kim@Sun.COM (void) memset(&attributes->build_date, 0,
3526*10652SHyon.Kim@Sun.COM sizeof (attributes->build_date));
3527*10652SHyon.Kim@Sun.COM }
3528*10652SHyon.Kim@Sun.COM
3529*10652SHyon.Kim@Sun.COM return (1);
3530*10652SHyon.Kim@Sun.COM }
3531*10652SHyon.Kim@Sun.COM
3532*10652SHyon.Kim@Sun.COM /*
3533*10652SHyon.Kim@Sun.COM * This function returns the attributes for the warpper library.
3534*10652SHyon.Kim@Sun.COM */
3535*10652SHyon.Kim@Sun.COM HBA_UINT32
SMHBA_GetVendorLibraryAttributes(HBA_UINT32 adapter_index,SMHBA_LIBRARYATTRIBUTES * attributes)3536*10652SHyon.Kim@Sun.COM SMHBA_GetVendorLibraryAttributes(
3537*10652SHyon.Kim@Sun.COM HBA_UINT32 adapter_index,
3538*10652SHyon.Kim@Sun.COM SMHBA_LIBRARYATTRIBUTES *attributes)
3539*10652SHyon.Kim@Sun.COM {
3540*10652SHyon.Kim@Sun.COM HBA_ADAPTER_INFO *adapt_infop;
3541*10652SHyon.Kim@Sun.COM SMHBAGetVendorLibraryAttributesFunc
3542*10652SHyon.Kim@Sun.COM registeredfunc;
3543*10652SHyon.Kim@Sun.COM HBA_UINT32 ret = 0;
3544*10652SHyon.Kim@Sun.COM
3545*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetVendorLibraryAttributes adapterindex:%d",
3546*10652SHyon.Kim@Sun.COM adapter_index, 0, 0);
3547*10652SHyon.Kim@Sun.COM if (_hbaapi_librarylist == NULL) {
3548*10652SHyon.Kim@Sun.COM DEBUG(1, "SMHBAAPI not loaded yet.", 0, 0, 0);
3549*10652SHyon.Kim@Sun.COM return (0);
3550*10652SHyon.Kim@Sun.COM }
3551*10652SHyon.Kim@Sun.COM
3552*10652SHyon.Kim@Sun.COM if (attributes == NULL) {
3553*10652SHyon.Kim@Sun.COM DEBUG(1, "SMHBA_GetVendorLibraryAttributes: "
3554*10652SHyon.Kim@Sun.COM "NULL pointer attributes",
3555*10652SHyon.Kim@Sun.COM 0, 0, 0);
3556*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR_ARG);
3557*10652SHyon.Kim@Sun.COM }
3558*10652SHyon.Kim@Sun.COM
3559*10652SHyon.Kim@Sun.COM (void) memset(attributes, 0, sizeof (SMHBA_LIBRARYATTRIBUTES));
3560*10652SHyon.Kim@Sun.COM
3561*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
3562*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AL_mutex);
3563*10652SHyon.Kim@Sun.COM for (adapt_infop = _hbaapi_adapterlist;
3564*10652SHyon.Kim@Sun.COM adapt_infop != NULL;
3565*10652SHyon.Kim@Sun.COM adapt_infop = adapt_infop->next) {
3566*10652SHyon.Kim@Sun.COM
3567*10652SHyon.Kim@Sun.COM if (adapt_infop->index == adapter_index) {
3568*10652SHyon.Kim@Sun.COM
3569*10652SHyon.Kim@Sun.COM if (adapt_infop->library->version != SMHBA) {
3570*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
3571*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
3572*10652SHyon.Kim@Sun.COM HBA_STATUS_ERROR_INCOMPATIBLE);
3573*10652SHyon.Kim@Sun.COM }
3574*10652SHyon.Kim@Sun.COM
3575*10652SHyon.Kim@Sun.COM registeredfunc = adapt_infop->library->
3576*10652SHyon.Kim@Sun.COM ftable.smhbafunctionTable.GetVendorLibraryAttributesHandler;
3577*10652SHyon.Kim@Sun.COM if (registeredfunc != NULL) {
3578*10652SHyon.Kim@Sun.COM ret = (registeredfunc)(attributes);
3579*10652SHyon.Kim@Sun.COM #ifdef NOTDEF
3580*10652SHyon.Kim@Sun.COM } else {
3581*10652SHyon.Kim@Sun.COM /* This should not happen since the VSL is already loaded. */
3582*10652SHyon.Kim@Sun.COM #endif
3583*10652SHyon.Kim@Sun.COM }
3584*10652SHyon.Kim@Sun.COM if (attributes->LibPath[0] == '\0') {
3585*10652SHyon.Kim@Sun.COM if (strlen(adapt_infop->library->LibraryPath) < 256) {
3586*10652SHyon.Kim@Sun.COM (void) strcpy(attributes->LibPath,
3587*10652SHyon.Kim@Sun.COM adapt_infop->library->LibraryPath);
3588*10652SHyon.Kim@Sun.COM }
3589*10652SHyon.Kim@Sun.COM }
3590*10652SHyon.Kim@Sun.COM break;
3591*10652SHyon.Kim@Sun.COM }
3592*10652SHyon.Kim@Sun.COM }
3593*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AL_mutex);
3594*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, ret);
3595*10652SHyon.Kim@Sun.COM }
3596*10652SHyon.Kim@Sun.COM
3597*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetAdapterAttributes(HBA_HANDLE handle,SMHBA_ADAPTERATTRIBUTES * hbaattributes)3598*10652SHyon.Kim@Sun.COM SMHBA_GetAdapterAttributes(
3599*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3600*10652SHyon.Kim@Sun.COM SMHBA_ADAPTERATTRIBUTES *hbaattributes)
3601*10652SHyon.Kim@Sun.COM {
3602*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3603*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3604*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3605*10652SHyon.Kim@Sun.COM SMHBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
3606*10652SHyon.Kim@Sun.COM
3607*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetAdapterAttributes", 0, 0, 0);
3608*10652SHyon.Kim@Sun.COM
3609*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3610*10652SHyon.Kim@Sun.COM
3611*10652SHyon.Kim@Sun.COM GetAdapterAttributesFunc =
3612*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetAdapterAttributesHandler;
3613*10652SHyon.Kim@Sun.COM if (GetAdapterAttributesFunc != NULL) {
3614*10652SHyon.Kim@Sun.COM status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
3615*10652SHyon.Kim@Sun.COM } else {
3616*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3617*10652SHyon.Kim@Sun.COM }
3618*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3619*10652SHyon.Kim@Sun.COM }
3620*10652SHyon.Kim@Sun.COM
3621*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetNumberOfPorts(HBA_HANDLE handle,HBA_UINT32 * numberofports)3622*10652SHyon.Kim@Sun.COM SMHBA_GetNumberOfPorts(
3623*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3624*10652SHyon.Kim@Sun.COM HBA_UINT32 *numberofports)
3625*10652SHyon.Kim@Sun.COM {
3626*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3627*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3628*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3629*10652SHyon.Kim@Sun.COM SMHBAGetNumberOfPortsFunc GetNumberOfPortsFunc;
3630*10652SHyon.Kim@Sun.COM
3631*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetAdapterAttributes", 0, 0, 0);
3632*10652SHyon.Kim@Sun.COM
3633*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3634*10652SHyon.Kim@Sun.COM
3635*10652SHyon.Kim@Sun.COM GetNumberOfPortsFunc =
3636*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetNumberOfPortsHandler;
3637*10652SHyon.Kim@Sun.COM if (GetNumberOfPortsFunc != NULL) {
3638*10652SHyon.Kim@Sun.COM status = ((GetNumberOfPortsFunc)(vendorHandle, numberofports));
3639*10652SHyon.Kim@Sun.COM } else {
3640*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3641*10652SHyon.Kim@Sun.COM }
3642*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3643*10652SHyon.Kim@Sun.COM }
3644*10652SHyon.Kim@Sun.COM
3645*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetPortType(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_PORTTYPE * porttype)3646*10652SHyon.Kim@Sun.COM SMHBA_GetPortType(
3647*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3648*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3649*10652SHyon.Kim@Sun.COM HBA_PORTTYPE *porttype)
3650*10652SHyon.Kim@Sun.COM {
3651*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3652*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3653*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3654*10652SHyon.Kim@Sun.COM SMHBAGetPortTypeFunc GetPortTypeFunc;
3655*10652SHyon.Kim@Sun.COM
3656*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetAdapterAttributes", 0, 0, 0);
3657*10652SHyon.Kim@Sun.COM
3658*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3659*10652SHyon.Kim@Sun.COM
3660*10652SHyon.Kim@Sun.COM GetPortTypeFunc =
3661*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetPortTypeHandler;
3662*10652SHyon.Kim@Sun.COM if (GetPortTypeFunc != NULL) {
3663*10652SHyon.Kim@Sun.COM status = ((GetPortTypeFunc)(vendorHandle, portindex, porttype));
3664*10652SHyon.Kim@Sun.COM } else {
3665*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3666*10652SHyon.Kim@Sun.COM }
3667*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3668*10652SHyon.Kim@Sun.COM }
3669*10652SHyon.Kim@Sun.COM
3670*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetAdapterPortAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,SMHBA_PORTATTRIBUTES * portattributes)3671*10652SHyon.Kim@Sun.COM SMHBA_GetAdapterPortAttributes(
3672*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3673*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3674*10652SHyon.Kim@Sun.COM SMHBA_PORTATTRIBUTES *portattributes)
3675*10652SHyon.Kim@Sun.COM {
3676*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3677*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3678*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3679*10652SHyon.Kim@Sun.COM SMHBAGetAdapterPortAttributesFunc
3680*10652SHyon.Kim@Sun.COM GetAdapterPortAttributesFunc;
3681*10652SHyon.Kim@Sun.COM
3682*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetAdapterPortAttributes", 0, 0, 0);
3683*10652SHyon.Kim@Sun.COM
3684*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3685*10652SHyon.Kim@Sun.COM
3686*10652SHyon.Kim@Sun.COM GetAdapterPortAttributesFunc =
3687*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
3688*10652SHyon.Kim@Sun.COM GetAdapterPortAttributesHandler;
3689*10652SHyon.Kim@Sun.COM if (GetAdapterPortAttributesFunc != NULL) {
3690*10652SHyon.Kim@Sun.COM status = ((GetAdapterPortAttributesFunc)
3691*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, portattributes));
3692*10652SHyon.Kim@Sun.COM } else {
3693*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3694*10652SHyon.Kim@Sun.COM }
3695*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3696*10652SHyon.Kim@Sun.COM }
3697*10652SHyon.Kim@Sun.COM
3698*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetDiscoveredPortAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 discoveredportindex,SMHBA_PORTATTRIBUTES * portattributes)3699*10652SHyon.Kim@Sun.COM SMHBA_GetDiscoveredPortAttributes(
3700*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3701*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3702*10652SHyon.Kim@Sun.COM HBA_UINT32 discoveredportindex,
3703*10652SHyon.Kim@Sun.COM SMHBA_PORTATTRIBUTES *portattributes)
3704*10652SHyon.Kim@Sun.COM {
3705*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3706*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3707*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3708*10652SHyon.Kim@Sun.COM SMHBAGetDiscoveredPortAttributesFunc
3709*10652SHyon.Kim@Sun.COM GetDiscoveredPortAttributesFunc;
3710*10652SHyon.Kim@Sun.COM
3711*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetDiscoveredPortAttributes", 0, 0, 0);
3712*10652SHyon.Kim@Sun.COM
3713*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3714*10652SHyon.Kim@Sun.COM
3715*10652SHyon.Kim@Sun.COM GetDiscoveredPortAttributesFunc =
3716*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
3717*10652SHyon.Kim@Sun.COM GetDiscoveredPortAttributesHandler;
3718*10652SHyon.Kim@Sun.COM if (GetDiscoveredPortAttributesFunc != NULL) {
3719*10652SHyon.Kim@Sun.COM status = ((GetDiscoveredPortAttributesFunc)
3720*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, discoveredportindex,
3721*10652SHyon.Kim@Sun.COM portattributes));
3722*10652SHyon.Kim@Sun.COM } else {
3723*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3724*10652SHyon.Kim@Sun.COM }
3725*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3726*10652SHyon.Kim@Sun.COM }
3727*10652SHyon.Kim@Sun.COM
3728*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetPortAttributesByWWN(HBA_HANDLE handle,HBA_WWN portWWN,HBA_WWN domainPortWWN,SMHBA_PORTATTRIBUTES * portattributes)3729*10652SHyon.Kim@Sun.COM SMHBA_GetPortAttributesByWWN(
3730*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3731*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
3732*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3733*10652SHyon.Kim@Sun.COM SMHBA_PORTATTRIBUTES *portattributes)
3734*10652SHyon.Kim@Sun.COM {
3735*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3736*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3737*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3738*10652SHyon.Kim@Sun.COM SMHBAGetPortAttributesByWWNFunc
3739*10652SHyon.Kim@Sun.COM GetPortAttributesByWWNFunc;
3740*10652SHyon.Kim@Sun.COM
3741*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetPortAttributesByWWN: %s", WWN2STR1(&portWWN), 0, 0);
3742*10652SHyon.Kim@Sun.COM
3743*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3744*10652SHyon.Kim@Sun.COM
3745*10652SHyon.Kim@Sun.COM GetPortAttributesByWWNFunc =
3746*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetPortAttributesByWWNHandler;
3747*10652SHyon.Kim@Sun.COM if (GetPortAttributesByWWNFunc != NULL) {
3748*10652SHyon.Kim@Sun.COM status = ((GetPortAttributesByWWNFunc)
3749*10652SHyon.Kim@Sun.COM (vendorHandle, portWWN, domainPortWWN, portattributes));
3750*10652SHyon.Kim@Sun.COM } else {
3751*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3752*10652SHyon.Kim@Sun.COM }
3753*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3754*10652SHyon.Kim@Sun.COM }
3755*10652SHyon.Kim@Sun.COM
3756*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetFCPhyAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 phyindex,SMHBA_FC_PHY * phytype)3757*10652SHyon.Kim@Sun.COM SMHBA_GetFCPhyAttributes(
3758*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3759*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3760*10652SHyon.Kim@Sun.COM HBA_UINT32 phyindex,
3761*10652SHyon.Kim@Sun.COM SMHBA_FC_PHY *phytype)
3762*10652SHyon.Kim@Sun.COM {
3763*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3764*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3765*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3766*10652SHyon.Kim@Sun.COM SMHBAGetFCPhyAttributesFunc GetFCPhyAttributesFunc;
3767*10652SHyon.Kim@Sun.COM
3768*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetFCPhyAttributesByWWN", 0, 0, 0);
3769*10652SHyon.Kim@Sun.COM
3770*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3771*10652SHyon.Kim@Sun.COM
3772*10652SHyon.Kim@Sun.COM GetFCPhyAttributesFunc =
3773*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetFCPhyAttributesHandler;
3774*10652SHyon.Kim@Sun.COM if (GetFCPhyAttributesFunc != NULL) {
3775*10652SHyon.Kim@Sun.COM status = ((GetFCPhyAttributesFunc)
3776*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, phyindex, phytype));
3777*10652SHyon.Kim@Sun.COM } else {
3778*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3779*10652SHyon.Kim@Sun.COM }
3780*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3781*10652SHyon.Kim@Sun.COM }
3782*10652SHyon.Kim@Sun.COM
3783*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetSASPhyAttributes(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 phyindex,SMHBA_SAS_PHY * phytype)3784*10652SHyon.Kim@Sun.COM SMHBA_GetSASPhyAttributes(
3785*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3786*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3787*10652SHyon.Kim@Sun.COM HBA_UINT32 phyindex,
3788*10652SHyon.Kim@Sun.COM SMHBA_SAS_PHY *phytype)
3789*10652SHyon.Kim@Sun.COM {
3790*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3791*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3792*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3793*10652SHyon.Kim@Sun.COM SMHBAGetSASPhyAttributesFunc GetSASPhyAttributesFunc;
3794*10652SHyon.Kim@Sun.COM
3795*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetFCPhyAttributesByWWN", 0, 0, 0);
3796*10652SHyon.Kim@Sun.COM
3797*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3798*10652SHyon.Kim@Sun.COM
3799*10652SHyon.Kim@Sun.COM GetSASPhyAttributesFunc =
3800*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetSASPhyAttributesHandler;
3801*10652SHyon.Kim@Sun.COM if (GetSASPhyAttributesFunc != NULL) {
3802*10652SHyon.Kim@Sun.COM status = ((GetSASPhyAttributesFunc)
3803*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, phyindex, phytype));
3804*10652SHyon.Kim@Sun.COM } else {
3805*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3806*10652SHyon.Kim@Sun.COM }
3807*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3808*10652SHyon.Kim@Sun.COM }
3809*10652SHyon.Kim@Sun.COM
3810*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetProtocolStatistics(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 protocoltype,SMHBA_PROTOCOLSTATISTICS * pProtocolStatistics)3811*10652SHyon.Kim@Sun.COM SMHBA_GetProtocolStatistics(
3812*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3813*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3814*10652SHyon.Kim@Sun.COM HBA_UINT32 protocoltype,
3815*10652SHyon.Kim@Sun.COM SMHBA_PROTOCOLSTATISTICS *pProtocolStatistics)
3816*10652SHyon.Kim@Sun.COM {
3817*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3818*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3819*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3820*10652SHyon.Kim@Sun.COM SMHBAGetProtocolStatisticsFunc
3821*10652SHyon.Kim@Sun.COM GetProtocolStatisticsFunc;
3822*10652SHyon.Kim@Sun.COM
3823*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetProtocolStatistics port index: %d protocol type: %d",
3824*10652SHyon.Kim@Sun.COM portindex, protocoltype, 0);
3825*10652SHyon.Kim@Sun.COM
3826*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3827*10652SHyon.Kim@Sun.COM
3828*10652SHyon.Kim@Sun.COM GetProtocolStatisticsFunc =
3829*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetProtocolStatisticsHandler;
3830*10652SHyon.Kim@Sun.COM if (GetProtocolStatisticsFunc != NULL) {
3831*10652SHyon.Kim@Sun.COM status = (GetProtocolStatisticsFunc)
3832*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, protocoltype, pProtocolStatistics);
3833*10652SHyon.Kim@Sun.COM } else {
3834*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3835*10652SHyon.Kim@Sun.COM }
3836*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3837*10652SHyon.Kim@Sun.COM }
3838*10652SHyon.Kim@Sun.COM
3839*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetPhyStatistics(HBA_HANDLE handle,HBA_UINT32 portindex,HBA_UINT32 phyindex,SMHBA_PHYSTATISTICS * pPhyStatistics)3840*10652SHyon.Kim@Sun.COM SMHBA_GetPhyStatistics(
3841*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3842*10652SHyon.Kim@Sun.COM HBA_UINT32 portindex,
3843*10652SHyon.Kim@Sun.COM HBA_UINT32 phyindex,
3844*10652SHyon.Kim@Sun.COM SMHBA_PHYSTATISTICS *pPhyStatistics)
3845*10652SHyon.Kim@Sun.COM {
3846*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3847*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3848*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3849*10652SHyon.Kim@Sun.COM SMHBAGetPhyStatisticsFunc
3850*10652SHyon.Kim@Sun.COM GetPhyStatisticsFunc;
3851*10652SHyon.Kim@Sun.COM
3852*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetPhyStatistics port index: %d phy idex: %d",
3853*10652SHyon.Kim@Sun.COM portindex, phyindex, 0);
3854*10652SHyon.Kim@Sun.COM
3855*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3856*10652SHyon.Kim@Sun.COM
3857*10652SHyon.Kim@Sun.COM GetPhyStatisticsFunc =
3858*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetPhyStatisticsHandler;
3859*10652SHyon.Kim@Sun.COM if (GetPhyStatisticsFunc != NULL) {
3860*10652SHyon.Kim@Sun.COM status = (GetPhyStatisticsFunc)
3861*10652SHyon.Kim@Sun.COM (vendorHandle, portindex, phyindex, pPhyStatistics);
3862*10652SHyon.Kim@Sun.COM } else {
3863*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3864*10652SHyon.Kim@Sun.COM }
3865*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3866*10652SHyon.Kim@Sun.COM }
3867*10652SHyon.Kim@Sun.COM
3868*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetBindingCapability(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,SMHBA_BIND_CAPABILITY * pFlags)3869*10652SHyon.Kim@Sun.COM SMHBA_GetBindingCapability(
3870*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3871*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3872*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3873*10652SHyon.Kim@Sun.COM SMHBA_BIND_CAPABILITY *pFlags)
3874*10652SHyon.Kim@Sun.COM {
3875*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3876*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3877*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3878*10652SHyon.Kim@Sun.COM SMHBAGetBindingCapabilityFunc GetBindingCapabilityFunc;
3879*10652SHyon.Kim@Sun.COM
3880*10652SHyon.Kim@Sun.COM DEBUG(2, "HBA_GetBindingCapability", 0, 0, 0);
3881*10652SHyon.Kim@Sun.COM
3882*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3883*10652SHyon.Kim@Sun.COM
3884*10652SHyon.Kim@Sun.COM GetBindingCapabilityFunc =
3885*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetBindingCapabilityHandler;
3886*10652SHyon.Kim@Sun.COM if (GetBindingCapabilityFunc != NULL) {
3887*10652SHyon.Kim@Sun.COM status = (GetBindingCapabilityFunc)(vendorHandle, hbaPortWWN,
3888*10652SHyon.Kim@Sun.COM domainPortWWN, pFlags);
3889*10652SHyon.Kim@Sun.COM } else {
3890*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3891*10652SHyon.Kim@Sun.COM }
3892*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3893*10652SHyon.Kim@Sun.COM }
3894*10652SHyon.Kim@Sun.COM
3895*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetBindingSupport(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,SMHBA_BIND_CAPABILITY * pFlags)3896*10652SHyon.Kim@Sun.COM SMHBA_GetBindingSupport(
3897*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3898*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3899*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3900*10652SHyon.Kim@Sun.COM SMHBA_BIND_CAPABILITY *pFlags)
3901*10652SHyon.Kim@Sun.COM {
3902*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3903*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3904*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3905*10652SHyon.Kim@Sun.COM SMHBAGetBindingSupportFunc
3906*10652SHyon.Kim@Sun.COM GetBindingSupporFunc;
3907*10652SHyon.Kim@Sun.COM
3908*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetBindingSupport port: %s",
3909*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3910*10652SHyon.Kim@Sun.COM
3911*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3912*10652SHyon.Kim@Sun.COM
3913*10652SHyon.Kim@Sun.COM GetBindingSupporFunc =
3914*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetBindingSupportHandler;
3915*10652SHyon.Kim@Sun.COM if (GetBindingSupporFunc != NULL) {
3916*10652SHyon.Kim@Sun.COM status = (GetBindingSupporFunc)(vendorHandle,
3917*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN, pFlags);
3918*10652SHyon.Kim@Sun.COM } else {
3919*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3920*10652SHyon.Kim@Sun.COM }
3921*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3922*10652SHyon.Kim@Sun.COM }
3923*10652SHyon.Kim@Sun.COM
3924*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_SetBindingSupport(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,SMHBA_BIND_CAPABILITY flags)3925*10652SHyon.Kim@Sun.COM SMHBA_SetBindingSupport(
3926*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3927*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3928*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3929*10652SHyon.Kim@Sun.COM SMHBA_BIND_CAPABILITY flags)
3930*10652SHyon.Kim@Sun.COM {
3931*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3932*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3933*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3934*10652SHyon.Kim@Sun.COM SMHBASetBindingSupportFunc
3935*10652SHyon.Kim@Sun.COM SetBindingSupporFunc;
3936*10652SHyon.Kim@Sun.COM
3937*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetBindingSupport port: %s",
3938*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3939*10652SHyon.Kim@Sun.COM
3940*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(HBAAPIV2);
3941*10652SHyon.Kim@Sun.COM
3942*10652SHyon.Kim@Sun.COM SetBindingSupporFunc =
3943*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.SetBindingSupportHandler;
3944*10652SHyon.Kim@Sun.COM if (SetBindingSupporFunc != NULL) {
3945*10652SHyon.Kim@Sun.COM status = (SetBindingSupporFunc)
3946*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN, domainPortWWN, flags);
3947*10652SHyon.Kim@Sun.COM } else {
3948*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3949*10652SHyon.Kim@Sun.COM }
3950*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3951*10652SHyon.Kim@Sun.COM }
3952*10652SHyon.Kim@Sun.COM
3953*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetTargetMapping(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,SMHBA_TARGETMAPPING * pMapping)3954*10652SHyon.Kim@Sun.COM SMHBA_GetTargetMapping(
3955*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3956*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3957*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3958*10652SHyon.Kim@Sun.COM SMHBA_TARGETMAPPING *pMapping)
3959*10652SHyon.Kim@Sun.COM {
3960*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3961*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3962*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3963*10652SHyon.Kim@Sun.COM SMHBAGetTargetMappingFunc GetTargetMappingFunc;
3964*10652SHyon.Kim@Sun.COM
3965*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetTargetMapping port WWN: %s",
3966*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3967*10652SHyon.Kim@Sun.COM
3968*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3969*10652SHyon.Kim@Sun.COM
3970*10652SHyon.Kim@Sun.COM GetTargetMappingFunc =
3971*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetTargetMappingHandler;
3972*10652SHyon.Kim@Sun.COM if (GetTargetMappingFunc != NULL) {
3973*10652SHyon.Kim@Sun.COM status = ((GetTargetMappingFunc)(vendorHandle,
3974*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN, pMapping));
3975*10652SHyon.Kim@Sun.COM } else {
3976*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
3977*10652SHyon.Kim@Sun.COM }
3978*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
3979*10652SHyon.Kim@Sun.COM }
3980*10652SHyon.Kim@Sun.COM
3981*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetPersistentBinding(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,SMHBA_BINDING * binding)3982*10652SHyon.Kim@Sun.COM SMHBA_GetPersistentBinding(
3983*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
3984*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
3985*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
3986*10652SHyon.Kim@Sun.COM SMHBA_BINDING *binding)
3987*10652SHyon.Kim@Sun.COM {
3988*10652SHyon.Kim@Sun.COM HBA_STATUS status;
3989*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
3990*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
3991*10652SHyon.Kim@Sun.COM SMHBAGetPersistentBindingFunc
3992*10652SHyon.Kim@Sun.COM GetPersistentBindingFunc;
3993*10652SHyon.Kim@Sun.COM
3994*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetPersistentBinding port WWN: %s",
3995*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
3996*10652SHyon.Kim@Sun.COM
3997*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
3998*10652SHyon.Kim@Sun.COM
3999*10652SHyon.Kim@Sun.COM GetPersistentBindingFunc =
4000*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetPersistentBindingHandler;
4001*10652SHyon.Kim@Sun.COM if (GetPersistentBindingFunc != NULL) {
4002*10652SHyon.Kim@Sun.COM status = ((GetPersistentBindingFunc)(vendorHandle,
4003*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN, binding));
4004*10652SHyon.Kim@Sun.COM } else {
4005*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4006*10652SHyon.Kim@Sun.COM }
4007*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4008*10652SHyon.Kim@Sun.COM }
4009*10652SHyon.Kim@Sun.COM
4010*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_SetPersistentBinding(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,const SMHBA_BINDING * binding)4011*10652SHyon.Kim@Sun.COM SMHBA_SetPersistentBinding(
4012*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4013*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4014*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4015*10652SHyon.Kim@Sun.COM const SMHBA_BINDING *binding)
4016*10652SHyon.Kim@Sun.COM {
4017*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4018*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4019*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4020*10652SHyon.Kim@Sun.COM SMHBASetPersistentBindingFunc
4021*10652SHyon.Kim@Sun.COM SetPersistentBindingFunc;
4022*10652SHyon.Kim@Sun.COM
4023*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_SetPersistentBinding port WWN: %s",
4024*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
4025*10652SHyon.Kim@Sun.COM
4026*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4027*10652SHyon.Kim@Sun.COM
4028*10652SHyon.Kim@Sun.COM SetPersistentBindingFunc =
4029*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.SetPersistentBindingHandler;
4030*10652SHyon.Kim@Sun.COM if (SetPersistentBindingFunc != NULL) {
4031*10652SHyon.Kim@Sun.COM status = ((SetPersistentBindingFunc)(vendorHandle,
4032*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN, binding));
4033*10652SHyon.Kim@Sun.COM } else {
4034*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4035*10652SHyon.Kim@Sun.COM }
4036*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4037*10652SHyon.Kim@Sun.COM }
4038*10652SHyon.Kim@Sun.COM
4039*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RemovePersistentBinding(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN,const SMHBA_BINDING * binding)4040*10652SHyon.Kim@Sun.COM SMHBA_RemovePersistentBinding(
4041*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4042*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4043*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4044*10652SHyon.Kim@Sun.COM const SMHBA_BINDING *binding)
4045*10652SHyon.Kim@Sun.COM {
4046*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4047*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4048*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4049*10652SHyon.Kim@Sun.COM SMHBARemovePersistentBindingFunc
4050*10652SHyon.Kim@Sun.COM RemovePersistentBindingFunc;
4051*10652SHyon.Kim@Sun.COM
4052*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RemovePersistentBinding port WWN: %s",
4053*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
4054*10652SHyon.Kim@Sun.COM
4055*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4056*10652SHyon.Kim@Sun.COM
4057*10652SHyon.Kim@Sun.COM RemovePersistentBindingFunc =
4058*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.RemovePersistentBindingHandler;
4059*10652SHyon.Kim@Sun.COM if (RemovePersistentBindingFunc != NULL) {
4060*10652SHyon.Kim@Sun.COM status = ((RemovePersistentBindingFunc)(vendorHandle,
4061*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN, binding));
4062*10652SHyon.Kim@Sun.COM } else {
4063*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4064*10652SHyon.Kim@Sun.COM }
4065*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4066*10652SHyon.Kim@Sun.COM }
4067*10652SHyon.Kim@Sun.COM
4068*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RemoveAllPersistentBindings(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN domainPortWWN)4069*10652SHyon.Kim@Sun.COM SMHBA_RemoveAllPersistentBindings(
4070*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4071*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4072*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN)
4073*10652SHyon.Kim@Sun.COM {
4074*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4075*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4076*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4077*10652SHyon.Kim@Sun.COM SMHBARemoveAllPersistentBindingsFunc
4078*10652SHyon.Kim@Sun.COM RemoveAllPersistentBindingsFunc;
4079*10652SHyon.Kim@Sun.COM
4080*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RemoveAllPersistentBinding port WWN: %s",
4081*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), 0, 0);
4082*10652SHyon.Kim@Sun.COM
4083*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4084*10652SHyon.Kim@Sun.COM
4085*10652SHyon.Kim@Sun.COM RemoveAllPersistentBindingsFunc =
4086*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
4087*10652SHyon.Kim@Sun.COM RemoveAllPersistentBindingsHandler;
4088*10652SHyon.Kim@Sun.COM if (RemoveAllPersistentBindingsFunc != NULL) {
4089*10652SHyon.Kim@Sun.COM status = ((RemoveAllPersistentBindingsFunc)(vendorHandle,
4090*10652SHyon.Kim@Sun.COM hbaPortWWN, domainPortWWN));
4091*10652SHyon.Kim@Sun.COM } else {
4092*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4093*10652SHyon.Kim@Sun.COM }
4094*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4095*10652SHyon.Kim@Sun.COM }
4096*10652SHyon.Kim@Sun.COM
4097*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_GetLUNStatistics(HBA_HANDLE handle,const HBA_SCSIID * lunit,SMHBA_PROTOCOLSTATISTICS * statistics)4098*10652SHyon.Kim@Sun.COM SMHBA_GetLUNStatistics(
4099*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4100*10652SHyon.Kim@Sun.COM const HBA_SCSIID *lunit,
4101*10652SHyon.Kim@Sun.COM SMHBA_PROTOCOLSTATISTICS *statistics)
4102*10652SHyon.Kim@Sun.COM {
4103*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4104*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4105*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4106*10652SHyon.Kim@Sun.COM SMHBAGetLUNStatisticsFunc GetLUNStatisticsFunc;
4107*10652SHyon.Kim@Sun.COM
4108*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_GetLUNStatistics", 0, 0, 0);
4109*10652SHyon.Kim@Sun.COM
4110*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4111*10652SHyon.Kim@Sun.COM
4112*10652SHyon.Kim@Sun.COM GetLUNStatisticsFunc =
4113*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.GetLUNStatisticsHandler;
4114*10652SHyon.Kim@Sun.COM if (GetLUNStatisticsFunc != NULL) {
4115*10652SHyon.Kim@Sun.COM status = ((GetLUNStatisticsFunc)(vendorHandle, lunit, statistics));
4116*10652SHyon.Kim@Sun.COM } else {
4117*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4118*10652SHyon.Kim@Sun.COM }
4119*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4120*10652SHyon.Kim@Sun.COM }
4121*10652SHyon.Kim@Sun.COM
4122*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_ScsiInquiry(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,SMHBA_SCSILUN smhbaLUN,HBA_UINT8 CDB_Byte1,HBA_UINT8 CDB_Byte2,void * pRspBuffer,HBA_UINT32 * pRspBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * pSenseBufferSize)4123*10652SHyon.Kim@Sun.COM SMHBA_ScsiInquiry(
4124*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4125*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4126*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4127*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4128*10652SHyon.Kim@Sun.COM SMHBA_SCSILUN smhbaLUN,
4129*10652SHyon.Kim@Sun.COM HBA_UINT8 CDB_Byte1,
4130*10652SHyon.Kim@Sun.COM HBA_UINT8 CDB_Byte2,
4131*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4132*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize,
4133*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
4134*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
4135*10652SHyon.Kim@Sun.COM HBA_UINT32 *pSenseBufferSize)
4136*10652SHyon.Kim@Sun.COM {
4137*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4138*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4139*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4140*10652SHyon.Kim@Sun.COM SMHBAScsiInquiryFunc ScsiInquiryFunc;
4141*10652SHyon.Kim@Sun.COM
4142*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_ScsiInquiry to hba port: %s discoveredPortWWN: %s",
4143*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
4144*10652SHyon.Kim@Sun.COM
4145*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4146*10652SHyon.Kim@Sun.COM
4147*10652SHyon.Kim@Sun.COM ScsiInquiryFunc =
4148*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.ScsiInquiryHandler;
4149*10652SHyon.Kim@Sun.COM if (ScsiInquiryFunc != NULL) {
4150*10652SHyon.Kim@Sun.COM status = ((ScsiInquiryFunc)(
4151*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
4152*10652SHyon.Kim@Sun.COM smhbaLUN, CDB_Byte1, CDB_Byte2, pRspBuffer, pRspBufferSize,
4153*10652SHyon.Kim@Sun.COM pScsiStatus, pSenseBuffer, pSenseBufferSize));
4154*10652SHyon.Kim@Sun.COM } else {
4155*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4156*10652SHyon.Kim@Sun.COM }
4157*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4158*10652SHyon.Kim@Sun.COM }
4159*10652SHyon.Kim@Sun.COM
4160*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_ScsiReportLUNs(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,void * pRspBuffer,HBA_UINT32 * pRspBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * pSenseBufferSize)4161*10652SHyon.Kim@Sun.COM SMHBA_ScsiReportLUNs(
4162*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4163*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4164*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4165*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4166*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4167*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize,
4168*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
4169*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
4170*10652SHyon.Kim@Sun.COM HBA_UINT32 *pSenseBufferSize)
4171*10652SHyon.Kim@Sun.COM {
4172*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4173*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4174*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4175*10652SHyon.Kim@Sun.COM SMHBAScsiReportLUNsFunc ScsiReportLUNsFunc;
4176*10652SHyon.Kim@Sun.COM
4177*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_ScsiReportLuns to hba port: %s discoveredPortWWN: %s",
4178*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
4179*10652SHyon.Kim@Sun.COM
4180*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4181*10652SHyon.Kim@Sun.COM
4182*10652SHyon.Kim@Sun.COM ScsiReportLUNsFunc =
4183*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.ScsiReportLUNsHandler;
4184*10652SHyon.Kim@Sun.COM if (ScsiReportLUNsFunc != NULL) {
4185*10652SHyon.Kim@Sun.COM status = ((ScsiReportLUNsFunc)(
4186*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
4187*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer,
4188*10652SHyon.Kim@Sun.COM pSenseBufferSize));
4189*10652SHyon.Kim@Sun.COM } else {
4190*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4191*10652SHyon.Kim@Sun.COM }
4192*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4193*10652SHyon.Kim@Sun.COM }
4194*10652SHyon.Kim@Sun.COM
4195*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_ScsiReadCapacity(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,SMHBA_SCSILUN smhbaLUN,void * pRspBuffer,HBA_UINT32 * pRspBufferSize,HBA_UINT8 * pScsiStatus,void * pSenseBuffer,HBA_UINT32 * pSenseBufferSize)4196*10652SHyon.Kim@Sun.COM SMHBA_ScsiReadCapacity(
4197*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4198*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4199*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4200*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4201*10652SHyon.Kim@Sun.COM SMHBA_SCSILUN smhbaLUN,
4202*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4203*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize,
4204*10652SHyon.Kim@Sun.COM HBA_UINT8 *pScsiStatus,
4205*10652SHyon.Kim@Sun.COM void *pSenseBuffer,
4206*10652SHyon.Kim@Sun.COM HBA_UINT32 *pSenseBufferSize)
4207*10652SHyon.Kim@Sun.COM {
4208*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4209*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4210*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4211*10652SHyon.Kim@Sun.COM SMHBAScsiReadCapacityFunc ScsiReadCapacityFunc;
4212*10652SHyon.Kim@Sun.COM
4213*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_ScsiReadCapacity to hba port: %s discoveredPortWWN: %s",
4214*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
4215*10652SHyon.Kim@Sun.COM
4216*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4217*10652SHyon.Kim@Sun.COM
4218*10652SHyon.Kim@Sun.COM ScsiReadCapacityFunc =
4219*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.ScsiReadCapacityHandler;
4220*10652SHyon.Kim@Sun.COM if (ScsiReadCapacityFunc != NULL) {
4221*10652SHyon.Kim@Sun.COM status = ((ScsiReadCapacityFunc)(
4222*10652SHyon.Kim@Sun.COM vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
4223*10652SHyon.Kim@Sun.COM smhbaLUN, pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer,
4224*10652SHyon.Kim@Sun.COM pSenseBufferSize));
4225*10652SHyon.Kim@Sun.COM } else {
4226*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4227*10652SHyon.Kim@Sun.COM }
4228*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4229*10652SHyon.Kim@Sun.COM }
4230*10652SHyon.Kim@Sun.COM
4231*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_SendTEST(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN destWWN,HBA_UINT32 destFCID,void * pRspBuffer,HBA_UINT32 pRspBufferSize)4232*10652SHyon.Kim@Sun.COM SMHBA_SendTEST(
4233*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4234*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4235*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
4236*10652SHyon.Kim@Sun.COM HBA_UINT32 destFCID,
4237*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4238*10652SHyon.Kim@Sun.COM HBA_UINT32 pRspBufferSize)
4239*10652SHyon.Kim@Sun.COM {
4240*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4241*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4242*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4243*10652SHyon.Kim@Sun.COM SMHBASendTESTFunc SendTESTFunc;
4244*10652SHyon.Kim@Sun.COM
4245*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_SendTEST, hbaPortWWN: %s destWWN",
4246*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN),
4247*10652SHyon.Kim@Sun.COM WWN2STR1(&destWWN), 0);
4248*10652SHyon.Kim@Sun.COM
4249*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4250*10652SHyon.Kim@Sun.COM
4251*10652SHyon.Kim@Sun.COM SendTESTFunc = lib_infop->ftable.smhbafunctionTable.SendTESTHandler;
4252*10652SHyon.Kim@Sun.COM if (SendTESTFunc != NULL) {
4253*10652SHyon.Kim@Sun.COM status = (SendTESTFunc)
4254*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN, destWWN, destFCID,
4255*10652SHyon.Kim@Sun.COM pRspBuffer, pRspBufferSize);
4256*10652SHyon.Kim@Sun.COM } else {
4257*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4258*10652SHyon.Kim@Sun.COM }
4259*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4260*10652SHyon.Kim@Sun.COM }
4261*10652SHyon.Kim@Sun.COM
4262*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_SendECHO(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN destWWN,HBA_UINT32 destFCID,void * pReqBuffer,HBA_UINT32 ReqBufferSize,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)4263*10652SHyon.Kim@Sun.COM SMHBA_SendECHO(
4264*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4265*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4266*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
4267*10652SHyon.Kim@Sun.COM HBA_UINT32 destFCID,
4268*10652SHyon.Kim@Sun.COM void *pReqBuffer,
4269*10652SHyon.Kim@Sun.COM HBA_UINT32 ReqBufferSize,
4270*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4271*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
4272*10652SHyon.Kim@Sun.COM {
4273*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4274*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4275*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4276*10652SHyon.Kim@Sun.COM SMHBASendECHOFunc SendECHOFunc;
4277*10652SHyon.Kim@Sun.COM
4278*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_SendECHO, hbaPortWWN: %s destWWN",
4279*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR1(&destWWN), 0);
4280*10652SHyon.Kim@Sun.COM
4281*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4282*10652SHyon.Kim@Sun.COM
4283*10652SHyon.Kim@Sun.COM SendECHOFunc = lib_infop->ftable.smhbafunctionTable.SendECHOHandler;
4284*10652SHyon.Kim@Sun.COM if (SendECHOFunc != NULL) {
4285*10652SHyon.Kim@Sun.COM status = (SendECHOFunc)
4286*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN, destWWN, destFCID,
4287*10652SHyon.Kim@Sun.COM pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
4288*10652SHyon.Kim@Sun.COM } else {
4289*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4290*10652SHyon.Kim@Sun.COM }
4291*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4292*10652SHyon.Kim@Sun.COM }
4293*10652SHyon.Kim@Sun.COM
4294*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_SendSMPPassThru(HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN destWWN,HBA_WWN domainPortWWN,void * pReqBuffer,HBA_UINT32 ReqBufferSize,void * pRspBuffer,HBA_UINT32 * pRspBufferSize)4295*10652SHyon.Kim@Sun.COM SMHBA_SendSMPPassThru(
4296*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4297*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4298*10652SHyon.Kim@Sun.COM HBA_WWN destWWN,
4299*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4300*10652SHyon.Kim@Sun.COM void *pReqBuffer,
4301*10652SHyon.Kim@Sun.COM HBA_UINT32 ReqBufferSize,
4302*10652SHyon.Kim@Sun.COM void *pRspBuffer,
4303*10652SHyon.Kim@Sun.COM HBA_UINT32 *pRspBufferSize)
4304*10652SHyon.Kim@Sun.COM {
4305*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4306*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4307*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4308*10652SHyon.Kim@Sun.COM SMHBASendSMPPassThruFunc SendSMPPassThruFunc;
4309*10652SHyon.Kim@Sun.COM
4310*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_SendSMPPassThru, hbaPortWWN: %s destWWN: %s",
4311*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR1(&destWWN), 0);
4312*10652SHyon.Kim@Sun.COM
4313*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4314*10652SHyon.Kim@Sun.COM
4315*10652SHyon.Kim@Sun.COM SendSMPPassThruFunc = lib_infop->ftable.\
4316*10652SHyon.Kim@Sun.COM smhbafunctionTable.SendSMPPassThruHandler;
4317*10652SHyon.Kim@Sun.COM
4318*10652SHyon.Kim@Sun.COM if (SendSMPPassThruFunc != NULL) {
4319*10652SHyon.Kim@Sun.COM status = (SendSMPPassThruFunc)
4320*10652SHyon.Kim@Sun.COM (vendorHandle, hbaPortWWN, destWWN, domainPortWWN,
4321*10652SHyon.Kim@Sun.COM pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
4322*10652SHyon.Kim@Sun.COM } else {
4323*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4324*10652SHyon.Kim@Sun.COM }
4325*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4326*10652SHyon.Kim@Sun.COM }
4327*10652SHyon.Kim@Sun.COM
4328*10652SHyon.Kim@Sun.COM /*
4329*10652SHyon.Kim@Sun.COM * Following the similar logic of HBAAPI addaspterevents_callback.
4330*10652SHyon.Kim@Sun.COM *
4331*10652SHyon.Kim@Sun.COM * Unlike other events Adapter Add Event is not limited to a specific
4332*10652SHyon.Kim@Sun.COM * adpater(i.e. no adatper handle is passed for registration) so
4333*10652SHyon.Kim@Sun.COM * the event should be passed to all registrants. The routine below
4334*10652SHyon.Kim@Sun.COM * is passed to the VSLs as a callback and when Adapter Add event is detected
4335*10652SHyon.Kim@Sun.COM * by VSL it will call smhba_adapteraddevents_callback() which in turn check
4336*10652SHyon.Kim@Sun.COM * if the passed userdata ptr matches with the one stored in the callback list
4337*10652SHyon.Kim@Sun.COM * and calls the stored callback.
4338*10652SHyon.Kim@Sun.COM *
4339*10652SHyon.Kim@Sun.COM * For the situation that multiple clients are registered for Adapter Add event
4340*10652SHyon.Kim@Sun.COM * each registration is passed to VSLs so VSL may call
4341*10652SHyon.Kim@Sun.COM * smhba_adapteraddevents_callback() multiple times or it may call only once
4342*10652SHyon.Kim@Sun.COM * since the callback function is same. For this implemneation, the userdata
4343*10652SHyon.Kim@Sun.COM * is stored in HBA_ALLADAPTERSCALLBACK_ELEM so it is expected that VSL call
4344*10652SHyon.Kim@Sun.COM * smhba_adapteraddevents_callback() only once and
4345*10652SHyon.Kim@Sun.COM * smhba_adapteraddevents_callback() will call the client callback with proper
4346*10652SHyon.Kim@Sun.COM * userdata.
4347*10652SHyon.Kim@Sun.COM */
4348*10652SHyon.Kim@Sun.COM static void
smhba_adapteraddevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType)4349*10652SHyon.Kim@Sun.COM smhba_adapteraddevents_callback(
4350*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_ARG_UNUSED */
4351*10652SHyon.Kim@Sun.COM void *data,
4352*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4353*10652SHyon.Kim@Sun.COM /* LINTED E_FUNC_ARG_UNUSED */
4354*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType)
4355*10652SHyon.Kim@Sun.COM {
4356*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
4357*10652SHyon.Kim@Sun.COM
4358*10652SHyon.Kim@Sun.COM DEBUG(3, "AddAdapterEvent, port:%s", WWN2STR1(&PortWWN), 0, 0);
4359*10652SHyon.Kim@Sun.COM
4360*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AAE_mutex);
4361*10652SHyon.Kim@Sun.COM for (cbp = _smhba_adapteraddevents_callback_list;
4362*10652SHyon.Kim@Sun.COM cbp != NULL;
4363*10652SHyon.Kim@Sun.COM cbp = cbp->next) {
4364*10652SHyon.Kim@Sun.COM (*cbp->callback)(cbp->userdata, PortWWN, HBA_EVENT_ADAPTER_ADD);
4365*10652SHyon.Kim@Sun.COM }
4366*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AAE_mutex);
4367*10652SHyon.Kim@Sun.COM
4368*10652SHyon.Kim@Sun.COM }
4369*10652SHyon.Kim@Sun.COM
4370*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForAdapterAddEvents(void (* pCallback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType),void * pUserData,HBA_CALLBACKHANDLE * pCallbackHandle)4371*10652SHyon.Kim@Sun.COM SMHBA_RegisterForAdapterAddEvents(
4372*10652SHyon.Kim@Sun.COM void (*pCallback) (
4373*10652SHyon.Kim@Sun.COM void *data,
4374*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4375*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
4376*10652SHyon.Kim@Sun.COM void *pUserData,
4377*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle) {
4378*10652SHyon.Kim@Sun.COM
4379*10652SHyon.Kim@Sun.COM HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
4380*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vcbp;
4381*10652SHyon.Kim@Sun.COM HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
4382*10652SHyon.Kim@Sun.COM SMHBARegisterForAdapterAddEventsFunc registeredfunc;
4383*10652SHyon.Kim@Sun.COM HBA_STATUS status = HBA_STATUS_OK;
4384*10652SHyon.Kim@Sun.COM HBA_STATUS failure = HBA_STATUS_OK;
4385*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4386*10652SHyon.Kim@Sun.COM int registered_cnt = 0;
4387*10652SHyon.Kim@Sun.COM int vendor_cnt = 0;
4388*10652SHyon.Kim@Sun.COM int not_supported_cnt = 0;
4389*10652SHyon.Kim@Sun.COM int status_OK_bar_cnt = 0;
4390*10652SHyon.Kim@Sun.COM int status_OK_cnt = 0;
4391*10652SHyon.Kim@Sun.COM
4392*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForAdapterAddEvents", 0, 0, 0);
4393*10652SHyon.Kim@Sun.COM ARE_WE_INITED();
4394*10652SHyon.Kim@Sun.COM
4395*10652SHyon.Kim@Sun.COM cbp = (HBA_ALLADAPTERSCALLBACK_ELEM *)
4396*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ALLADAPTERSCALLBACK_ELEM));
4397*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) cbp;
4398*10652SHyon.Kim@Sun.COM if (cbp == NULL) {
4399*10652SHyon.Kim@Sun.COM return (HBA_STATUS_ERROR);
4400*10652SHyon.Kim@Sun.COM }
4401*10652SHyon.Kim@Sun.COM
4402*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_LL_mutex);
4403*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AAE_mutex);
4404*10652SHyon.Kim@Sun.COM cbp->callback = pCallback;
4405*10652SHyon.Kim@Sun.COM cbp->userdata = pUserData;
4406*10652SHyon.Kim@Sun.COM cbp->next = _smhba_adapteraddevents_callback_list;
4407*10652SHyon.Kim@Sun.COM _smhba_adapteraddevents_callback_list = cbp;
4408*10652SHyon.Kim@Sun.COM
4409*10652SHyon.Kim@Sun.COM /*
4410*10652SHyon.Kim@Sun.COM * Need to release the mutex now incase the vendor function invokes the
4411*10652SHyon.Kim@Sun.COM * callback. We will grap the mutex later to attach the vendor handle
4412*10652SHyon.Kim@Sun.COM * list to the callback structure
4413*10652SHyon.Kim@Sun.COM */
4414*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AAE_mutex);
4415*10652SHyon.Kim@Sun.COM
4416*10652SHyon.Kim@Sun.COM
4417*10652SHyon.Kim@Sun.COM /*
4418*10652SHyon.Kim@Sun.COM * now create a list of vendors (vendor libraryies, NOT ADAPTERS)
4419*10652SHyon.Kim@Sun.COM * that have successfully registerred
4420*10652SHyon.Kim@Sun.COM */
4421*10652SHyon.Kim@Sun.COM vendorhandlelist = NULL;
4422*10652SHyon.Kim@Sun.COM for (lib_infop = _hbaapi_librarylist;
4423*10652SHyon.Kim@Sun.COM lib_infop != NULL;
4424*10652SHyon.Kim@Sun.COM lib_infop = lib_infop->next) {
4425*10652SHyon.Kim@Sun.COM
4426*10652SHyon.Kim@Sun.COM /* only for HBAAPI V2 */
4427*10652SHyon.Kim@Sun.COM if (lib_infop->version != SMHBA) {
4428*10652SHyon.Kim@Sun.COM continue;
4429*10652SHyon.Kim@Sun.COM } else {
4430*10652SHyon.Kim@Sun.COM vendor_cnt++;
4431*10652SHyon.Kim@Sun.COM }
4432*10652SHyon.Kim@Sun.COM
4433*10652SHyon.Kim@Sun.COM registeredfunc =
4434*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
4435*10652SHyon.Kim@Sun.COM RegisterForAdapterAddEventsHandler;
4436*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4437*10652SHyon.Kim@Sun.COM continue;
4438*10652SHyon.Kim@Sun.COM }
4439*10652SHyon.Kim@Sun.COM
4440*10652SHyon.Kim@Sun.COM vcbp = (HBA_VENDORCALLBACK_ELEM *)
4441*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_VENDORCALLBACK_ELEM));
4442*10652SHyon.Kim@Sun.COM if (vcbp == NULL) {
4443*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
4444*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
4445*10652SHyon.Kim@Sun.COM break;
4446*10652SHyon.Kim@Sun.COM }
4447*10652SHyon.Kim@Sun.COM
4448*10652SHyon.Kim@Sun.COM registered_cnt++;
4449*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_adapteraddevents_callback,
4450*10652SHyon.Kim@Sun.COM pUserData, &vcbp->vendorcbhandle);
4451*10652SHyon.Kim@Sun.COM if (status == HBA_STATUS_ERROR_NOT_SUPPORTED) {
4452*10652SHyon.Kim@Sun.COM not_supported_cnt++;
4453*10652SHyon.Kim@Sun.COM free(vcbp);
4454*10652SHyon.Kim@Sun.COM continue;
4455*10652SHyon.Kim@Sun.COM } else if (status != HBA_STATUS_OK) {
4456*10652SHyon.Kim@Sun.COM status_OK_bar_cnt++;
4457*10652SHyon.Kim@Sun.COM DEBUG(1,
4458*10652SHyon.Kim@Sun.COM "SMHBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
4459*10652SHyon.Kim@Sun.COM lib_infop->LibraryPath, status, 0);
4460*10652SHyon.Kim@Sun.COM failure = status;
4461*10652SHyon.Kim@Sun.COM free(vcbp);
4462*10652SHyon.Kim@Sun.COM continue;
4463*10652SHyon.Kim@Sun.COM } else {
4464*10652SHyon.Kim@Sun.COM status_OK_cnt++;
4465*10652SHyon.Kim@Sun.COM }
4466*10652SHyon.Kim@Sun.COM vcbp->lib_info = lib_infop;
4467*10652SHyon.Kim@Sun.COM vcbp->next = vendorhandlelist;
4468*10652SHyon.Kim@Sun.COM vendorhandlelist = vcbp;
4469*10652SHyon.Kim@Sun.COM }
4470*10652SHyon.Kim@Sun.COM
4471*10652SHyon.Kim@Sun.COM if (vendor_cnt == 0) {
4472*10652SHyon.Kim@Sun.COM /* no SMHBA VSL found. Should be okay?? */
4473*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
4474*10652SHyon.Kim@Sun.COM } else if (registered_cnt == 0) {
4475*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4476*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
4477*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
4478*10652SHyon.Kim@Sun.COM } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
4479*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR_NOT_SUPPORTED;
4480*10652SHyon.Kim@Sun.COM } else if (status_OK_cnt == 0) {
4481*10652SHyon.Kim@Sun.COM /*
4482*10652SHyon.Kim@Sun.COM * At least one vendor library registered this function, but no
4483*10652SHyon.Kim@Sun.COM * vendor call succeeded
4484*10652SHyon.Kim@Sun.COM */
4485*10652SHyon.Kim@Sun.COM (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
4486*10652SHyon.Kim@Sun.COM status = failure;
4487*10652SHyon.Kim@Sun.COM } else {
4488*10652SHyon.Kim@Sun.COM /* we have had atleast some success, now finish up */
4489*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AAE_mutex);
4490*10652SHyon.Kim@Sun.COM /*
4491*10652SHyon.Kim@Sun.COM * this seems silly, but what if another thread called
4492*10652SHyon.Kim@Sun.COM * the callback remove
4493*10652SHyon.Kim@Sun.COM */
4494*10652SHyon.Kim@Sun.COM for (cbp = _smhba_adapteraddevents_callback_list;
4495*10652SHyon.Kim@Sun.COM cbp != NULL; cbp = cbp->next) {
4496*10652SHyon.Kim@Sun.COM if ((HBA_CALLBACKHANDLE)cbp == *pCallbackHandle) {
4497*10652SHyon.Kim@Sun.COM /* yup, its still there, hooray */
4498*10652SHyon.Kim@Sun.COM cbp->vendorhandlelist = vendorhandlelist;
4499*10652SHyon.Kim@Sun.COM vendorhandlelist = NULL;
4500*10652SHyon.Kim@Sun.COM break;
4501*10652SHyon.Kim@Sun.COM }
4502*10652SHyon.Kim@Sun.COM }
4503*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AAE_mutex);
4504*10652SHyon.Kim@Sun.COM if (vendorhandlelist != NULL) {
4505*10652SHyon.Kim@Sun.COM /*
4506*10652SHyon.Kim@Sun.COM * bummer, somebody removed the callback before we finished
4507*10652SHyon.Kim@Sun.COM * registration, probably will never happen
4508*10652SHyon.Kim@Sun.COM */
4509*10652SHyon.Kim@Sun.COM freevendorhandlelist(vendorhandlelist);
4510*10652SHyon.Kim@Sun.COM DEBUG(1,
4511*10652SHyon.Kim@Sun.COM "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
4512*10652SHyon.Kim@Sun.COM "called for a handle before registration was finished.",
4513*10652SHyon.Kim@Sun.COM 0, 0, 0);
4514*10652SHyon.Kim@Sun.COM status = HBA_STATUS_ERROR;
4515*10652SHyon.Kim@Sun.COM } else {
4516*10652SHyon.Kim@Sun.COM status = HBA_STATUS_OK;
4517*10652SHyon.Kim@Sun.COM }
4518*10652SHyon.Kim@Sun.COM }
4519*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4520*10652SHyon.Kim@Sun.COM }
4521*10652SHyon.Kim@Sun.COM
4522*10652SHyon.Kim@Sun.COM /* SMHBA Adapter Events (other than add) ******************************** */
4523*10652SHyon.Kim@Sun.COM static void
smhba_adapterevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType)4524*10652SHyon.Kim@Sun.COM smhba_adapterevents_callback(void *data,
4525*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4526*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType)
4527*10652SHyon.Kim@Sun.COM {
4528*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4529*10652SHyon.Kim@Sun.COM
4530*10652SHyon.Kim@Sun.COM DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
4531*10652SHyon.Kim@Sun.COM eventType, 0);
4532*10652SHyon.Kim@Sun.COM
4533*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_hbaapi_AE_mutex);
4534*10652SHyon.Kim@Sun.COM for (acbp = _smhba_adapterevents_callback_list;
4535*10652SHyon.Kim@Sun.COM acbp != NULL;
4536*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
4537*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
4538*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, PortWWN, eventType);
4539*10652SHyon.Kim@Sun.COM break;
4540*10652SHyon.Kim@Sun.COM }
4541*10652SHyon.Kim@Sun.COM }
4542*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_hbaapi_AE_mutex);
4543*10652SHyon.Kim@Sun.COM }
4544*10652SHyon.Kim@Sun.COM
4545*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForAdapterEvents(void (* pCallback)(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType),void * pUserData,HBA_HANDLE handle,HBA_CALLBACKHANDLE * pCallbackHandle)4546*10652SHyon.Kim@Sun.COM SMHBA_RegisterForAdapterEvents(
4547*10652SHyon.Kim@Sun.COM void (*pCallback) (
4548*10652SHyon.Kim@Sun.COM void *data,
4549*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4550*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
4551*10652SHyon.Kim@Sun.COM void *pUserData,
4552*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4553*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle) {
4554*10652SHyon.Kim@Sun.COM
4555*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4556*10652SHyon.Kim@Sun.COM SMHBARegisterForAdapterEventsFunc registeredfunc;
4557*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4558*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4559*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4560*10652SHyon.Kim@Sun.COM
4561*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForAdapterEvents", 0, 0, 0);
4562*10652SHyon.Kim@Sun.COM
4563*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4564*10652SHyon.Kim@Sun.COM
4565*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
4566*10652SHyon.Kim@Sun.COM
4567*10652SHyon.Kim@Sun.COM registeredfunc = lib_infop->ftable.smhbafunctionTable.\
4568*10652SHyon.Kim@Sun.COM RegisterForAdapterEventsHandler;
4569*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4570*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
4571*10652SHyon.Kim@Sun.COM }
4572*10652SHyon.Kim@Sun.COM
4573*10652SHyon.Kim@Sun.COM /*
4574*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
4575*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
4576*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
4577*10652SHyon.Kim@Sun.COM */
4578*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
4579*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
4580*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
4581*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
4582*10652SHyon.Kim@Sun.COM }
4583*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) acbp;
4584*10652SHyon.Kim@Sun.COM acbp->callback = pCallback;
4585*10652SHyon.Kim@Sun.COM acbp->userdata = pUserData;
4586*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
4587*10652SHyon.Kim@Sun.COM
4588*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_adapterevents_callback,
4589*10652SHyon.Kim@Sun.COM (void *)acbp,
4590*10652SHyon.Kim@Sun.COM vendorHandle,
4591*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
4592*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
4593*10652SHyon.Kim@Sun.COM free(acbp);
4594*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4595*10652SHyon.Kim@Sun.COM }
4596*10652SHyon.Kim@Sun.COM
4597*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_AE_mutex);
4598*10652SHyon.Kim@Sun.COM acbp->next = _smhba_adapterevents_callback_list;
4599*10652SHyon.Kim@Sun.COM _hbaapi_adapterevents_callback_list = acbp;
4600*10652SHyon.Kim@Sun.COM
4601*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_AE_mutex);
4602*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
4603*10652SHyon.Kim@Sun.COM }
4604*10652SHyon.Kim@Sun.COM
4605*10652SHyon.Kim@Sun.COM /* Adapter Port Events *********************************************** */
4606*10652SHyon.Kim@Sun.COM static void
smhba_adapterportevents_callback(void * data,HBA_WWN PortWWN,HBA_UINT32 eventType,HBA_UINT32 fabricPortID)4607*10652SHyon.Kim@Sun.COM smhba_adapterportevents_callback(void *data,
4608*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4609*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
4610*10652SHyon.Kim@Sun.COM HBA_UINT32 fabricPortID)
4611*10652SHyon.Kim@Sun.COM {
4612*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4613*10652SHyon.Kim@Sun.COM
4614*10652SHyon.Kim@Sun.COM DEBUG(3,
4615*10652SHyon.Kim@Sun.COM "SMHBA_AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
4616*10652SHyon.Kim@Sun.COM WWN2STR1(&PortWWN), eventType, fabricPortID);
4617*10652SHyon.Kim@Sun.COM
4618*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APE_mutex);
4619*10652SHyon.Kim@Sun.COM
4620*10652SHyon.Kim@Sun.COM for (acbp = _smhba_adapterportevents_callback_list;
4621*10652SHyon.Kim@Sun.COM acbp != NULL;
4622*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
4623*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
4624*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, PortWWN,
4625*10652SHyon.Kim@Sun.COM eventType, fabricPortID);
4626*10652SHyon.Kim@Sun.COM break;
4627*10652SHyon.Kim@Sun.COM }
4628*10652SHyon.Kim@Sun.COM }
4629*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APE_mutex);
4630*10652SHyon.Kim@Sun.COM }
4631*10652SHyon.Kim@Sun.COM
4632*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForAdapterPortEvents(void (* pCallback)(void * pData,HBA_WWN PortWWN,HBA_UINT32 eventType,HBA_UINT32 fabricPortID),void * pUserData,HBA_HANDLE handle,HBA_WWN portWWN,HBA_UINT32 specificEventType,HBA_CALLBACKHANDLE * pCallbackHandle)4633*10652SHyon.Kim@Sun.COM SMHBA_RegisterForAdapterPortEvents(
4634*10652SHyon.Kim@Sun.COM void (*pCallback) (
4635*10652SHyon.Kim@Sun.COM void *pData,
4636*10652SHyon.Kim@Sun.COM HBA_WWN PortWWN,
4637*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType,
4638*10652SHyon.Kim@Sun.COM HBA_UINT32 fabricPortID),
4639*10652SHyon.Kim@Sun.COM void *pUserData,
4640*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4641*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4642*10652SHyon.Kim@Sun.COM HBA_UINT32 specificEventType,
4643*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle) {
4644*10652SHyon.Kim@Sun.COM
4645*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4646*10652SHyon.Kim@Sun.COM SMHBARegisterForAdapterPortEventsFunc registeredfunc;
4647*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4648*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4649*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4650*10652SHyon.Kim@Sun.COM
4651*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForAdapterPortEvents for port: %s",
4652*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), 0, 0);
4653*10652SHyon.Kim@Sun.COM
4654*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4655*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
4656*10652SHyon.Kim@Sun.COM
4657*10652SHyon.Kim@Sun.COM registeredfunc =
4658*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
4659*10652SHyon.Kim@Sun.COM RegisterForAdapterPortEventsHandler;
4660*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4661*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
4662*10652SHyon.Kim@Sun.COM }
4663*10652SHyon.Kim@Sun.COM
4664*10652SHyon.Kim@Sun.COM /*
4665*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
4666*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
4667*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
4668*10652SHyon.Kim@Sun.COM */
4669*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
4670*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
4671*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
4672*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
4673*10652SHyon.Kim@Sun.COM }
4674*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) acbp;
4675*10652SHyon.Kim@Sun.COM acbp->callback = pCallback;
4676*10652SHyon.Kim@Sun.COM acbp->userdata = pUserData;
4677*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
4678*10652SHyon.Kim@Sun.COM
4679*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_adapterportevents_callback,
4680*10652SHyon.Kim@Sun.COM (void *)acbp,
4681*10652SHyon.Kim@Sun.COM vendorHandle,
4682*10652SHyon.Kim@Sun.COM portWWN,
4683*10652SHyon.Kim@Sun.COM specificEventType,
4684*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
4685*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
4686*10652SHyon.Kim@Sun.COM free(acbp);
4687*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4688*10652SHyon.Kim@Sun.COM }
4689*10652SHyon.Kim@Sun.COM
4690*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APE_mutex);
4691*10652SHyon.Kim@Sun.COM acbp->next = _smhba_adapterportevents_callback_list;
4692*10652SHyon.Kim@Sun.COM _smhba_adapterportevents_callback_list = acbp;
4693*10652SHyon.Kim@Sun.COM
4694*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APE_mutex);
4695*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
4696*10652SHyon.Kim@Sun.COM }
4697*10652SHyon.Kim@Sun.COM
4698*10652SHyon.Kim@Sun.COM /* SMHBA Adapter Port Stat Events ******************************** */
4699*10652SHyon.Kim@Sun.COM static void
smhba_adapterportstatevents_callback(void * data,HBA_WWN portWWN,HBA_UINT32 protocolType,HBA_UINT32 eventType)4700*10652SHyon.Kim@Sun.COM smhba_adapterportstatevents_callback(void *data,
4701*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4702*10652SHyon.Kim@Sun.COM HBA_UINT32 protocolType,
4703*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType)
4704*10652SHyon.Kim@Sun.COM {
4705*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4706*10652SHyon.Kim@Sun.COM
4707*10652SHyon.Kim@Sun.COM DEBUG(3,
4708*10652SHyon.Kim@Sun.COM "SMBA_AdapterPortStateEvent, port:%s, eventType:%d",
4709*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), eventType, 0);
4710*10652SHyon.Kim@Sun.COM
4711*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APSE_mutex);
4712*10652SHyon.Kim@Sun.COM for (acbp = _smhba_adapterportstatevents_callback_list;
4713*10652SHyon.Kim@Sun.COM acbp != NULL;
4714*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
4715*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
4716*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, portWWN,
4717*10652SHyon.Kim@Sun.COM protocolType, eventType);
4718*10652SHyon.Kim@Sun.COM return;
4719*10652SHyon.Kim@Sun.COM }
4720*10652SHyon.Kim@Sun.COM }
4721*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APSE_mutex);
4722*10652SHyon.Kim@Sun.COM }
4723*10652SHyon.Kim@Sun.COM
4724*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForAdapterPortStatEvents(void (* pCallback)(void * pData,HBA_WWN portWWN,HBA_UINT32 protocolType,HBA_UINT32 eventType),void * pUserData,HBA_HANDLE handle,HBA_WWN portWWN,HBA_UINT32 protocolType,SMHBA_PROTOCOLSTATISTICS stats,HBA_UINT32 statType,HBA_CALLBACKHANDLE * pCallbackHandle)4725*10652SHyon.Kim@Sun.COM SMHBA_RegisterForAdapterPortStatEvents(
4726*10652SHyon.Kim@Sun.COM void (*pCallback) (
4727*10652SHyon.Kim@Sun.COM void *pData,
4728*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4729*10652SHyon.Kim@Sun.COM HBA_UINT32 protocolType,
4730*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
4731*10652SHyon.Kim@Sun.COM void *pUserData,
4732*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4733*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4734*10652SHyon.Kim@Sun.COM HBA_UINT32 protocolType,
4735*10652SHyon.Kim@Sun.COM SMHBA_PROTOCOLSTATISTICS stats,
4736*10652SHyon.Kim@Sun.COM HBA_UINT32 statType,
4737*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle) {
4738*10652SHyon.Kim@Sun.COM
4739*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4740*10652SHyon.Kim@Sun.COM SMHBARegisterForAdapterPortStatEventsFunc
4741*10652SHyon.Kim@Sun.COM registeredfunc;
4742*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4743*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4744*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4745*10652SHyon.Kim@Sun.COM
4746*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForAdapterPortStatEvents for port: %s",
4747*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), 0, 0);
4748*10652SHyon.Kim@Sun.COM
4749*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4750*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
4751*10652SHyon.Kim@Sun.COM
4752*10652SHyon.Kim@Sun.COM registeredfunc =
4753*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
4754*10652SHyon.Kim@Sun.COM RegisterForAdapterPortStatEventsHandler;
4755*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4756*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
4757*10652SHyon.Kim@Sun.COM }
4758*10652SHyon.Kim@Sun.COM
4759*10652SHyon.Kim@Sun.COM /*
4760*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
4761*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
4762*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
4763*10652SHyon.Kim@Sun.COM */
4764*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
4765*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
4766*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
4767*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
4768*10652SHyon.Kim@Sun.COM }
4769*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) acbp;
4770*10652SHyon.Kim@Sun.COM acbp->callback = pCallback;
4771*10652SHyon.Kim@Sun.COM acbp->userdata = pUserData;
4772*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
4773*10652SHyon.Kim@Sun.COM
4774*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_adapterportstatevents_callback,
4775*10652SHyon.Kim@Sun.COM (void *)acbp,
4776*10652SHyon.Kim@Sun.COM vendorHandle,
4777*10652SHyon.Kim@Sun.COM portWWN,
4778*10652SHyon.Kim@Sun.COM protocolType,
4779*10652SHyon.Kim@Sun.COM stats,
4780*10652SHyon.Kim@Sun.COM statType,
4781*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
4782*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
4783*10652SHyon.Kim@Sun.COM free(acbp);
4784*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4785*10652SHyon.Kim@Sun.COM }
4786*10652SHyon.Kim@Sun.COM
4787*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APSE_mutex);
4788*10652SHyon.Kim@Sun.COM acbp->next = _smhba_adapterportstatevents_callback_list;
4789*10652SHyon.Kim@Sun.COM _smhba_adapterportstatevents_callback_list = acbp;
4790*10652SHyon.Kim@Sun.COM
4791*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APSE_mutex);
4792*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
4793*10652SHyon.Kim@Sun.COM }
4794*10652SHyon.Kim@Sun.COM
4795*10652SHyon.Kim@Sun.COM /* SMHBA Adapter Port Phy Stat Events ************************************ */
4796*10652SHyon.Kim@Sun.COM static void
smhba_adapterphystatevents_callback(void * data,HBA_WWN portWWN,HBA_UINT32 phyIndex,HBA_UINT32 eventType)4797*10652SHyon.Kim@Sun.COM smhba_adapterphystatevents_callback(void *data,
4798*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4799*10652SHyon.Kim@Sun.COM HBA_UINT32 phyIndex,
4800*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType)
4801*10652SHyon.Kim@Sun.COM {
4802*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4803*10652SHyon.Kim@Sun.COM
4804*10652SHyon.Kim@Sun.COM DEBUG(3,
4805*10652SHyon.Kim@Sun.COM "SMBA_AdapterPortStateEvent, port:%s, eventType:%d",
4806*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), eventType, 0);
4807*10652SHyon.Kim@Sun.COM
4808*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APHYSE_mutex);
4809*10652SHyon.Kim@Sun.COM for (acbp = _smhba_adapterphystatevents_callback_list;
4810*10652SHyon.Kim@Sun.COM acbp != NULL;
4811*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
4812*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
4813*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, portWWN, phyIndex, eventType);
4814*10652SHyon.Kim@Sun.COM return;
4815*10652SHyon.Kim@Sun.COM }
4816*10652SHyon.Kim@Sun.COM }
4817*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APHYSE_mutex);
4818*10652SHyon.Kim@Sun.COM }
4819*10652SHyon.Kim@Sun.COM
4820*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForAdapterPhyStatEvents(void (* pCallback)(void * pData,HBA_WWN portWWN,HBA_UINT32 phyIndex,HBA_UINT32 eventType),void * pUserData,HBA_HANDLE handle,HBA_WWN portWWN,HBA_UINT32 phyIndex,SMHBA_PHYSTATISTICS stats,HBA_UINT32 statType,HBA_CALLBACKHANDLE * pCallbackHandle)4821*10652SHyon.Kim@Sun.COM SMHBA_RegisterForAdapterPhyStatEvents(
4822*10652SHyon.Kim@Sun.COM void (*pCallback) (
4823*10652SHyon.Kim@Sun.COM void *pData,
4824*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4825*10652SHyon.Kim@Sun.COM HBA_UINT32 phyIndex,
4826*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
4827*10652SHyon.Kim@Sun.COM void *pUserData,
4828*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4829*10652SHyon.Kim@Sun.COM HBA_WWN portWWN,
4830*10652SHyon.Kim@Sun.COM HBA_UINT32 phyIndex,
4831*10652SHyon.Kim@Sun.COM SMHBA_PHYSTATISTICS stats,
4832*10652SHyon.Kim@Sun.COM HBA_UINT32 statType,
4833*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle) {
4834*10652SHyon.Kim@Sun.COM
4835*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4836*10652SHyon.Kim@Sun.COM SMHBARegisterForAdapterPhyStatEventsFunc
4837*10652SHyon.Kim@Sun.COM registeredfunc;
4838*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4839*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4840*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4841*10652SHyon.Kim@Sun.COM
4842*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForAdapterPhyStatEvents for port: %s",
4843*10652SHyon.Kim@Sun.COM WWN2STR1(&portWWN), 0, 0);
4844*10652SHyon.Kim@Sun.COM
4845*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4846*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
4847*10652SHyon.Kim@Sun.COM
4848*10652SHyon.Kim@Sun.COM registeredfunc =
4849*10652SHyon.Kim@Sun.COM lib_infop->ftable.smhbafunctionTable.\
4850*10652SHyon.Kim@Sun.COM RegisterForAdapterPhyStatEventsHandler;
4851*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4852*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
4853*10652SHyon.Kim@Sun.COM }
4854*10652SHyon.Kim@Sun.COM
4855*10652SHyon.Kim@Sun.COM /*
4856*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
4857*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
4858*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
4859*10652SHyon.Kim@Sun.COM */
4860*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
4861*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
4862*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
4863*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
4864*10652SHyon.Kim@Sun.COM }
4865*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) acbp;
4866*10652SHyon.Kim@Sun.COM acbp->callback = pCallback;
4867*10652SHyon.Kim@Sun.COM acbp->userdata = pUserData;
4868*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
4869*10652SHyon.Kim@Sun.COM
4870*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_adapterphystatevents_callback,
4871*10652SHyon.Kim@Sun.COM (void *)acbp,
4872*10652SHyon.Kim@Sun.COM vendorHandle,
4873*10652SHyon.Kim@Sun.COM portWWN,
4874*10652SHyon.Kim@Sun.COM phyIndex,
4875*10652SHyon.Kim@Sun.COM stats,
4876*10652SHyon.Kim@Sun.COM statType,
4877*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle);
4878*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
4879*10652SHyon.Kim@Sun.COM free(acbp);
4880*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4881*10652SHyon.Kim@Sun.COM }
4882*10652SHyon.Kim@Sun.COM
4883*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_APHYSE_mutex);
4884*10652SHyon.Kim@Sun.COM acbp->next = _smhba_adapterphystatevents_callback_list;
4885*10652SHyon.Kim@Sun.COM _smhba_adapterphystatevents_callback_list = acbp;
4886*10652SHyon.Kim@Sun.COM
4887*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_APHYSE_mutex);
4888*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
4889*10652SHyon.Kim@Sun.COM }
4890*10652SHyon.Kim@Sun.COM
4891*10652SHyon.Kim@Sun.COM /* SMHBA Target Events ********************************************* */
4892*10652SHyon.Kim@Sun.COM static void
smhba_targetevents_callback(void * data,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,HBA_UINT32 eventType)4893*10652SHyon.Kim@Sun.COM smhba_targetevents_callback(void *data,
4894*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4895*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4896*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4897*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType)
4898*10652SHyon.Kim@Sun.COM {
4899*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4900*10652SHyon.Kim@Sun.COM
4901*10652SHyon.Kim@Sun.COM DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
4902*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
4903*10652SHyon.Kim@Sun.COM
4904*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_TE_mutex);
4905*10652SHyon.Kim@Sun.COM for (acbp = _smhba_targetevents_callback_list;
4906*10652SHyon.Kim@Sun.COM acbp != NULL;
4907*10652SHyon.Kim@Sun.COM acbp = acbp->next) {
4908*10652SHyon.Kim@Sun.COM if (data == (void *)acbp) {
4909*10652SHyon.Kim@Sun.COM (*acbp->callback)(acbp->userdata, hbaPortWWN,
4910*10652SHyon.Kim@Sun.COM discoveredPortWWN, domainPortWWN, eventType);
4911*10652SHyon.Kim@Sun.COM break;
4912*10652SHyon.Kim@Sun.COM }
4913*10652SHyon.Kim@Sun.COM }
4914*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_TE_mutex);
4915*10652SHyon.Kim@Sun.COM }
4916*10652SHyon.Kim@Sun.COM
4917*10652SHyon.Kim@Sun.COM HBA_STATUS
SMHBA_RegisterForTargetEvents(void (* pCallback)(void * pData,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,HBA_UINT32 eventType),void * pUserData,HBA_HANDLE handle,HBA_WWN hbaPortWWN,HBA_WWN discoveredPortWWN,HBA_WWN domainPortWWN,HBA_CALLBACKHANDLE * pCallbackHandle,HBA_UINT32 allTargets)4918*10652SHyon.Kim@Sun.COM SMHBA_RegisterForTargetEvents(
4919*10652SHyon.Kim@Sun.COM void (*pCallback) (
4920*10652SHyon.Kim@Sun.COM void *pData,
4921*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4922*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4923*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4924*10652SHyon.Kim@Sun.COM HBA_UINT32 eventType),
4925*10652SHyon.Kim@Sun.COM void *pUserData,
4926*10652SHyon.Kim@Sun.COM HBA_HANDLE handle,
4927*10652SHyon.Kim@Sun.COM HBA_WWN hbaPortWWN,
4928*10652SHyon.Kim@Sun.COM HBA_WWN discoveredPortWWN,
4929*10652SHyon.Kim@Sun.COM HBA_WWN domainPortWWN,
4930*10652SHyon.Kim@Sun.COM HBA_CALLBACKHANDLE *pCallbackHandle,
4931*10652SHyon.Kim@Sun.COM HBA_UINT32 allTargets) {
4932*10652SHyon.Kim@Sun.COM
4933*10652SHyon.Kim@Sun.COM HBA_ADAPTERCALLBACK_ELEM *acbp;
4934*10652SHyon.Kim@Sun.COM SMHBARegisterForTargetEventsFunc
4935*10652SHyon.Kim@Sun.COM registeredfunc;
4936*10652SHyon.Kim@Sun.COM HBA_STATUS status;
4937*10652SHyon.Kim@Sun.COM HBA_LIBRARY_INFO *lib_infop;
4938*10652SHyon.Kim@Sun.COM HBA_HANDLE vendorHandle;
4939*10652SHyon.Kim@Sun.COM
4940*10652SHyon.Kim@Sun.COM DEBUG(2, "SMHBA_RegisterForTargetEvents, hbaPort:"
4941*10652SHyon.Kim@Sun.COM "%s, discoveredPort: %s",
4942*10652SHyon.Kim@Sun.COM WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
4943*10652SHyon.Kim@Sun.COM
4944*10652SHyon.Kim@Sun.COM CHECKLIBRARYANDVERSION(SMHBA);
4945*10652SHyon.Kim@Sun.COM /* we now have the _hbaapi_LL_mutex */
4946*10652SHyon.Kim@Sun.COM
4947*10652SHyon.Kim@Sun.COM registeredfunc = lib_infop->ftable.smhbafunctionTable.\
4948*10652SHyon.Kim@Sun.COM RegisterForTargetEventsHandler;
4949*10652SHyon.Kim@Sun.COM
4950*10652SHyon.Kim@Sun.COM if (registeredfunc == NULL) {
4951*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
4952*10652SHyon.Kim@Sun.COM }
4953*10652SHyon.Kim@Sun.COM
4954*10652SHyon.Kim@Sun.COM /*
4955*10652SHyon.Kim@Sun.COM * that allocated memory is used both as the handle for the
4956*10652SHyon.Kim@Sun.COM * caller, and as userdata to the vendor call so that on
4957*10652SHyon.Kim@Sun.COM * callback the specific registration may be recalled
4958*10652SHyon.Kim@Sun.COM */
4959*10652SHyon.Kim@Sun.COM acbp = (HBA_ADAPTERCALLBACK_ELEM *)
4960*10652SHyon.Kim@Sun.COM calloc(1, sizeof (HBA_ADAPTERCALLBACK_ELEM));
4961*10652SHyon.Kim@Sun.COM if (acbp == NULL) {
4962*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
4963*10652SHyon.Kim@Sun.COM }
4964*10652SHyon.Kim@Sun.COM *pCallbackHandle = (HBA_CALLBACKHANDLE) acbp;
4965*10652SHyon.Kim@Sun.COM acbp->callback = pCallback;
4966*10652SHyon.Kim@Sun.COM acbp->userdata = pUserData;
4967*10652SHyon.Kim@Sun.COM acbp->lib_info = lib_infop;
4968*10652SHyon.Kim@Sun.COM
4969*10652SHyon.Kim@Sun.COM status = (registeredfunc)(smhba_targetevents_callback,
4970*10652SHyon.Kim@Sun.COM (void *)acbp,
4971*10652SHyon.Kim@Sun.COM vendorHandle,
4972*10652SHyon.Kim@Sun.COM hbaPortWWN,
4973*10652SHyon.Kim@Sun.COM discoveredPortWWN,
4974*10652SHyon.Kim@Sun.COM domainPortWWN,
4975*10652SHyon.Kim@Sun.COM &acbp->vendorcbhandle,
4976*10652SHyon.Kim@Sun.COM allTargets);
4977*10652SHyon.Kim@Sun.COM if (status != HBA_STATUS_OK) {
4978*10652SHyon.Kim@Sun.COM free(acbp);
4979*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
4980*10652SHyon.Kim@Sun.COM }
4981*10652SHyon.Kim@Sun.COM
4982*10652SHyon.Kim@Sun.COM GRAB_MUTEX(&_smhba_TE_mutex);
4983*10652SHyon.Kim@Sun.COM acbp->next = _smhba_targetevents_callback_list;
4984*10652SHyon.Kim@Sun.COM _smhba_targetevents_callback_list = acbp;
4985*10652SHyon.Kim@Sun.COM
4986*10652SHyon.Kim@Sun.COM RELEASE_MUTEX(&_smhba_TE_mutex);
4987*10652SHyon.Kim@Sun.COM RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
4988*10652SHyon.Kim@Sun.COM }
4989