fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBAAPILIB-sun.c - Implements the Sun Extention for Target mode
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FCHBA discovery
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 *
bff3dadc2c9a6711b6e359fc39d0170de218be50duo liu - Sun Microsystems - Beijing China * 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 *************************************************************************
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
bff3dadc2c9a6711b6e359fc39d0170de218be50duo liu - Sun Microsystems - Beijing China/*
a79493184c9332129c9c91500069322f6f3fafddReed * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
bff3dadc2c9a6711b6e359fc39d0170de218be50duo liu - Sun Microsystems - Beijing China * Use is subject to license terms.
bff3dadc2c9a6711b6e359fc39d0170de218be50duo liu - Sun Microsystems - Beijing China */
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 <dlfcn.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "hbaapi.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "hbaapi-sun.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/*
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 Forteextern int _hbaapi_debuglevel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define DEBUG(L, STR, A1, A2, A3)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if defined(USESYSLOG) && defined(USELOGFILE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern FILE *_hbaapi_debug_fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int _hbaapi_sysloginit;
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*/
a79493184c9332129c9c91500069322f6f3fafddReed
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 */
a79493184c9332129c9c91500069322f6f3fafddReed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <pthread.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
a79493184c9332129c9c91500069322f6f3fafddReed * 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
a79493184c9332129c9c91500069322f6f3fafddReed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HBA_LIBRARY_STATUS and HBA_LIBRARY_INFO are redefined here.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Avoid any change in the common code.
a79493184c9332129c9c91500069322f6f3fafddReed */
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 Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern HBA_LIBRARY_INFO *_hbaapi_librarylist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern HBA_UINT32 _hbaapi_total_library_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern pthread_mutex_t _hbaapi_LL_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern CRITICAL_SECTION _hbaapi_LL_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function type def fop Sun extentions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_UINT32 (* Sun_HBAGetNumberOfTgtAdaptersFunc)();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAGetTgtAdapterNameFunc)(HBA_UINT32, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_HANDLE (* Sun_HBAOpenTgtAdapterFunc)(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAOpenTgtAdapterByWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE *, HBA_WWN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBANPIVGetAdapterAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_ADAPTERATTRIBUTES *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAGetNPIVPortInfoFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_UINT32, HBA_NPIVATTRIBUTES *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBADeleteNPIVPortFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_WWN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBACreateNPIVPortFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_WWN, HBA_WWN, HBA_UINT32 *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAAdapterReturnWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_WWN *, HBA_WWN *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAAdapterCreateWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_WWN *, HBA_WWN *, HBA_WWN *,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_INT32);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBAGetPortNPIVAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (HBA_HANDLE, HBA_UINT32, HBA_PORTNPIVATTRIBUTES *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef HBA_STATUS (* Sun_HBARegisterForAdapterDeviceEventsFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void (*)(void *, HBA_WWN, HBA_UINT32, HBA_UINT32),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void *, HBA_HANDLE, HBA_WWN, HBA_CALLBACKHANDLE *);
a79493184c9332129c9c91500069322f6f3fafddReedtypedef HBA_STATUS (* Sun_HBADoForceLipFunc)(HBA_HANDLE, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Individual adapter (hba) information
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Same as hbaadapter with different structure name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct hba_tgtadapter_info {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_tgtadapter_info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS GNstatus; /* status from GetTgtAdapterNameFunc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN nodeWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *library;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 index;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} HBA_TGTADAPTER_INFO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Make the list as an array with max size 16
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_TGTADAPTER_INFO *_hbaapi_tgtadapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_UINT32 _hbaapi_total_tgtadapter_count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef POSIX_THREADS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepthread_mutex_t _hbaapi_tgtAL_mutex = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#elif defined(WIN32)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCRITICAL_SECTION _hbaapi_tgtAL_mutex;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
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 * 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 ForteSun_HBA_GetNumberOfTgtAdapters()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int j=0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAGetNumberOfTgtAdaptersFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAGetTgtAdapterNameFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetTgtAdapterNameFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_BOOLEAN found_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_TGTADAPTER_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_tgtAL_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 if (lib_infop->hLibrary != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = (Sun_HBAGetNumberOfTgtAdaptersFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcGetNumberOfTgtAdapters");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetTgtAdapterNameFunc = (Sun_HBAGetTgtAdapterNameFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcGetTgtAdapterName");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetNumberOfTgtAdaptersFunc == NULL ||
a79493184c9332129c9c91500069322f6f3fafddReed GetTgtAdapterNameFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = GetTgtAdapterNameFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte num_adapters = ((GetNumberOfTgtAdaptersFunc)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef WIN32
a79493184c9332129c9c91500069322f6f3fafddReed DEBUG(1, "HBAAPI: number of target mode adapters for %s = %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryName, num_adapters, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
a79493184c9332129c9c91500069322f6f3fafddReed DEBUG(1, "HBAAPI: number of target mode_adapters for %s = %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, num_adapters, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < num_adapters; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found_name = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = (GetTgtAdapterNameFunc)(j, (char *)&adaptername);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status == HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_tgtadapterlist;
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_TGTADAPTER_INFO *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_TGTADAPTER_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_TGTADAPTER_INFO));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_tgtAL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_tgtadapter_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];
a79493184c9332129c9c91500069322f6f3fafddReed sprintf(dummyname, "NULLADAPTER-%s-%03d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lib_infop->LibraryPath, _hbaapi_total_tgtadapter_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_tgtadapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop->index = _hbaapi_total_tgtadapter_count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_tgtadapterlist = adapt_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_total_tgtadapter_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = GetTgtAdapterNameFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX(&_hbaapi_tgtAL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_tgtadapter_count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSun_HBA_GetTgtAdapterName(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 adapterindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *adaptername)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_TGTADAPTER_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_tgtAL_mutex);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *adaptername = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for(adapt_infop = _hbaapi_tgtadapterlist;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapt_infop = adapt_infop->next) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(adapt_infop->index == adapterindex) {
a79493184c9332129c9c91500069322f6f3fafddReed 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 ForteSun_HBA_OpenTgtAdapter(char* adaptername)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAOpenTgtAdapterFunc OpenTgtAdapterFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_TGTADAPTER_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_tgtadapterlist;
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 OpenTgtAdapterFunc = (Sun_HBAOpenTgtAdapterFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcOpenTgtAdapter");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (OpenTgtAdapterFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* retrieve the vendor handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = (OpenTgtAdapterFunc)(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/*
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 ForteSun_HBA_OpenTgtAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAGetNumberOfTgtAdaptersFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAOpenTgtAdapterByWWNFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OpenTgtAdapterByWWNFunc;
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 GetNumberOfTgtAdaptersFunc = (Sun_HBAGetNumberOfTgtAdaptersFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcGetNumberOfTgtAdapters");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte OpenTgtAdapterByWWNFunc = (Sun_HBAOpenTgtAdapterByWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcOpenTgtAdapterByWWN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetNumberOfTgtAdaptersFunc == NULL ||
a79493184c9332129c9c91500069322f6f3fafddReed OpenTgtAdapterByWWNFunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = OpenTgtAdapterByWWNFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) ((GetNumberOfTgtAdaptersFunc)());
a79493184c9332129c9c91500069322f6f3fafddReed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if((status = (OpenTgtAdapterByWWNFunc)(&handle, nodeWWN))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != HBA_STATUS_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNumberOfTgtAdaptersFunc = OpenTgtAdapterByWWNFunc = NULL;
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 GetNumberOfTgtAdaptersFunc = OpenTgtAdapterByWWNFunc = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic HBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_NPIV_CheckLibrary(HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO **lib_infopp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE *vendorhandle) {
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 NPIVCHECKLIBRARY() \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = HBA_NPIV_CheckLibrary(handle, &lib_infop, &vendorHandle); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(status != HBA_STATUS_OK) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(status); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSun_HBA_NPIVGetAdapterAttributes (
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 Sun_HBANPIVGetAdapterAttributesFunc NPIVGetAdapterAttributesFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(2, "HBA_NPIVGetAdapterAttributes", 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVGetAdapterAttributesFunc = (Sun_HBANPIVGetAdapterAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcNPIVGetAdapterAttributes");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (NPIVGetAdapterAttributesFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((NPIVGetAdapterAttributesFunc)(vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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 ForteSun_HBA_GetNPIVPortInfo (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 vportindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_NPIVATTRIBUTES *attributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAGetNPIVPortInfoFunc GetNPIVPortInfoFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetNPIVPortInfoFunc = (Sun_HBAGetNPIVPortInfoFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcGetNPIVPortInfo");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetNPIVPortInfoFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetNPIVPortInfoFunc)(vendorHandle, portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vportindex, attributes));
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 ForteSun_HBA_DeleteNPIVPort (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN vportWWN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBADeleteNPIVPortFunc DeleteNPIVPortFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DeleteNPIVPortFunc = (Sun_HBADeleteNPIVPortFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcDeleteNPIVPort");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DeleteNPIVPortFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((DeleteNPIVPortFunc)(vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portindex, vportWWN));
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 ForteSun_HBA_CreateNPIVPort (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN vnodeWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN vportWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 *vportindex)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBACreateNPIVPortFunc CreateNPIVPortFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CreateNPIVPortFunc = (Sun_HBACreateNPIVPortFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcCreateNPIVPort");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (CreateNPIVPortFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((CreateNPIVPortFunc)(vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portindex, vnodeWWN, vportWWN, vportindex));
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 ForteSun_HBA_GetPortNPIVAttributes (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_PORTNPIVATTRIBUTES *portnpivattributes)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAGetPortNPIVAttributesFunc GetPortNPIVAttributesFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte GetPortNPIVAttributesFunc = (Sun_HBAGetPortNPIVAttributesFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcGetPortNPIVAttributes");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (GetPortNPIVAttributesFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((GetPortNPIVAttributesFunc)(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vendorHandle, portindex, portnpivattributes));
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 ForteSun_HBA_AdapterCreateWWN (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN *nwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN *pwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN *OUI,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_INT32 method)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAAdapterCreateWWNFunc AdapterCreateWWNFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterCreateWWNFunc = (Sun_HBAAdapterCreateWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcAdapterCreateWWN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (AdapterCreateWWNFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((AdapterCreateWWNFunc)(vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portindex, nwwn, pwwn, OUI, method));
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 ForteSun_HBA_AdapterReturnWWN (
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 portindex,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN *nwwn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN *pwwn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBAAdapterReturnWWNFunc AdapterReturnWWNFunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterReturnWWNFunc = (Sun_HBAAdapterReturnWWNFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary, "Sun_fcAdapterReturnWWN");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (AdapterReturnWWNFunc != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = ((AdapterReturnWWNFunc)(vendorHandle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte portindex, nwwn, pwwn));
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 Fortetypedef struct hba_npivadaptercallback_elem {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hba_npivadaptercallback_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_NPIVADAPTERCALLBACK_ELEM;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern HBA_NPIVADAPTERCALLBACK_ELEM *_hbaapi_adapterdeviceevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Adapter Device Events ********************************************************/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadapterdeviceevents_callback (void *data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_WWN PortWWN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 eventType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_UINT32 fabricPortID)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_NPIVADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DEBUG(3, "AdapterDeviceEvent, 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_adapterdeviceevents_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 Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHBA_STATUS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSun_HBA_RegisterForAdapterDeviceEvents (
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_NPIVADAPTERCALLBACK_ELEM *acbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_STATUS status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_LIBRARY_INFO *lib_infop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBA_HANDLE vendorHandle;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Sun_HBARegisterForAdapterDeviceEventsFunc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (callbackHandle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return(HBA_STATUS_ERROR_ARG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NPIVCHECKLIBRARY();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte registeredfunc = (Sun_HBARegisterForAdapterDeviceEventsFunc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dlsym(lib_infop->hLibrary,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sun_fcRegisterForAdapterDeviceEvents");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (registeredfunc == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte acbp = (HBA_NPIVADAPTERCALLBACK_ELEM *)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte calloc(1, sizeof(HBA_NPIVADAPTERCALLBACK_ELEM));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if(acbp == NULL) {
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)(adapterdeviceevents_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_adapterdeviceevents_callback_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _hbaapi_adapterdeviceevents_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}
a79493184c9332129c9c91500069322f6f3fafddReed
a79493184c9332129c9c91500069322f6f3fafddReedHBA_STATUS
a79493184c9332129c9c91500069322f6f3fafddReedSun_HBA_ForceLip(HBA_HANDLE handle, int *rval)
a79493184c9332129c9c91500069322f6f3fafddReed{
a79493184c9332129c9c91500069322f6f3fafddReed HBA_STATUS status;
a79493184c9332129c9c91500069322f6f3fafddReed HBA_LIBRARY_INFO *lib_infop;
a79493184c9332129c9c91500069322f6f3fafddReed HBA_HANDLE vendorHandle;
a79493184c9332129c9c91500069322f6f3fafddReed
a79493184c9332129c9c91500069322f6f3fafddReed Sun_HBADoForceLipFunc DoForceLipFunc;
a79493184c9332129c9c91500069322f6f3fafddReed
a79493184c9332129c9c91500069322f6f3fafddReed DEBUG(2, "Sun_HBA_DoForceLip", 0, 0, 0);
a79493184c9332129c9c91500069322f6f3fafddReed
a79493184c9332129c9c91500069322f6f3fafddReed NPIVCHECKLIBRARY();
a79493184c9332129c9c91500069322f6f3fafddReed DoForceLipFunc = (Sun_HBADoForceLipFunc)
a79493184c9332129c9c91500069322f6f3fafddReed dlsym(lib_infop->hLibrary, "Sun_fcDoForceLip");
a79493184c9332129c9c91500069322f6f3fafddReed if (DoForceLipFunc != NULL) {
a79493184c9332129c9c91500069322f6f3fafddReed status = ((DoForceLipFunc)(vendorHandle, rval));
a79493184c9332129c9c91500069322f6f3fafddReed } else {
a79493184c9332129c9c91500069322f6f3fafddReed status = HBA_STATUS_ERROR_NOT_SUPPORTED;
a79493184c9332129c9c91500069322f6f3fafddReed }
a79493184c9332129c9c91500069322f6f3fafddReed RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status);
a79493184c9332129c9c91500069322f6f3fafddReed}