Print this page
NEX-5010 Fix for NEX-4680 introduced cstyle issues
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
NEX-4680 NEF needs Sun_HBA_* API to be working after library reload
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/hbaapi/common/HBAAPILIB.c
+++ new/usr/src/lib/hbaapi/common/HBAAPILIB.c
1 1 /*************************************************************************
2 2 * Description
3 3 * HBAAPILIB.c - Implements a sample common (wrapper) HBA API library
4 4 *
5 5 * License:
6 6 * The contents of this file are subject to the SNIA Public License
7 7 * Version 1.0 (the "License"); you may not use this file except in
8 8 * compliance with the License. You may obtain a copy of the License at
9 9 *
10 10 * /http://www.snia.org/English/Resources/Code/OpenSource.html
11 11 *
12 12 * Software distributed under the License is distributed on an "AS IS"
13 13 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14 14 * the License for the specific language governing rights and limitations
15 15 * under the License.
16 16 *
17 17 * The Original Code is SNIA HBA API Wrapper Library
18 18 *
19 19 * The Initial Developer of the Original Code is:
20 20 * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
21 21 *
22 22 * Contributor(s):
23 23 * Tuan Lam, QLogic Corp. (t_lam@qlc.com)
24 24 * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com)
25 25 * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com)
26 26 * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
27 27 *
28 28 *************************************************************************
29 29 */
30 30
31 31 #ifdef WIN32
32 32 #include <windows.h>
33 33 #include <string.h>
34 34 /*
35 35 * Next define forces entry points in the dll to be exported
36 36 * See hbaapi.h to see what it does.
|
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
37 37 */
38 38 #define HBAAPI_EXPORTS
39 39 #else
40 40 #include <dlfcn.h>
41 41 #include <strings.h>
42 42 #endif
43 43 #include <stdio.h>
44 44 #include <time.h>
45 45 #include "hbaapi.h"
46 46 #include "vendorhbaapi.h"
47 +#include "hbaapi-sun.h"
47 48 #include <stdlib.h>
48 49 #ifdef USESYSLOG
49 50 #include <syslog.h>
50 51 #endif
51 52
52 53 /*
53 54 * LIBRARY_NUM is a shortcut to figure out which library we need to call.
54 55 * The top 16 bits of handle are the library index
55 56 */
56 57 #define LIBRARY_NUM(handle) ((handle)>>16)
57 58
58 59 /*
59 60 * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
60 61 * with all upper 16 bits set to 0
61 62 */
62 63 #define VENDOR_HANDLE(handle) ((handle)&0xFFFF)
63 64
64 65 #define HBA_HANDLE_FROM_LOCAL(library, vendor) \
65 66 (((library)<<16) | ((vendor)&0x0000FFFF))
66 67
67 68 int _hbaapi_debuglevel = 0;
68 69 #define DEBUG(L, STR, A1, A2, A3)
69 70
70 71 #if defined(USESYSLOG) && defined(USELOGFILE)
71 72 FILE *_hbaapi_debug_fd = NULL;
72 73 int _hbaapi_sysloginit = 0;
73 74 #undef DEBUG
74 75 #ifdef WIN32
75 76 #define DEBUG(L, STR, A1, A2, A3)\
76 77 if ((L) <= _hbaapi_debuglevel) {\
77 78 if(_hbaapi_sysloginit == 0) {\
78 79 openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
79 80 _hbaapi_sysloginit = 1;\
80 81 }\
81 82 syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
82 83 if(_hbaapi_debug_fd == NULL) {\
83 84 char _logFile[MAX_PATH]; \
84 85 GetTempPath(MAX_PATH, _logFile); \
85 86 strcat(_logFile, "HBAAPI.log"); \
86 87 _hbaapi_debug_fd = fopen(_logFile, "a");\
87 88 }\
88 89 if(_hbaapi_debug_fd != NULL) {\
89 90 fprintf(_hbaapi_debug_fd, (STR ## "\n"), (A1), (A2), (A3));\
90 91 }\
91 92 }
92 93 #else /* WIN32*/
93 94 #define DEBUG(L, STR, A1, A2, A3)\
94 95 if ((L) <= _hbaapi_debuglevel) {\
95 96 if(_hbaapi_sysloginit == 0) {\
96 97 openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
97 98 _hbaapi_sysloginit = 1;\
98 99 }\
99 100 syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
100 101 if(_hbaapi_debug_fd == NULL) {\
101 102 _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
102 103 }\
103 104 if(_hbaapi_debug_fd != NULL) {\
104 105 fprintf(_hbaapi_debug_fd, (STR ## "\n"), (A1), (A2), (A3));\
105 106 }\
106 107 }
107 108 #endif /* WIN32*/
108 109
109 110 #else /* Not both USESYSLOG and USELOGFILE */
110 111 #if defined(USESYSLOG)
111 112 int _hbaapi_sysloginit = 0;
112 113 #undef DEBUG
113 114 #define DEBUG(L, STR, A1, A2, A3) \
114 115 if ((L) <= _hbaapi_debuglevel) {\
115 116 if(_hbaapi_sysloginit == 0) {\
116 117 openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
117 118 _hbaapi_sysloginit = 1;\
118 119 }\
119 120 syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
120 121 }
121 122 #endif /* USESYSLOG */
122 123 #if defined(USELOGFILE)
123 124 FILE *_hbaapi_debug_fd = NULL;
124 125 #undef DEBUG
125 126 #ifdef WIN32
126 127 #define DEBUG(L, STR, A1, A2, A3) \
127 128 if((L) <= _hbaapi_debuglevel) {\
128 129 if(_hbaapi_debug_fd == NULL) {\
129 130 char _logFile[MAX_PATH]; \
130 131 GetTempPath(MAX_PATH, _logFile); \
131 132 strcat(_logFile, "HBAAPI.log"); \
132 133 _hbaapi_debug_fd = fopen(_logFile, "a");\
133 134 }\
134 135 }
135 136 #else /* WIN32 */
136 137 #define DEBUG(L, STR, A1, A2, A3) \
137 138 if((L) <= _hbaapi_debuglevel) {\
138 139 if(_hbaapi_debug_fd == NULL) {\
139 140 _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
140 141 }\
141 142 if(_hbaapi_debug_fd != NULL) { \
142 143 fprintf(_hbaapi_debug_fd, (STR) ## "\n", (A1), (A2), (A3));\
143 144 }\
144 145 }
145 146 #endif /* WIN32 */
146 147 #endif /* USELOGFILE */
147 148 #endif /* Not both USELOGFILE and USESYSLOG */
148 149
149 150 #ifdef POSIX_THREADS
150 151 #include <pthread.h>
151 152 /*
152 153 * When multiple mutex's are grabed, they must be always be grabbed in
153 154 * the same order, or deadlock can result. There are three levels
154 155 * of mutex's involved in this API. If LL_mutex is grabbed, always grap
155 156 * it first. If AL_mutex is grabbed, it may not be grabbed before
156 157 * LL_mutex. If grabbed in a multi grab sequence, the mutex's protecting
157 158 * the callback lists must always be grabbed last and release before calling
158 159 * a vendor specific library function that might invoke a callback function
159 160 * on the same thread.
160 161 */
161 162 #define GRAB_MUTEX(M) grab_mutex(M)
162 163 #define RELEASE_MUTEX(M) release_mutex(M)
163 164 #define RELEASE_MUTEX_RETURN(M,RET) release_mutex(M); return(RET)
164 165 #elif defined (WIN32)
165 166 #define GRAB_MUTEX(m) EnterCriticalSection(m)
166 167 #define RELEASE_MUTEX(m) LeaveCriticalSection(m)
167 168 #define RELEASE_MUTEX_RETURN(m, RET) LeaveCriticalSection(m); return(RET)
168 169 #else
169 170 #define GRAB_MUTEX(M)
170 171 #define RELEASE_MUTEX(M)
171 172 #define RELEASE_MUTEX_RETURN(M,RET) return(RET)
172 173 #endif
173 174
174 175 /*
175 176 * Vendor library information
176 177 */
177 178 typedef enum {
178 179 HBA_LIBRARY_UNKNOWN,
179 180 HBA_LIBRARY_LOADED,
180 181 HBA_LIBRARY_NOT_LOADED
181 182 } HBA_LIBRARY_STATUS;
182 183
183 184 typedef struct hba_library_info {
184 185 struct hba_library_info
185 186 *next;
186 187 #ifdef WIN32
187 188 HINSTANCE hLibrary; /* Handle to a loaded DLL */
188 189 #else
189 190 char *LibraryName;
190 191 void* hLibrary; /* Handle to a loaded DLL */
191 192 #endif
192 193 char *LibraryPath;
193 194 HBA_ENTRYPOINTSV2 functionTable; /* Function pointers */
194 195 HBA_LIBRARY_STATUS status; /* info on this library */
195 196 HBA_UINT32 index;
196 197 } HBA_LIBRARY_INFO, *PHBA_LIBRARY_INFO;
197 198
198 199 #define ARE_WE_INITED() \
199 200 if (_hbaapi_librarylist == NULL) { \
200 201 return(HBA_STATUS_ERROR); \
201 202 }
202 203 HBA_LIBRARY_INFO *_hbaapi_librarylist = NULL;
203 204 HBA_UINT32 _hbaapi_total_library_count = 0;
204 205 #ifdef POSIX_THREADS
205 206 pthread_mutex_t _hbaapi_LL_mutex = PTHREAD_MUTEX_INITIALIZER;
206 207 #elif defined(WIN32)
207 208 CRITICAL_SECTION _hbaapi_LL_mutex;
208 209 #endif
209 210
210 211 /*
211 212 * Individual adapter (hba) information
212 213 */
213 214 typedef struct hba_adapter_info {
214 215 struct hba_adapter_info
215 216 *next;
216 217 HBA_STATUS GNstatus; /* status from GetAdapterNameFunc */
217 218 char *name;
218 219 HBA_WWN nodeWWN;
219 220 HBA_LIBRARY_INFO *library;
220 221 HBA_UINT32 index;
221 222 } HBA_ADAPTER_INFO;
222 223
223 224 HBA_ADAPTER_INFO *_hbaapi_adapterlist = NULL;
224 225 HBA_UINT32 _hbaapi_total_adapter_count = 0;
225 226 #ifdef POSIX_THREADS
226 227 pthread_mutex_t _hbaapi_AL_mutex = PTHREAD_MUTEX_INITIALIZER;
227 228 #elif defined(WIN32)
228 229 CRITICAL_SECTION _hbaapi_AL_mutex;
229 230 #endif
230 231
231 232 /*
232 233 * Call back registration
233 234 */
234 235 typedef struct hba_vendorcallback_elem {
235 236 struct hba_vendorcallback_elem
236 237 *next;
237 238 HBA_CALLBACKHANDLE vendorcbhandle;
238 239 HBA_LIBRARY_INFO *lib_info;
239 240 } HBA_VENDORCALLBACK_ELEM;
240 241
241 242 /*
242 243 * Each instance of HBA_ADAPTERCALLBACK_ELEM represents a call to one of
243 244 * "register" functions that apply to a particular adapter.
244 245 * HBA_ALLADAPTERSCALLBACK_ELEM is used just for HBA_RegisterForAdapterAddEvents
245 246 */
246 247 typedef struct hba_adaptercallback_elem {
247 248 struct hba_adaptercallback_elem
248 249 *next;
249 250 HBA_LIBRARY_INFO *lib_info;
250 251 void *userdata;
251 252 HBA_CALLBACKHANDLE vendorcbhandle;
252 253 void (*callback)();
253 254 } HBA_ADAPTERCALLBACK_ELEM;
254 255
255 256 typedef struct hba_alladapterscallback_elem {
256 257 struct hba_alladapterscallback_elem
257 258 *next;
258 259 void *userdata;
259 260 HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
260 261 void (*callback)();
261 262 } HBA_ALLADAPTERSCALLBACK_ELEM;
262 263
263 264 HBA_ALLADAPTERSCALLBACK_ELEM *_hbaapi_adapteraddevents_callback_list = NULL;
264 265 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterevents_callback_list = NULL;
265 266 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportevents_callback_list = NULL;
266 267 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportstatevents_callback_list = NULL;
267 268 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_targetevents_callback_list = NULL;
268 269 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_linkevents_callback_list = NULL;
269 270 HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterdeviceevents_callback_list = NULL;
270 271 #ifdef POSIX_THREADS
271 272 /* mutex's to protect each list */
272 273 pthread_mutex_t _hbaapi_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
273 274 pthread_mutex_t _hbaapi_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
274 275 pthread_mutex_t _hbaapi_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
275 276 pthread_mutex_t _hbaapi_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
276 277 pthread_mutex_t _hbaapi_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
277 278 pthread_mutex_t _hbaapi_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
278 279 #elif defined(WIN32)
279 280 CRITICAL_SECTION _hbaapi_AAE_mutex;
280 281 CRITICAL_SECTION _hbaapi_AE_mutex;
281 282 CRITICAL_SECTION _hbaapi_APE_mutex;
282 283 CRITICAL_SECTION _hbaapi_APSE_mutex;
283 284 CRITICAL_SECTION _hbaapi_TE_mutex;
284 285 CRITICAL_SECTION _hbaapi_LE_mutex;
285 286 #endif
286 287
287 288 HBA_ADAPTERCALLBACK_ELEM **cb_lists_array[] = {
288 289 &_hbaapi_adapterevents_callback_list,
289 290 &_hbaapi_adapterportevents_callback_list,
290 291 &_hbaapi_adapterportstatevents_callback_list,
291 292 &_hbaapi_targetevents_callback_list,
292 293 &_hbaapi_linkevents_callback_list,
293 294 &_hbaapi_adapterdeviceevents_callback_list,
294 295 NULL};
295 296
296 297 /*
297 298 * Common library internal. Mutex handling
298 299 */
299 300 #ifdef POSIX_THREADS
300 301 static void
301 302 grab_mutex(pthread_mutex_t *mp) {
302 303 int ret;
303 304 if((ret = pthread_mutex_lock(mp)) != 0) {
304 305 perror("pthread_mutex_lock - HBAAPI:");
305 306 DEBUG(0, "pthread_mutex_lock returned %d", ret, 0, 0);
306 307 }
307 308 }
308 309
309 310 static void
310 311 release_mutex(pthread_mutex_t *mp) {
311 312 int ret;
312 313 if((ret = pthread_mutex_unlock(mp)) != 0) {
313 314 perror("pthread_mutex_unlock - HBAAPI:");
314 315 DEBUG(0, "pthread_mutex_unlock returned %d", ret, 0, 0);
315 316 }
316 317 }
317 318 #endif
318 319
319 320 /*
320 321 * Common library internal. Check library and return vendorhandle
321 322 */
322 323 static HBA_STATUS
323 324 HBA_CheckLibrary(HBA_HANDLE handle,
324 325 HBA_LIBRARY_INFO **lib_infopp,
325 326 HBA_HANDLE *vendorhandle) {
326 327
327 328 HBA_UINT32 libraryIndex;
328 329 HBA_LIBRARY_INFO *lib_infop;
329 330
330 331 if (vendorhandle == NULL) {
331 332 return(HBA_STATUS_ERROR_ARG);
332 333 }
333 334 if(_hbaapi_librarylist == NULL) {
334 335 return(HBA_STATUS_ERROR);
335 336 }
336 337 libraryIndex = LIBRARY_NUM(handle);
337 338
338 339 GRAB_MUTEX(&_hbaapi_LL_mutex);
339 340 for(lib_infop = _hbaapi_librarylist;
340 341 lib_infop != NULL;
341 342 lib_infop = lib_infop->next) {
342 343 if(lib_infop->index == libraryIndex) {
343 344 if(lib_infop->status != HBA_LIBRARY_LOADED) {
344 345 return HBA_STATUS_ERROR;
345 346 }
346 347 *lib_infopp = lib_infop;
347 348 *vendorhandle = VENDOR_HANDLE(handle);
348 349 /* caller will release the mutex */
349 350 return HBA_STATUS_OK;
350 351 }
351 352 }
352 353 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INVALID_HANDLE);
353 354 }
354 355 #define CHECKLIBRARY() \
355 356 status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);\
356 357 if(status != HBA_STATUS_OK) { \
357 358 return(status); \
358 359 }
359 360
360 361 /*
361 362 *freevendorhandlelist is called with _hbaapi_LL_mutex already held
362 363 */
363 364 static void
364 365 freevendorhandlelist(HBA_VENDORCALLBACK_ELEM *vhlist) {
365 366 HBA_VENDORCALLBACK_ELEM *vhlp;
366 367 HBA_VENDORCALLBACK_ELEM *vnext;
367 368 HBARemoveCallbackFunc registeredfunc;
368 369
369 370 for(vhlp = vhlist; vhlp != NULL; vhlp = vnext) {
370 371 vnext = vhlp->next;
371 372 registeredfunc =
372 373 vhlp->lib_info->functionTable.RemoveCallbackHandler;
373 374 if(registeredfunc == NULL) {
374 375 continue;
375 376 }
376 377 (registeredfunc)(vhlp->vendorcbhandle);
377 378 free(vhlp);
378 379 }
379 380 }
380 381
381 382 static
382 383 HBA_STATUS
383 384 local_remove_callback(HBA_CALLBACKHANDLE cbhandle) {
384 385 HBA_ADAPTERCALLBACK_ELEM ***listp;
385 386 HBA_ADAPTERCALLBACK_ELEM **lastp;
386 387 HBA_ALLADAPTERSCALLBACK_ELEM **lap;
387 388 HBA_ALLADAPTERSCALLBACK_ELEM *allcbp;
388 389 HBA_ADAPTERCALLBACK_ELEM *cbp;
389 390 HBARemoveCallbackFunc registeredfunc;
390 391 HBA_VENDORCALLBACK_ELEM *vhlp;
391 392 HBA_VENDORCALLBACK_ELEM *vnext;
392 393 int found;
393 394 HBA_STATUS status = HBA_STATUS_ERROR_INVALID_HANDLE;
394 395
395 396
396 397 /* search through the simple lists first */
397 398 GRAB_MUTEX(&_hbaapi_AAE_mutex);
398 399 GRAB_MUTEX(&_hbaapi_AE_mutex);
399 400 GRAB_MUTEX(&_hbaapi_APE_mutex);
400 401 GRAB_MUTEX(&_hbaapi_APSE_mutex);
401 402 GRAB_MUTEX(&_hbaapi_TE_mutex);
402 403 GRAB_MUTEX(&_hbaapi_LE_mutex);
403 404 for(listp = cb_lists_array, found = 0; found == 0, *listp != NULL; listp++) {
404 405 lastp = *listp;
405 406 for(cbp=**listp; cbp != NULL; cbp = cbp->next) {
406 407 if(cbhandle != (HBA_CALLBACKHANDLE)cbp) {
407 408 lastp = &(cbp->next);
408 409 continue;
409 410 }
410 411 found = 1;
411 412 registeredfunc = cbp->lib_info->functionTable.RemoveCallbackHandler;
412 413 if(registeredfunc == NULL) {
413 414 break;
414 415 }
415 416 (registeredfunc)(cbp->vendorcbhandle);
416 417 *lastp = cbp->next;
417 418 free(cbp);
418 419 break;
419 420 }
420 421 }
421 422 RELEASE_MUTEX(&_hbaapi_LE_mutex);
422 423 RELEASE_MUTEX(&_hbaapi_TE_mutex);
423 424 RELEASE_MUTEX(&_hbaapi_APSE_mutex);
424 425 RELEASE_MUTEX(&_hbaapi_APE_mutex);
425 426 RELEASE_MUTEX(&_hbaapi_AE_mutex);
426 427 RELEASE_MUTEX(&_hbaapi_AAE_mutex);
427 428 if(found != 0) {
428 429 if(registeredfunc == NULL) {
429 430 return HBA_STATUS_ERROR_NOT_SUPPORTED;
430 431 }
431 432 return HBA_STATUS_OK;
432 433 }
433 434
434 435 GRAB_MUTEX(&_hbaapi_AAE_mutex);
435 436 /* if it wasnt in the simple lists, look in the list for adapteraddevents */
436 437 lap = &_hbaapi_adapteraddevents_callback_list;
437 438 for(allcbp = _hbaapi_adapteraddevents_callback_list;
438 439 allcbp != NULL;
439 440 allcbp = allcbp->next) {
440 441 if(cbhandle != (HBA_CALLBACKHANDLE)allcbp) {
441 442 lap = &allcbp->next;
442 443 continue;
443 444 }
444 445 for(vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
445 446 vnext = vhlp->next;
446 447 registeredfunc =
447 448 vhlp->lib_info->functionTable.RemoveCallbackHandler;
448 449 if(registeredfunc == NULL) {
449 450 continue;
450 451 }
451 452 (registeredfunc)(vhlp->vendorcbhandle);
452 453 free(vhlp);
453 454 }
454 455 *lap = allcbp->next;
455 456 free(allcbp);
456 457 status = HBA_STATUS_OK;
457 458 break;
458 459 }
459 460 RELEASE_MUTEX(&_hbaapi_AAE_mutex);
460 461 return(status);
461 462 }
462 463
463 464 static char wwn_str1[17];
464 465 static char wwn_str2[17];
465 466 static char wwn_str3[17];
466 467 #define WWN2STR1(wwn) WWN2str(wwn_str1, (wwn))
467 468 #define WWN2STR2(wwn) WWN2str(wwn_str2, (wwn))
468 469 #define WWN2STR3(wwn) WWN2str(wwn_str3, (wwn))
469 470 static char *
470 471 WWN2str(char *buf, HBA_WWN *wwn) {
471 472 int j;
472 473 unsigned char *pc = (unsigned char *)&(wwn->wwn[0]);
473 474 buf[0] = '\0';
474 475 for (j=0; j<16; j+=2) {
475 476 sprintf(&buf[j], "%02X", (int)*pc++);
476 477 }
477 478 return(buf);
478 479 }
479 480
480 481
481 482 #ifdef WIN32
482 483 BOOL APIENTRY
483 484 DllMain( HANDLE hModule,
484 485 DWORD ul_reason_for_call,
485 486 LPVOID lpReserved
486 487 )
487 488 {
488 489 switch (ul_reason_for_call)
489 490 {
490 491 case DLL_PROCESS_ATTACH:
491 492 break;
492 493 case DLL_PROCESS_DETACH:
493 494 break;
494 495 case DLL_THREAD_ATTACH:
495 496 case DLL_THREAD_DETACH:
496 497 break;
497 498 }
498 499 return TRUE;
499 500 }
500 501 #endif
501 502
502 503 /*
503 504 * Read in the config file and load all the specified vendor specific
504 505 * libraries and perform the function registration exercise
505 506 */
506 507 HBA_STATUS
507 508 HBA_LoadLibrary(void) {
508 509 HBARegisterLibraryFunc
509 510 RegisterFunc;
510 511 HBARegisterLibraryV2Func
511 512 RegisterV2Func;
512 513 HBALoadLibraryFunc LoadLibraryFunc;
513 514 HBAGetVersionFunc GetVersionFunc;
514 515 #ifdef POSIX_THREADS
515 516 int ret;
516 517 #endif
517 518 HBA_STATUS status;
518 519 #ifdef NOTDEF
519 520 HBA_UINT32 libversion;
520 521 #endif
521 522
522 523 /* Open configuration file from known location */
523 524 #ifdef WIN32
524 525 LONG lStatus;
525 526 HKEY hkSniaHba, hkVendorLib;
526 527 FILETIME ftLastWriteTime;
527 528 TCHAR cSubKeyName[256];
528 529 DWORD i, dwSize, dwType;
529 530 BYTE byFileName[MAX_PATH];
530 531 HBA_LIBRARY_INFO *lib_infop;
531 532
532 533 if(_hbaapi_librarylist != NULL) {
533 534 /* this is an app programming error */
534 535 return HBA_STATUS_ERROR;
535 536 }
536 537
537 538 lStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\SNIA\\HBA",
538 539 0, KEY_READ, &hkSniaHba);
539 540 if (lStatus != ERROR_SUCCESS) {
540 541 /* ???Opportunity to send error msg, configuration error */
541 542 return HBA_STATUS_ERROR;
542 543 }
543 544 /*
544 545 * Enumerate all the subkeys. These have the form:
545 546 * HKLM\Software\SNIA\HBA\<Vendor id> - note that we don't care
546 547 * what the vendor id is
547 548 */
548 549 for (i = 0; ; i++) {
549 550 dwSize = 255; /* how big the buffer is */
550 551 lStatus = RegEnumKeyEx(hkSniaHba, i,
551 552 (char *)&cSubKeyName, &dwSize, NULL,
552 553 NULL, NULL, &ftLastWriteTime);
553 554 if (lStatus == ERROR_NO_MORE_ITEMS) {
554 555 break; /* we're done */
555 556 } else if (lStatus == ERROR_MORE_DATA) { /* buffer not big enough */
556 557 /* do whatever */
557 558 ;
558 559 }
559 560 /* Now open the subkey that pertains to this vendor's library */
560 561 lStatus = RegOpenKeyEx(hkSniaHba, cSubKeyName, 0, KEY_READ,
561 562 &hkVendorLib);
562 563 if (lStatus != ERROR_SUCCESS) {
563 564 RegCloseKey(hkSniaHba);
564 565 /* ???Opportunity to send error msg, installation error */
565 566 return HBA_STATUS_ERROR; /* you may want to return something
566 567 * else or keep trying */
567 568 }
568 569 /* The name of the library is contained in a REG_SZ Value
569 570 * keyed to "LibraryFile" */
570 571 dwSize = MAX_PATH;
571 572 lStatus = RegQueryValueEx(hkVendorLib, "LibraryFile", NULL, &dwType,
572 573 byFileName, &dwSize);
573 574 if (lStatus != ERROR_SUCCESS) {
574 575 RegCloseKey(hkVendorLib);
575 576 /* ???Opportunity to send error msg, installation error */
576 577 continue;
577 578 }
578 579 lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof(HBA_LIBRARY_INFO));
579 580 if(lib_infop == NULL) {
580 581 /* what is the right thing to do in MS land??? */
581 582 RegCloseKey(hkVendorLib);
582 583 /* ???Opportunity to send error msg, installation error */
583 584 return(HBA_STATUS_ERROR);
584 585 }
585 586 lib_infop->status = HBA_LIBRARY_NOT_LOADED;
586 587 lib_infop->next = _hbaapi_librarylist;
587 588 lib_infop->index = _hbaapi_total_library_count;
588 589 _hbaapi_total_library_count++;
589 590 _hbaapi_librarylist = lib_infop;
590 591
591 592 /* Now I can try to load the library */
592 593 lib_infop->hLibrary = LoadLibrary(byFileName);
593 594 if (lib_infop->hLibrary == NULL){
594 595 /* printf("unable to load library %s\n", librarypath); */
595 596 /* ???Opportunity to send error msg, installation error */
596 597 goto dud_library;
597 598 }
598 599 lib_infop->LibraryPath = strdup(byFileName);
599 600 DEBUG(1, "HBAAPI loading: %s\n", byFileName, 0, 0);
600 601
601 602 /* Call the registration function to get the list of pointers */
602 603 RegisterV2Func = (HBARegisterLibraryV2Func)
603 604 GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
604 605 if (RegisterV2Func != NULL) {
605 606 /* Load the function pointers directly into
606 607 * the table of functions */
607 608 status = ((RegisterV2Func)(&lib_infop->functionTable));
608 609 if (status != HBA_STATUS_OK) {
609 610 /* library not loaded */
610 611 /* ???Opportunity to send error msg, library error? */
611 612 goto dud_library;
612 613 }
613 614 } else {
614 615 /* Maybe the vendor library is only Rev1 */
615 616 RegisterFunc = (HBARegisterLibraryFunc)
616 617 GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibrary");
617 618 if(RegisterFunc == NULL) {
618 619 /* ???Opportunity to send error msg, library error? */
619 620 goto dud_library;
620 621 }
621 622 /* Load the function points directly into
622 623 * the Rev 2 table of functions */
623 624 status = ((RegisterFunc)(
624 625 (HBA_ENTRYPOINTS *)(&lib_infop->functionTable)));
625 626 if (status != HBA_STATUS_OK) {
626 627 /* library not loaded */
627 628 /* ???Opportunity to send error msg, library error? */
628 629 goto dud_library;
629 630 }
630 631 }
631 632
632 633 /* successfully loaded library */
633 634 GetVersionFunc = lib_infop->functionTable.GetVersionHandler;
634 635 if (GetVersionFunc == NULL) {
635 636 /* ???Opportunity to send error msg, library error? */
636 637 goto dud_library;
637 638 }
638 639 #ifdef NOTDEF /* save for a later time... when it matters */
639 640 /* Check the version of this library before loading */
640 641 /* Actually... This wrapper is compatible with version 1 */
641 642 libversion = ((GetVersionFunc)());
642 643 if (libversion < HBA_LIBVERSION) {
643 644 goto dud_library;
644 645 }
645 646 #endif
646 647 LoadLibraryFunc = lib_infop->functionTable.LoadLibraryHandler;
647 648 if (LoadLibraryFunc == NULL) {
648 649 /* Hmmm, dont we need to flag this in a realy big way??? */
649 650 /* How about messages to the system event logger ??? */
650 651 /* ???Opportunity to send error msg, library error? */
651 652 goto dud_library;
652 653 }
653 654 /* Initialize this library */
654 655 status = ((LoadLibraryFunc)());
655 656 if (status != HBA_STATUS_OK) {
656 657 /* ???Opportunity to send error msg, library error? */
657 658 continue;
658 659 }
659 660 /* successfully loaded library */
660 661 lib_infop->status = HBA_LIBRARY_LOADED;
661 662
662 663 dud_library: /* its also just the end of the loop */
663 664 RegCloseKey(hkVendorLib);
664 665 }
665 666 RegCloseKey(hkSniaHba);
666 667
667 668 #else /* Unix as opposed to Win32 */
668 669 FILE *hbaconf;
669 670 char fullline[512]; /* line read from HBA.conf */
670 671 char *libraryname; /* Read in from file HBA.conf */
671 672 char *librarypath; /* Read in from file HBA.conf */
672 673 char hbaConfFilePath[256];
673 674 char *charPtr;
674 675 HBA_LIBRARY_INFO *lib_infop;
675 676
676 677 if(_hbaapi_librarylist != NULL) {
677 678 fprintf(stderr,
678 679 "HBA_LoadLibrary: previously unfreed "
679 680 "libraries exist, call HBA_FreeLibrary().\n");
680 681 return HBA_STATUS_ERROR;
681 682 }
682 683
683 684 strcpy(hbaConfFilePath, "/etc/hba.conf");
684 685
685 686 if ((hbaconf = fopen(hbaConfFilePath, "r")) == NULL) {
686 687 printf("Cannot open %s\n", hbaConfFilePath);
687 688 return HBA_STATUS_ERROR;
688 689 }
689 690
690 691 /* Read in each line and load library */
691 692 while ((hbaconf != NULL) && (fgets(fullline, sizeof(fullline), hbaconf))) {
692 693 /* Skip the comments... */
693 694 if ((fullline[0] == '#') || (fullline[0] == '\n')) {
694 695 continue;
695 696 }
696 697
697 698 /* grab first 'thing' in line (if its there)*/
698 699 if((libraryname = strtok(fullline, " \t\n")) != NULL) {
699 700 if(strlen(libraryname) >= 64) {
700 701 fprintf(stderr, "Library name(%s) in %s is > 64 characters\n",
701 702 libraryname, hbaConfFilePath);
702 703 }
703 704 }
704 705 /* grab second 'thing' in line (if its there)*/
705 706 if((librarypath = strtok(NULL, " \t\n")) != NULL) {
706 707 if(strlen(librarypath) >= 256) {
707 708 fprintf(stderr, "Library path(%s) in %s is > 256 characters\n",
708 709 librarypath, hbaConfFilePath);
709 710 }
710 711 }
711 712
712 713 /* there should be no more 'things' in the line */
713 714 if((charPtr = strtok(NULL, " \n\t")) != NULL) {
714 715 fprintf(stderr, "Extraneous characters (\"%s\") in %s\n",
715 716 charPtr, hbaConfFilePath);
716 717 }
717 718
718 719 /* Continue to the next line if library name or path is invalid */
719 720 if (libraryname == NULL ||
720 721 strlen(libraryname) == 0 ||
721 722 librarypath == NULL ||
722 723 (strlen(librarypath) == 0)) {
723 724 continue;
724 725 }
725 726 /*
726 727 * Special case....
727 728 * Look for loglevel
728 729 */
729 730 if(strcmp(libraryname, "debuglevel") == 0) {
730 731 _hbaapi_debuglevel = strtol(librarypath, NULL, 10);
731 732 /* error handling does the right thing automagically */
732 733 continue;
733 734 }
734 735
735 736 lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof(HBA_LIBRARY_INFO));
736 737 if(lib_infop == NULL) {
737 738 fprintf(stderr, "HBA_LoadLibrary: out of memeory\n");
738 739 return(HBA_STATUS_ERROR);
739 740 }
740 741 lib_infop->status = HBA_LIBRARY_NOT_LOADED;
741 742 lib_infop->LibraryName = strdup(libraryname);
742 743 lib_infop->LibraryPath = strdup(librarypath);
743 744 lib_infop->index = _hbaapi_total_library_count;
744 745 _hbaapi_total_library_count++;
745 746 lib_infop->next = _hbaapi_librarylist;
746 747 _hbaapi_librarylist = lib_infop;
747 748
748 749 /* Load the DLL now */
749 750 if((lib_infop->hLibrary = dlopen(librarypath,RTLD_LAZY)) == NULL) {
750 751 /*printf("unable to load library %s\n", librarypath); */
751 752 continue;
752 753 }
753 754 /* Call the registration function to get the list of pointers */
754 755 RegisterV2Func = (HBARegisterLibraryV2Func)
755 756 dlsym(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
756 757 if (RegisterV2Func != NULL) {
757 758 /* Load the function points directly into
758 759 * the table of functions */
759 760 status = ((RegisterV2Func)(&lib_infop->functionTable));
760 761 if (status != HBA_STATUS_OK) {
761 762 /* library not loaded */
762 763 continue;
763 764 }
764 765 } else {
765 766 /* Maybe the vendor library is only Rev1 */
766 767 RegisterFunc = (HBARegisterLibraryFunc)
767 768 dlsym(lib_infop->hLibrary, "HBA_RegisterLibrary");
768 769 if(RegisterFunc == NULL) {
769 770 /* This function is required */
770 771 fprintf(stderr,
771 772 "HBA_LoadLibrary: vendor specific RegisterLibrary "
772 773 "function not found. lib: %s\n", librarypath);
773 774 DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary "
774 775 "function not found. lib: %s\n", librarypath, 0, 0);
775 776 continue;
776 777 }
777 778 /* Load the function points directly into
778 779 * the table of functions */
779 780 status = ((RegisterFunc)
780 781 ((HBA_ENTRYPOINTS *)(&lib_infop->functionTable)));
781 782 if (status != HBA_STATUS_OK) {
782 783 /* library not loaded */
783 784 fprintf(stderr,
784 785 "HBA_LoadLibrary: vendor specific RegisterLibrary "
785 786 "function encountered an error. lib: %s\n", librarypath);
786 787 DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary "
787 788 "function encountered an error. lib: %s\n", librarypath, 0, 0);
788 789 continue;
789 790 }
790 791 }
791 792
792 793 /* successfully loaded library */
793 794 if((GetVersionFunc = lib_infop->functionTable.GetVersionHandler)
794 795 == NULL) {
795 796 continue;
796 797 }
797 798 #ifdef NOTDEF /* save for a later time... when it matters */
798 799 libversion = ((GetVersionFunc)());
799 800 /* Check the version of this library before loading */
800 801 /* Actually... This wrapper is compatible with version 1 */
801 802 if(libversion < HBA_LIBVERSION) {
802 803 printf("Library version mismatch. Got %d expected %d.\n",
803 804 libversion, HBA_LIBVERSION);
804 805 continue;
805 806 }
806 807 DEBUG(1, "%s libversion = %d", librarypath, libversion, 0);
807 808 #endif
808 809 LoadLibraryFunc = lib_infop->functionTable.LoadLibraryHandler;
809 810 if (LoadLibraryFunc == NULL) {
810 811 /* this function is required */
811 812 fprintf(stderr,
812 813 "HBA_LoadLibrary: vendor specific LoadLibrary "
813 814 "function not found. lib: %s\n", librarypath);
814 815 DEBUG(0, "HBA_LoadLibrary: vendor specific LoadLibrary "
815 816 "function not found. lib: %s\n", librarypath, 0, 0);
816 817 continue;
817 818 }
818 819 /* Initialize this library */
819 820 if((status = ((LoadLibraryFunc)())) != HBA_STATUS_OK) {
820 821 /* maybe this should be a printf so that we CANNOT miss it */
821 822 fprintf(stderr,
822 823 "HBA_LoadLibrary: Encounterd and error loading: %s",
823 824 librarypath);
824 825 DEBUG(0, "Encounterd and error loading: %s", librarypath, 0, 0);
825 826 DEBUG(0, " HBA_STATUS: %d", status, 0, 0);
826 827 continue;
827 828 }
828 829 /* successfully loaded library */
829 830 lib_infop->status = HBA_LIBRARY_LOADED;
830 831 }
831 832
832 833 fclose(hbaconf);
833 834 #endif /* WIN32 or UNIX */
834 835 #ifdef POSIX_THREADS
835 836 ret = pthread_mutex_init(&_hbaapi_LL_mutex, NULL);
836 837 if(ret == 0) {
837 838 ret = pthread_mutex_init(&_hbaapi_AL_mutex, NULL);
838 839 }
839 840 if(ret == 0) {
840 841 ret = pthread_mutex_init(&_hbaapi_AAE_mutex, NULL);
841 842 }
842 843 if(ret == 0) {
843 844 ret = pthread_mutex_init(&_hbaapi_AE_mutex, NULL);
844 845 }
845 846 if(ret == 0) {
846 847 ret = pthread_mutex_init(&_hbaapi_APE_mutex, NULL);
847 848 }
848 849 if(ret == 0) {
849 850 ret = pthread_mutex_init(&_hbaapi_APSE_mutex, NULL);
850 851 }
851 852 if(ret == 0) {
852 853 ret = pthread_mutex_init(&_hbaapi_TE_mutex, NULL);
853 854 }
854 855 if(ret == 0) {
855 856 ret = pthread_mutex_init(&_hbaapi_LE_mutex, NULL);
856 857 }
857 858 if(ret != 0) {
858 859 perror("pthread_mutec_init - HBA_LoadLibrary");
859 860 return(HBA_STATUS_ERROR);
860 861 }
861 862 #elif defined(WIN32)
862 863 InitializeCriticalSection(&_hbaapi_LL_mutex);
863 864 InitializeCriticalSection(&_hbaapi_AL_mutex);
864 865 InitializeCriticalSection(&_hbaapi_AAE_mutex);
865 866 InitializeCriticalSection(&_hbaapi_AE_mutex);
866 867 InitializeCriticalSection(&_hbaapi_APE_mutex);
867 868 InitializeCriticalSection(&_hbaapi_APSE_mutex);
868 869 InitializeCriticalSection(&_hbaapi_TE_mutex);
869 870 InitializeCriticalSection(&_hbaapi_LE_mutex);
870 871 #endif
871 872
872 873
873 874 return HBA_STATUS_OK;
874 875 }
875 876
876 877 HBA_STATUS
877 878 HBA_FreeLibrary(void) {
878 879 HBAFreeLibraryFunc FreeLibraryFunc;
879 880 HBA_LIBRARY_INFO *lib_infop;
880 881 HBA_LIBRARY_INFO *lib_next;
881 882 HBA_ADAPTERCALLBACK_ELEM
882 883 ***listp;
883 884 HBA_ADAPTER_INFO *adapt_infop;
884 885 HBA_ADAPTER_INFO *adapt_next;
885 886
886 887 ARE_WE_INITED();
887 888 GRAB_MUTEX(&_hbaapi_LL_mutex);
888 889 GRAB_MUTEX(&_hbaapi_AL_mutex);
889 890
890 891 DEBUG(1, "HBA_FreeLibrary()", 0, 0, 0);
891 892 for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_next) {
892 893 lib_next = lib_infop->next;
893 894 if (lib_infop->status == HBA_LIBRARY_LOADED) {
894 895 FreeLibraryFunc = lib_infop->functionTable.FreeLibraryHandler;
895 896 if (FreeLibraryFunc != NULL) {
896 897 /* Free this library */
897 898 (void)((FreeLibraryFunc)());
898 899 }
899 900 #ifdef WIN32
900 901 FreeLibrary(lib_infop->hLibrary); /* Unload DLL from memory */
901 902 #else
902 903 dlclose(lib_infop->hLibrary); /* Unload DLL from memory */
903 904 #endif
904 905 }
905 906 #ifndef WIN32
906 907 free(lib_infop->LibraryName);
907 908 #endif
908 909 free(lib_infop->LibraryPath);
909 910 free(lib_infop);
910 911
911 912 }
912 913 _hbaapi_librarylist = NULL;
913 914 /* OK, now all functions are disabled except for LoadLibrary,
914 915 * Hope no other thread calls it before we have returned */
915 916 _hbaapi_total_library_count = 0;
916 917
917 918 for(adapt_infop = _hbaapi_adapterlist;
918 919 adapt_infop != NULL;
919 920 adapt_infop = adapt_next) {
920 921 adapt_next = adapt_infop->next;
921 922 free(adapt_infop->name);
922 923 free(adapt_infop);
923 924 }
924 925 _hbaapi_adapterlist = NULL;
925 926 _hbaapi_total_adapter_count = 0;
926 927
927 928 /* Free up the callbacks, this is not the most efficient, but it works */
928 929 while((volatile HBA_ADAPTERCALLBACK_ELEM *)
929 930 _hbaapi_adapteraddevents_callback_list
930 931 != NULL) {
931 932 local_remove_callback((HBA_CALLBACKHANDLE)
932 933 _hbaapi_adapteraddevents_callback_list);
933 934 }
934 935 for(listp = cb_lists_array; *listp != NULL; listp++) {
935 936 while((volatile HBA_ADAPTERCALLBACK_ELEM ***)**listp != NULL) {
936 937 local_remove_callback((HBA_CALLBACKHANDLE)**listp);
937 938 }
938 939 }
939 940
940 941 RELEASE_MUTEX(&_hbaapi_AL_mutex);
941 942 RELEASE_MUTEX(&_hbaapi_LL_mutex);
942 943
943 944 #ifdef USESYSLOG
944 945 closelog();
945 946 #endif
946 947 #ifdef USELOGFILE
947 948 if(_hbaapi_debug_fd != NULL) {
948 949 fclose(_hbaapi_debug_fd);
949 950 }
950 951 _hbaapi_debug_fd = NULL;
951 952 #endif
952 953 #ifdef POSIX_THREADS
953 954 /* this will unlock them as well, but who cares */
954 955 pthread_mutex_destroy(&_hbaapi_LE_mutex);
955 956 pthread_mutex_destroy(&_hbaapi_TE_mutex);
956 957 pthread_mutex_destroy(&_hbaapi_APSE_mutex);
957 958 pthread_mutex_destroy(&_hbaapi_APE_mutex);
958 959 pthread_mutex_destroy(&_hbaapi_AE_mutex);
959 960 pthread_mutex_destroy(&_hbaapi_AAE_mutex);
960 961 pthread_mutex_destroy(&_hbaapi_AL_mutex);
961 962 pthread_mutex_destroy(&_hbaapi_LL_mutex);
|
↓ open down ↓ |
905 lines elided |
↑ open up ↑ |
962 963 #elif defined(WIN32)
963 964 DeleteCriticalSection(&_hbaapi_LL_mutex);
964 965 DeleteCriticalSection(&_hbaapi_AL_mutex);
965 966 DeleteCriticalSection(&_hbaapi_AAE_mutex);
966 967 DeleteCriticalSection(&_hbaapi_AE_mutex);
967 968 DeleteCriticalSection(&_hbaapi_APE_mutex);
968 969 DeleteCriticalSection(&_hbaapi_APSE_mutex);
969 970 DeleteCriticalSection(&_hbaapi_TE_mutex);
970 971 DeleteCriticalSection(&_hbaapi_LE_mutex);
971 972 #endif
972 -
973 - return HBA_STATUS_OK;
973 +
974 + return (Sun_HBA_FreeLibrary());
974 975 }
975 -
976 +
976 977 /*
977 978 * The API used to use fixed size tables as its primary data structure.
978 979 * Indexing from 1 to N identified each adapters. Now the adapters are
979 980 * on a linked list. There is a unique "index" foreach each adapter.
980 981 * Adapters always keep their index, even if they are removed from the
981 982 * hardware. The only time the indexing is reset is on HBA_FreeLibrary
982 983 */
983 984 HBA_UINT32
984 985 HBA_GetNumberOfAdapters(void) {
985 986 int j=0;
986 987 HBA_LIBRARY_INFO *lib_infop;
987 988 HBAGetNumberOfAdaptersFunc
988 989 GetNumberOfAdaptersFunc;
989 990 HBAGetAdapterNameFunc
990 991 GetAdapterNameFunc;
991 992 HBA_BOOLEAN found_name;
992 993 HBA_ADAPTER_INFO *adapt_infop;
993 994 HBA_STATUS status;
994 995
995 996 char adaptername[256];
996 997 int num_adapters; /* local */
997 998
998 999 if(_hbaapi_librarylist == NULL) {
999 1000 return (0);
1000 1001 }
1001 1002 GRAB_MUTEX(&_hbaapi_LL_mutex); /* pay attention to order */
1002 1003 GRAB_MUTEX(&_hbaapi_AL_mutex);
1003 1004
1004 1005 for (lib_infop = _hbaapi_librarylist;
1005 1006 lib_infop != NULL;
1006 1007 lib_infop = lib_infop->next) {
1007 1008
1008 1009 if (lib_infop->status != HBA_LIBRARY_LOADED) {
1009 1010 continue;
1010 1011 }
1011 1012
1012 1013 GetNumberOfAdaptersFunc =
1013 1014 lib_infop->functionTable.GetNumberOfAdaptersHandler;
1014 1015 if (GetNumberOfAdaptersFunc == NULL) {
1015 1016 continue;
1016 1017 }
1017 1018 num_adapters = ((GetNumberOfAdaptersFunc)());
1018 1019 #ifndef WIN32
1019 1020 DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
1020 1021 lib_infop->LibraryName, num_adapters, 0);
1021 1022 #else
1022 1023 DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
1023 1024 lib_infop->LibraryPath, num_adapters, 0);
1024 1025 #endif
1025 1026
1026 1027 /* Also get the names of all the adapters here and cache */
1027 1028 GetAdapterNameFunc = lib_infop->functionTable.GetAdapterNameHandler;
1028 1029 if(GetAdapterNameFunc == NULL) {
1029 1030 continue;
1030 1031 }
1031 1032
1032 1033 for (j = 0; j < num_adapters; j++) {
1033 1034 found_name = 0;
1034 1035 status = (GetAdapterNameFunc)(j, (char *)&adaptername);
1035 1036 if(status == HBA_STATUS_OK) {
1036 1037 for(adapt_infop = _hbaapi_adapterlist;
1037 1038 adapt_infop != NULL;
1038 1039 adapt_infop = adapt_infop->next) {
1039 1040 /*
1040 1041 * check for duplicates, really, this may just be a second
1041 1042 * call to this function
1042 1043 * ??? how do we know when a name becomes stale?
1043 1044 */
1044 1045 if(strcmp(adaptername, adapt_infop->name) == 0) {
1045 1046 /* already got this one */
1046 1047 found_name++;
1047 1048 break;
1048 1049 }
1049 1050 }
1050 1051 if(found_name != 0) {
1051 1052 continue;
1052 1053 }
1053 1054 }
1054 1055
1055 1056 adapt_infop = (HBA_ADAPTER_INFO *)
1056 1057 calloc(1, sizeof(HBA_ADAPTER_INFO));
1057 1058 if(adapt_infop == NULL) {
1058 1059 #ifndef WIN32
1059 1060 fprintf(stderr,
1060 1061 "HBA_GetNumberOfAdapters: calloc failed on sizeof:%d\n",
1061 1062 sizeof(HBA_ADAPTER_INFO));
1062 1063 #endif
1063 1064 RELEASE_MUTEX(&_hbaapi_AL_mutex);
1064 1065 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
1065 1066 _hbaapi_total_adapter_count);
1066 1067 }
1067 1068 if((adapt_infop->GNstatus = status) == HBA_STATUS_OK) {
1068 1069 adapt_infop->name = strdup(adaptername);
1069 1070 } else {
1070 1071 char dummyname[512];
1071 1072 sprintf(dummyname, "NULLADAPTER-%s-%03d",
1072 1073 lib_infop->LibraryPath, _hbaapi_total_adapter_count);
1073 1074 dummyname[255] = '\0';
1074 1075 adapt_infop->name = strdup(dummyname);
1075 1076 }
1076 1077 adapt_infop->library = lib_infop;
1077 1078 adapt_infop->next = _hbaapi_adapterlist;
1078 1079 adapt_infop->index = _hbaapi_total_adapter_count;
1079 1080 _hbaapi_adapterlist = adapt_infop;
1080 1081 _hbaapi_total_adapter_count++;
1081 1082 }
1082 1083 }
1083 1084 RELEASE_MUTEX(&_hbaapi_AL_mutex);
1084 1085 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
1085 1086 }
1086 1087
1087 1088 HBA_STATUS
1088 1089 HBA_GetAdapterName(
1089 1090 HBA_UINT32 adapterindex,
1090 1091 char *adaptername)
1091 1092 {
1092 1093 HBA_ADAPTER_INFO *adapt_infop;
1093 1094 HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
1094 1095
1095 1096 if (adaptername == NULL) {
1096 1097 return(HBA_STATUS_ERROR_ARG);
1097 1098 }
1098 1099 /*
1099 1100 * The adapter index is from old code, but we have
1100 1101 * to support it. Go down the list looking for
1101 1102 * the adapter
1102 1103 */
1103 1104 ARE_WE_INITED();
1104 1105 GRAB_MUTEX(&_hbaapi_AL_mutex);
1105 1106 *adaptername = '\0';
1106 1107 for(adapt_infop = _hbaapi_adapterlist;
1107 1108 adapt_infop != NULL;
1108 1109 adapt_infop = adapt_infop->next) {
1109 1110
1110 1111 if(adapt_infop->index == adapterindex) {
1111 1112 if(adapt_infop->name != NULL &&
1112 1113 adapt_infop->GNstatus == HBA_STATUS_OK) {
1113 1114 strcpy(adaptername, adapt_infop->name);
1114 1115 } else {
1115 1116 *adaptername = '\0';
1116 1117 }
1117 1118 ret = adapt_infop->GNstatus;
1118 1119 break;
1119 1120 }
1120 1121 }
1121 1122 DEBUG(2, "GetAdapterName for index:%d ->%s", adapterindex, adaptername, 0);
1122 1123 RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret);
1123 1124 }
1124 1125
1125 1126 HBA_HANDLE
1126 1127 HBA_OpenAdapter(char* adaptername) {
1127 1128 HBA_HANDLE handle;
1128 1129 HBAOpenAdapterFunc OpenAdapterFunc;
1129 1130 HBA_ADAPTER_INFO *adapt_infop;
1130 1131 HBA_LIBRARY_INFO *lib_infop;
1131 1132
1132 1133 DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0);
1133 1134
1134 1135 if(_hbaapi_librarylist == NULL) {
1135 1136 return(HBA_HANDLE_INVALID);
1136 1137 }
1137 1138 if (adaptername == NULL) {
1138 1139 return(HBA_STATUS_ERROR_ARG);
1139 1140 }
1140 1141 handle = HBA_HANDLE_INVALID;
1141 1142 GRAB_MUTEX(&_hbaapi_AL_mutex);
1142 1143 for(adapt_infop = _hbaapi_adapterlist;
1143 1144 adapt_infop != NULL;
1144 1145 adapt_infop = adapt_infop->next) {
1145 1146 if (strcmp(adaptername, adapt_infop->name) != 0) {
1146 1147 continue;
1147 1148 }
1148 1149 lib_infop = adapt_infop->library;
1149 1150 OpenAdapterFunc =
1150 1151 lib_infop->functionTable.OpenAdapterHandler;
1151 1152 if (OpenAdapterFunc != NULL) {
1152 1153 /* retrieve the vendor handle */
1153 1154 handle = (OpenAdapterFunc)(adaptername);
1154 1155 if(handle != 0) {
1155 1156 /* or this with the library index to get the common handle */
1156 1157 handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1157 1158 }
1158 1159 }
1159 1160 break;
1160 1161 }
1161 1162 RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, handle);
1162 1163 }
1163 1164 /*
1164 1165 * This function ignores the list of known adapters and instead tries
1165 1166 * each vendors open function to see if one of them
1166 1167 * can open an adapter when referenced with a particular WWN
1167 1168 */
1168 1169 HBA_STATUS
1169 1170 HBA_OpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN) {
1170 1171 HBA_HANDLE handle;
1171 1172 HBA_LIBRARY_INFO *lib_infop;
1172 1173 HBAGetNumberOfAdaptersFunc
1173 1174 GetNumberOfAdaptersFunc;
1174 1175 HBAOpenAdapterByWWNFunc
1175 1176 OpenAdapterFunc;
1176 1177 HBA_STATUS status;
1177 1178
1178 1179 DEBUG(2, "OpenAdapterByWWN: %s", WWN2STR1(&nodeWWN), 0, 0);
1179 1180
1180 1181 if (phandle == NULL) {
1181 1182 return(HBA_STATUS_ERROR_ARG);
1182 1183 }
1183 1184
1184 1185 ARE_WE_INITED();
1185 1186
1186 1187 *phandle = HBA_HANDLE_INVALID;
1187 1188
1188 1189 GRAB_MUTEX(&_hbaapi_LL_mutex);
1189 1190 for (lib_infop = _hbaapi_librarylist;
1190 1191 lib_infop != NULL;
1191 1192 lib_infop = lib_infop->next) {
1192 1193
1193 1194 status = HBA_STATUS_ERROR_ILLEGAL_WWN;
1194 1195
1195 1196 if (lib_infop->status != HBA_LIBRARY_LOADED) {
1196 1197 continue;
1197 1198 }
1198 1199
1199 1200 GetNumberOfAdaptersFunc =
1200 1201 lib_infop->functionTable.GetNumberOfAdaptersHandler;
1201 1202 if (GetNumberOfAdaptersFunc == NULL) {
1202 1203 continue;
1203 1204 }
1204 1205
1205 1206 /* look for new hardware */
1206 1207 (void) ((GetNumberOfAdaptersFunc)());
1207 1208
1208 1209 OpenAdapterFunc = lib_infop->functionTable.OpenAdapterByWWNHandler;
1209 1210 if (OpenAdapterFunc == NULL) {
1210 1211 continue;
1211 1212 }
1212 1213 /*
1213 1214 * We do not know if the WWN is known by this vendor,
1214 1215 * just try it
1215 1216 */
1216 1217 if((status = (OpenAdapterFunc)(&handle, nodeWWN)) != HBA_STATUS_OK) {
1217 1218 continue;
1218 1219 }
1219 1220 /* OK, make a vendor non-specific handle */
1220 1221 *phandle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
1221 1222 status = HBA_STATUS_OK;
1222 1223 break;
1223 1224 }
1224 1225 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1225 1226 }
1226 1227
1227 1228 void
1228 1229 HBA_RefreshAdapterConfiguration() {
1229 1230 DEBUG(2, "HBA_RefreshAdapterConfiguration", 0, 0, 0);
1230 1231 (void)HBA_GetNumberOfAdapters();
1231 1232 return;
1232 1233 }
1233 1234
1234 1235 HBA_UINT32
1235 1236 HBA_GetVersion() {
1236 1237 DEBUG(2, "HBA_GetVersion", 0, 0, 0);
1237 1238 return HBA_LIBVERSION;
1238 1239 }
1239 1240
1240 1241 /*
1241 1242 * This function is VERY OS dependent. Wing it as best you can.
1242 1243 */
1243 1244 HBA_UINT32
1244 1245 HBA_GetWrapperLibraryAttributes (
1245 1246 HBA_LIBRARYATTRIBUTES *attributes)
1246 1247 {
1247 1248
1248 1249 DEBUG(2, "HBA_GetWrapperLibraryAttributes", 0, 0, 0);
1249 1250
1250 1251 if (attributes == NULL) {
1251 1252 return(HBA_STATUS_ERROR_ARG);
1252 1253 }
1253 1254
1254 1255 memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES));
1255 1256
1256 1257 #if defined(SOLARIS)
1257 1258 if((handle = dlopen("libHBAAPI.so", RTLD_NOW)) != NULL) {
1258 1259 if(dlinfo(handle, RTLD_DI_LINKMAP, &map) >= 0) {
1259 1260 for(mp = map; mp != NULL; mp = mp->l_next) {
1260 1261 if(strlen(map->l_name) < 256) {
1261 1262 strcpy(attributes->LibPath, map->l_lname);
1262 1263 }
1263 1264 }
1264 1265 }
1265 1266 }
1266 1267 #elif defined(WIN32)
1267 1268 {
1268 1269 HMODULE module;
1269 1270
1270 1271 /* No need to do anything with the module handle */
1271 1272 /* It wasn't alloocated so it doesn't need to be freed */
1272 1273 module = GetModuleHandle("HBAAPI");
1273 1274 if ( module != NULL ) {
1274 1275 if ( GetModuleFileName(module, attributes->LibPath,
1275 1276 sizeof(attributes->LibPath)) == 0 ) {
1276 1277 attributes->LibPath[0] = '\0';
1277 1278 }
1278 1279 }
1279 1280 }
1280 1281 #endif
1281 1282 #if defined(VENDOR)
1282 1283 strcpy(attributes->VName, VENDOR);
1283 1284 #else
1284 1285 attributes->VName[0] = '\0';
1285 1286 #endif
1286 1287 #if defined(VERSION)
1287 1288 strcpy(attributes->VVersion, VERSION);
1288 1289 #else
1289 1290 attributes->VVersion[0] = '\0';
1290 1291 #endif
1291 1292 #if defined(BUILD_DATE)
1292 1293 #if defined(WIN32)
1293 1294 {
1294 1295 int matchCount;
1295 1296 matchCount = sscanf(BUILD_DATE, "%u/%u/%u %u:%u:%u",
1296 1297 &attributes->build_date.tm_year,
1297 1298 &attributes->build_date.tm_mon,
1298 1299 &attributes->build_date.tm_mday,
1299 1300 &attributes->build_date.tm_hour,
1300 1301 &attributes->build_date.tm_min,
1301 1302 &attributes->build_date.tm_sec
1302 1303 );
1303 1304
1304 1305 if ( matchCount != 6 ) {
1305 1306 memset(&attributes->build_date, 0, sizeof(struct tm));
1306 1307 } else {
1307 1308 attributes->build_date.tm_year -= 1900;
1308 1309 attributes->build_date.tm_isdst = -1;
1309 1310 }
1310 1311
1311 1312 }
1312 1313 #else
1313 1314 if(strptime(BUILD_DATE, "%Y/%m/%d %T %Z", &(attributes->build_date)) == NULL) {
1314 1315 memset(&attributes->build_date, 0, sizeof(struct tm));
1315 1316 }
1316 1317 #endif
1317 1318 #else
1318 1319 memset(&attributes->build_date, 0, sizeof(struct tm));
1319 1320 #endif
1320 1321 return 2;
1321 1322 }
1322 1323
1323 1324 /*
1324 1325 * Callback registation and handling
1325 1326 */
1326 1327 HBA_STATUS
1327 1328 HBA_RemoveCallback (HBA_CALLBACKHANDLE cbhandle) {
1328 1329 HBA_STATUS status;
1329 1330
1330 1331 DEBUG(2, "HBA_RemoveCallback", 0, 0, 0);
1331 1332 ARE_WE_INITED();
1332 1333
1333 1334 GRAB_MUTEX(&_hbaapi_LL_mutex);
1334 1335 status = local_remove_callback(cbhandle);
1335 1336 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1336 1337 }
1337 1338
1338 1339 /* Adapter Add Events *********************************************************/
1339 1340 static void
1340 1341 adapteraddevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) {
1341 1342 HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
1342 1343
1343 1344 DEBUG(3, "AddAdapterEvent, port:%s", WWN2STR1(&PortWWN), 0, 0);
1344 1345
1345 1346 GRAB_MUTEX(&_hbaapi_AAE_mutex);
1346 1347 for(cbp = _hbaapi_adapteraddevents_callback_list;
1347 1348 cbp != NULL;
1348 1349 cbp = cbp->next) {
1349 1350 (*cbp->callback)(data, PortWWN, HBA_EVENT_ADAPTER_ADD);
1350 1351 }
1351 1352 RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1352 1353
1353 1354 }
1354 1355 HBA_STATUS
1355 1356 HBA_RegisterForAdapterAddEvents (
1356 1357 void (*callback) (
1357 1358 void *data,
1358 1359 HBA_WWN PortWWN,
1359 1360 HBA_UINT32 eventType
1360 1361 ),
1361 1362 void *userData,
1362 1363 HBA_CALLBACKHANDLE *callbackHandle) {
1363 1364
1364 1365 HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
1365 1366 HBA_VENDORCALLBACK_ELEM *vcbp;
1366 1367 HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
1367 1368 HBARegisterForAdapterAddEventsFunc registeredfunc;
1368 1369 HBA_STATUS status = HBA_STATUS_OK;
1369 1370 HBA_STATUS failure = HBA_STATUS_OK;
1370 1371 HBA_LIBRARY_INFO *lib_infop;
1371 1372 int registered_cnt = 0;
1372 1373 int vendor_cnt = 0;
1373 1374 int not_supported_cnt = 0;
1374 1375 int status_OK_bar_cnt = 0;
1375 1376 int status_OK_cnt = 0;
1376 1377
1377 1378 DEBUG(2, "HBA_RegisterForAdapterAddEvents", 0, 0, 0);
1378 1379
1379 1380 if (callbackHandle == NULL) {
1380 1381 return(HBA_STATUS_ERROR_ARG);
1381 1382 }
1382 1383 ARE_WE_INITED();
1383 1384
1384 1385 cbp = (HBA_ALLADAPTERSCALLBACK_ELEM *)
1385 1386 calloc(1, sizeof(HBA_ALLADAPTERSCALLBACK_ELEM));
1386 1387 *callbackHandle = (HBA_CALLBACKHANDLE) cbp;
1387 1388 if(cbp == NULL) {
1388 1389 #ifndef WIN32
1389 1390 fprintf(stderr,
1390 1391 "HBA_RegisterForAdapterAddEvents: calloc failed for %d bytes\n",
1391 1392 sizeof(HBA_ALLADAPTERSCALLBACK_ELEM));
1392 1393 #endif
1393 1394 return HBA_STATUS_ERROR;
1394 1395 }
1395 1396
1396 1397 GRAB_MUTEX(&_hbaapi_LL_mutex);
1397 1398 GRAB_MUTEX(&_hbaapi_AAE_mutex);
1398 1399 cbp->callback = callback;
1399 1400 cbp->next = _hbaapi_adapteraddevents_callback_list;
1400 1401 _hbaapi_adapteraddevents_callback_list = cbp;
1401 1402 /* Need to release the mutex now incase the vendor function invokes the
1402 1403 * callback. We will grap the mutex later to attach the vendor handle list
1403 1404 * to the callback structure */
1404 1405 RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1405 1406
1406 1407
1407 1408 /*
1408 1409 * now create a list of vendors (vendor libraryies, NOT ADAPTERS) that have
1409 1410 * successfully registerred
1410 1411 */
1411 1412 vendorhandlelist = NULL;
1412 1413 for(lib_infop = _hbaapi_librarylist;
1413 1414 lib_infop != NULL;
1414 1415 lib_infop = lib_infop->next) {
1415 1416
1416 1417 vendor_cnt++;
1417 1418
1418 1419 registeredfunc =
1419 1420 lib_infop->functionTable.RegisterForAdapterAddEventsHandler;
1420 1421 if(registeredfunc == NULL) {
1421 1422 continue;
1422 1423 }
1423 1424
1424 1425 vcbp = (HBA_VENDORCALLBACK_ELEM *)
1425 1426 calloc(1, sizeof(HBA_VENDORCALLBACK_ELEM));
1426 1427 if(vcbp == NULL) {
1427 1428 #ifndef WIN32
1428 1429 fprintf(stderr,
1429 1430 "HBA_RegisterForAdapterAddEvents: "
1430 1431 "calloc failed for %d bytes\n",
1431 1432 sizeof(HBA_VENDORCALLBACK_ELEM));
1432 1433 #endif
1433 1434 freevendorhandlelist(vendorhandlelist);
1434 1435 status = HBA_STATUS_ERROR;
1435 1436 break;
1436 1437 }
1437 1438
1438 1439 registered_cnt++;
1439 1440 status = (registeredfunc)(adapteraddevents_callback,
1440 1441 userData, &vcbp->vendorcbhandle);
1441 1442 if(status == HBA_STATUS_ERROR_NOT_SUPPORTED) {
1442 1443 not_supported_cnt++;
1443 1444 free(vcbp);
1444 1445 continue;
1445 1446 } else if (status != HBA_STATUS_OK) {
1446 1447 status_OK_bar_cnt++;
1447 1448 DEBUG(0,
1448 1449 "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
1449 1450 lib_infop->LibraryPath, status, 0);
1450 1451 #ifndef WIN32
1451 1452 fprintf(stderr,
1452 1453 "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
1453 1454 lib_infop->LibraryPath, status);
1454 1455 #endif
1455 1456 failure = status;
1456 1457 free(vcbp);
1457 1458 continue;
1458 1459 } else {
1459 1460 status_OK_cnt++;
1460 1461 }
1461 1462 vcbp->lib_info = lib_infop;
1462 1463 vcbp->next = vendorhandlelist;
1463 1464 vendorhandlelist = vcbp;
1464 1465 }
1465 1466 if(registered_cnt == 0) {
1466 1467 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
1467 1468 freevendorhandlelist(vendorhandlelist);
1468 1469 local_remove_callback((HBA_CALLBACKHANDLE) cbp);
1469 1470 } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
1470 1471 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
1471 1472 } else if (status_OK_cnt == 0) {
1472 1473 /* At least one vendor library registered this function, but no
1473 1474 * vendor call succeeded */
1474 1475 local_remove_callback((HBA_CALLBACKHANDLE) cbp);
1475 1476 status = failure;
1476 1477 } else {
1477 1478 /* we have had atleast some success, now finish up */
1478 1479 GRAB_MUTEX(&_hbaapi_AAE_mutex);
1479 1480 /* this seems silly, but what if another thread called
1480 1481 * the callback remove */
1481 1482 for(cbp = _hbaapi_adapteraddevents_callback_list;
1482 1483 cbp != NULL; cbp = cbp->next) {
1483 1484 if((HBA_CALLBACKHANDLE)cbp == *callbackHandle) {
1484 1485 /* yup, its still there, hooray */
1485 1486 cbp->vendorhandlelist = vendorhandlelist;
1486 1487 vendorhandlelist = NULL;
1487 1488 break;
1488 1489 }
1489 1490 }
1490 1491 RELEASE_MUTEX(&_hbaapi_AAE_mutex);
1491 1492 if(vendorhandlelist != NULL) {
1492 1493 /* bummer, somebody removed the callback before we finished
1493 1494 * registration, probably will never happen */
1494 1495 freevendorhandlelist(vendorhandlelist);
1495 1496 DEBUG(0,
1496 1497 "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
1497 1498 "called for a handle before registration was finished.",
1498 1499 0, 0, 0);
1499 1500 status = HBA_STATUS_ERROR;
1500 1501 } else {
1501 1502 status = HBA_STATUS_OK;
1502 1503 }
1503 1504 }
1504 1505 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1505 1506 }
1506 1507
1507 1508 /* Adapter Events (other than add) ********************************************/
1508 1509 static void
1509 1510 adapterevents_callback (void *data,
1510 1511 HBA_WWN PortWWN,
1511 1512 HBA_UINT32 eventType) {
1512 1513 HBA_ADAPTERCALLBACK_ELEM *acbp;
1513 1514
1514 1515 DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
1515 1516 eventType, 0);
1516 1517
1517 1518 GRAB_MUTEX(&_hbaapi_AE_mutex);
1518 1519 for(acbp = _hbaapi_adapterevents_callback_list;
1519 1520 acbp != NULL;
1520 1521 acbp = acbp->next) {
1521 1522 if(data == (void *)acbp) {
1522 1523 (*acbp->callback)(acbp->userdata, PortWWN, eventType);
1523 1524 break;
1524 1525 }
1525 1526 }
1526 1527 RELEASE_MUTEX(&_hbaapi_AE_mutex);
1527 1528 }
1528 1529 HBA_STATUS
1529 1530 HBA_RegisterForAdapterEvents (
1530 1531 void (*callback) (
1531 1532 void *data,
1532 1533 HBA_WWN PortWWN,
1533 1534 HBA_UINT32 eventType
1534 1535 ),
1535 1536 void *userData,
1536 1537 HBA_HANDLE handle,
1537 1538 HBA_CALLBACKHANDLE *callbackHandle) {
1538 1539
1539 1540 HBA_ADAPTERCALLBACK_ELEM *acbp;
1540 1541 HBARegisterForAdapterEventsFunc registeredfunc;
1541 1542 HBA_STATUS status;
1542 1543 HBA_LIBRARY_INFO *lib_infop;
1543 1544 HBA_HANDLE vendorHandle;
1544 1545
1545 1546 DEBUG(2, "HBA_RegisterForAdapterEvents", 0, 0, 0);
1546 1547
1547 1548 if (callbackHandle == NULL) {
1548 1549 return(HBA_STATUS_ERROR_ARG);
1549 1550 }
1550 1551
1551 1552 CHECKLIBRARY();
1552 1553
1553 1554 /* we now have the _hbaapi_LL_mutex */
1554 1555
1555 1556 registeredfunc = lib_infop->functionTable.RegisterForAdapterEventsHandler;
1556 1557 if(registeredfunc == NULL) {
1557 1558 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1558 1559 }
1559 1560
1560 1561 /*
1561 1562 * that allocated memory is used both as the handle for the
1562 1563 * caller, and as userdata to the vendor call so that on
1563 1564 * callback the specific registration may be recalled
1564 1565 */
1565 1566 acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1566 1567 calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
1567 1568 if(acbp == NULL) {
1568 1569 #ifndef WIN32
1569 1570 fprintf(stderr,
1570 1571 "HBA_RegisterForAdapterEvents: calloc failed for %d bytes\n",
1571 1572 sizeof(HBA_ADAPTERCALLBACK_ELEM));
1572 1573 #endif
1573 1574 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1574 1575 }
1575 1576 *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1576 1577 acbp->callback = callback;
1577 1578 acbp->userdata = userData;
1578 1579 acbp->lib_info = lib_infop;
1579 1580
1580 1581 status = (registeredfunc)(adapterevents_callback,
1581 1582 (void *)acbp,
1582 1583 vendorHandle,
1583 1584 &acbp->vendorcbhandle);
1584 1585 if(status != HBA_STATUS_OK) {
1585 1586 free(acbp);
1586 1587 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1587 1588 }
1588 1589
1589 1590 GRAB_MUTEX(&_hbaapi_AE_mutex);
1590 1591 acbp->next = _hbaapi_adapterevents_callback_list;
1591 1592 _hbaapi_adapterevents_callback_list = acbp;
1592 1593 RELEASE_MUTEX(&_hbaapi_AE_mutex);
1593 1594
1594 1595 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1595 1596 }
1596 1597
1597 1598 /* Adapter Port Events ********************************************************/
1598 1599 static void
1599 1600 adapterportevents_callback (void *data,
1600 1601 HBA_WWN PortWWN,
1601 1602 HBA_UINT32 eventType,
1602 1603 HBA_UINT32 fabricPortID) {
1603 1604 HBA_ADAPTERCALLBACK_ELEM *acbp;
1604 1605
1605 1606 DEBUG(3, "AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
1606 1607 WWN2STR1(&PortWWN), eventType, fabricPortID);
1607 1608
1608 1609 GRAB_MUTEX(&_hbaapi_APE_mutex);
1609 1610
1610 1611 for(acbp = _hbaapi_adapterportevents_callback_list;
1611 1612 acbp != NULL;
1612 1613 acbp = acbp->next) {
1613 1614 if(data == (void *)acbp) {
1614 1615 (*acbp->callback)(acbp->userdata, PortWWN, eventType, fabricPortID);
1615 1616 break;
1616 1617 }
1617 1618 }
1618 1619 RELEASE_MUTEX(&_hbaapi_APE_mutex);
1619 1620 }
1620 1621 HBA_STATUS
1621 1622 HBA_RegisterForAdapterPortEvents (
1622 1623 void (*callback) (
1623 1624 void *data,
1624 1625 HBA_WWN PortWWN,
1625 1626 HBA_UINT32 eventType,
1626 1627 HBA_UINT32 fabricPortID
1627 1628 ),
1628 1629 void *userData,
1629 1630 HBA_HANDLE handle,
1630 1631 HBA_WWN PortWWN,
1631 1632 HBA_CALLBACKHANDLE *callbackHandle) {
1632 1633
1633 1634 HBA_ADAPTERCALLBACK_ELEM *acbp;
1634 1635 HBARegisterForAdapterPortEventsFunc registeredfunc;
1635 1636 HBA_STATUS status;
1636 1637 HBA_LIBRARY_INFO *lib_infop;
1637 1638 HBA_HANDLE vendorHandle;
1638 1639
1639 1640 DEBUG(2, "HBA_RegisterForAdapterPortEvents for port: %s",
1640 1641 WWN2STR1(&PortWWN), 0, 0);
1641 1642
1642 1643 if (callbackHandle == NULL) {
1643 1644 return(HBA_STATUS_ERROR_ARG);
1644 1645 }
1645 1646
1646 1647 CHECKLIBRARY();
1647 1648 /* we now have the _hbaapi_LL_mutex */
1648 1649
1649 1650 registeredfunc =
1650 1651 lib_infop->functionTable.RegisterForAdapterPortEventsHandler;
1651 1652 if(registeredfunc == NULL) {
1652 1653 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1653 1654 }
1654 1655
1655 1656 /*
1656 1657 * that allocated memory is used both as the handle for the
1657 1658 * caller, and as userdata to the vendor call so that on
1658 1659 * callback the specific registration may be recalled
1659 1660 */
1660 1661 acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1661 1662 calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
1662 1663 if(acbp == NULL) {
1663 1664 #ifndef WIN32
1664 1665 fprintf(stderr,
1665 1666 "HBA_RegisterForAdapterPortEvents: "
1666 1667 "calloc failed for %d bytes\n",
1667 1668 sizeof(HBA_ADAPTERCALLBACK_ELEM));
1668 1669 #endif
1669 1670 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1670 1671
1671 1672 }
1672 1673 *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1673 1674 acbp->callback = callback;
1674 1675 acbp->userdata = userData;
1675 1676 acbp->lib_info = lib_infop;
1676 1677
1677 1678 status = (registeredfunc)(adapterportevents_callback,
1678 1679 (void *)acbp,
1679 1680 vendorHandle,
1680 1681 PortWWN,
1681 1682 &acbp->vendorcbhandle);
1682 1683 if(status != HBA_STATUS_OK) {
1683 1684 free(acbp);
1684 1685 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1685 1686 }
1686 1687
1687 1688 GRAB_MUTEX(&_hbaapi_APE_mutex);
1688 1689 acbp->next = _hbaapi_adapterportevents_callback_list;
1689 1690 _hbaapi_adapterportevents_callback_list = acbp;
1690 1691 RELEASE_MUTEX(&_hbaapi_APE_mutex);
1691 1692
1692 1693 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1693 1694 }
1694 1695
1695 1696 /* Adapter State Events *******************************************************/
1696 1697 static void
1697 1698 adapterportstatevents_callback (void *data,
1698 1699 HBA_WWN PortWWN,
1699 1700 HBA_UINT32 eventType) {
1700 1701 HBA_ADAPTERCALLBACK_ELEM *acbp;
1701 1702
1702 1703 DEBUG(3, "AdapterPortStateEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
1703 1704 eventType, 0);
1704 1705
1705 1706 GRAB_MUTEX(&_hbaapi_APSE_mutex);
1706 1707 for(acbp = _hbaapi_adapterportstatevents_callback_list;
1707 1708 acbp != NULL;
1708 1709 acbp = acbp->next) {
1709 1710 if(data == (void *)acbp) {
1710 1711 (*acbp->callback)(acbp->userdata, PortWWN, eventType);
1711 1712 return;
1712 1713 }
1713 1714 }
1714 1715 }
1715 1716 HBA_STATUS
1716 1717 HBA_RegisterForAdapterPortStatEvents (
1717 1718 void (*callback) (
1718 1719 void *data,
1719 1720 HBA_WWN PortWWN,
1720 1721 HBA_UINT32 eventType
1721 1722 ),
1722 1723 void *userData,
1723 1724 HBA_HANDLE handle,
1724 1725 HBA_WWN PortWWN,
1725 1726 HBA_PORTSTATISTICS stats,
1726 1727 HBA_UINT32 statType,
1727 1728 HBA_CALLBACKHANDLE *callbackHandle) {
1728 1729
1729 1730 HBA_ADAPTERCALLBACK_ELEM *acbp;
1730 1731 HBARegisterForAdapterPortStatEventsFunc
1731 1732 registeredfunc;
1732 1733 HBA_STATUS status;
1733 1734 HBA_LIBRARY_INFO *lib_infop;
1734 1735 HBA_HANDLE vendorHandle;
1735 1736
1736 1737 DEBUG(2, "HBA_RegisterForAdapterPortStatEvents for port: %s",
1737 1738 WWN2STR1(&PortWWN), 0, 0);
1738 1739
1739 1740 if (callbackHandle == NULL) {
1740 1741 return(HBA_STATUS_ERROR_ARG);
1741 1742 }
1742 1743
1743 1744 CHECKLIBRARY();
1744 1745 /* we now have the _hbaapi_LL_mutex */
1745 1746
1746 1747 registeredfunc =
1747 1748 lib_infop->functionTable.RegisterForAdapterPortStatEventsHandler;
1748 1749 if(registeredfunc == NULL) {
1749 1750 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1750 1751 }
1751 1752
1752 1753 /*
1753 1754 * that allocated memory is used both as the handle for the
1754 1755 * caller, and as userdata to the vendor call so that on
1755 1756 * callback the specific registration may be recalled
1756 1757 */
1757 1758 acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1758 1759 calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
1759 1760 if(acbp == NULL) {
1760 1761 #ifndef WIN32
1761 1762 fprintf(stderr,
1762 1763 "HBA_RegisterForAdapterPortStatEvents: "
1763 1764 "calloc failed for %d bytes\n",
1764 1765 sizeof(HBA_ADAPTERCALLBACK_ELEM));
1765 1766 #endif
1766 1767 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1767 1768 }
1768 1769 *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1769 1770 acbp->callback = callback;
1770 1771 acbp->userdata = userData;
1771 1772 acbp->lib_info = lib_infop;
1772 1773
1773 1774 status = (registeredfunc)(adapterportstatevents_callback,
1774 1775 (void *)acbp,
1775 1776 vendorHandle,
1776 1777 PortWWN,
1777 1778 stats,
1778 1779 statType,
1779 1780 &acbp->vendorcbhandle);
1780 1781 if(status != HBA_STATUS_OK) {
1781 1782 free(acbp);
1782 1783 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1783 1784 }
1784 1785
1785 1786 GRAB_MUTEX(&_hbaapi_APSE_mutex);
1786 1787 acbp->next = _hbaapi_adapterportstatevents_callback_list;
1787 1788 _hbaapi_adapterportstatevents_callback_list = acbp;
1788 1789 RELEASE_MUTEX(&_hbaapi_APSE_mutex);
1789 1790
1790 1791 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1791 1792 }
1792 1793
1793 1794 /* Target Events **************************************************************/
1794 1795 static void
1795 1796 targetevents_callback (void *data,
1796 1797 HBA_WWN hbaPortWWN,
1797 1798 HBA_WWN discoveredPortWWN,
1798 1799 HBA_UINT32 eventType) {
1799 1800 HBA_ADAPTERCALLBACK_ELEM *acbp;
1800 1801
1801 1802 DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
1802 1803 WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
1803 1804
1804 1805 GRAB_MUTEX(&_hbaapi_TE_mutex);
1805 1806 for(acbp = _hbaapi_targetevents_callback_list;
1806 1807 acbp != NULL;
1807 1808 acbp = acbp->next) {
1808 1809 if(data == (void *)acbp) {
1809 1810 (*acbp->callback)(acbp->userdata, hbaPortWWN,
1810 1811 discoveredPortWWN, eventType);
1811 1812 break;
1812 1813 }
1813 1814 }
1814 1815 RELEASE_MUTEX(&_hbaapi_TE_mutex);
1815 1816 }
1816 1817 HBA_STATUS
1817 1818 HBA_RegisterForTargetEvents (
1818 1819 void (*callback) (
1819 1820 void *data,
1820 1821 HBA_WWN hbaPortWWN,
1821 1822 HBA_WWN discoveredPortWWN,
1822 1823 HBA_UINT32 eventType
1823 1824 ),
1824 1825 void *userData,
1825 1826 HBA_HANDLE handle,
1826 1827 HBA_WWN hbaPortWWN,
1827 1828 HBA_WWN discoveredPortWWN,
1828 1829 HBA_CALLBACKHANDLE *callbackHandle,
1829 1830 HBA_UINT32 allTargets) {
1830 1831
1831 1832 HBA_ADAPTERCALLBACK_ELEM
1832 1833 *acbp;
1833 1834 HBARegisterForTargetEventsFunc
1834 1835 registeredfunc;
1835 1836 HBA_STATUS status;
1836 1837 HBA_LIBRARY_INFO *lib_infop;
1837 1838 HBA_HANDLE vendorHandle;
1838 1839
1839 1840 DEBUG(2, "HBA_RegisterForTargetEvents, hbaPort: %s, discoveredPort: %s",
1840 1841 WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
1841 1842
1842 1843 if (callbackHandle == NULL) {
1843 1844 return(HBA_STATUS_ERROR_ARG);
1844 1845 }
1845 1846
1846 1847 CHECKLIBRARY();
1847 1848 /* we now have the _hbaapi_LL_mutex */
1848 1849
1849 1850 registeredfunc = lib_infop->functionTable.RegisterForTargetEventsHandler;
1850 1851 if(registeredfunc == NULL) {
1851 1852 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1852 1853 }
1853 1854
1854 1855 /*
1855 1856 * that allocated memory is used both as the handle for the
1856 1857 * caller, and as userdata to the vendor call so that on
1857 1858 * callback the specific registration may be recalled
1858 1859 */
1859 1860 acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1860 1861 calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
1861 1862 if(acbp == NULL) {
1862 1863 #ifndef WIN32
1863 1864 fprintf(stderr,
1864 1865 "HBA_RegisterForTargetEvents: calloc failed for %d bytes\n",
1865 1866 sizeof(HBA_ADAPTERCALLBACK_ELEM));
1866 1867 #endif
1867 1868 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1868 1869 }
1869 1870 *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1870 1871 acbp->callback = callback;
1871 1872 acbp->userdata = userData;
1872 1873 acbp->lib_info = lib_infop;
1873 1874
1874 1875 status = (registeredfunc)(targetevents_callback,
1875 1876 (void *)acbp,
1876 1877 vendorHandle,
1877 1878 hbaPortWWN,
1878 1879 discoveredPortWWN,
1879 1880 &acbp->vendorcbhandle,
1880 1881 allTargets);
1881 1882 if(status != HBA_STATUS_OK) {
1882 1883 free(acbp);
1883 1884 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1884 1885 }
1885 1886
1886 1887 GRAB_MUTEX(&_hbaapi_TE_mutex);
1887 1888 acbp->next = _hbaapi_targetevents_callback_list;
1888 1889 _hbaapi_targetevents_callback_list = acbp;
1889 1890 RELEASE_MUTEX(&_hbaapi_TE_mutex);
1890 1891
1891 1892 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1892 1893 }
1893 1894
1894 1895 /* Link Events ****************************************************************/
1895 1896 static void
1896 1897 linkevents_callback (void *data,
1897 1898 HBA_WWN adapterWWN,
1898 1899 HBA_UINT32 eventType,
1899 1900 void *pRLIRBuffer,
1900 1901 HBA_UINT32 RLIRBufferSize) {
1901 1902 HBA_ADAPTERCALLBACK_ELEM *acbp;
1902 1903
1903 1904 DEBUG(3, "LinkEvent, hbaWWN:%s, eventType:%d",
1904 1905 WWN2STR1(&adapterWWN), eventType, 0);
1905 1906
1906 1907 GRAB_MUTEX(&_hbaapi_LE_mutex);
1907 1908 for(acbp = _hbaapi_linkevents_callback_list;
1908 1909 acbp != NULL;
1909 1910 acbp = acbp->next) {
1910 1911 if(data == (void *)acbp) {
1911 1912 (*acbp->callback)(acbp->userdata, adapterWWN,
1912 1913 eventType, pRLIRBuffer, RLIRBufferSize);
1913 1914 break;
1914 1915 }
1915 1916 }
1916 1917 RELEASE_MUTEX(&_hbaapi_LE_mutex);
1917 1918 }
1918 1919 HBA_STATUS
1919 1920 HBA_RegisterForLinkEvents (
1920 1921 void (*callback) (
1921 1922 void *data,
1922 1923 HBA_WWN adapterWWN,
1923 1924 HBA_UINT32 eventType,
1924 1925 void *pRLIRBuffer,
1925 1926 HBA_UINT32 RLIRBufferSize),
1926 1927 void *userData,
1927 1928 void *pRLIRBuffer,
1928 1929 HBA_UINT32 RLIRBufferSize,
1929 1930 HBA_HANDLE handle,
1930 1931 HBA_CALLBACKHANDLE *callbackHandle) {
1931 1932
1932 1933 HBA_ADAPTERCALLBACK_ELEM *acbp;
1933 1934 HBARegisterForLinkEventsFunc
1934 1935 registeredfunc;
1935 1936 HBA_STATUS status;
1936 1937 HBA_LIBRARY_INFO *lib_infop;
1937 1938 HBA_HANDLE vendorHandle;
1938 1939
1939 1940 DEBUG(2, "HBA_RegisterForLinkEvents", 0, 0, 0);
1940 1941
1941 1942 if (callbackHandle == NULL) {
1942 1943 return(HBA_STATUS_ERROR_ARG);
1943 1944 }
1944 1945
1945 1946 CHECKLIBRARY();
1946 1947 /* we now have the _hbaapi_LL_mutex */
1947 1948
1948 1949 registeredfunc = lib_infop->functionTable.RegisterForLinkEventsHandler;
1949 1950 if(registeredfunc == NULL) {
1950 1951 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
1951 1952 }
1952 1953
1953 1954 /*
1954 1955 * that allocated memory is used both as the handle for the
1955 1956 * caller, and as userdata to the vendor call so that on
1956 1957 * callback the specific registration may be recalled
1957 1958 */
1958 1959 acbp = (HBA_ADAPTERCALLBACK_ELEM *)
1959 1960 calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
1960 1961 if(acbp == NULL) {
1961 1962 #ifndef WIN32
1962 1963 fprintf(stderr,
1963 1964 "HBA_RegisterForLinkEvents: calloc failed for %d bytes\n",
1964 1965 sizeof(HBA_ADAPTERCALLBACK_ELEM));
1965 1966 #endif
1966 1967 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
1967 1968 }
1968 1969 *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
1969 1970 acbp->callback = callback;
1970 1971 acbp->userdata = userData;
1971 1972 acbp->lib_info = lib_infop;
1972 1973
1973 1974 status = (registeredfunc)(linkevents_callback,
1974 1975 (void *)acbp,
1975 1976 pRLIRBuffer,
1976 1977 RLIRBufferSize,
1977 1978 vendorHandle,
1978 1979 &acbp->vendorcbhandle);
1979 1980 if(status != HBA_STATUS_OK) {
1980 1981 free(acbp);
1981 1982 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
1982 1983 }
1983 1984
1984 1985 GRAB_MUTEX(&_hbaapi_LE_mutex);
1985 1986 acbp->next = _hbaapi_linkevents_callback_list;
1986 1987 _hbaapi_linkevents_callback_list = acbp;
1987 1988 RELEASE_MUTEX(&_hbaapi_LE_mutex);
1988 1989
1989 1990 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
1990 1991 }
1991 1992
1992 1993
1993 1994 /*
1994 1995 * All of the functions below are almost passthru functions to the
1995 1996 * vendor specific function
1996 1997 */
1997 1998
1998 1999 void
1999 2000 HBA_CloseAdapter(HBA_HANDLE handle) {
2000 2001 HBA_STATUS status;
2001 2002 HBA_LIBRARY_INFO *lib_infop;
2002 2003 HBA_HANDLE vendorHandle;
2003 2004 HBACloseAdapterFunc CloseAdapterFunc;
2004 2005
2005 2006 DEBUG(2, "HBA_CloseAdapter", 0, 0, 0);
2006 2007
2007 2008 status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2008 2009 if (status == HBA_STATUS_OK) {
2009 2010 CloseAdapterFunc = lib_infop->functionTable.CloseAdapterHandler;
2010 2011 if (CloseAdapterFunc != NULL) {
2011 2012 ((CloseAdapterFunc)(vendorHandle));
2012 2013 }
2013 2014 RELEASE_MUTEX(&_hbaapi_LL_mutex);
2014 2015 }
2015 2016 }
2016 2017
2017 2018 HBA_STATUS
2018 2019 HBA_GetAdapterAttributes (
2019 2020 HBA_HANDLE handle,
2020 2021 HBA_ADAPTERATTRIBUTES
2021 2022 *hbaattributes)
2022 2023 {
2023 2024 HBA_STATUS status;
2024 2025 HBA_LIBRARY_INFO *lib_infop;
2025 2026 HBA_HANDLE vendorHandle;
2026 2027 HBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
2027 2028
2028 2029 DEBUG(2, "HBA_GetAdapterAttributes", 0, 0, 0);
2029 2030
2030 2031 CHECKLIBRARY();
2031 2032 GetAdapterAttributesFunc =
2032 2033 lib_infop->functionTable.GetAdapterAttributesHandler;
2033 2034 if (GetAdapterAttributesFunc != NULL) {
2034 2035 status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
2035 2036 } else {
2036 2037 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2037 2038 }
2038 2039 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2039 2040 }
2040 2041
2041 2042 HBA_STATUS
2042 2043 HBA_GetAdapterPortAttributes (
2043 2044 HBA_HANDLE handle,
2044 2045 HBA_UINT32 portindex,
2045 2046 HBA_PORTATTRIBUTES *portattributes)
2046 2047 {
2047 2048 HBA_STATUS status;
2048 2049 HBA_LIBRARY_INFO *lib_infop;
2049 2050 HBA_HANDLE vendorHandle;
2050 2051 HBAGetAdapterPortAttributesFunc
2051 2052 GetAdapterPortAttributesFunc;
2052 2053
2053 2054 DEBUG(2, "HBA_GetAdapterPortAttributes", 0, 0, 0);
2054 2055
2055 2056 CHECKLIBRARY();
2056 2057 GetAdapterPortAttributesFunc =
2057 2058 lib_infop->functionTable.GetAdapterPortAttributesHandler;
2058 2059 if (GetAdapterPortAttributesFunc != NULL) {
2059 2060 status = ((GetAdapterPortAttributesFunc)
2060 2061 (vendorHandle, portindex, portattributes));
2061 2062 } else {
2062 2063 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2063 2064 }
2064 2065 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2065 2066 }
2066 2067
2067 2068 HBA_STATUS
2068 2069 HBA_GetPortStatistics (
2069 2070 HBA_HANDLE handle,
2070 2071 HBA_UINT32 portindex,
2071 2072 HBA_PORTSTATISTICS *portstatistics)
2072 2073 {
2073 2074 HBA_STATUS status;
2074 2075 HBA_LIBRARY_INFO *lib_infop;
2075 2076 HBA_HANDLE vendorHandle;
2076 2077 HBAGetPortStatisticsFunc
2077 2078 GetPortStatisticsFunc;
2078 2079
2079 2080 DEBUG(2, "HBA_GetPortStatistics", 0, 0, 0);
2080 2081
2081 2082 CHECKLIBRARY();
2082 2083 GetPortStatisticsFunc =
2083 2084 lib_infop->functionTable.GetPortStatisticsHandler;
2084 2085 if (GetPortStatisticsFunc != NULL) {
2085 2086 status = ((GetPortStatisticsFunc)
2086 2087 (vendorHandle, portindex, portstatistics));
2087 2088 } else {
2088 2089 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2089 2090 }
2090 2091 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2091 2092 }
2092 2093
2093 2094 HBA_STATUS
2094 2095 HBA_GetDiscoveredPortAttributes (
2095 2096 HBA_HANDLE handle,
2096 2097 HBA_UINT32 portindex,
2097 2098 HBA_UINT32 discoveredportindex,
2098 2099 HBA_PORTATTRIBUTES *portattributes)
2099 2100 {
2100 2101 HBA_STATUS status;
2101 2102 HBA_LIBRARY_INFO *lib_infop;
2102 2103 HBA_HANDLE vendorHandle;
2103 2104 HBAGetDiscoveredPortAttributesFunc
2104 2105 GetDiscoveredPortAttributesFunc;
2105 2106
2106 2107 DEBUG(2, "HBA_GetDiscoveredPortAttributes", 0, 0, 0);
2107 2108
2108 2109 CHECKLIBRARY();
2109 2110 GetDiscoveredPortAttributesFunc =
2110 2111 lib_infop->functionTable.GetDiscoveredPortAttributesHandler;
2111 2112 if (GetDiscoveredPortAttributesFunc != NULL) {
2112 2113 status = ((GetDiscoveredPortAttributesFunc)
2113 2114 (vendorHandle, portindex, discoveredportindex,
2114 2115 portattributes));
2115 2116 } else {
2116 2117 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2117 2118 }
2118 2119 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2119 2120 }
2120 2121
2121 2122 HBA_STATUS
2122 2123 HBA_GetPortAttributesByWWN (
2123 2124 HBA_HANDLE handle,
2124 2125 HBA_WWN PortWWN,
2125 2126 HBA_PORTATTRIBUTES *portattributes)
2126 2127 {
2127 2128 HBA_STATUS status;
2128 2129 HBA_LIBRARY_INFO *lib_infop;
2129 2130 HBA_HANDLE vendorHandle;
2130 2131 HBAGetPortAttributesByWWNFunc
2131 2132 GetPortAttributesByWWNFunc;
2132 2133
2133 2134 DEBUG(2, "HBA_GetPortAttributesByWWN: %s", WWN2STR1(&PortWWN), 0, 0);
2134 2135
2135 2136 CHECKLIBRARY();
2136 2137 GetPortAttributesByWWNFunc =
2137 2138 lib_infop->functionTable.GetPortAttributesByWWNHandler;
2138 2139 if (GetPortAttributesByWWNFunc != NULL) {
2139 2140 status = ((GetPortAttributesByWWNFunc)
2140 2141 (vendorHandle, PortWWN, portattributes));
2141 2142 } else {
2142 2143 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2143 2144 }
2144 2145 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2145 2146 }
2146 2147
2147 2148 HBA_STATUS
2148 2149 HBA_SendCTPassThru (
2149 2150 HBA_HANDLE handle,
2150 2151 void *pReqBuffer,
2151 2152 HBA_UINT32 ReqBufferSize,
2152 2153 void *pRspBuffer,
2153 2154 HBA_UINT32 RspBufferSize)
2154 2155 {
2155 2156 HBA_STATUS status;
2156 2157 HBA_LIBRARY_INFO *lib_infop;
2157 2158 HBA_HANDLE vendorHandle;
2158 2159 HBASendCTPassThruFunc
2159 2160 SendCTPassThruFunc;
2160 2161
2161 2162 DEBUG(2, "HBA_SendCTPassThru", 0, 0, 0);
2162 2163
2163 2164 CHECKLIBRARY();
2164 2165 SendCTPassThruFunc = lib_infop->functionTable.SendCTPassThruHandler;
2165 2166 if (SendCTPassThruFunc != NULL) {
2166 2167 status = (SendCTPassThruFunc)
2167 2168 (vendorHandle,
2168 2169 pReqBuffer, ReqBufferSize,
2169 2170 pRspBuffer, RspBufferSize);
2170 2171 } else {
2171 2172 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2172 2173 }
2173 2174 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2174 2175 }
2175 2176
2176 2177 HBA_STATUS
2177 2178 HBA_SendCTPassThruV2 (
2178 2179 HBA_HANDLE handle,
2179 2180 HBA_WWN hbaPortWWN,
2180 2181 void *pReqBuffer,
2181 2182 HBA_UINT32 ReqBufferSize,
2182 2183 void *pRspBuffer,
2183 2184 HBA_UINT32 *pRspBufferSize)
2184 2185 {
2185 2186 HBA_STATUS status;
2186 2187 HBA_LIBRARY_INFO *lib_infop;
2187 2188 HBA_HANDLE vendorHandle;
2188 2189 HBASendCTPassThruV2Func
2189 2190 registeredfunc;
2190 2191
2191 2192 DEBUG(2, "HBA_SendCTPassThruV2m hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
2192 2193
2193 2194 CHECKLIBRARY();
2194 2195 registeredfunc = lib_infop->functionTable.SendCTPassThruV2Handler;
2195 2196 if (registeredfunc != NULL) {
2196 2197 status = (registeredfunc)
2197 2198 (vendorHandle, hbaPortWWN,
2198 2199 pReqBuffer, ReqBufferSize,
2199 2200 pRspBuffer, pRspBufferSize);
2200 2201 } else {
2201 2202 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2202 2203 }
2203 2204 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2204 2205 }
2205 2206
2206 2207 HBA_STATUS
2207 2208 HBA_GetEventBuffer (
2208 2209 HBA_HANDLE handle,
2209 2210 PHBA_EVENTINFO EventBuffer,
2210 2211 HBA_UINT32 *EventBufferCount)
2211 2212 {
2212 2213 HBA_STATUS status;
2213 2214 HBA_LIBRARY_INFO *lib_infop;
2214 2215 HBA_HANDLE vendorHandle;
2215 2216 HBAGetEventBufferFunc
2216 2217 GetEventBufferFunc;
2217 2218
2218 2219 DEBUG(2, "HBA_GetEventBuffer", 0, 0, 0);
2219 2220
2220 2221 CHECKLIBRARY();
2221 2222 GetEventBufferFunc = lib_infop->functionTable.GetEventBufferHandler;
2222 2223 if (GetEventBufferFunc != NULL) {
2223 2224 status = (GetEventBufferFunc)
2224 2225 (vendorHandle, EventBuffer, EventBufferCount);
2225 2226 } else {
2226 2227 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2227 2228 }
2228 2229 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2229 2230 }
2230 2231
2231 2232 HBA_STATUS
2232 2233 HBA_SetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO Info) {
2233 2234 HBA_STATUS status;
2234 2235 HBA_LIBRARY_INFO *lib_infop;
2235 2236 HBA_HANDLE vendorHandle;
2236 2237 HBASetRNIDMgmtInfoFunc
2237 2238 SetRNIDMgmtInfoFunc;
2238 2239
2239 2240 DEBUG(2, "HBA_SetRNIDMgmtInfo", 0, 0, 0);
2240 2241
2241 2242 CHECKLIBRARY();
2242 2243 SetRNIDMgmtInfoFunc = lib_infop->functionTable.SetRNIDMgmtInfoHandler;
2243 2244 if (SetRNIDMgmtInfoFunc != NULL) {
2244 2245 status = (SetRNIDMgmtInfoFunc)(vendorHandle, Info);
2245 2246 } else {
2246 2247 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2247 2248 }
2248 2249 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2249 2250 }
2250 2251
2251 2252 HBA_STATUS
2252 2253 HBA_GetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *pInfo) {
2253 2254 HBA_STATUS status;
2254 2255 HBA_LIBRARY_INFO *lib_infop;
2255 2256 HBA_HANDLE vendorHandle;
2256 2257 HBAGetRNIDMgmtInfoFunc
2257 2258 GetRNIDMgmtInfoFunc;
2258 2259
2259 2260 DEBUG(2, "HBA_GetRNIDMgmtInfo", 0, 0, 0);
2260 2261
2261 2262 CHECKLIBRARY();
2262 2263 GetRNIDMgmtInfoFunc = lib_infop->functionTable.GetRNIDMgmtInfoHandler;
2263 2264 if (GetRNIDMgmtInfoFunc != NULL) {
2264 2265 status = (GetRNIDMgmtInfoFunc)(vendorHandle, pInfo);
2265 2266 } else {
2266 2267 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2267 2268 }
2268 2269 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2269 2270 }
2270 2271
2271 2272 HBA_STATUS
2272 2273 HBA_SendRNID (
2273 2274 HBA_HANDLE handle,
2274 2275 HBA_WWN wwn,
2275 2276 HBA_WWNTYPE wwntype,
2276 2277 void *pRspBuffer,
2277 2278 HBA_UINT32 *pRspBufferSize)
2278 2279 {
2279 2280 HBA_STATUS status;
2280 2281 HBA_LIBRARY_INFO *lib_infop;
2281 2282 HBA_HANDLE vendorHandle;
2282 2283 HBASendRNIDFunc SendRNIDFunc;
2283 2284
2284 2285 DEBUG(2, "HBA_SendRNID for wwn: %s", WWN2STR1(&wwn), 0, 0);
2285 2286
2286 2287 CHECKLIBRARY();
2287 2288 SendRNIDFunc = lib_infop->functionTable.SendRNIDHandler;
2288 2289 if (SendRNIDFunc != NULL) {
2289 2290 status = ((SendRNIDFunc)(vendorHandle, wwn, wwntype,
2290 2291 pRspBuffer, pRspBufferSize));
2291 2292 } else {
2292 2293 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2293 2294 }
2294 2295 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2295 2296 }
2296 2297
2297 2298 HBA_STATUS
2298 2299 HBA_SendRNIDV2(
2299 2300 HBA_HANDLE handle,
2300 2301 HBA_WWN hbaPortWWN,
2301 2302 HBA_WWN destWWN,
2302 2303 HBA_UINT32 destFCID,
2303 2304 HBA_UINT32 NodeIdDataFormat,
2304 2305 void *pRspBuffer,
2305 2306 HBA_UINT32 *pRspBufferSize)
2306 2307 {
2307 2308 HBA_STATUS status;
2308 2309 HBA_LIBRARY_INFO *lib_infop;
2309 2310 HBA_HANDLE vendorHandle;
2310 2311 HBASendRNIDV2Func registeredfunc;
2311 2312
2312 2313 DEBUG(2, "HBA_SendRNIDV2, hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
2313 2314
2314 2315 CHECKLIBRARY();
2315 2316 registeredfunc = lib_infop->functionTable.SendRNIDV2Handler;
2316 2317 if (registeredfunc != NULL) {
2317 2318 status = (registeredfunc)
2318 2319 (vendorHandle, hbaPortWWN, destWWN, destFCID, NodeIdDataFormat,
2319 2320 pRspBuffer, pRspBufferSize);
2320 2321 } else {
2321 2322 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2322 2323 }
2323 2324 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2324 2325 }
2325 2326
2326 2327 void
2327 2328 HBA_RefreshInformation (HBA_HANDLE handle) {
2328 2329 HBA_STATUS status;
2329 2330 HBA_LIBRARY_INFO *lib_infop;
2330 2331 HBA_HANDLE vendorHandle;
2331 2332 HBARefreshInformationFunc
2332 2333 RefreshInformationFunc;
2333 2334
2334 2335 DEBUG(2, "HBA_RefreshInformation", 0, 0, 0);
2335 2336
2336 2337 status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2337 2338 if(status == HBA_STATUS_OK) {
2338 2339 RefreshInformationFunc =
2339 2340 lib_infop->functionTable.RefreshInformationHandler;
2340 2341 if (RefreshInformationFunc != NULL) {
2341 2342 ((RefreshInformationFunc)(vendorHandle));
2342 2343 }
2343 2344 RELEASE_MUTEX(&_hbaapi_LL_mutex);
2344 2345 }
2345 2346 }
2346 2347
2347 2348 void
2348 2349 HBA_ResetStatistics (HBA_HANDLE handle, HBA_UINT32 portindex) {
2349 2350 HBA_STATUS status;
2350 2351 HBA_LIBRARY_INFO *lib_infop;
2351 2352 HBA_HANDLE vendorHandle;
2352 2353 HBAResetStatisticsFunc
2353 2354 ResetStatisticsFunc;
2354 2355
2355 2356 DEBUG(2, "HBA_ResetStatistics", 0, 0, 0);
2356 2357
2357 2358 status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
2358 2359 if(status == HBA_STATUS_OK) {
2359 2360 ResetStatisticsFunc = lib_infop->functionTable.ResetStatisticsHandler;
2360 2361 if (ResetStatisticsFunc != NULL) {
2361 2362 ((ResetStatisticsFunc)(vendorHandle, portindex));
2362 2363 }
2363 2364 RELEASE_MUTEX(&_hbaapi_LL_mutex);
2364 2365 }
2365 2366 }
2366 2367
2367 2368 HBA_STATUS
2368 2369 HBA_GetFcpTargetMapping (HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) {
2369 2370 HBA_STATUS status;
2370 2371 HBA_LIBRARY_INFO *lib_infop;
2371 2372 HBA_HANDLE vendorHandle;
2372 2373 HBAGetFcpTargetMappingFunc GetFcpTargetMappingFunc;
2373 2374
2374 2375 DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
2375 2376
2376 2377 CHECKLIBRARY();
2377 2378 GetFcpTargetMappingFunc =
2378 2379 lib_infop->functionTable.GetFcpTargetMappingHandler;
2379 2380 if (GetFcpTargetMappingFunc != NULL) {
2380 2381 status = ((GetFcpTargetMappingFunc)(vendorHandle, mapping));
2381 2382 } else {
2382 2383 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2383 2384 }
2384 2385 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2385 2386 }
2386 2387
2387 2388 HBA_STATUS
2388 2389 HBA_GetFcpTargetMappingV2 (
2389 2390 HBA_HANDLE handle,
2390 2391 HBA_WWN hbaPortWWN,
2391 2392 HBA_FCPTARGETMAPPINGV2
2392 2393 *pmapping)
2393 2394 {
2394 2395 HBA_STATUS status;
2395 2396 HBA_LIBRARY_INFO *lib_infop;
2396 2397 HBA_HANDLE vendorHandle;
2397 2398 HBAGetFcpTargetMappingV2Func
2398 2399 registeredfunc;
2399 2400
2400 2401 DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
2401 2402
2402 2403 CHECKLIBRARY();
2403 2404 registeredfunc =
2404 2405 lib_infop->functionTable.GetFcpTargetMappingV2Handler;
2405 2406 if (registeredfunc != NULL) {
2406 2407 status = ((registeredfunc)(vendorHandle, hbaPortWWN, pmapping));
2407 2408 } else {
2408 2409 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2409 2410 }
2410 2411 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2411 2412 }
2412 2413
2413 2414 HBA_STATUS
2414 2415 HBA_GetFcpPersistentBinding (HBA_HANDLE handle, PHBA_FCPBINDING binding) {
2415 2416 HBA_STATUS status;
2416 2417 HBA_LIBRARY_INFO *lib_infop;
2417 2418 HBA_HANDLE vendorHandle;
2418 2419 HBAGetFcpPersistentBindingFunc
2419 2420 GetFcpPersistentBindingFunc;
2420 2421
2421 2422 DEBUG(2, "HBA_GetFcpPersistentBinding", 0, 0, 0);
2422 2423
2423 2424 CHECKLIBRARY();
2424 2425 GetFcpPersistentBindingFunc =
2425 2426 lib_infop->functionTable.GetFcpPersistentBindingHandler;
2426 2427 if (GetFcpPersistentBindingFunc != NULL) {
2427 2428 status = ((GetFcpPersistentBindingFunc)(vendorHandle, binding));
2428 2429 } else {
2429 2430 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2430 2431 }
2431 2432 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2432 2433 }
2433 2434
2434 2435 HBA_STATUS
2435 2436 HBA_ScsiInquiryV2 (
2436 2437 HBA_HANDLE handle,
2437 2438 HBA_WWN hbaPortWWN,
2438 2439 HBA_WWN discoveredPortWWN,
2439 2440 HBA_UINT64 fcLUN,
2440 2441 HBA_UINT8 CDB_Byte1,
2441 2442 HBA_UINT8 CDB_Byte2,
2442 2443 void *pRspBuffer,
2443 2444 HBA_UINT32 *pRspBufferSize,
2444 2445 HBA_UINT8 *pScsiStatus,
2445 2446 void *pSenseBuffer,
2446 2447 HBA_UINT32 *pSenseBufferSize)
2447 2448 {
2448 2449 HBA_STATUS status;
2449 2450 HBA_LIBRARY_INFO *lib_infop;
2450 2451 HBA_HANDLE vendorHandle;
2451 2452 HBAScsiInquiryV2Func ScsiInquiryV2Func;
2452 2453
2453 2454 DEBUG(2, "HBA_ScsiInquiryV2 to discoveredPortWWN: %s",
2454 2455 WWN2STR1(&discoveredPortWWN), 0, 0);
2455 2456
2456 2457 CHECKLIBRARY();
2457 2458 ScsiInquiryV2Func =
2458 2459 lib_infop->functionTable.ScsiInquiryV2Handler;
2459 2460 if (ScsiInquiryV2Func != NULL) {
2460 2461 status =((ScsiInquiryV2Func)(
2461 2462 vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, CDB_Byte1,
2462 2463 CDB_Byte2, pRspBuffer, pRspBufferSize, pScsiStatus,
2463 2464 pSenseBuffer, pSenseBufferSize));
2464 2465 } else {
2465 2466 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2466 2467 }
2467 2468 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2468 2469 }
2469 2470
2470 2471 HBA_STATUS
2471 2472 HBA_SendScsiInquiry (
2472 2473 HBA_HANDLE handle,
2473 2474 HBA_WWN PortWWN,
2474 2475 HBA_UINT64 fcLUN,
2475 2476 HBA_UINT8 EVPD,
2476 2477 HBA_UINT32 PageCode,
2477 2478 void *pRspBuffer,
2478 2479 HBA_UINT32 RspBufferSize,
2479 2480 void *pSenseBuffer,
2480 2481 HBA_UINT32 SenseBufferSize)
2481 2482 {
2482 2483 HBA_STATUS status;
2483 2484 HBA_LIBRARY_INFO *lib_infop;
2484 2485 HBA_HANDLE vendorHandle;
2485 2486 HBASendScsiInquiryFunc SendScsiInquiryFunc;
2486 2487
2487 2488 DEBUG(2, "HBA_SendScsiInquiry to PortWWN: %s", WWN2STR1(&PortWWN), 0, 0);
2488 2489
2489 2490 CHECKLIBRARY();
2490 2491 SendScsiInquiryFunc = lib_infop->functionTable.ScsiInquiryHandler;
2491 2492 if (SendScsiInquiryFunc != NULL) {
2492 2493 status =((SendScsiInquiryFunc)(
2493 2494 vendorHandle, PortWWN, fcLUN, EVPD, PageCode, pRspBuffer,
2494 2495 RspBufferSize, pSenseBuffer, SenseBufferSize));
2495 2496 } else {
2496 2497 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2497 2498 }
2498 2499 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2499 2500 }
2500 2501
2501 2502 HBA_STATUS
2502 2503 HBA_ScsiReportLUNsV2 (
2503 2504 HBA_HANDLE handle,
2504 2505 HBA_WWN hbaPortWWN,
2505 2506 HBA_WWN discoveredPortWWN,
2506 2507 void *pRespBuffer,
2507 2508 HBA_UINT32 *pRespBufferSize,
2508 2509 HBA_UINT8 *pScsiStatus,
2509 2510 void *pSenseBuffer,
2510 2511 HBA_UINT32 *pSenseBufferSize)
2511 2512 {
2512 2513 HBA_STATUS status;
2513 2514 HBA_LIBRARY_INFO *lib_infop;
2514 2515 HBA_HANDLE vendorHandle;
2515 2516 HBAScsiReportLUNsV2Func ScsiReportLUNsV2Func;
2516 2517
2517 2518 DEBUG(2, "HBA_ScsiReportLUNsV2 to discoveredPortWWN: %s",
2518 2519 WWN2STR1(&discoveredPortWWN), 0, 0);
2519 2520
2520 2521 CHECKLIBRARY();
2521 2522 ScsiReportLUNsV2Func = lib_infop->functionTable.ScsiReportLUNsV2Handler;
2522 2523 if (ScsiReportLUNsV2Func != NULL) {
2523 2524 status = ((ScsiReportLUNsV2Func)(
2524 2525 vendorHandle, hbaPortWWN, discoveredPortWWN,
2525 2526 pRespBuffer, pRespBufferSize,
2526 2527 pScsiStatus,
2527 2528 pSenseBuffer, pSenseBufferSize));
2528 2529 } else {
2529 2530 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2530 2531 }
2531 2532 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2532 2533 }
2533 2534
2534 2535 HBA_STATUS
2535 2536 HBA_SendReportLUNs (
2536 2537 HBA_HANDLE handle,
2537 2538 HBA_WWN portWWN,
2538 2539 void *pRspBuffer,
2539 2540 HBA_UINT32 RspBufferSize,
2540 2541 void *pSenseBuffer,
2541 2542 HBA_UINT32 SenseBufferSize)
2542 2543 {
2543 2544 HBA_STATUS status;
2544 2545 HBA_LIBRARY_INFO *lib_infop;
2545 2546 HBA_HANDLE vendorHandle;
2546 2547 HBASendReportLUNsFunc SendReportLUNsFunc;
2547 2548
2548 2549 DEBUG(2, "HBA_SendReportLUNs to PortWWN: %s", WWN2STR1(&portWWN), 0, 0);
2549 2550
2550 2551 CHECKLIBRARY();
2551 2552 SendReportLUNsFunc = lib_infop->functionTable.ReportLUNsHandler;
2552 2553 if (SendReportLUNsFunc != NULL) {
2553 2554 status = ((SendReportLUNsFunc)(
2554 2555 vendorHandle, portWWN, pRspBuffer,
2555 2556 RspBufferSize, pSenseBuffer, SenseBufferSize));
2556 2557 } else {
2557 2558 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2558 2559 }
2559 2560 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2560 2561 }
2561 2562
2562 2563 HBA_STATUS
2563 2564 HBA_ScsiReadCapacityV2 (
2564 2565 HBA_HANDLE handle,
2565 2566 HBA_WWN hbaPortWWN,
2566 2567 HBA_WWN discoveredPortWWN,
2567 2568 HBA_UINT64 fcLUN,
2568 2569 void *pRspBuffer,
2569 2570 HBA_UINT32 *pRspBufferSize,
2570 2571 HBA_UINT8 *pScsiStatus,
2571 2572 void *pSenseBuffer,
2572 2573 HBA_UINT32 *SenseBufferSize)
2573 2574 {
2574 2575 HBA_STATUS status;
2575 2576 HBA_LIBRARY_INFO *lib_infop;
2576 2577 HBA_HANDLE vendorHandle;
2577 2578 HBAScsiReadCapacityV2Func ScsiReadCapacityV2Func;
2578 2579
2579 2580 DEBUG(2, "HBA_ScsiReadCapacityV2 to discoveredPortWWN: %s",
2580 2581 WWN2STR1(&discoveredPortWWN), 0, 0);
2581 2582
2582 2583 CHECKLIBRARY();
2583 2584 ScsiReadCapacityV2Func =
2584 2585 lib_infop->functionTable.ScsiReadCapacityV2Handler;
2585 2586 if (ScsiReadCapacityV2Func != NULL) {
2586 2587 status =((ScsiReadCapacityV2Func)(
2587 2588 vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN,
2588 2589 pRspBuffer, pRspBufferSize,
2589 2590 pScsiStatus,
2590 2591 pSenseBuffer, SenseBufferSize));
2591 2592 } else {
2592 2593 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2593 2594 }
2594 2595 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2595 2596 }
2596 2597
2597 2598 HBA_STATUS
2598 2599 HBA_SendReadCapacity (
2599 2600 HBA_HANDLE handle,
2600 2601 HBA_WWN portWWN,
2601 2602 HBA_UINT64 fcLUN,
2602 2603 void *pRspBuffer,
2603 2604 HBA_UINT32 RspBufferSize,
2604 2605 void *pSenseBuffer,
2605 2606 HBA_UINT32 SenseBufferSize)
2606 2607 {
2607 2608 HBA_STATUS status;
2608 2609 HBA_LIBRARY_INFO *lib_infop;
2609 2610 HBA_HANDLE vendorHandle;
2610 2611 HBASendReadCapacityFunc SendReadCapacityFunc;
2611 2612
2612 2613 DEBUG(2, "HBA_SendReadCapacity to portWWN: %s", WWN2STR1(&portWWN), 0, 0);
2613 2614
2614 2615 CHECKLIBRARY();
2615 2616 SendReadCapacityFunc = lib_infop->functionTable.ReadCapacityHandler;
2616 2617 if (SendReadCapacityFunc != NULL) {
2617 2618 status =((SendReadCapacityFunc)
2618 2619 (vendorHandle, portWWN, fcLUN, pRspBuffer,
2619 2620 RspBufferSize, pSenseBuffer, SenseBufferSize));
2620 2621 } else {
2621 2622 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2622 2623 }
2623 2624 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2624 2625 }
2625 2626
2626 2627 HBA_STATUS
2627 2628 HBA_SendRLS (
2628 2629 HBA_HANDLE handle,
2629 2630 HBA_WWN hbaPortWWN,
2630 2631 HBA_WWN destWWN,
2631 2632 void *pRspBuffer,
2632 2633 HBA_UINT32 *pRspBufferSize)
2633 2634 {
2634 2635 HBA_STATUS status;
2635 2636 HBA_LIBRARY_INFO *lib_infop;
2636 2637 HBA_HANDLE vendorHandle;
2637 2638 HBASendRLSFunc registeredfunc;
2638 2639
2639 2640 DEBUG(2, "HBA_SendRLS to agent_wwn: %s:%d",
2640 2641 WWN2STR1(&agent_wwn), agent_domain, 0);
2641 2642
2642 2643 CHECKLIBRARY();
2643 2644 registeredfunc = lib_infop->functionTable.SendRLSHandler;
2644 2645 if (registeredfunc != NULL) {
2645 2646 status =(registeredfunc)(
2646 2647 vendorHandle, hbaPortWWN, destWWN, pRspBuffer, pRspBufferSize);
2647 2648 } else {
2648 2649 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2649 2650 }
2650 2651 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2651 2652 }
2652 2653
2653 2654 HBA_STATUS
2654 2655 HBA_SendRPL (
2655 2656 HBA_HANDLE handle,
2656 2657 HBA_WWN hbaPortWWN,
2657 2658 HBA_WWN agent_wwn,
2658 2659 HBA_UINT32 agent_domain,
2659 2660 HBA_UINT32 portindex,
2660 2661 void *pRspBuffer,
2661 2662 HBA_UINT32 *pRspBufferSize)
2662 2663 {
2663 2664 HBA_STATUS status;
2664 2665 HBA_LIBRARY_INFO *lib_infop;
2665 2666 HBA_HANDLE vendorHandle;
2666 2667 HBASendRPLFunc registeredfunc;
2667 2668
2668 2669 DEBUG(2, "HBA_SendRPL to agent_wwn: %s:%d",
2669 2670 WWN2STR1(&agent_wwn), agent_domain, 0);
2670 2671
2671 2672 CHECKLIBRARY();
2672 2673 registeredfunc = lib_infop->functionTable.SendRPLHandler;
2673 2674 if (registeredfunc != NULL) {
2674 2675 status =(registeredfunc)(
2675 2676 vendorHandle, hbaPortWWN, agent_wwn, agent_domain, portindex,
2676 2677 pRspBuffer, pRspBufferSize);
2677 2678 } else {
2678 2679 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2679 2680 }
2680 2681 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2681 2682 }
2682 2683
2683 2684 HBA_STATUS
2684 2685 HBA_SendRPS (
2685 2686 HBA_HANDLE handle,
2686 2687 HBA_WWN hbaPortWWN,
2687 2688 HBA_WWN agent_wwn,
2688 2689 HBA_UINT32 agent_domain,
2689 2690 HBA_WWN object_wwn,
2690 2691 HBA_UINT32 object_port_number,
2691 2692 void *pRspBuffer,
2692 2693 HBA_UINT32 *pRspBufferSize)
2693 2694 {
2694 2695 HBA_STATUS status;
2695 2696 HBA_LIBRARY_INFO *lib_infop;
2696 2697 HBA_HANDLE vendorHandle;
2697 2698 HBASendRPSFunc registeredfunc;
2698 2699
2699 2700 DEBUG(2, "HBA_SendRPS to agent_wwn: %s:%d",
2700 2701 WWN2STR1(&agent_wwn), agent_domain, 0);
2701 2702
2702 2703 CHECKLIBRARY();
2703 2704 registeredfunc = lib_infop->functionTable.SendRPSHandler;
2704 2705 if (registeredfunc != NULL) {
2705 2706 status =(registeredfunc)(
2706 2707 vendorHandle, hbaPortWWN, agent_wwn, agent_domain,
2707 2708 object_wwn, object_port_number,
2708 2709 pRspBuffer, pRspBufferSize);
2709 2710 } else {
2710 2711 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2711 2712 }
2712 2713 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2713 2714 }
2714 2715
2715 2716 HBA_STATUS
2716 2717 HBA_SendSRL (
2717 2718 HBA_HANDLE handle,
2718 2719 HBA_WWN hbaPortWWN,
2719 2720 HBA_WWN wwn,
2720 2721 HBA_UINT32 domain,
2721 2722 void *pRspBuffer,
2722 2723 HBA_UINT32 *pRspBufferSize)
2723 2724 {
2724 2725 HBA_STATUS status;
2725 2726 HBA_LIBRARY_INFO *lib_infop;
2726 2727 HBA_HANDLE vendorHandle;
2727 2728 HBASendSRLFunc registeredfunc;
2728 2729
2729 2730 DEBUG(2, "HBA_SendSRL to wwn:%s domain:%d", WWN2STR1(&wwn), domain, 0);
2730 2731
2731 2732 CHECKLIBRARY();
2732 2733 registeredfunc = lib_infop->functionTable.SendSRLHandler;
2733 2734 if (registeredfunc != NULL) {
2734 2735 status =(registeredfunc)(
2735 2736 vendorHandle, hbaPortWWN, wwn, domain,
2736 2737 pRspBuffer, pRspBufferSize);
2737 2738 } else {
2738 2739 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2739 2740 }
2740 2741 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2741 2742 }
2742 2743
2743 2744 HBA_STATUS
2744 2745 HBA_SendLIRR (
2745 2746 HBA_HANDLE handle,
2746 2747 HBA_WWN sourceWWN,
2747 2748 HBA_WWN destWWN,
2748 2749 HBA_UINT8 function,
2749 2750 HBA_UINT8 type,
2750 2751 void *pRspBuffer,
2751 2752 HBA_UINT32 *pRspBufferSize)
2752 2753 {
2753 2754 HBA_STATUS status;
2754 2755 HBA_LIBRARY_INFO *lib_infop;
2755 2756 HBA_HANDLE vendorHandle;
2756 2757 HBASendLIRRFunc registeredfunc;
2757 2758
2758 2759 DEBUG(2, "HBA_SendLIRR destWWN:%s", WWN2STR1(&destWWN), 0, 0);
2759 2760
2760 2761 CHECKLIBRARY();
2761 2762 registeredfunc = lib_infop->functionTable.SendLIRRHandler;
2762 2763 if (registeredfunc != NULL) {
2763 2764 status =(registeredfunc)(
2764 2765 vendorHandle, sourceWWN, destWWN, function, type,
2765 2766 pRspBuffer, pRspBufferSize);
2766 2767 } else {
2767 2768 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2768 2769 }
2769 2770 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2770 2771 }
2771 2772
2772 2773 HBA_STATUS
2773 2774 HBA_GetBindingCapability(
2774 2775 HBA_HANDLE handle,
2775 2776 HBA_WWN hbaPortWWN,
2776 2777 HBA_BIND_CAPABILITY *pcapability)
2777 2778 {
2778 2779 HBA_STATUS status;
2779 2780 HBA_LIBRARY_INFO *lib_infop;
2780 2781 HBA_HANDLE vendorHandle;
2781 2782 HBAGetBindingCapabilityFunc
2782 2783 registeredfunc;
2783 2784
2784 2785 DEBUG(2, "HBA_GetBindingCapability", 0, 0, 0);
2785 2786
2786 2787 CHECKLIBRARY();
2787 2788 registeredfunc = lib_infop->functionTable.GetBindingCapabilityHandler;
2788 2789 if (registeredfunc != NULL) {
2789 2790 status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
2790 2791 } else {
2791 2792 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2792 2793 }
2793 2794 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2794 2795 }
2795 2796
2796 2797 HBA_STATUS
2797 2798 HBA_GetBindingSupport (
2798 2799 HBA_HANDLE handle,
2799 2800 HBA_WWN hbaPortWWN,
2800 2801 HBA_BIND_CAPABILITY *pcapability)
2801 2802 {
2802 2803 HBA_STATUS status;
2803 2804 HBA_LIBRARY_INFO *lib_infop;
2804 2805 HBA_HANDLE vendorHandle;
2805 2806 HBAGetBindingSupportFunc
2806 2807 registeredfunc;
2807 2808
2808 2809 DEBUG(2, "HBA_GetBindingSupport", 0, 0, 0);
2809 2810
2810 2811 CHECKLIBRARY();
2811 2812 registeredfunc = lib_infop->functionTable.GetBindingSupportHandler;
2812 2813 if (registeredfunc != NULL) {
2813 2814 status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
2814 2815 } else {
2815 2816 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2816 2817 }
2817 2818 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2818 2819 }
2819 2820
2820 2821 HBA_STATUS
2821 2822 HBA_SetBindingSupport(
2822 2823 HBA_HANDLE handle,
2823 2824 HBA_WWN hbaPortWWN,
2824 2825 HBA_BIND_CAPABILITY capability)
2825 2826 {
2826 2827 HBA_STATUS status;
2827 2828 HBA_LIBRARY_INFO *lib_infop;
2828 2829 HBA_HANDLE vendorHandle;
2829 2830 HBASetBindingSupportFunc
2830 2831 registeredfunc;
2831 2832
2832 2833 DEBUG(2, "HBA_SetBindingSupport", 0, 0, 0);
2833 2834
2834 2835 CHECKLIBRARY();
2835 2836 registeredfunc = lib_infop->functionTable.SetBindingSupportHandler;
2836 2837 if (registeredfunc != NULL) {
2837 2838 status =(registeredfunc)(vendorHandle, hbaPortWWN, capability);
2838 2839 } else {
2839 2840 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2840 2841 }
2841 2842 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2842 2843 }
2843 2844
2844 2845 HBA_STATUS
2845 2846 HBA_SetPersistentBindingV2 (
2846 2847 HBA_HANDLE handle,
2847 2848 HBA_WWN hbaPortWWN,
2848 2849 const HBA_FCPBINDING2
2849 2850 *pbinding)
2850 2851 {
2851 2852 HBA_STATUS status;
2852 2853 HBA_LIBRARY_INFO *lib_infop;
2853 2854 HBA_HANDLE vendorHandle;
2854 2855 HBASetPersistentBindingV2Func
2855 2856 registeredfunc;
2856 2857
2857 2858 DEBUG(2, "HBA_SetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0);
2858 2859
2859 2860 CHECKLIBRARY();
2860 2861 registeredfunc = lib_infop->functionTable.SetPersistentBindingV2Handler;
2861 2862 if (registeredfunc != NULL) {
2862 2863 status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
2863 2864 } else {
2864 2865 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2865 2866 }
2866 2867 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2867 2868 }
2868 2869
2869 2870 HBA_STATUS
2870 2871 HBA_GetPersistentBindingV2 (
2871 2872 HBA_HANDLE handle,
2872 2873 HBA_WWN hbaPortWWN,
2873 2874 HBA_FCPBINDING2 *pbinding)
2874 2875 {
2875 2876 HBA_STATUS status;
2876 2877 HBA_LIBRARY_INFO *lib_infop;
2877 2878 HBA_HANDLE vendorHandle;
2878 2879 HBAGetPersistentBindingV2Func
2879 2880 registeredfunc;
2880 2881
2881 2882 DEBUG(2, "HBA_GetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0);
2882 2883
2883 2884 CHECKLIBRARY();
2884 2885 registeredfunc = lib_infop->functionTable.GetPersistentBindingV2Handler;
2885 2886 if (registeredfunc != NULL) {
2886 2887 status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
2887 2888 } else {
2888 2889 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2889 2890 }
2890 2891 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2891 2892 }
2892 2893
2893 2894 HBA_STATUS
2894 2895 HBA_RemovePersistentBinding (
2895 2896 HBA_HANDLE handle,
2896 2897 HBA_WWN hbaPortWWN,
2897 2898 const HBA_FCPBINDING2
2898 2899 *pbinding)
2899 2900 {
2900 2901 HBA_STATUS status;
2901 2902 HBA_LIBRARY_INFO *lib_infop;
2902 2903 HBA_HANDLE vendorHandle;
2903 2904 HBARemovePersistentBindingFunc
2904 2905 registeredfunc;
2905 2906
2906 2907 DEBUG(2, "HBA_RemovePersistentBinding", 0, 0, 0);
2907 2908
2908 2909 CHECKLIBRARY();
2909 2910 registeredfunc =
2910 2911 lib_infop->functionTable.RemovePersistentBindingHandler;
2911 2912 if (registeredfunc != NULL) {
2912 2913 status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
2913 2914 } else {
2914 2915 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2915 2916 }
2916 2917 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2917 2918 }
2918 2919
2919 2920 HBA_STATUS
2920 2921 HBA_RemoveAllPersistentBindings (
2921 2922 HBA_HANDLE handle,
2922 2923 HBA_WWN hbaPortWWN)
2923 2924 {
2924 2925 HBA_STATUS status;
2925 2926 HBA_LIBRARY_INFO *lib_infop;
2926 2927 HBA_HANDLE vendorHandle;
2927 2928 HBARemoveAllPersistentBindingsFunc
2928 2929 registeredfunc;
2929 2930
2930 2931 DEBUG(2, "HBA_RemoveAllPersistentBindings", 0, 0, 0);
2931 2932
2932 2933 CHECKLIBRARY();
2933 2934 registeredfunc =
2934 2935 lib_infop->functionTable.RemoveAllPersistentBindingsHandler;
2935 2936 if (registeredfunc != NULL) {
2936 2937 status =(registeredfunc)(vendorHandle, hbaPortWWN);
2937 2938 } else {
2938 2939 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2939 2940 }
2940 2941 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2941 2942 }
2942 2943
2943 2944 HBA_STATUS
2944 2945 HBA_GetFC4Statistics (
2945 2946 HBA_HANDLE handle,
2946 2947 HBA_WWN portWWN,
2947 2948 HBA_UINT8 FC4type,
2948 2949 HBA_FC4STATISTICS *pstatistics)
2949 2950 {
2950 2951 HBA_STATUS status;
2951 2952 HBA_LIBRARY_INFO *lib_infop;
2952 2953 HBA_HANDLE vendorHandle;
2953 2954 HBAGetFC4StatisticsFunc
2954 2955 registeredfunc;
2955 2956
2956 2957 DEBUG(2, "HBA_GetFC4Statistics port: %s", WWN2STR1(&portWWN), 0, 0);
2957 2958
2958 2959 CHECKLIBRARY();
2959 2960 registeredfunc =
2960 2961 lib_infop->functionTable.GetFC4StatisticsHandler;
2961 2962 if (registeredfunc != NULL) {
2962 2963 status =(registeredfunc)
2963 2964 (vendorHandle, portWWN, FC4type, pstatistics);
2964 2965 } else {
2965 2966 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2966 2967 }
2967 2968 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2968 2969 }
2969 2970
2970 2971 HBA_STATUS
2971 2972 HBA_GetFCPStatistics (
2972 2973 HBA_HANDLE handle,
2973 2974 const HBA_SCSIID *lunit,
2974 2975 HBA_FC4STATISTICS *pstatistics)
2975 2976 {
2976 2977 HBA_STATUS status;
2977 2978 HBA_LIBRARY_INFO *lib_infop;
2978 2979 HBA_HANDLE vendorHandle;
2979 2980 HBAGetFCPStatisticsFunc
2980 2981 registeredfunc;
2981 2982
2982 2983 DEBUG(2, "HBA_GetFCPStatistics", 0, 0, 0);
2983 2984
2984 2985 CHECKLIBRARY();
2985 2986 registeredfunc =
2986 2987 lib_infop->functionTable.GetFCPStatisticsHandler;
2987 2988 if (registeredfunc != NULL) {
2988 2989 status =(registeredfunc)(vendorHandle, lunit, pstatistics);
2989 2990 } else {
2990 2991 status = HBA_STATUS_ERROR_NOT_SUPPORTED;
2991 2992 }
2992 2993 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
2993 2994 }
2994 2995
2995 2996 HBA_UINT32
2996 2997 HBA_GetVendorLibraryAttributes (
2997 2998 HBA_UINT32 adapter_index,
2998 2999 HBA_LIBRARYATTRIBUTES *attributes)
2999 3000 {
3000 3001 HBA_ADAPTER_INFO *adapt_infop;
3001 3002 HBAGetVendorLibraryAttributesFunc
3002 3003 registeredfunc;
3003 3004 HBA_UINT32 ret = 0;
3004 3005
3005 3006 DEBUG(2, "HBA_GetVendorLibraryAttributes adapterindex:%d",
3006 3007 adapter_index, 0, 0);
3007 3008 if(_hbaapi_librarylist == NULL) {
3008 3009 DEBUG(1, "HBAAPI not loaded yet.", 0, 0, 0);
3009 3010 return(0);
3010 3011 }
3011 3012
3012 3013 if (attributes == NULL) {
3013 3014 return(HBA_STATUS_ERROR_ARG);
3014 3015 }
3015 3016
3016 3017 memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES));
3017 3018
3018 3019 GRAB_MUTEX(&_hbaapi_LL_mutex);
3019 3020 GRAB_MUTEX(&_hbaapi_AL_mutex);
3020 3021 for(adapt_infop = _hbaapi_adapterlist;
3021 3022 adapt_infop != NULL;
3022 3023 adapt_infop = adapt_infop->next) {
3023 3024
3024 3025 if(adapt_infop->index == adapter_index) {
3025 3026 registeredfunc = adapt_infop->library->
3026 3027 functionTable.GetVendorLibraryAttributesHandler;
3027 3028 if(registeredfunc != NULL) {
3028 3029 ret = (registeredfunc)(attributes);
3029 3030 } else {
3030 3031 /* Version 1 libary? */
3031 3032 HBAGetVersionFunc GetVersionFunc;
3032 3033 GetVersionFunc = adapt_infop->library->
3033 3034 functionTable.GetVersionHandler;
3034 3035 if(GetVersionFunc != NULL) {
3035 3036 ret = ((GetVersionFunc)());
3036 3037 }
3037 3038 #ifdef NOTDEF
3038 3039 else {
3039 3040 /* This should not happen, dont think its going to */
3040 3041 }
3041 3042 #endif
3042 3043 }
3043 3044 if (attributes->LibPath[0] == '\0') {
3044 3045 if(strlen(adapt_infop->library->LibraryPath) < 256) {
3045 3046 strcpy(attributes->LibPath,
3046 3047 adapt_infop->library->LibraryPath);
3047 3048 }
3048 3049 }
3049 3050 break;
3050 3051 }
3051 3052 }
3052 3053 RELEASE_MUTEX(&_hbaapi_AL_mutex);
3053 3054 RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, ret);
3054 3055 }
|
↓ open down ↓ |
2069 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX