fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBAAPILIB.c - Implements a sample common (wrapper) HBA API library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * License:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the SNIA Public License
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Version 1.0 (the "License"); you may not use this file except in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * compliance with the License. You may obtain a copy of the License at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /http://www.snia.org/English/Resources/Code/OpenSource.html
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Software distributed under the License is distributed on an "AS IS"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the License for the specific language governing rights and limitations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The Original Code is SNIA HBA API Wrapper Library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The Initial Developer of the Original Code is:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contributor(s):
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Tuan Lam, QLogic Corp. (t_lam@qlc.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <windows.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Next define forces entry points in the dll to be exported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See hbaapi.h to see what it does.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define HBAAPI_EXPORTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <dlfcn.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "hbaapi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "vendorhbaapi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USESYSLOG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <syslog.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LIBRARY_NUM is a shortcut to figure out which library we need to call.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The top 16 bits of handle are the library index
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define LIBRARY_NUM(handle) ((handle)>>16)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with all upper 16 bits set to 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define VENDOR_HANDLE(handle) ((handle)&0xFFFF)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define HBA_HANDLE_FROM_LOCAL(library, vendor) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((library)<<16) | ((vendor)&0x0000FFFF))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint _hbaapi_debuglevel = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(USESYSLOG) && defined(USELOGFILE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFILE *_hbaapi_debug_fd = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint _hbaapi_sysloginit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#undef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3)\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((L) <= _hbaapi_debuglevel) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_sysloginit == 0) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_sysloginit = 1;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd == NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char _logFile[MAX_PATH]; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetTempPath(MAX_PATH, _logFile); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcat(_logFile, "HBAAPI.log"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debug_fd = fopen(_logFile, "a");\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd != NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(_hbaapi_debug_fd, (STR ## "\n"), (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* WIN32*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3)\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((L) <= _hbaapi_debuglevel) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_sysloginit == 0) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_sysloginit = 1;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd == NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd != NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(_hbaapi_debug_fd, (STR ## "\n"), (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* WIN32*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* Not both USESYSLOG and USELOGFILE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(USESYSLOG)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint _hbaapi_sysloginit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#undef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((L) <= _hbaapi_debuglevel) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_sysloginit == 0) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_sysloginit = 1;\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog (LOG_INFO, (STR), (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USESYSLOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(USELOGFILE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFILE *_hbaapi_debug_fd = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#undef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((L) <= _hbaapi_debuglevel) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd == NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char _logFile[MAX_PATH]; \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetTempPath(MAX_PATH, _logFile); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcat(_logFile, "HBAAPI.log"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debug_fd = fopen(_logFile, "a");\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* WIN32 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((L) <= _hbaapi_debuglevel) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd == NULL) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd != NULL) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(_hbaapi_debug_fd, (STR) ## "\n", (A1), (A2), (A3));\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* WIN32 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* USELOGFILE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* Not both USELOGFILE and USESYSLOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When multiple mutex's are grabed, they must be always be grabbed in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the same order, or deadlock can result. There are three levels
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of mutex's involved in this API. If LL_mutex is grabbed, always grap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it first. If AL_mutex is grabbed, it may not be grabbed before
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LL_mutex. If grabbed in a multi grab sequence, the mutex's protecting
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the callback lists must always be grabbed last and release before calling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a vendor specific library function that might invoke a callback function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on the same thread.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define GRAB_MUTEX(M) grab_mutex(M)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX(M) release_mutex(M)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX_RETURN(M,RET) release_mutex(M); return(RET)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined (WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define GRAB_MUTEX(m) EnterCriticalSection(m)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX(m) LeaveCriticalSection(m)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX_RETURN(m, RET) LeaveCriticalSection(m); return(RET)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define GRAB_MUTEX(M)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX(M)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RELEASE_MUTEX_RETURN(M,RET) return(RET)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Vendor library information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_UNKNOWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_LOADED,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_NOT_LOADED
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_LIBRARY_STATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_library_info {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_library_info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HINSTANCE hLibrary; /* Handle to a loaded DLL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *LibraryName;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void* hLibrary; /* Handle to a loaded DLL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *LibraryPath;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ENTRYPOINTSV2 functionTable; /* Function pointers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_STATUS status; /* info on this library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_LIBRARY_INFO, *PHBA_LIBRARY_INFO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ARE_WE_INITED() \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_hbaapi_librarylist == NULL) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_LIBRARY_INFO *_hbaapi_librarylist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32 _hbaapi_total_library_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_LL_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_LL_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Individual adapter (hba) information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_adapter_info {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_adapter_info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS GNstatus; /* status from GetAdapterNameFunc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN nodeWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_ADAPTER_INFO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTER_INFO *_hbaapi_adapterlist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32 _hbaapi_total_adapter_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_AL_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_AL_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Call back registration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_vendorcallback_elem {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_vendorcallback_elem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE vendorcbhandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_VENDORCALLBACK_ELEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Each instance of HBA_ADAPTERCALLBACK_ELEM represents a call to one of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * "register" functions that apply to a particular adapter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBA_ALLADAPTERSCALLBACK_ELEM is used just for HBA_RegisterForAdapterAddEvents
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_adaptercallback_elem {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_adaptercallback_elem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_info;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userdata;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE vendorcbhandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback)();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_ADAPTERCALLBACK_ELEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_alladapterscallback_elem {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_alladapterscallback_elem
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userdata;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback)();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_ALLADAPTERSCALLBACK_ELEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ALLADAPTERSCALLBACK_ELEM *_hbaapi_adapteraddevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportstatevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_targetevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_linkevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterdeviceevents_callback_list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* mutex's to protect each list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_AAE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_AE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_APE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_APSE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_TE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_LE_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ADAPTERCALLBACK_ELEM **cb_lists_array[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_adapterevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_adapterportevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_adapterportstatevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_targetevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_linkevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &_hbaapi_adapterdeviceevents_callback_list,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common library internal. Mutex handling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortegrab_mutex(pthread_mutex_t *mp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((ret = pthread_mutex_lock(mp)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror("pthread_mutex_lock - HBAAPI:");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "pthread_mutex_lock returned %d", ret, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterelease_mutex(pthread_mutex_t *mp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((ret = pthread_mutex_unlock(mp)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror("pthread_mutex_unlock - HBAAPI:");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "pthread_mutex_unlock returned %d", ret, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common library internal. Check library and return vendorhandle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic HBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_CheckLibrary(HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO **lib_infopp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE *vendorhandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 libraryIndex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vendorhandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libraryIndex = LIBRARY_NUM(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(lib_infop = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = lib_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(lib_infop->index == libraryIndex) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(lib_infop->status != HBA_LIBRARY_LOADED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lib_infopp = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *vendorhandle = VENDOR_HANDLE(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* caller will release the mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INVALID_HANDLE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define CHECKLIBRARY() \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(status); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *freevendorhandlelist is called with _hbaapi_LL_mutex already held
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefreevendorhandlelist(HBA_VENDORCALLBACK_ELEM *vhlist) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vhlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vnext;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARemoveCallbackFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(vhlp = vhlist; vhlp != NULL; vhlp = vnext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vnext = vhlp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vhlp->lib_info->functionTable.RemoveCallbackHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (registeredfunc)(vhlp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(vhlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelocal_remove_callback(HBA_CALLBACKHANDLE cbhandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM ***listp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM **lastp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ALLADAPTERSCALLBACK_ELEM **lap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ALLADAPTERSCALLBACK_ELEM *allcbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *cbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARemoveCallbackFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vhlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vnext;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_ERROR_INVALID_HANDLE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* search through the simple lists first */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(listp = cb_lists_array, found = 0; found == 0, *listp != NULL; listp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lastp = *listp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(cbp=**listp; cbp != NULL; cbp = cbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(cbhandle != (HBA_CALLBACKHANDLE)cbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lastp = &(cbp->next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = cbp->lib_info->functionTable.RemoveCallbackHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (registeredfunc)(cbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lastp = cbp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(cbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(found != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if it wasnt in the simple lists, look in the list for adapteraddevents */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lap = &_hbaapi_adapteraddevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(allcbp = _hbaapi_adapteraddevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte allcbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte allcbp = allcbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(cbhandle != (HBA_CALLBACKHANDLE)allcbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lap = &allcbp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vnext = vhlp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vhlp->lib_info->functionTable.RemoveCallbackHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (registeredfunc)(vhlp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(vhlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *lap = allcbp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(allcbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char wwn_str1[17];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char wwn_str2[17];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char wwn_str3[17];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define WWN2STR1(wwn) WWN2str(wwn_str1, (wwn))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define WWN2STR2(wwn) WWN2str(wwn_str2, (wwn))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define WWN2STR3(wwn) WWN2str(wwn_str3, (wwn))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteWWN2str(char *buf, HBA_WWN *wwn) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *pc = (unsigned char *)&(wwn->wwn[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j=0; j<16; j+=2) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(&buf[j], "%02X", (int)*pc++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteBOOL APIENTRY
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDllMain( HANDLE hModule,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DWORD ul_reason_for_call,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LPVOID lpReserved
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte )
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (ul_reason_for_call)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DLL_PROCESS_ATTACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DLL_PROCESS_DETACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DLL_THREAD_ATTACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case DLL_THREAD_DETACH:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read in the config file and load all the specified vendor specific
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * libraries and perform the function registration exercise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_LoadLibrary(void) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterLibraryFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterLibraryV2Func
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterV2Func;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBALoadLibraryFunc LoadLibraryFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetVersionFunc GetVersionFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 libversion;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Open configuration file from known location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LONG lStatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HKEY hkSniaHba, hkVendorLib;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FILETIME ftLastWriteTime;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TCHAR cSubKeyName[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DWORD i, dwSize, dwType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte BYTE byFileName[MAX_PATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this is an app programming error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\SNIA\\HBA",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, KEY_READ, &hkSniaHba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lStatus != ERROR_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, configuration error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Enumerate all the subkeys. These have the form:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HKLM\Software\SNIA\HBA\<Vendor id> - note that we don't care
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * what the vendor id is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; ; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dwSize = 255; /* how big the buffer is */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lStatus = RegEnumKeyEx(hkSniaHba, i,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)&cSubKeyName, &dwSize, NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, NULL, &ftLastWriteTime);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lStatus == ERROR_NO_MORE_ITEMS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break; /* we're done */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (lStatus == ERROR_MORE_DATA) { /* buffer not big enough */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do whatever */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now open the subkey that pertains to this vendor's library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lStatus = RegOpenKeyEx(hkSniaHba, cSubKeyName, 0, KEY_READ,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &hkVendorLib);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lStatus != ERROR_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegCloseKey(hkSniaHba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, installation error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR; /* you may want to return something
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * else or keep trying */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The name of the library is contained in a REG_SZ Value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * keyed to "LibraryFile" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dwSize = MAX_PATH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lStatus = RegQueryValueEx(hkVendorLib, "LibraryFile", NULL, &dwType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte byFileName, &dwSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lStatus != ERROR_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegCloseKey(hkVendorLib);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, installation error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof(HBA_LIBRARY_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(lib_infop == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* what is the right thing to do in MS land??? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegCloseKey(hkVendorLib);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, installation error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->status = HBA_LIBRARY_NOT_LOADED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->next = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->index = _hbaapi_total_library_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_library_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_librarylist = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now I can try to load the library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->hLibrary = LoadLibrary(byFileName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lib_infop->hLibrary == NULL){
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* printf("unable to load library %s\n", librarypath); */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, installation error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath = strdup(byFileName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "HBAAPI loading: %s\n", byFileName, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Call the registration function to get the list of pointers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterV2Func = (HBARegisterLibraryV2Func)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RegisterV2Func != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the function pointers directly into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the table of functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((RegisterV2Func)(&lib_infop->functionTable));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* library not loaded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Maybe the vendor library is only Rev1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterFunc = (HBARegisterLibraryFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibrary");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(RegisterFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the function points directly into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the Rev 2 table of functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((RegisterFunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_ENTRYPOINTS *)(&lib_infop->functionTable)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* library not loaded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successfully loaded library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetVersionFunc = lib_infop->functionTable.GetVersionHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetVersionFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the version of this library before loading */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Actually... This wrapper is compatible with version 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libversion = ((GetVersionFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef NOTDEF /* save for a later time... when it matters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (libversion < HBA_LIBVERSION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LoadLibraryFunc = lib_infop->functionTable.LoadLibraryHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (LoadLibraryFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Hmmm, dont we need to flag this in a realy big way??? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* How about messages to the system event logger ??? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto dud_library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize this library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((LoadLibraryFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* ???Opportunity to send error msg, library error? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successfully loaded library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->status = HBA_LIBRARY_LOADED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dud_library: /* its also just the end of the loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegCloseKey(hkVendorLib);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegCloseKey(hkSniaHba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* Unix as opposed to Win32 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FILE *hbaconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fullline[512]; /* line read from HBA.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *libraryname; /* Read in from file HBA.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *librarypath; /* Read in from file HBA.conf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char hbaConfFilePath[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *charPtr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_LoadLibrary: previously unfreed "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "libraries exist, call HBA_FreeLibrary().\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(hbaConfFilePath, "/etc/hba.conf");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hbaconf = fopen(hbaConfFilePath, "r")) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("Cannot open %s\n", hbaConfFilePath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Read in each line and load library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((hbaconf != NULL) && (fgets(fullline, sizeof(fullline), hbaconf))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Skip the comments... */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fullline[0] == '#') || (fullline[0] == '\n')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* grab first 'thing' in line (if its there)*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((libraryname = strtok(fullline, " \t\n")) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strlen(libraryname) >= 64) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "Library name(%s) in %s is > 64 characters\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libraryname, hbaConfFilePath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* grab second 'thing' in line (if its there)*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((librarypath = strtok(NULL, " \t\n")) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strlen(librarypath) >= 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "Library path(%s) in %s is > 256 characters\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte librarypath, hbaConfFilePath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* there should be no more 'things' in the line */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((charPtr = strtok(NULL, " \n\t")) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "Extraneous characters (\"%s\") in %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte charPtr, hbaConfFilePath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Continue to the next line if library name or path is invalid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (libraryname == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(libraryname) == 0 ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte librarypath == NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strlen(librarypath) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special case....
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Look for loglevel
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strcmp(libraryname, "debuglevel") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debuglevel = strtol(librarypath, NULL, 10);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error handling does the right thing automagically */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof(HBA_LIBRARY_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(lib_infop == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr, "HBA_LoadLibrary: out of memeory\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->status = HBA_LIBRARY_NOT_LOADED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryName = strdup(libraryname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath = strdup(librarypath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->index = _hbaapi_total_library_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_library_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->next = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_librarylist = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the DLL now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((lib_infop->hLibrary = dlopen(librarypath,RTLD_LAZY)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*printf("unable to load library %s\n", librarypath); */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Call the registration function to get the list of pointers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterV2Func = (HBARegisterLibraryV2Func)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RegisterV2Func != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the function points directly into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the table of functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((RegisterV2Func)(&lib_infop->functionTable));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* library not loaded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Maybe the vendor library is only Rev1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RegisterFunc = (HBARegisterLibraryFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "HBA_RegisterLibrary");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(RegisterFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This function is required */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_LoadLibrary: vendor specific RegisterLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function not found. lib: %s\n", librarypath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function not found. lib: %s\n", librarypath, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Load the function points directly into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the table of functions */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((RegisterFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((HBA_ENTRYPOINTS *)(&lib_infop->functionTable)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* library not loaded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_LoadLibrary: vendor specific RegisterLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function encountered an error. lib: %s\n", librarypath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function encountered an error. lib: %s\n", librarypath, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successfully loaded library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((GetVersionFunc = lib_infop->functionTable.GetVersionHandler)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libversion = ((GetVersionFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the version of this library before loading */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Actually... This wrapper is compatible with version 1 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef NOTDEF /* save for a later time... when it matters */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(libversion < HBA_LIBVERSION) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte printf("Library version mismatch. Got %d expected %d.\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte libversion, HBA_LIBVERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "%s libversion = %d", librarypath, libversion, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte LoadLibraryFunc = lib_infop->functionTable.LoadLibraryHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (LoadLibraryFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this function is required */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_LoadLibrary: vendor specific LoadLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function not found. lib: %s\n", librarypath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "HBA_LoadLibrary: vendor specific LoadLibrary "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "function not found. lib: %s\n", librarypath, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize this library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((status = ((LoadLibraryFunc)())) != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* maybe this should be a printf so that we CANNOT miss it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_LoadLibrary: Encounterd and error loading: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte librarypath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, "Encounterd and error loading: %s", librarypath, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0, " HBA_STATUS: %d", status, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* successfully loaded library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->status = HBA_LIBRARY_LOADED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fclose(hbaconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* WIN32 or UNIX */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_LL_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_AL_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_AAE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_AE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_APE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_APSE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_TE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = pthread_mutex_init(&_hbaapi_LE_mutex, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(ret != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror("pthread_mutec_init - HBA_LoadLibrary");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte InitializeCriticalSection(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_FreeLibrary(void) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAFreeLibraryFunc FreeLibraryFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ***listp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ARE_WE_INITED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "HBA_FreeLibrary()", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_next = lib_infop->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lib_infop->status == HBA_LIBRARY_LOADED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FreeLibraryFunc = lib_infop->functionTable.FreeLibraryHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (FreeLibraryFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free this library */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((FreeLibraryFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FreeLibrary(lib_infop->hLibrary); /* Unload DLL from memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlclose(lib_infop->hLibrary); /* Unload DLL from memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lib_infop->LibraryName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lib_infop->LibraryPath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(lib_infop);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_librarylist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OK, now all functions are disabled except for LoadLibrary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Hope no other thread calls it before we have returned */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_library_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_next = adapt_infop->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(adapt_infop->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(adapt_infop);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterlist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_adapter_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free up the callbacks, this is not the most efficient, but it works */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while((volatile HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapteraddevents_callback_list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_remove_callback((HBA_CALLBACKHANDLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapteraddevents_callback_list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(listp = cb_lists_array; *listp != NULL; listp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while((volatile HBA_ADAPTERCALLBACK_ELEM ***)**listp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_remove_callback((HBA_CALLBACKHANDLE)**listp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USESYSLOG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte closelog();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef USELOGFILE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_debug_fd != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fclose(_hbaapi_debug_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_debug_fd = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this will unlock them as well, but who cares */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pthread_mutex_destroy(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteCriticalSection(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The API used to use fixed size tables as its primary data structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Indexing from 1 to N identified each adapters. Now the adapters are
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on a linked list. There is a unique "index" foreach each adapter.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Adapters always keep their index, even if they are removed from the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hardware. The only time the indexing is reset is on HBA_FreeLibrary
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetNumberOfAdapters(void) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j=0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetNumberOfAdaptersFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfAdaptersFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetAdapterNameFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetAdapterNameFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_BOOLEAN found_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char adaptername[256];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int num_adapters; /* local */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex); /* pay attention to order */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (lib_infop = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = lib_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lib_infop->status != HBA_LIBRARY_LOADED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfAdaptersFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetNumberOfAdaptersHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetNumberOfAdaptersFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_adapters = ((GetNumberOfAdaptersFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryName, num_adapters, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "HBAAPI: num_adapters for %s = %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, num_adapters, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Also get the names of all the adapters here and cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetAdapterNameFunc = lib_infop->functionTable.GetAdapterNameHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(GetAdapterNameFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < num_adapters; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_name = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (GetAdapterNameFunc)(j, (char *)&adaptername);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check for duplicates, really, this may just be a second
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * call to this function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ??? how do we know when a name becomes stale?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strcmp(adaptername, adapt_infop->name) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* already got this one */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_name++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(found_name != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = (HBA_ADAPTER_INFO *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTER_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(adapt_infop == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_GetNumberOfAdapters: calloc failed on sizeof:%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTER_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_adapter_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((adapt_infop->GNstatus = status) == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->name = strdup(adaptername);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char dummyname[512];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sprintf(dummyname, "NULLADAPTER-%s-%03d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, _hbaapi_total_adapter_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dummyname[255] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->name = strdup(dummyname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->library = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->next = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->index = _hbaapi_total_adapter_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterlist = adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_adapter_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetAdapterName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 adapterindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *adaptername)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adaptername == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The adapter index is from old code, but we have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to support it. Go down the list looking for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the adapter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ARE_WE_INITED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *adaptername = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(adapt_infop->index == adapterindex) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(adapt_infop->name != NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->GNstatus == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(adaptername, adapt_infop->name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *adaptername = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = adapt_infop->GNstatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "GetAdapterName for index:%d ->%s", adapterindex, adaptername, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_HANDLE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_OpenAdapter(char* adaptername) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAOpenAdapterFunc OpenAdapterFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_HANDLE_INVALID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (adaptername == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_HANDLE_INVALID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(adaptername, adapt_infop->name) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = adapt_infop->library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OpenAdapterFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.OpenAdapterHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (OpenAdapterFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* retrieve the vendor handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = (OpenAdapterFunc)(adaptername);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(handle != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* or this with the library index to get the common handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function ignores the list of known adapters and instead tries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * each vendors open function to see if one of them
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * can open an adapter when referenced with a particular WWN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_OpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetNumberOfAdaptersFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfAdaptersFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAOpenAdapterByWWNFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OpenAdapterFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "OpenAdapterByWWN: %s", WWN2STR1(&nodeWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (phandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ARE_WE_INITED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *phandle = HBA_HANDLE_INVALID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (lib_infop = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = lib_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_ILLEGAL_WWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lib_infop->status != HBA_LIBRARY_LOADED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfAdaptersFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetNumberOfAdaptersHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetNumberOfAdaptersFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* look for new hardware */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ((GetNumberOfAdaptersFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OpenAdapterFunc = lib_infop->functionTable.OpenAdapterByWWNHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (OpenAdapterFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We do not know if the WWN is known by this vendor,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * just try it
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((status = (OpenAdapterFunc)(&handle, nodeWWN)) != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* OK, make a vendor non-specific handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *phandle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RefreshAdapterConfiguration() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RefreshAdapterConfiguration", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void)HBA_GetNumberOfAdapters();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetVersion() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetVersion", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_LIBVERSION;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function is VERY OS dependent. Wing it as best you can.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetWrapperLibraryAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARYATTRIBUTES *attributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetWrapperLibraryAttributes", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attributes == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(SOLARIS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((handle = dlopen("libHBAAPI.so", RTLD_NOW)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(dlinfo(handle, RTLD_DI_LINKMAP, &map) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(mp = map; mp != NULL; mp = mp->l_next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strlen(map->l_name) < 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(attributes->LibPath, map->l_lname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HMODULE module;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No need to do anything with the module handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* It wasn't alloocated so it doesn't need to be freed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte module = GetModuleHandle("HBAAPI");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ( module != NULL ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ( GetModuleFileName(module, attributes->LibPath,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(attributes->LibPath)) == 0 ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes->LibPath[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(VENDOR)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(attributes->VName, VENDOR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes->VName[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(VERSION)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(attributes->VVersion, VERSION);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes->VVersion[0] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(BUILD_DATE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int matchCount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte matchCount = sscanf(BUILD_DATE, "%u/%u/%u %u:%u:%u",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_year,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_mon,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_mday,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_hour,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_min,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &attributes->build_date.tm_sec
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte );
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ( matchCount != 6 ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes->build_date, 0, sizeof(struct tm));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes->build_date.tm_year -= 1900;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attributes->build_date.tm_isdst = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strptime(BUILD_DATE, "%Y/%m/%d %T %Z", &(attributes->build_date)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes->build_date, 0, sizeof(struct tm));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(&attributes->build_date, 0, sizeof(struct tm));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Callback registation and handling
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RemoveCallback (HBA_CALLBACKHANDLE cbhandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RemoveCallback", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ARE_WE_INITED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = local_remove_callback(cbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Adapter Add Events *********************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadapteraddevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "AddAdapterEvent, port:%s", WWN2STR1(&PortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(cbp = _hbaapi_adapteraddevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp = cbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*cbp->callback)(data, PortWWN, HBA_EVENT_ADAPTER_ADD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForAdapterAddEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ALLADAPTERSCALLBACK_ELEM *cbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vcbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_VENDORCALLBACK_ELEM *vendorhandlelist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForAdapterAddEventsFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status = HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS failure = HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int registered_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int vendor_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int not_supported_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status_OK_bar_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status_OK_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForAdapterAddEvents", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ARE_WE_INITED();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp = (HBA_ALLADAPTERSCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ALLADAPTERSCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) cbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(cbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterAddEvents: calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ALLADAPTERSCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp->next = _hbaapi_adapteraddevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapteraddevents_callback_list = cbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Need to release the mutex now incase the vendor function invokes the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback. We will grap the mutex later to attach the vendor handle list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the callback structure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * now create a list of vendors (vendor libraryies, NOT ADAPTERS) that have
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * successfully registerred
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorhandlelist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(lib_infop = _hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop = lib_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendor_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RegisterForAdapterAddEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vcbp = (HBA_VENDORCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_VENDORCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(vcbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterAddEvents: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_VENDORCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte freevendorhandlelist(vendorhandlelist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registered_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(adapteraddevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte userData, &vcbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status == HBA_STATUS_ERROR_NOT_SUPPORTED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte not_supported_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(vcbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status_OK_bar_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, status, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte failure = status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(vcbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status_OK_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vcbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vcbp->next = vendorhandlelist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorhandlelist = vcbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registered_cnt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte freevendorhandlelist(vendorhandlelist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_remove_callback((HBA_CALLBACKHANDLE) cbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (status_OK_cnt == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* At least one vendor library registered this function, but no
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * vendor call succeeded */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local_remove_callback((HBA_CALLBACKHANDLE) cbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = failure;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we have had atleast some success, now finish up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this seems silly, but what if another thread called
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the callback remove */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(cbp = _hbaapi_adapteraddevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp != NULL; cbp = cbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((HBA_CALLBACKHANDLE)cbp == *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* yup, its still there, hooray */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cbp->vendorhandlelist = vendorhandlelist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorhandlelist = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AAE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(vendorhandlelist != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bummer, somebody removed the callback before we finished
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * registration, probably will never happen */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte freevendorhandlelist(vendorhandlelist);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "called for a handle before registration was finished.",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Adapter Events (other than add) ********************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadapterevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(acbp = _hbaapi_adapterevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = acbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(data == (void *)acbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*acbp->callback)(acbp->userdata, PortWWN, eventType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForAdapterEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForAdapterEventsFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForAdapterEvents", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we now have the _hbaapi_LL_mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.RegisterForAdapterEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that allocated memory is used both as the handle for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller, and as userdata to the vendor call so that on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback the specific registration may be recalled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterEvents: calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->userdata = userData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(adapterevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)acbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &acbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(acbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->next = _hbaapi_adapterevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterevents_callback_list = acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Adapter Port Events ********************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadapterportevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 fabricPortID) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&PortWWN), eventType, fabricPortID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(acbp = _hbaapi_adapterportevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = acbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(data == (void *)acbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*acbp->callback)(acbp->userdata, PortWWN, eventType, fabricPortID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForAdapterPortEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 fabricPortID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForAdapterPortEventsFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForAdapterPortEvents for port: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&PortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we now have the _hbaapi_LL_mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RegisterForAdapterPortEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that allocated memory is used both as the handle for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller, and as userdata to the vendor call so that on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback the specific registration may be recalled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterPortEvents: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->userdata = userData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(adapterportevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)acbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &acbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(acbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->next = _hbaapi_adapterportevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterportevents_callback_list = acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_APE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Adapter State Events *******************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadapterportstatevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "AdapterPortStateEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(acbp = _hbaapi_adapterportstatevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = acbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(data == (void *)acbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*acbp->callback)(acbp->userdata, PortWWN, eventType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForAdapterPortStatEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTSTATISTICS stats,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 statType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForAdapterPortStatEventsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForAdapterPortStatEvents for port: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&PortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we now have the _hbaapi_LL_mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RegisterForAdapterPortStatEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that allocated memory is used both as the handle for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller, and as userdata to the vendor call so that on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback the specific registration may be recalled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForAdapterPortStatEvents: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->userdata = userData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(adapterportstatevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)acbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stats,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte statType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &acbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(acbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->next = _hbaapi_adapterportstatevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterportstatevents_callback_list = acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_APSE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Target Events **************************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetargetevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(acbp = _hbaapi_targetevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = acbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(data == (void *)acbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*acbp->callback)(acbp->userdata, hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveredPortWWN, eventType);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForTargetEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 allTargets) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForTargetEventsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForTargetEvents, hbaPort: %s, discoveredPort: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we now have the _hbaapi_LL_mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.RegisterForTargetEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that allocated memory is used both as the handle for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller, and as userdata to the vendor call so that on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback the specific registration may be recalled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForTargetEvents: calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->userdata = userData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(targetevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)acbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &acbp->vendorcbhandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte allTargets);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(acbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->next = _hbaapi_targetevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_targetevents_callback_list = acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_TE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Link Events ****************************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortelinkevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN adapterWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRLIRBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RLIRBufferSize) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "LinkEvent, hbaWWN:%s, eventType:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&adapterWWN), eventType, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(acbp = _hbaapi_linkevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = acbp->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(data == (void *)acbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*acbp->callback)(acbp->userdata, adapterWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventType, pRLIRBuffer, RLIRBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RegisterForLinkEvents (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*callback) (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN adapterWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRLIRBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RLIRBufferSize),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *userData,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRLIRBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RLIRBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_CALLBACKHANDLE *callbackHandle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARegisterForLinkEventsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RegisterForLinkEvents", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we now have the _hbaapi_LL_mutex */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.RegisterForLinkEventsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that allocated memory is used both as the handle for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caller, and as userdata to the vendor call so that on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * callback the specific registration may be recalled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_ADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "HBA_RegisterForLinkEvents: calloc failed for %d bytes\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof(HBA_ADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *callbackHandle = (HBA_CALLBACKHANDLE) acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->callback = callback;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->userdata = userData;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->lib_info = lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)(linkevents_callback,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)acbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRLIRBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RLIRBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &acbp->vendorcbhandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(acbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp->next = _hbaapi_linkevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_linkevents_callback_list = acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LE_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * All of the functions below are almost passthru functions to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * vendor specific function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_CloseAdapter(HBA_HANDLE handle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBACloseAdapterFunc CloseAdapterFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_CloseAdapter", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CloseAdapterFunc = lib_infop->functionTable.CloseAdapterHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CloseAdapterFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((CloseAdapterFunc)(vendorHandle));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetAdapterAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTERATTRIBUTES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hbaattributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetAdapterAttributes", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetAdapterAttributesFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetAdapterAttributesHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetAdapterAttributesFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetAdapterPortAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES *portattributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetAdapterPortAttributesFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetAdapterPortAttributesFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetAdapterPortAttributes", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetAdapterPortAttributesFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetAdapterPortAttributesHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetAdapterPortAttributesFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetAdapterPortAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, portindex, portattributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetPortStatistics (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTSTATISTICS *portstatistics)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetPortStatisticsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetPortStatisticsFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetPortStatistics", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetPortStatisticsFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetPortStatisticsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetPortStatisticsFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetPortStatisticsFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, portindex, portstatistics));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetDiscoveredPortAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 discoveredportindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES *portattributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetDiscoveredPortAttributesFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetDiscoveredPortAttributesFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetDiscoveredPortAttributes", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetDiscoveredPortAttributesFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetDiscoveredPortAttributesHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetDiscoveredPortAttributesFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetDiscoveredPortAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, portindex, discoveredportindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portattributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetPortAttributesByWWN (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTATTRIBUTES *portattributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetPortAttributesByWWNFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetPortAttributesByWWNFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetPortAttributesByWWN: %s", WWN2STR1(&PortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetPortAttributesByWWNFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetPortAttributesByWWNHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetPortAttributesByWWNFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetPortAttributesByWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, PortWWN, portattributes));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendCTPassThru (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pReqBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 ReqBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendCTPassThruFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendCTPassThruFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendCTPassThru", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendCTPassThruFunc = lib_infop->functionTable.SendCTPassThruHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SendCTPassThruFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (SendCTPassThruFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pReqBuffer, ReqBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, RspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendCTPassThruV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pReqBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 ReqBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendCTPassThruV2Func
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendCTPassThruV2m hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendCTPassThruV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pReqBuffer, ReqBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetEventBuffer (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PHBA_EVENTINFO EventBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *EventBufferCount)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetEventBufferFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetEventBufferFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetEventBuffer", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetEventBufferFunc = lib_infop->functionTable.GetEventBufferHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetEventBufferFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (GetEventBufferFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, EventBuffer, EventBufferCount);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO Info) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASetRNIDMgmtInfoFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SetRNIDMgmtInfoFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SetRNIDMgmtInfo", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SetRNIDMgmtInfoFunc = lib_infop->functionTable.SetRNIDMgmtInfoHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SetRNIDMgmtInfoFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (SetRNIDMgmtInfoFunc)(vendorHandle, Info);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *pInfo) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetRNIDMgmtInfoFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetRNIDMgmtInfoFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetRNIDMgmtInfo", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetRNIDMgmtInfoFunc = lib_infop->functionTable.GetRNIDMgmtInfoHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetRNIDMgmtInfoFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (GetRNIDMgmtInfoFunc)(vendorHandle, pInfo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendRNID (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWNTYPE wwntype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendRNIDFunc SendRNIDFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendRNID for wwn: %s", WWN2STR1(&wwn), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendRNIDFunc = lib_infop->functionTable.SendRNIDHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SendRNIDFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((SendRNIDFunc)(vendorHandle, wwn, wwntype,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendRNIDV2(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 destFCID,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 NodeIdDataFormat,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendRNIDV2Func registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendRNIDV2, hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendRNIDV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (registeredfunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, hbaPortWWN, destWWN, destFCID, NodeIdDataFormat,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RefreshInformation (HBA_HANDLE handle) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARefreshInformationFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RefreshInformationFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RefreshInformation", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RefreshInformationFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RefreshInformationHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (RefreshInformationFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((RefreshInformationFunc)(vendorHandle));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ResetStatistics (HBA_HANDLE handle, HBA_UINT32 portindex) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAResetStatisticsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ResetStatisticsFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_ResetStatistics", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ResetStatisticsFunc = lib_infop->functionTable.ResetStatisticsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ResetStatisticsFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((ResetStatisticsFunc)(vendorHandle, portindex));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetFcpTargetMapping (HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetFcpTargetMappingFunc GetFcpTargetMappingFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetFcpTargetMappingFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetFcpTargetMappingHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetFcpTargetMappingFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetFcpTargetMappingFunc)(vendorHandle, mapping));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetFcpTargetMappingV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPTARGETMAPPINGV2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pmapping)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetFcpTargetMappingV2Func
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetFcpTargetMappingV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((registeredfunc)(vendorHandle, hbaPortWWN, pmapping));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetFcpPersistentBinding (HBA_HANDLE handle, PHBA_FCPBINDING binding) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetFcpPersistentBindingFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetFcpPersistentBindingFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetFcpPersistentBinding", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetFcpPersistentBindingFunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetFcpPersistentBindingHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetFcpPersistentBindingFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetFcpPersistentBindingFunc)(vendorHandle, binding));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ScsiInquiryV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT64 fcLUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 CDB_Byte1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 CDB_Byte2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pSenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAScsiInquiryV2Func ScsiInquiryV2Func;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_ScsiInquiryV2 to discoveredPortWWN: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&discoveredPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ScsiInquiryV2Func =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.ScsiInquiryV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ScsiInquiryV2Func != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =((ScsiInquiryV2Func)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, CDB_Byte1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CDB_Byte2, pRspBuffer, pRspBufferSize, pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pSenseBuffer, pSenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendScsiInquiry (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT64 fcLUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 EVPD,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 PageCode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 SenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendScsiInquiryFunc SendScsiInquiryFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendScsiInquiry to PortWWN: %s", WWN2STR1(&PortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendScsiInquiryFunc = lib_infop->functionTable.ScsiInquiryHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SendScsiInquiryFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =((SendScsiInquiryFunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, PortWWN, fcLUN, EVPD, PageCode, pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RspBufferSize, pSenseBuffer, SenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ScsiReportLUNsV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRespBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRespBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pSenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAScsiReportLUNsV2Func ScsiReportLUNsV2Func;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_ScsiReportLUNsV2 to discoveredPortWWN: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&discoveredPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ScsiReportLUNsV2Func = lib_infop->functionTable.ScsiReportLUNsV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ScsiReportLUNsV2Func != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((ScsiReportLUNsV2Func)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRespBuffer, pRespBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pSenseBuffer, pSenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendReportLUNs (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN portWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 SenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendReportLUNsFunc SendReportLUNsFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendReportLUNs to PortWWN: %s", WWN2STR1(&portWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendReportLUNsFunc = lib_infop->functionTable.ReportLUNsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SendReportLUNsFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((SendReportLUNsFunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, portWWN, pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RspBufferSize, pSenseBuffer, SenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_ScsiReadCapacityV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN discoveredPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT64 fcLUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 *pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *SenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAScsiReadCapacityV2Func ScsiReadCapacityV2Func;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_ScsiReadCapacityV2 to discoveredPortWWN: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&discoveredPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ScsiReadCapacityV2Func =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.ScsiReadCapacityV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ScsiReadCapacityV2Func != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =((ScsiReadCapacityV2Func)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pScsiStatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pSenseBuffer, SenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendReadCapacity (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN portWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT64 fcLUN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 RspBufferSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pSenseBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 SenseBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendReadCapacityFunc SendReadCapacityFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendReadCapacity to portWWN: %s", WWN2STR1(&portWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SendReadCapacityFunc = lib_infop->functionTable.ReadCapacityHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SendReadCapacityFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =((SendReadCapacityFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, portWWN, fcLUN, pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RspBufferSize, pSenseBuffer, SenseBufferSize));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendRLS (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendRLSFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendRLS to agent_wwn: %s:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&agent_wwn), agent_domain, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendRLSHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, destWWN, pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendRPL (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN agent_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 agent_domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendRPLFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendRPL to agent_wwn: %s:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&agent_wwn), agent_domain, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendRPLHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, agent_wwn, agent_domain, portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendRPS (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN agent_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 agent_domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN object_wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 object_port_number,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendRPSFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendRPS to agent_wwn: %s:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte WWN2STR1(&agent_wwn), agent_domain, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendRPSHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, agent_wwn, agent_domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte object_wwn, object_port_number,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendSRL (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN wwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendSRLFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendSRL to wwn:%s domain:%d", WWN2STR1(&wwn), domain, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendSRLHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, hbaPortWWN, wwn, domain,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SendLIRR (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN sourceWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN destWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 function,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *pRspBuffer,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *pRspBufferSize)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASendLIRRFunc registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SendLIRR destWWN:%s", WWN2STR1(&destWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SendLIRRHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, sourceWWN, destWWN, function, type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pRspBuffer, pRspBufferSize);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetBindingCapability(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_BIND_CAPABILITY *pcapability)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetBindingCapabilityFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetBindingCapability", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.GetBindingCapabilityHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetBindingSupport (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_BIND_CAPABILITY *pcapability)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetBindingSupportFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetBindingSupport", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.GetBindingSupportHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SetBindingSupport(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_BIND_CAPABILITY capability)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASetBindingSupportFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SetBindingSupport", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SetBindingSupportHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, capability);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_SetPersistentBindingV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const HBA_FCPBINDING2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pbinding)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASetPersistentBindingV2Func
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_SetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.SetPersistentBindingV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetPersistentBindingV2 (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FCPBINDING2 *pbinding)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetPersistentBindingV2Func
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = lib_infop->functionTable.GetPersistentBindingV2Handler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RemovePersistentBinding (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const HBA_FCPBINDING2
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *pbinding)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARemovePersistentBindingFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RemovePersistentBinding", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RemovePersistentBindingHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_RemoveAllPersistentBindings (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN hbaPortWWN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBARemoveAllPersistentBindingsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_RemoveAllPersistentBindings", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.RemoveAllPersistentBindingsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, hbaPortWWN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetFC4Statistics (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN portWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT8 FC4type,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FC4STATISTICS *pstatistics)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetFC4StatisticsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetFC4Statistics port: %s", WWN2STR1(&portWWN), 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetFC4StatisticsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (vendorHandle, portWWN, FC4type, pstatistics);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetFCPStatistics (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const HBA_SCSIID *lunit,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_FC4STATISTICS *pstatistics)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetFCPStatisticsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetFCPStatistics", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->functionTable.GetFCPStatisticsHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status =(registeredfunc)(vendorHandle, lunit, pstatistics);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_STATUS_ERROR_NOT_SUPPORTED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_GetVendorLibraryAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 adapter_index,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARYATTRIBUTES *attributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_ADAPTER_INFO *adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetVendorLibraryAttributesFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 ret = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_GetVendorLibraryAttributes adapterindex:%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapter_index, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(_hbaapi_librarylist == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(1, "HBAAPI not loaded yet.", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attributes == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_LL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GRAB_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_adapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(adapt_infop->index == adapter_index) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = adapt_infop->library->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte functionTable.GetVendorLibraryAttributesHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(registeredfunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = (registeredfunc)(attributes);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Version 1 libary? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAGetVersionFunc GetVersionFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetVersionFunc = adapt_infop->library->
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte functionTable.GetVersionHandler;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(GetVersionFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = ((GetVersionFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef NOTDEF
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This should not happen, dont think its going to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (attributes->LibPath[0] == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(strlen(adapt_infop->library->LibraryPath) < 256) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcpy(attributes->LibPath,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->library->LibraryPath);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_AL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, ret);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}