9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * ************************************************************************
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Description
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * HBAAPILIB.c - Implements a sample common (wrapper) HBA API library
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The contents of this file are subject to the SNIA Public License
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Version 1.0 (the "License"); you may not use this file except in
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * compliance with the License. You may obtain a copy of the License at
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * /http://www.snia.org/English/Resources/Code/OpenSource.html
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Software distributed under the License is distributed on an "AS IS"
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the License for the specific language governing rights and limitations
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * under the License.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The Original Code is SNIA HBA API Wrapper Library
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The Initial Developer of the Original Code is:
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Contributor(s):
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Tuan Lam, QLogic Corp. (t_lam@qlc.com)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * ************************************************************************
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Adding on SM-HBA support
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The implementation includes Three different categories functions to support
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * both HBAAPI and SM-HBA through the same library.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * SM-HBA unique interface:
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 1. CHECKLIBRARYANDVERSION(SMHBA) : match SMHBA VSL
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Or checking specifically if version is SMHBA beforehand.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 2. resolved to ftable.smhbafunctiontable.{interface}
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * HBAAPIV2 unique functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 1. CHECKLIBRARYANDVERSION(HBAAPIV2) : validate and match HBAAPI V2 VSL.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Or checking specifically if version is HBAAPIV2 beforehand.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 2. resolved to ftable.functiontable.{interface}
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Common interface between SM-HBA and HBAAPIV2.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 1. CHECKLIBRARY() : to validate the VSL.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 2. FUNCCOMMON macro to map the appropriate entry point table
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * (union ftable).
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 3. If the interface is not supported by HBAAPI(Version 1)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the funtiion ptr will be set to NULL.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Common interface between HBAAPI and HBAAPIV2.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 1. Check if version is not SMHBA).
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * 2. ftable.functiontalbe.(interface)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * ************************************************************************
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Use is subject to license terms.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Next define forces entry points in the dll to be exported
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * See hbaapi.h to see what it does.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * LIBRARY_NUM is a shortcut to figure out which library we need to call.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The top 16 bits of handle are the library index
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * VENDOR_HANDLE turns a global library handle into a vendor specific handle,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * with all upper 16 bits set to 0
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#else /* WIN32 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* WIN32 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#else /* Not both USESYSLOG and USELOGFILE */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* USESYSLOG */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#else /* WIN32 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* WIN32 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* USELOGFILE */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* Not both USELOGFILE and USESYSLOG */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * When multiple mutex's are grabed, they must be always be grabbed in
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the same order, or deadlock can result. There are three levels
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * of mutex's involved in this API. If LL_mutex is grabbed, always grap
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * it first. If AL_mutex is grabbed, it may not be grabbed before
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * LL_mutex. If grabbed in a multi grab sequence, the mutex's protecting
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the callback lists must always be grabbed last and release before calling
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * a vendor specific library function that might invoke a callback function
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * on the same thread.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#define RELEASE_MUTEX_RETURN(M, RET) release_mutex(M); return (RET)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#define RELEASE_MUTEX_RETURN(m, RET) LeaveCriticalSection(m); return (RET)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Vendor library information
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimtypedef enum {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimtypedef enum {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBA_ENTRYPOINTS smhbafunctionTable; /* smhba function pointers */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBA_ENTRYPOINTSV2 functionTable; /* hba api function pointers */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBA_LIBRARY_STATUS status; /* info on this library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_LL_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Macro to use the right function table between smhba and hbaapi.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Macro to use the right function ptr between smhba and hbaapi function table.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Should be used for an interface common to SM-HBA and HBAAPIV2.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Macro to use the hbaapi function ptr.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Should be used for an interface applicable only HBAAPIV2.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Macro to use the hbaapi function ptr.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Should be used for an interface applicable only HBAAPIV2.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Individual adapter (hba) information
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBA_STATUS GNstatus; /* status from GetAdapterNameFunc */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_AL_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Call back registration
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Each instance of HBA_ADAPTERCALLBACK_ELEM represents a call to one of
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * "register" functions that apply to a particular adapter.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * HBA_ALLADAPTERSCALLBACK_ELEM is used just for HBA_RegisterForAdapterAddEvents
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ALLADAPTERSCALLBACK_ELEM *_hbaapi_adapteraddevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportstatevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_hbaapi_targetevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_hbaapi_linkevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ALLADAPTERSCALLBACK_ELEM *_smhba_adapteraddevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_smhba_adapterevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_smhba_adapterportevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_smhba_adapterportstatevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_smhba_adapterphystatevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ADAPTERCALLBACK_ELEM *_smhba_targetevents_callback_list = NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* mutex's to protect each list */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _hbaapi_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_AAE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_AE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_APE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_APSE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_APHYSE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_TE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimpthread_mutex_t _smhba_LE_mutex = PTHREAD_MUTEX_INITIALIZER;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Common library internal. Mutex handling
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_SET_NOT_USED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "pthread_mutex_lock returned %d", ret, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_SET_NOT_USED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "pthread_mutex_unlock returned %d", ret, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Common library internal. Check library and return vendorhandle
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* caller will release the mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INVALID_HANDLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle); \
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * freevendorhandlelist is called with _hbaapi_LL_mutex already held
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimfreevendorhandlelist(HBA_VENDORCALLBACK_ELEM *vhlist) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimlocal_remove_callback(HBA_CALLBACKHANDLE cbhandle) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBA_STATUS status = HBA_STATUS_ERROR_INVALID_HANDLE;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* search through the simple lists first */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (cbp = **listp; cbp != NULL; cbp = cbp->next) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * if it wasnt in the simple lists,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * look in the list for adapteraddevents
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (allcbp = _hbaapi_adapteraddevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* should be HBAAPIV2 VSL to get to here */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vhlp->lib_info->ftable.functionTable.RemoveCallbackHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* now search smhba adapteradd events. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (allcbp = _smhba_adapteraddevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* should be SMHBA VSL to get to here */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_STATIC_UE_STATIC_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_STATIC_UE_STATIC_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_STATIC_UE_STATIC_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimstatic char *
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_STATIC_UE_STATIC_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim unsigned char *pc = (unsigned char *)&(wwn->wwn[0]);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Read in the config file and load all the specified vendor specific
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * libraries and perform the function registration exercise
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Open configuration file from known location */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* this is an app programming error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lStatus = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\SNIA\\HBA",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, configuration error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Enumerate all the subkeys. These have the form:
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * HKLM\Software\SNIA\HBA\<Vendor id> - note that we don't care
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * what the vendor id is
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (i = 0; ; i++) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim break; /* we're done */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (lStatus == ERROR_MORE_DATA) { /* buffer not big enough */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* do whatever */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Now open the subkey that pertains to this vendor's library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lStatus = RegOpenKeyEx(hkSniaHba, cSubKeyName, 0, KEY_READ,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, installation error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * you may want to return something
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * else or keep trying
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The name of the library is contained in a REG_SZ Value
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * keyed to "LibraryFile"
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lStatus = RegQueryValueEx(hkVendorLib, "LibraryFile", NULL, &dwType,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, installation error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof (HBA_LIBRARY_INFO));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* what is the right thing to do in MS land??? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, installation error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Now I can try to load the library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* printf("unable to load library %s\n", librarypath); */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, installation error */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "HBAAPI loading: %s\n", byFileName, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GetProcAddress(lib_infop->hLibrary, "SMHBA_RegisterLibrary");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Call the registration function to get the list of pointers */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RegisterV2Func = (HBARegisterLibraryV2Func)GetProcAddress(
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Load the function pointers directly into
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the table of functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (HBA_ENTRYPOINTSV2 *)(&lib_infop->ftable.functionTable));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Maybe the vendor library is only Rev1 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GetProcAddress(lib_infop->hLibrary, "HBA_RegisterLibrary");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Load the function points directly into
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the Rev 2 table of functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (HBA_ENTRYPOINTS *)(&lib_infop->ftable.functionTable)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* successfully loaded library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * SM-HBA and HBAAPI has a seperate handler for GetVersion but
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * they have the same function signature so use the same variable here.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GetVersionFunc = FUNCCOMMON(lib_infop, GetVersionHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Check the version of this library before loading */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#ifdef NOTDEF /* save for a later time... when it matters */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Check the version of this library before loading */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Actually... This wrapper is compatible with version 1 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#ifdef NOTDEF /* save for a later time... when it matters */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim LoadLibraryFunc = FUNCCOMMON(lib_infop, LoadLibraryHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Hmmm, dont we need to flag this in a realy big way??? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* How about messages to the system event logger ??? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Initialize this library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* ???Opportunity to send error msg, library error? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* successfully loaded library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim dud_library: /* its also just the end of the loop */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#else /* Unix as opposed to Win32 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim char *libraryname; /* Read in from file HBA.conf */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim char *librarypath; /* Read in from file HBA.conf */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: previously unfreed "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "libraries exist, call HBA_FreeLibrary().\n");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((hbaconf = fopen(hbaConfFilePath, "r")) == NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) printf("Cannot open %s\n", hbaConfFilePath);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Read in each line and load library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Skip the comments... */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((fullline[0] == '#') || (fullline[0] == '\n')) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* grab first 'thing' in line (if its there) */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((libraryname = strtok(fullline, " \t\n")) != NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Library name(%s) in %s is > 64 characters\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* grab second 'thing' in line (if its there) */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((librarypath = strtok(NULL, " \t\n")) != NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Library path(%s) in %s is > 256 characters\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* there should be no more 'things' in the line */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) fprintf(stderr, "Extraneous characters (\"%s\") in %s\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Continue to the next line if library name or path is invalid */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Special case....
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Look for loglevel
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim _hbaapi_debuglevel = strtol(librarypath, NULL, 10);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* error handling does the right thing automagically */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof (HBA_LIBRARY_INFO));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) fprintf(stderr, "HBA_LoadLibrary: out of memeory\n");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Load the DLL now */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((lib_infop->hLibrary = dlopen(librarypath, RTLD_LAZY)) == NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* printf("unable to load library %s\n", librarypath); */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Call the registration function to get the list of pointers */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim dlsym(lib_infop->hLibrary, "SMHBA_RegisterLibrary");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Load the function points directly into
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the table of functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim dlsym(lib_infop->hLibrary, "HBA_RegisterLibraryV2");
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Load the function points directly into
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the table of functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Maybe the vendor library is only Rev1 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* This function is required */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: vendor specific RegisterLibrary "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "RegisterLibrary function not found. lib: %s\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Load the function points directly into
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the table of functions
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ((HBA_ENTRYPOINTS *)(&lib_infop->ftable.functionTable)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* library not loaded */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: vendor specific RegisterLibrary "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "function encountered an error. lib: %s\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: vendor specific RegisterLibrary "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "function encountered an error. lib: %s\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* successfully loaded library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * SM-HBA and HBAAPI has a seperate handler for GetVersion but
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * they have the same function signature so use the same variable here.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((GetVersionFunc = FUNCCOMMON(lib_infop, GetVersionHandler))
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Got %d expected %d.\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Check the version of this library before loading */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Actually... This wrapper is compatible with version 1 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "Got %d expected %d.\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "%s libversion = %d", librarypath, libversion, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim LoadLibraryFunc = FUNCCOMMON(lib_infop, LoadLibraryHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* this function is required */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: vendor specific LoadLibrary "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "HBA_LoadLibrary: vendor specific LoadLibrary "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "function not found. lib: %s\n", librarypath, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Initialize this library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((status = ((LoadLibraryFunc)())) != HBA_STATUS_OK) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* maybe this should be a printf so that we CANNOT miss it */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_LoadLibrary: Encounterd and error loading: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "Encounterd and error loading: %s", librarypath, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* successfully loaded library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim#endif /* WIN32 or UNIX */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The _hbaapi_LL_mutex is already grabbed to proctect the caller of
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * HBA_FreeLibrary() during loading.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The mutexes are already initialized
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * with PTHREAD_MUTEX_INITIALIZER. Do we need to init again?
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Keeping the code from HBAAPI source...
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ret = pthread_mutex_init(&_hbaapi_AAE_mutex, NULL);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ret = pthread_mutex_init(&_hbaapi_APE_mutex, NULL);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ret = pthread_mutex_init(&_hbaapi_APSE_mutex, NULL);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ret = pthread_mutex_init(&_smhba_APSE_mutex, NULL);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (ret != 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_SET_NOT_USED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (lib_infop = _hbaapi_librarylist; lib_infop != NULL;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim FreeLibraryFunc = FUNCCOMMON(lib_infop, FreeLibraryHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Free this library */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(1, "HBA_FreeLibrary() Failed %d", status, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim FreeLibrary(lib_infop->hLibrary); /* Unload DLL from memory */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) dlclose(lib_infop->hLibrary); /* Unload DLL from memory */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * OK, now all functions are disabled except for LoadLibrary,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Hope no other thread calls it before we have returned
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Free up the callbacks, this is not the most efficient, but it works
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim while ((volatile HBA_ADAPTERCALLBACK_ELEM *)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim while ((volatile HBA_ADAPTERCALLBACK_ELEM *)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (listp = cb_lists_array; *listp != NULL; listp++) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim while ((volatile HBA_ADAPTERCALLBACK_ELEM ***)**listp != NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) local_remove_callback((HBA_CALLBACKHANDLE)**listp);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* this will unlock them as well, but who cares */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The API used to use fixed size tables as its primary data structure.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Indexing from 1 to N identified each adapters. Now the adapters are
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * on a linked list. There is a unique "index" foreach each adapter.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Adapters always keep their index, even if they are removed from the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * hardware. The only time the indexing is reset is on HBA_FreeLibrary
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim return (0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GRAB_MUTEX(&_hbaapi_LL_mutex); /* pay attention to order */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Also get the names of all the adapters here and cache */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GetAdapterNameFunc = FUNCCOMMON(lib_infop, GetAdapterNameHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (j = 0; j < num_adapters; j++) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (GetAdapterNameFunc)(j, (char *)&adaptername);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * check for duplicates, really,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * this may just be a second
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * call to this function
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * ??? how do we know when a name becomes stale?
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* already got this one */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_GetNumberOfAdapters: calloc failed"
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim " on sizeof:%lu\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTER_INFO)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((adapt_infop->GNstatus = status) == HBA_STATUS_OK) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) sprintf(dummyname, "NULLADAPTER-%255s-%03d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->LibraryPath, _hbaapi_total_adapter_count);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count);
0778188f242b11e5d53f771c9e8a069354b3d5d4Hengqing Hu DEBUG(1, "HBA_GetAdapterName: NULL pointer adaptername",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * The adapter index is from old code, but we have
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * to support it. Go down the list looking for
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the adapter
0778188f242b11e5d53f771c9e8a069354b3d5d4Hengqing Hu DEBUG(1, "HBA_OpenAdapter: NULL pointer adaptername",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim OpenAdapterFunc = FUNCCOMMON(lib_infop, OpenAdapterHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* retrieve the vendor handle */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* or this with the library index to get the common handle */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Finding an adapter with matching WWN.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_OpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "OpenAdapterByWWN: %s", WWN2STR1(&nodeWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* only for HBAAPIV2 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* look for new hardware */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.OpenAdapterByWWNHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * We do not know if the WWN is known by this vendor,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * just try it
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((status = (OpenAdapterFunc)(&handle, nodeWWN)) != HBA_STATUS_OK) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* OK, make a vendor non-specific handle */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim *phandle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RefreshAdapterConfiguration", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * This function is VERY OS dependent. Wing it as best you can.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_GetWrapperLibraryAttributes", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "NULL pointer attributes",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(attributes, 0, sizeof (HBA_LIBRARYATTRIBUTES));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((handle = dlopen("libHBAAPI.so", RTLD_NOW)) != NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* No need to do anything with the module handle */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* It wasn't alloocated so it doesn't need to be freed */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim matchCount = sscanf(BUILD_DATE, "%u/%u/%u %u:%u:%u",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim memset(&attributes->build_date, 0, sizeof (struct tm));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "%Y/%m/%d %T %Z", &(attributes->build_date)) == NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(&attributes->build_date, 0, sizeof (struct tm));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(&attributes->build_date, 0, sizeof (struct tm));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim return (2);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Callback registation and handling
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Adapter Add Events ************************************************* */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_ARG_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kimadapteraddevents_callback(void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AddAdapterEvent, port: %s", WWN2STR1(&PortWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*cbp->callback)(data, PortWWN, HBA_EVENT_ADAPTER_ADD);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RegisterForAdapterAddEvents", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: calloc failed "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ALLADAPTERSCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim cbp->next = _hbaapi_adapteraddevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Need to release the mutex now incase the vendor function invokes the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback. We will grap the mutex later to attach the vendor handle
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * list to the callback structure
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * now create a list of vendors (vendor libraryies, NOT ADAPTERS)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that have successfully registerred
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* only for HBAAPI V2 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RegisterForAdapterAddEventsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_VENDORCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(adapteraddevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* no HBAAPIV2 is deteced. should be okay? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (registered_cnt == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (status_OK_cnt == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * At least one vendor library registered this function, but no
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * vendor call succeeded
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we have had atleast some success, now finish up */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * this seems silly, but what if another thread called
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the callback remove
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* yup, its still there, hooray */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * bummer, somebody removed the callback before we finished
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * registration, probably will never happen
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "called for a handle before registration was finished.",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Adapter Events (other than add) ************************************** */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*acbp->callback)(acbp->userdata, PortWWN, eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RegisterForAdapterEventsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterEvents: calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Adapter Port Events ************************************************** */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (acbp = _hbaapi_adapterportevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*acbp->callback)(acbp->userdata, PortWWN, eventType, fabricPortID);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBARegisterForAdapterPortEventsFunc registeredfunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RegisterForAdapterPortEvents for port: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RegisterForAdapterPortEventsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterPortEvents: "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(adapterportevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim acbp->next = _hbaapi_adapterportevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Adapter State Events ************************************************ */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AdapterPortStatEvent, port:%s, eventType:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (acbp = _hbaapi_adapterportstatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*acbp->callback)(acbp->userdata, PortWWN, eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RegisterForAdapterPortStatEvents for port: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RegisterForAdapterPortStatEventsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterPortStatEvents: "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(adapterportstatevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim acbp->next = _hbaapi_adapterportstatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim _hbaapi_adapterportstatevents_callback_list = acbp;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Target Events ******************************************************* */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RegisterForTargetEvents, hbaPort: %s, discoveredPort: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RegisterForTargetEventsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForTargetEvents: calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Link Events ********************************************************* */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, RegisterForLinkEventsHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForLinkEvents: calloc failed for %lu bytes\n",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (unsigned long)(sizeof (HBA_ADAPTERCALLBACK_ELEM)));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * All of the functions below are almost passthru functions to the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * vendor specific function
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim CloseAdapterFunc = FUNCCOMMON(lib_infop, CloseAdapterHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetAdapterAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetAdapterPortAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetPortStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_GetDiscoveredPortAttributes", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetDiscoveredPortAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_GetPortAttributesByWWN: %s", WWN2STR1(&PortWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetPortAttributesByWWNHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.SendCTPassThruHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendCTPassThruV2Handler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetEventBufferHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_SetRNIDMgmtInfo(HBA_HANDLE handle, HBA_MGMTINFO Info) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SetRNIDMgmtInfoFunc = FUNCCOMMON(lib_infop, SetRNIDMgmtInfoHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (SetRNIDMgmtInfoFunc)(vendorHandle, Info);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_GetRNIDMgmtInfo(HBA_HANDLE handle, HBA_MGMTINFO *pInfo) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim GetRNIDMgmtInfoFunc = FUNCCOMMON(lib_infop, GetRNIDMgmtInfoHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (GetRNIDMgmtInfoFunc)(vendorHandle, pInfo);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_SendRNID for wwn: %s", WWN2STR1(&wwn), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SendRNIDFunc = lib_infop->ftable.functionTable.SendRNIDHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((SendRNIDFunc)(vendorHandle, wwn, wwntype,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_SendRNIDV2, hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendRNIDV2Handler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (vendorHandle, hbaPortWWN, destWWN, destFCID, NodeIdDataFormat,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_ResetStatistics(HBA_HANDLE handle, HBA_UINT32 portindex) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ResetStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_GetFcpTargetMapping(HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim HBAGetFcpTargetMappingFunc GetFcpTargetMappingFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetFcpTargetMappingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetFcpTargetMappingFunc)(vendorHandle, mapping));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetFcpTargetMappingV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((registeredfunc)(vendorHandle, hbaPortWWN, pmapping));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon KimHBA_GetFcpPersistentBinding(HBA_HANDLE handle, PHBA_FCPBINDING binding) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetFcpPersistentBindingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetFcpPersistentBindingFunc)(vendorHandle, binding));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_ScsiInquiryV2 to discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ScsiInquiryV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, CDB_Byte1,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim CDB_Byte2, pRspBuffer, pRspBufferSize, pScsiStatus,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ScsiInquiryHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, PortWWN, fcLUN, EVPD, PageCode, pRspBuffer,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_ScsiReportLUNsV2 to discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ScsiReportLUNsV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_SendReportLUNs to PortWWN: %s", WWN2STR1(&portWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SendReportLUNsFunc = lib_infop->ftable.functionTable.ReportLUNsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_ScsiReadCapacityV2 to discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ScsiReadCapacityV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INCOMPATIBLE);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.ReadCapacityHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendRPLHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, agent_wwn, agent_domain, portindex,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendRPSHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_SendSRL to wwn:%s domain:%d", WWN2STR1(&wwn), domain, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendSRLHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendRLSHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_SendLIRR destWWN:%s", WWN2STR1(&destWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = FUNCCOMMON(lib_infop, SendLIRRHandler);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetBindingCapabilityHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetBindingSupportHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, pcapability);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.SetBindingSupportHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, capability);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.SetPersistentBindingV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetPersistentBindingV2Handler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RemovePersistentBindingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN, pbinding);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_RemoveAllPersistentBindings", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.RemoveAllPersistentBindingsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, hbaPortWWN);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_GetFC4Statistics port: %s", WWN2STR1(&portWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetFC4StatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.functionTable.GetFCPStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(vendorHandle, lunit, pstatistics);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "HBA_GetVendorLibraryAttributes adapterindex:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim return (0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_GetVendorLibraryAttributes: NULL pointer attributes",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(attributes, 0, sizeof (HBA_LIBRARYATTRIBUTES));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ftable.functionTable.GetVendorLibraryAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* Version 1 libary? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* This should not happen, dont think its going to */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strlen(adapt_infop->library->LibraryPath) < 256) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * This function returns SM-HBA version that the warpper library implemented.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * This function returns the attributes for the warpper library.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetWrapperLibraryAttributes", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "NULL pointer attributes",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(attributes, 0, sizeof (SMHBA_LIBRARYATTRIBUTES));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if ((handle = dlopen("libSMHBAAPI.so", RTLD_NOW)) != NULL) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim return (1);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * This function returns the attributes for the warpper library.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetVendorLibraryAttributes adapterindex:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim return (0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "NULL pointer attributes",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) memset(attributes, 0, sizeof (SMHBA_LIBRARYATTRIBUTES));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim ftable.smhbafunctionTable.GetVendorLibraryAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* This should not happen since the VSL is already loaded. */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim if (strlen(adapt_infop->library->LibraryPath) < 256) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBAGetAdapterAttributesFunc GetAdapterAttributesFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetAdapterAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetNumberOfPortsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetNumberOfPortsFunc)(vendorHandle, numberofports));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetPortTypeHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetPortTypeFunc)(vendorHandle, portindex, porttype));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetAdapterPortAttributes", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetDiscoveredPortAttributes", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetPortAttributesByWWN: %s", WWN2STR1(&portWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetPortAttributesByWWNHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (vendorHandle, portWWN, domainPortWWN, portattributes));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBAGetFCPhyAttributesFunc GetFCPhyAttributesFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetFCPhyAttributesByWWN", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetFCPhyAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBAGetSASPhyAttributesFunc GetSASPhyAttributesFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetFCPhyAttributesByWWN", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetSASPhyAttributesHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetProtocolStatistics port index: %d protocol type: %d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetProtocolStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (vendorHandle, portindex, protocoltype, pProtocolStatistics);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetPhyStatistics port index: %d phy idex: %d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetPhyStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (vendorHandle, portindex, phyindex, pPhyStatistics);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBAGetBindingCapabilityFunc GetBindingCapabilityFunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetBindingCapabilityHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (GetBindingCapabilityFunc)(vendorHandle, hbaPortWWN,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetBindingSupportHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.SetBindingSupportHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetTargetMappingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_GetPersistentBinding port WWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetPersistentBindingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_SetPersistentBinding port WWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.SetPersistentBindingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RemovePersistentBinding port WWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.RemovePersistentBindingHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((RemovePersistentBindingFunc)(vendorHandle,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RemoveAllPersistentBinding port WWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((RemoveAllPersistentBindingsFunc)(vendorHandle,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.GetLUNStatisticsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = ((GetLUNStatisticsFunc)(vendorHandle, lunit, statistics));
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_ScsiInquiry to hba port: %s discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.ScsiInquiryHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim smhbaLUN, CDB_Byte1, CDB_Byte2, pRspBuffer, pRspBufferSize,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_ScsiReportLuns to hba port: %s discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.ScsiReportLUNsHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_ScsiReadCapacity to hba port: %s discoveredPortWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR1(&discoveredPortWWN), 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim lib_infop->ftable.smhbafunctionTable.ScsiReadCapacityHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim vendorHandle, hbaPortWWN, discoveredPortWWN, domainPortWWN,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim smhbaLUN, pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SendTESTFunc = lib_infop->ftable.smhbafunctionTable.SendTESTHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SendECHOFunc = lib_infop->ftable.smhbafunctionTable.SendECHOHandler;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_SendSMPPassThru, hbaPortWWN: %s destWWN: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Following the similar logic of HBAAPI addaspterevents_callback.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Unlike other events Adapter Add Event is not limited to a specific
0778188f242b11e5d53f771c9e8a069354b3d5d4Hengqing Hu * adapter(i.e. no adapter handle is passed for registration) so
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the event should be passed to all registrants. The routine below
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * is passed to the VSLs as a callback and when Adapter Add event is detected
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * by VSL it will call smhba_adapteraddevents_callback() which in turn check
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * if the passed userdata ptr matches with the one stored in the callback list
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * and calls the stored callback.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * For the situation that multiple clients are registered for Adapter Add event
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * each registration is passed to VSLs so VSL may call
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * smhba_adapteraddevents_callback() multiple times or it may call only once
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * since the callback function is same. For this implemneation, the userdata
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * is stored in HBA_ALLADAPTERSCALLBACK_ELEM so it is expected that VSL call
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * smhba_adapteraddevents_callback() only once and
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * smhba_adapteraddevents_callback() will call the client callback with proper
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * userdata.
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_ARG_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* LINTED E_FUNC_ARG_UNUSED */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AddAdapterEvent, port:%s", WWN2STR1(&PortWWN), 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*cbp->callback)(cbp->userdata, PortWWN, HBA_EVENT_ADAPTER_ADD);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBARegisterForAdapterAddEventsFunc registeredfunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RegisterForAdapterAddEvents", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * Need to release the mutex now incase the vendor function invokes the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback. We will grap the mutex later to attach the vendor handle
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * list to the callback structure
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * now create a list of vendors (vendor libraryies, NOT ADAPTERS)
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that have successfully registerred
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* only for HBAAPI V2 */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_adapteraddevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "SMHBA_RegisterForAdapterAddEvents: Library->%s, Error->%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* no SMHBA VSL found. Should be okay?? */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (registered_cnt == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (status_OK_cnt == 0 && not_supported_cnt != 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim } else if (status_OK_cnt == 0) {
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * At least one vendor library registered this function, but no
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * vendor call succeeded
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (void) local_remove_callback((HBA_CALLBACKHANDLE) cbp);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we have had atleast some success, now finish up */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * this seems silly, but what if another thread called
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * the callback remove
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* yup, its still there, hooray */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * bummer, somebody removed the callback before we finished
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * registration, probably will never happen
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was "
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "called for a handle before registration was finished.",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* SMHBA Adapter Events (other than add) ******************************** */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN),
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*acbp->callback)(acbp->userdata, PortWWN, eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RegisterForAdapterEvents", 0, 0, 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = lib_infop->ftable.smhbafunctionTable.\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_adapterevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* Adapter Port Events *********************************************** */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "SMHBA_AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (acbp = _smhba_adapterportevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim SMHBARegisterForAdapterPortEventsFunc registeredfunc;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RegisterForAdapterPortEvents for port: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_adapterportevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim acbp->next = _smhba_adapterportevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* SMHBA Adapter Port Stat Events ******************************** */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "SMBA_AdapterPortStateEvent, port:%s, eventType:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (acbp = _smhba_adapterportstatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RegisterForAdapterPortStatEvents for port: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_adapterportstatevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim acbp->next = _smhba_adapterportstatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* SMHBA Adapter Port Phy Stat Events ************************************ */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "SMBA_AdapterPortStateEvent, port:%s, eventType:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim for (acbp = _smhba_adapterphystatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim (*acbp->callback)(acbp->userdata, portWWN, phyIndex, eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(2, "SMHBA_RegisterForAdapterPhyStatEvents for port: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_adapterphystatevents_callback,
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim acbp->next = _smhba_adapterphystatevents_callback_list;
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim/* SMHBA Target Events ********************************************* */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim "%s, discoveredPort: %s",
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim /* we now have the _hbaapi_LL_mutex */
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim registeredfunc = lib_infop->ftable.smhbafunctionTable.\
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * that allocated memory is used both as the handle for the
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * caller, and as userdata to the vendor call so that on
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim * callback the specific registration may be recalled
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR);
9e86db79b7d1bbc5f2f04e99954cbd5eae0e22bbHyon Kim status = (registeredfunc)(smhba_targetevents_callback,