pax_global_header00006660000000000000000000000064121475162620014520gustar00rootroot0000000000000052 comment=f122ddb45429c3866a87a9a3de4b41777d3db195 libhbaapi-2.2.9/000077500000000000000000000000001214751626200134455ustar00rootroot00000000000000libhbaapi-2.2.9/COPYING000066400000000000000000000521711214751626200145060ustar00rootroot00000000000000STORAGE NETWORKING INDUSTRY ASSOCIATION PUBLIC LICENSE Version 1.1 1. Definitions. 1.1 "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. 1.2 "Contributor" means each entity that creates or contributes to the creation of Modifications. 1.3 "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. 1.4 "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. 1.5 "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. 1.6 "Executable" means Covered Code in any form other than Source Code. 1.7 "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. 1.8 "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. 1.9 "License" means this document. 1.10 "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 1.11 "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. B. Any new file that contains any part of the Original Code or previous Modifications. 1.12 "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. 1.13 "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 1.14 "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. 1.15 "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity 2. Source Code License. 2.1 The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and (b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). (c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. (d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. 2.2 Contributor Grant. Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). (c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. (d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. 3. Distribution Obligations. 3.1 Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. 3.2 Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. 3.3 Description of Modifications. You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. 3.4 Intellectual Property Matters. (a) Third Party Claims. If Contributor has actual knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter. (b) Contributor API's. If Contributor's Modifications include an application programming interface and Contributor has actual knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. (c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. 3.5 Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be most likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability (excluding any liability arising from intellectual property claims relating to the Covered Code) incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.6 Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligation of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability (excluding any liability arising from intellectual property claims relating to the Covered Code) incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 3.7 Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. 4. Inability to Comply Due to Statute or Regulation. If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Application of this License. This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. 6. Versions of the License. 6.1 New Versions. The Storage Networking Industry Association (the "SNIA") may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. 6.2 Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by the SNIA. No one other than the SNIA has the right to modify the terms applicable to Covered Code created under this License. 6.3 Derivative Works. If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "Storage Networking Industry Association," "SNIA," or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the SNIA Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) 7. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 8. TERMINATION. 8.1 This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within a reasonable time after becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 8.2 If You initiate litigation by asserting a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: (a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. 8.3 If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. 8.4 In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. 9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 10. U.S. GOVERNMENT END USERS. The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. 11. MISCELLANEOUS This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. 12. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. 13. MULTIPLE-LICENSED CODE. Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of this License or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. 14. ACCEPTANCE. This License is accepted by You if You retain, use, or distribute the Covered Code for any purpose. EXHIBIT A �The SNIA Public License. The contents of this file are subject to the SNIA Public License Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at www.snia.org/smi/developers/cim/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is . The Initial Developer of the Original Code is [COMPLETE THIS] . libhbaapi-2.2.9/HBAAPI.pc.in000066400000000000000000000003261214751626200153230ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: HBAAPI Description: SNIA HBAAPI Fabric Management Version: @VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lHBAAPI -ldl libhbaapi-2.2.9/INSTALL000066400000000000000000000005451214751626200145020ustar00rootroot00000000000000This document explains how to build the sourceforge HBA API wraper library from source. ## # HBA API Wrapper Library ########################## DEPENDENCIES * autoconf * autotools * sysconftool * automake * libtool PROCESS 1) Bootstrap, configure, make and make install # ./bootstrap.sh # rpm --eval "%configure" | sh # make # make install libhbaapi-2.2.9/Makefile.am000066400000000000000000000011411214751626200154760ustar00rootroot00000000000000lib_LTLIBRARIES = libHBAAPI.la libHBAAPI_la_SOURCES = hbaapi.h vendorhbaapi.h nodist_libHBAAPI_la_SOURCES = hbaapilib.c libHBAAPI_la_LDFLAGS = -version-info 2:2:0 nobase_include_HEADERS = hbaapi.h vendorhbaapi.h pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = HBAAPI.pc dist_sysconf_DATA = hba.conf dist_noinst_DATA = HBAAPI.pc.in libHBAAPI.spec clean-local: -if [ ${abs_srcdir} != ${abs_builddir} ]; then \ rm -f hba.conf; \ fi # re-write hba.conf to edit out everything except for comments and blank lines FORCE: hba.conf: FORCE grep "^#\|^[[:space:]]*$$" ${srcdir}/$@ > $@.tmp mv $@.tmp $@ libhbaapi-2.2.9/bootstrap.sh000077500000000000000000000000451214751626200160200ustar00rootroot00000000000000#! /bin/sh exec autoreconf --install libhbaapi-2.2.9/build.sh000077500000000000000000000002031214751626200150760ustar00rootroot00000000000000#!/bin/sh TARGET=hbaapi_build_2.2.tar.gz ./bootstrap.sh tar --exclude build.sh --exclude .git --exclude ${TARGET} -zcf ${TARGET} . libhbaapi-2.2.9/configure.ac000066400000000000000000000003301214751626200157270ustar00rootroot00000000000000AC_INIT([libHBAAPI], [2.2.9], [fcoe-devel@open-fcoe.org]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_PROG_LIBTOOL AC_CONFIG_FILES([Makefile HBAAPI.pc]) AC_OUTPUT libhbaapi-2.2.9/hba.conf000066400000000000000000000021271214751626200150500ustar00rootroot00000000000000# # This file contains names and references to HBA libraries # # Format: # # # # The library name should be prepended with the domain of # the manufacturer or driver author. # # 32bit/64bit implementation note: # If a 32bit implementation tries to load a 64 bit library, # the load will fail with the result that the 64 bit vendor # library is ignored. # Likewise, if a 64bit implementation tries to load a 32 bit library, # the load will fail with the result that the 32 bit vendor # library is ignored. org.snia.sample32 /usr/lib/libsample.so com.qlogic.qla32 /usr/lib/libhbaapiqla.so com.emulex.lightpulse32 /usr/lib/libhbaapiemu.so com.emulex.lightpulse64 /usr/lib/sparcv9/libhbaapiemu.so JniHbaLib /opt/JNIsnia/Solaris/Jni/32bit/JniHbaLib.so JniHbaLib /opt/JNIsnia/Solaris/Jni/64bit/JniHbaLib.so # Set a debug level (depends on compilation switches) # # Format: # # "debuglevel" # # 0 is default, 1 show vendor library opens, # 2 shows function calls, 3 shows callback events # # Uncomment the next line to specify a level #debuglevel 3 libhbaapi-2.2.9/hbaapi.h000066400000000000000000000626431214751626200150550ustar00rootroot00000000000000/****************************************************************************** * * Description * hbaapi.h - general header file for client * and library developers * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is SNIA HBA API general header file * * The Initial Developer of the Original Code is: * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) * * Contributor(s): * Tuan Lam, QLogic Corp. (t_lam@qlc.com) * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com) * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com) * ******************************************************************************* * * Changes: * 03/09/2000 Initial Draft * (for other changes... see the CVS logs) ******************************************************************************/ #ifdef __cplusplus extern "C" { #endif #ifndef HBA_API_H #define HBA_API_H /* Library version string */ #define HBA_LIBVERSION 2 /* DLL imports for WIN32 operation */ #ifdef WIN32 #ifdef HBAAPI_EXPORTS #define HBA_API __declspec(dllexport) #else #define HBA_API __declspec(dllimport) #endif #else #define HBA_API #endif /* OS specific definitions */ #ifdef WIN32 typedef unsigned char HBA_UINT8; // Unsigned 8 bits typedef char HBA_INT8; // Signed 8 bits typedef unsigned short HBA_UINT16; // Unsigned 16 bits typedef short HBA_INT16; // Signed 16 bits typedef unsigned int HBA_UINT32; // Unsigned 32 bits typedef int HBA_INT32; // Signed 32 bits typedef void* HBA_PVOID; // Pointer to void typedef HBA_UINT32 HBA_VOID32; // Opaque 32 bits /* Don't confuse, _WIN32 with WIN32... OK, how do you accompish that */ #ifdef _WIN32 typedef _int64 HBA_INT64; typedef unsigned _int64 HBA_UINT64; #else typedef struct { TN_UINT32 lo_val; TN_UINT32 hi_val; } HBA_INT64; typedef struct { TN_UINT32 lo_val; TN_UINT32 hi_val; } HBA_UINT64; #endif /* #ifdef _WIN32 */ #else /* Note this section needs to be cleaned up for various Unix platforms */ typedef unsigned char HBA_UINT8; /* Unsigned 8 bits */ typedef char HBA_INT8; /* Signed 8 bits */ typedef unsigned short HBA_UINT16; /* Unsigned 16 bits */ typedef short HBA_INT16; /* Signed 16 bits */ typedef unsigned int HBA_UINT32; /* Unsigned 32 bits */ typedef int HBA_INT32; /* Signed 32 bits */ typedef void* HBA_PVOID; /* Pointer to void */ typedef HBA_UINT32 HBA_VOID32; /* Opaque 32 bits */ typedef long long HBA_INT64; typedef long long HBA_UINT64; #endif /* #ifdef WIN32 */ /* 6.1 Handle to Device */ typedef HBA_UINT32 HBA_HANDLE; #define HBA_HANDLE_INVALID 0 /* 6.1 Status Return Values */ typedef HBA_UINT32 HBA_STATUS; #define HBA_STATUS_OK 0 #define HBA_STATUS_ERROR 1 /* Error */ #define HBA_STATUS_ERROR_NOT_SUPPORTED 2 /* Function not supported.*/ #define HBA_STATUS_ERROR_INVALID_HANDLE 3 /* invalid handle */ #define HBA_STATUS_ERROR_ARG 4 /* Bad argument */ #define HBA_STATUS_ERROR_ILLEGAL_WWN 5 /* WWN not recognized */ #define HBA_STATUS_ERROR_ILLEGAL_INDEX 6 /* Index not recognized */ #define HBA_STATUS_ERROR_MORE_DATA 7 /* Larger buffer required */ #define HBA_STATUS_ERROR_STALE_DATA 8 /* Information has changed since * last call to * HBA_Refreshinformation */ #define HBA_STATUS_SCSI_CHECK_CONDITION 9 /* Obvious */ #define HBA_STATUS_ERROR_BUSY 10 /* HBA busy or reserved, * retry may be effective */ #define HBA_STATUS_ERROR_TRY_AGAIN 11 /* Request timedout, * retry may be effective */ #define HBA_STATUS_ERROR_UNAVAILABLE 12 /* Referenced HBA has been removed * or deactivated */ #define HBA_STATUS_ERROR_ELS_REJECT 13 /* The requested ELS was rejected by * the local HBA */ #define HBA_STATUS_ERROR_INVALID_LUN 14 /* The specified LUN is not provided * the specified HBA */ #define HBA_STATUS_ERROR_INCOMPATIBLE 15 /* An incompatibility has been * detected among the library and driver modules * invoked which will cause one or more functions * in the highest version that all support to * operate incorrectly. The differing function * sets of software modules implementing different * versions of the HBA API specification does not * in itself constitute an incompatibility. Known * interoperability bugs among supposedly * compatible versions should be reported as * incompatibilities, but not all such * interoperability bugs may be known. This value * may be returned by any function that calls a * Vendor Specific Library and returns an * HBA_STATUS, and by HBA_LoadLibrary and * HBA_GetAdapterName. */ #define HBA_STATUS_ERROR_AMBIGUOUS_WWN 16 /* Multiple adapters have a matching * WWN. This could occur if the * NodeWWN of multiple adapters is * identical */ #define HBA_STATUS_ERROR_LOCAL_BUS 17 /* A persistent binding request * included a bad local SCSI bus * number */ #define HBA_STATUS_ERROR_LOCAL_TARGET 18 /* A persistent binding request * included a bad local SCSI target * number */ #define HBA_STATUS_ERROR_LOCAL_LUN 19 /* A persistent binding request * included a bad local SCSI logical * unit number */ #define HBA_STATUS_ERROR_LOCAL_SCSIID_BOUND 20 /* A persistent binding set request * included a local SCSI ID that was * already bound */ #define HBA_STATUS_ERROR_TARGET_FCID 21 /* A persistent binding request * included a bad or unlocatable FCP * Target FCID */ #define HBA_STATUS_ERROR_TARGET_NODE_WWN 22 /* A persistent binding request * included a bad FCP Target Node * WWN */ #define HBA_STATUS_ERROR_TARGET_PORT_WWN 23 /* A persistent binding request * included a bad FCP Target Port * WWN */ #define HBA_STATUS_ERROR_TARGET_LUN 24 /* A persistent binding request * included an FCP Logical Unit Number * not defined by the identified * Target*/ #define HBA_STATUS_ERROR_TARGET_LUID 25 /* A persistent binding request * included an undefined or otherwise * inaccessible Logical Unit Unique * Identifier */ #define HBA_STATUS_ERROR_NO_SUCH_BINDING 26 /* A persistent binding remove request * included a binding which did not * match a binding established by the * specified port */ #define HBA_STATUS_ERROR_NOT_A_TARGET 27 /* A SCSI command was requested to an * Nx_Port that was not a SCSI * Target Port */ #define HBA_STATUS_ERROR_UNSUPPORTED_FC4 28 /* A request was made concerning an * unsupported FC-4 protocol */ #define HBA_STATUS_ERROR_INCAPABLE 29 /* A request was made to enable * unimplemented capabilities for a * port */ #define HBA_STATUS_ERROR_TARGET_BUSY 30 /* A SCSI function was requested * at a time when issuing the * requested command would cause a * a SCSI overlapped command * condition (see SAM-3) */ /* 6.4.1 Port Operational Modes Values */ typedef HBA_UINT32 HBA_PORTTYPE; #define HBA_PORTTYPE_UNKNOWN 1 /* Unknown */ #define HBA_PORTTYPE_OTHER 2 /* Other */ #define HBA_PORTTYPE_NOTPRESENT 3 /* Not present */ #define HBA_PORTTYPE_NPORT 5 /* Fabric */ #define HBA_PORTTYPE_NLPORT 6 /* Public Loop */ #define HBA_PORTTYPE_FLPORT 7 #define HBA_PORTTYPE_FPORT 8 /* Fabric Port */ #define HBA_PORTTYPE_LPORT 20 /* Private Loop */ #define HBA_PORTTYPE_PTP 21 /* Point to Point */ typedef HBA_UINT32 HBA_PORTSTATE; #define HBA_PORTSTATE_UNKNOWN 1 /* Unknown */ #define HBA_PORTSTATE_ONLINE 2 /* Operational */ #define HBA_PORTSTATE_OFFLINE 3 /* User Offline */ #define HBA_PORTSTATE_BYPASSED 4 /* Bypassed */ #define HBA_PORTSTATE_DIAGNOSTICS 5 /* In diagnostics mode */ #define HBA_PORTSTATE_LINKDOWN 6 /* Link Down */ #define HBA_PORTSTATE_ERROR 7 /* Port Error */ #define HBA_PORTSTATE_LOOPBACK 8 /* Loopback */ typedef HBA_UINT32 HBA_PORTSPEED; #define HBA_PORTSPEED_UNKNOWN 0 /* Unknown - transceiver incable * of reporting */ #define HBA_PORTSPEED_1GBIT 1 /* 1 GBit/sec */ #define HBA_PORTSPEED_2GBIT 2 /* 2 GBit/sec */ #define HBA_PORTSPEED_10GBIT 4 /* 10 GBit/sec */ #define HBA_PORTSPEED_NOT_NEGOTIATED (1 << 15) /* Speed not established */ /* 6.4.1.4 See "Class of Service - Format" in GC-GS-4 */ typedef HBA_UINT32 HBA_COS; /* 6.4.1.5 Fc4Types Values */ typedef struct HBA_fc4types { HBA_UINT8 bits[32]; /* 32 bytes of FC-4 per GS-2 */ } HBA_FC4TYPES, *PHBA_FC4TYPES; /* 6.1 Basic Types */ typedef struct HBA_wwn { HBA_UINT8 wwn[8]; } HBA_WWN, *PHBA_WWN; typedef struct HBA_ipaddress { int ipversion; /* see enumerations in RNID */ union { unsigned char ipv4address[4]; unsigned char ipv6address[16]; } ipaddress; } HBA_IPADDRESS, *PHBA_IPADDRESS; typedef HBA_INT8 HBA_BOOLEAN; /* 6.3.1 Adapter Attributes */ typedef struct hba_AdapterAttributes { char Manufacturer[64]; char SerialNumber[64]; char Model[256]; char ModelDescription[256]; HBA_WWN NodeWWN; char NodeSymbolicName[256]; char HardwareVersion[256]; char DriverVersion[256]; char OptionROMVersion[256]; char FirmwareVersion[256]; HBA_UINT32 VendorSpecificID; HBA_UINT32 NumberOfPorts; char DriverName[256]; } HBA_ADAPTERATTRIBUTES, *PHBA_ADAPTERATTRIBUTES; /* 6.4.1.6 Port Attributes */ typedef struct HBA_PortAttributes { HBA_WWN NodeWWN; HBA_WWN PortWWN; HBA_UINT32 PortFcId; HBA_PORTTYPE PortType; HBA_PORTSTATE PortState; HBA_COS PortSupportedClassofService; HBA_FC4TYPES PortSupportedFc4Types; HBA_FC4TYPES PortActiveFc4Types; char PortSymbolicName[256]; char OSDeviceName[256]; HBA_PORTSPEED PortSupportedSpeed; HBA_PORTSPEED PortSpeed; HBA_UINT32 PortMaxFrameSize; HBA_WWN FabricName; HBA_UINT32 NumberofDiscoveredPorts; } HBA_PORTATTRIBUTES, *PHBA_PORTATTRIBUTES; /* 6.5.1 Port Statistics */ typedef struct HBA_PortStatistics { HBA_INT64 SecondsSinceLastReset; HBA_INT64 TxFrames; HBA_INT64 TxWords; HBA_INT64 RxFrames; HBA_INT64 RxWords; HBA_INT64 LIPCount; HBA_INT64 NOSCount; HBA_INT64 ErrorFrames; HBA_INT64 DumpedFrames; HBA_INT64 LinkFailureCount; HBA_INT64 LossOfSyncCount; HBA_INT64 LossOfSignalCount; HBA_INT64 PrimitiveSeqProtocolErrCount; HBA_INT64 InvalidTxWordCount; HBA_INT64 InvalidCRCCount; } HBA_PORTSTATISTICS, *PHBA_PORTSTATISTICS; /* 6.6.1 FCP Attributes */ typedef enum HBA_fcpbindingtype { TO_D_ID, TO_WWN, TO_OTHER } HBA_FCPBINDINGTYPE; typedef struct HBA_ScsiId { char OSDeviceName[256]; HBA_UINT32 ScsiBusNumber; HBA_UINT32 ScsiTargetNumber; HBA_UINT32 ScsiOSLun; } HBA_SCSIID, *PHBA_SCSIID; typedef struct HBA_FcpId { HBA_UINT32 FcId; HBA_WWN NodeWWN; HBA_WWN PortWWN; HBA_UINT64 FcpLun; } HBA_FCPID, *PHBA_FCPID; typedef struct HBA_LUID { char buffer[256]; } HBA_LUID, *PHBA_LUID; typedef struct HBA_FcpScsiEntry { HBA_SCSIID ScsiId; HBA_FCPID FcpId; } HBA_FCPSCSIENTRY, *PHBA_FCPSCSIENTRY; typedef struct HBA_FcpScsiEntryV2 { HBA_SCSIID ScsiId; HBA_FCPID FcpId; HBA_LUID LUID; } HBA_FCPSCSIENTRYV2, *PHBA_FCPSCSIENTRYV2; typedef struct HBA_FCPTargetMapping { HBA_UINT32 NumberOfEntries; HBA_FCPSCSIENTRY entry[1]; /* Variable length array * containing mappings */ } HBA_FCPTARGETMAPPING, *PHBA_FCPTARGETMAPPING; typedef struct HBA_FCPTargetMappingV2 { HBA_UINT32 NumberOfEntries; HBA_FCPSCSIENTRYV2 entry[1]; /* Variable length array * containing mappings */ } HBA_FCPTARGETMAPPINGV2, *PHBA_FCPTARGETMAPPINGV2; typedef struct HBA_FCPBindingEntry { HBA_FCPBINDINGTYPE type; HBA_SCSIID ScsiId; HBA_FCPID FcpId; /* WWN valid only if type is * to WWN, FcpLun always valid */ HBA_UINT32 FcId; } HBA_FCPBINDINGENTRY, *PHBA_FCPBINDINGENTRY; typedef struct HBA_FCPBinding { HBA_UINT32 NumberOfEntries; HBA_FCPBINDINGENTRY entry[1]; /* Variable length array */ } HBA_FCPBINDING, *PHBA_FCPBINDING; /* 6.7.1 FC-3 Management Atrributes */ typedef enum HBA_wwntype { NODE_WWN, PORT_WWN } HBA_WWNTYPE; typedef struct HBA_MgmtInfo { HBA_WWN wwn; HBA_UINT32 unittype; HBA_UINT32 PortId; HBA_UINT32 NumberOfAttachedNodes; HBA_UINT16 IPVersion; HBA_UINT16 UDPPort; HBA_UINT8 IPAddress[16]; HBA_UINT16 reserved; HBA_UINT16 TopologyDiscoveryFlags; } HBA_MGMTINFO, *PHBA_MGMTINFO; /* Event Codes */ #define HBA_EVENT_LIP_OCCURRED 1 #define HBA_EVENT_LINK_UP 2 #define HBA_EVENT_LINK_DOWN 3 #define HBA_EVENT_LIP_RESET_OCCURRED 4 #define HBA_EVENT_RSCN 5 #define HBA_EVENT_PROPRIETARY 0xFFFF typedef struct HBA_Link_EventInfo { HBA_UINT32 PortFcId; /* Port where event occurred */ HBA_UINT32 Reserved[3]; } HBA_LINK_EVENTINFO, *PHBA_LINK_EVENTINFO; typedef struct HBA_RSCN_EventInfo { HBA_UINT32 PortFcId; /* Port where event occurred */ HBA_UINT32 NPortPage; /* Reference FC-FS for RSCN ELS * "Affected N-Port Pages"*/ HBA_UINT32 Reserved[2]; } HBA_RSCN_EVENTINFO, *PHBA_RSCN_EVENTINFO; typedef struct HBA_Pty_EventInfo { HBA_UINT32 PtyData[4]; /* Proprietary data */ } HBA_PTY_EVENTINFO, *PHBA_PTY_EVENTINFO; typedef struct HBA_EventInfo { HBA_UINT32 EventCode; union { HBA_LINK_EVENTINFO Link_EventInfo; HBA_RSCN_EVENTINFO RSCN_EventInfo; HBA_PTY_EVENTINFO Pty_EventInfo; } Event; } HBA_EVENTINFO, *PHBA_EVENTINFO; typedef struct HBA_LibraryAttributes { HBA_BOOLEAN final; char LibPath[256]; char VName[256]; char VVersion[256]; struct tm build_date; } HBA_LIBRARYATTRIBUTES, *PHBA_LIBRARYATTRIBUTES; /* Persistant Binding... */ typedef HBA_UINT32 HBA_BIND_TYPE; #define HBA_BIND_TO_D_ID 0x0001 #define HBA_BIND_TO_WWPN 0x0002 #define HBA_BIND_TO_WWNN 0x0004 #define HBA_BIND_TO_LUID 0x0008 #define HBA_BIND_TARGETS 0x0800 /* A bit mask of Rev 2.0 persistent binding capabilities */ typedef HBA_UINT32 HBA_BIND_CAPABILITY; /* The following are bit flags indicating persistent binding capabilities */ #define HBA_CAN_BIND_TO_D_ID 0x0001 #define HBA_CAN_BIND_TO_WWPN 0x0002 #define HBA_CAN_BIND_TO_WWNN 0x0004 #define HBA_CAN_BIND_TO_LUID 0x0008 #define HBA_CAN_BIND_ANY_LUNS 0x0400 #define HBA_CAN_BIND_TARGETS 0x0800 #define HBA_CAN_BIND_AUTOMAP 0x1000 #define HBA_CAN_BIND_CONFIGURED 0x2000 #define HBA_BIND_STATUS_DISABLED 0x00 #define HBA_BIND_STATUS_ENABLED 0x01 typedef HBA_UINT32 HBA_BIND_STATUS; #define HBA_BIND_EFFECTIVE_AT_REBOOT 0x00 #define HBA_BIND_EFFECTIVE_IMMEDIATE 0x01 typedef HBA_UINT32 HBA_BIND_EFFECTIVE; typedef struct HBA_FCPBindingEntry2 { HBA_BIND_TYPE type; HBA_SCSIID ScsiId; HBA_FCPID FcpId; HBA_LUID LUID; HBA_STATUS status; } HBA_FCPBINDINGENTRY2, *PHBA_FCPBINDINGENTRY2; typedef struct HBA_FcpBinding2 { HBA_UINT32 NumberOfEntries; HBA_FCPBINDINGENTRY2 entry[1]; /* Variable length array */ } HBA_FCPBINDING2, *PHBA_FCPBINDING2; /* FC-4 Instrumentation */ typedef struct HBA_FC4Statistics { HBA_INT64 InputRequests; HBA_INT64 OutputRequests; HBA_INT64 ControlRequests; HBA_INT64 InputMegabytes; HBA_INT64 OutputMegabytes; } HBA_FC4STATISTICS, *PHBA_FC4STATISTICS; typedef void * HBA_CALLBACKHANDLE; /* Adapter Level Events */ #define HBA_EVENT_ADAPTER_UNKNOWN 0x100 #define HBA_EVENT_ADAPTER_ADD 0x101 #define HBA_EVENT_ADAPTER_REMOVE 0x102 #define HBA_EVENT_ADAPTER_CHANGE 0x103 /* Port Level Events */ #define HBA_EVENT_PORT_UNKNOWN 0x200 #define HBA_EVENT_PORT_OFFLINE 0x201 #define HBA_EVENT_PORT_ONLINE 0x202 #define HBA_EVENT_PORT_NEW_TARGETS 0x203 #define HBA_EVENT_PORT_FABRIC 0x204 /* Port Statistics Events */ #define HBA_EVENT_PORT_STAT_THRESHOLD 0x301 #define HBA_EVENT_PORT_STAT_GROWTH 0x302 /* Target Level Events */ #define HBA_EVENT_TARGET_UNKNOWN 0x400 #define HBA_EVENT_TARGET_OFFLINE 0x401 #define HBA_EVENT_TARGET_ONLINE 0x402 #define HBA_EVENT_TARGET_REMOVED 0x403 /* Fabric Link Events */ #define HBA_EVENT_LINK_UNKNOWN 0x500 #define HBA_EVENT_LINK_INCIDENT 0x501 HBA_API HBA_UINT32 HBA_GetVersion(); /* * Make sure HBA_LoadLibrary returns before any other threads * make calls to the library */ HBA_API HBA_STATUS HBA_LoadLibrary(); HBA_API HBA_STATUS HBA_FreeLibrary(); HBA_API HBA_UINT32 HBA_GetNumberOfAdapters(); HBA_API HBA_STATUS HBA_GetAdapterName( HBA_UINT32 adapterindex, char *adaptername ); HBA_API HBA_HANDLE HBA_OpenAdapter( char* adaptername ); HBA_API HBA_STATUS HBA_OpenAdapterByWWN( HBA_HANDLE *handle, HBA_WWN wwn ); HBA_API void HBA_CloseAdapter( HBA_HANDLE handle ); HBA_API HBA_STATUS HBA_GetAdapterAttributes( HBA_HANDLE handle, HBA_ADAPTERATTRIBUTES *hbaattributes ); HBA_API HBA_STATUS HBA_GetAdapterPortAttributes( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTATTRIBUTES *portattributes ); HBA_API HBA_STATUS HBA_GetPortStatistics( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTSTATISTICS *portstatistics ); HBA_API HBA_STATUS HBA_GetDiscoveredPortAttributes( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_UINT32 discoveredportindex, HBA_PORTATTRIBUTES *portattributes ); HBA_API HBA_STATUS HBA_GetPortAttributesByWWN( HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTATTRIBUTES *portattributes ); HBA_API HBA_STATUS HBA_SendCTPassThruV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_SendCTPassThru( HBA_HANDLE handle, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 RspBufferSize ); HBA_API void HBA_RefreshAdapterConfiguration(); HBA_API HBA_STATUS HBA_GetEventBuffer( HBA_HANDLE handle, HBA_EVENTINFO *EventBuffer, HBA_UINT32 *EventBufferCount ); HBA_API HBA_STATUS HBA_SetRNIDMgmtInfo( HBA_HANDLE handle, HBA_MGMTINFO *pInfo ); HBA_API HBA_STATUS HBA_GetRNIDMgmtInfo( HBA_HANDLE handle, HBA_MGMTINFO *pInfo ); HBA_API HBA_STATUS HBA_SendRNIDV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, HBA_UINT32 destFCID, HBA_UINT32 NodeIdDataFormat, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_SendRNID( HBA_HANDLE handle, HBA_WWN wwn, HBA_WWNTYPE wwntype, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_SendRPL ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN agent_wwn, HBA_UINT32 agent_domain, HBA_UINT32 portindex, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_SendRPS ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN agent_wwn, HBA_UINT32 agent_domain, HBA_WWN object_wwn, HBA_UINT32 object_port_number, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_SendSRL ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN wwn, HBA_UINT32 domain, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_SendRLS ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_SendLIRR ( HBA_HANDLE handle, HBA_WWN sourceWWN, HBA_WWN destWWN, HBA_UINT8 function, HBA_UINT8 type, void *pRspBuffer, HBA_UINT32 *pRspBufferSize ); HBA_API HBA_STATUS HBA_GetFC4Statistics ( HBA_HANDLE handle, HBA_WWN portWWN, HBA_UINT8 FC4type, HBA_FC4STATISTICS *pstatistics ); HBA_API HBA_STATUS HBA_GetFCPStatistics ( HBA_HANDLE handle, const HBA_SCSIID *lunit, HBA_FC4STATISTICS *pstatistics); HBA_API void HBA_RefreshInformation( HBA_HANDLE handle ); HBA_API void HBA_ResetStatistics( HBA_HANDLE handle, HBA_UINT32 portindex ); HBA_API HBA_STATUS HBA_GetFcpTargetMapping( HBA_HANDLE handle, HBA_FCPTARGETMAPPING *pmapping ); HBA_API HBA_STATUS HBA_GetFcpTargetMappingV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPTARGETMAPPINGV2 *pmapping ); HBA_API HBA_STATUS HBA_GetBindingCapability( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pcapability ); HBA_API HBA_STATUS HBA_GetBindingSupport( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pcapability ); HBA_API HBA_STATUS HBA_SetBindingSupportFunc( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY capability ); HBA_API HBA_STATUS HBA_SetPersistentBindingV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, const HBA_FCPBINDING2 *pbinding ); HBA_API HBA_STATUS HBA_GetPersistentBindingV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPBINDING2 *binding ); HBA_API HBA_STATUS HBA_RemovePersistentBinding( HBA_HANDLE handle, HBA_WWN hbaPortWWN, const HBA_FCPBINDING2 *pbinding ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_GetFcpPersistentBinding( HBA_HANDLE handle, HBA_FCPBINDING *binding ); HBA_API HBA_STATUS HBA_RemoveAllPersistentBindings( HBA_HANDLE handle, HBA_WWN hbaPortWWN ); HBA_STATUS HBA_ScsiInquiryV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT64 fcLUN, HBA_UINT8 CDB_Byte1, HBA_UINT8 CDB_BYte2, void *pRspBuffer, HBA_UINT32 *pRspBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *pSenseBufferSize ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_SendScsiInquiry ( HBA_HANDLE handle, HBA_WWN PortWWN, HBA_UINT64 fcLUN, HBA_UINT8 EVPD, HBA_UINT32 PageCode, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize ); HBA_API HBA_STATUS HBA_ScsiReportLUNsV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, void *pRespBuffer, HBA_UINT32 *pRespBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *pSenseBufferSize ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_SendReportLUNs ( HBA_HANDLE handle, HBA_WWN portWWN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize ); HBA_API HBA_STATUS HBA_ScsiReadCapacityV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT64 fcLUN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *SenseBufferSize ); /* Depricated, but supported */ HBA_API HBA_STATUS HBA_SendReadCapacity ( HBA_HANDLE handle, HBA_WWN portWWN, HBA_UINT64 fcLUN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize ); HBA_API HBA_UINT32 HBA_GetVendorLibraryAttributes ( HBA_UINT32 adapter_index, HBA_LIBRARYATTRIBUTES *attributes ); HBA_API HBA_STATUS HBA_RemoveCallback( HBA_CALLBACKHANDLE callbackHandle ); HBA_API HBA_STATUS HBA_RegisterForAdapterAddEvents( void (*callback) ( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_CALLBACKHANDLE *callbackHandle ); HBA_API HBA_STATUS HBA_RegisterForAdapterEvents( void (*callback)( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_CALLBACKHANDLE *callbackHandle ); HBA_API HBA_STATUS HBA_RegisterForAdapterPortEvents( void (*callback)( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType, HBA_UINT32 fabricPortID ), void *userData, HBA_HANDLE handle, HBA_WWN PortWWN, HBA_CALLBACKHANDLE *callbackHandle ); HBA_API HBA_STATUS HBA_RegisterForAdapterPortStatEvents( void (*callback)( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTSTATISTICS stats, HBA_UINT32 statType, HBA_CALLBACKHANDLE *callbackHandle ); HBA_API HBA_STATUS HBA_RegisterForTargetEvents( void (*callback)( void *data, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_CALLBACKHANDLE *callbackHandle, HBA_UINT32 allTargets ); HBA_API HBA_STATUS HBA_RegisterForLinkEvents( void (*callback) ( void *data, HBA_WWN adapterWWN, HBA_UINT32 eventType, void *pRLIRBuffer, HBA_UINT32 RLIRBufferSize ), void *userData, void *pRLIRBuffer, HBA_UINT32 RLIRBufferSize, HBA_HANDLE handle, HBA_CALLBACKHANDLE *callbackHandle ); /* Wrapper library specific entry points */ HBA_API HBA_UINT32 HBA_GetWrapperLibraryAttributes ( HBA_LIBRARYATTRIBUTES *attributes ); #endif /* HBA_API_H */ #ifdef __cplusplus } #endif libhbaapi-2.2.9/hbaapilib.c000066400000000000000000002264301214751626200155330ustar00rootroot00000000000000/************************************************************************* * Description * HBAAPILIB.c - Implements a sample common (wrapper) HBA API library * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is SNIA HBA API Wrapper Library * * The Initial Developer of the Original Code is: * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) * * Contributor(s): * Tuan Lam, QLogic Corp. (t_lam@qlc.com) * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com) * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com) * ************************************************************************* */ #include #include #include #include #include #define __USE_XOPEN #include #include #include "hbaapi.h" #include "vendorhbaapi.h" #include #ifdef USESYSLOG #include #endif /* * LIBRARY_NUM is a shortcut to figure out which library we need to call. * The top 16 bits of handle are the library index */ #define LIBRARY_NUM(handle) ((handle)>>16) /* * VENDOR_HANDLE turns a global library handle into a vendor specific handle, * with all upper 16 bits set to 0 */ #define VENDOR_HANDLE(handle) ((handle)&0xFFFF) #define HBA_HANDLE_FROM_LOCAL(library, vendor) \ (((library)<<16) | ((vendor)&0x0000FFFF)) int _hbaapi_debuglevel = 0; #define DEBUG(L, STR, A1, A2, A3) #if defined(USESYSLOG) && defined(USELOGFILE) FILE *_hbaapi_debug_fd = NULL; int _hbaapi_sysloginit = 0; #undef DEBUG #define DEBUG(L, STR, A1, A2, A3)\ if ((L) <= _hbaapi_debuglevel) {\ if(_hbaapi_sysloginit == 0) {\ openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\ _hbaapi_sysloginit = 1;\ }\ syslog (LOG_INFO, (STR), (A1), (A2), (A3));\ if(_hbaapi_debug_fd == NULL) {\ _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\ }\ if(_hbaapi_debug_fd != NULL) {\ fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\ }\ } #else /* Not both USESYSLOG and USELOGFILE */ #if defined(USESYSLOG) int _hbaapi_sysloginit = 0; #undef DEBUG #define DEBUG(L, STR, A1, A2, A3) \ if ((L) <= _hbaapi_debuglevel) {\ if(_hbaapi_sysloginit == 0) {\ openlog("HBAAPI", LOG_PID|LOG_ODELAY ,LOG_USER);\ _hbaapi_sysloginit = 1;\ }\ syslog (LOG_INFO, (STR), (A1), (A2), (A3));\ } #endif /* USESYSLOG */ #if defined(USELOGFILE) FILE *_hbaapi_debug_fd = NULL; #undef DEBUG #define DEBUG(L, STR, A1, A2, A3) \ if((L) <= _hbaapi_debuglevel) {\ if(_hbaapi_debug_fd == NULL) {\ _hbaapi_debug_fd = fopen("/tmp/HBAAPI.log", "a");\ }\ if(_hbaapi_debug_fd != NULL) { \ fprintf(_hbaapi_debug_fd, #STR "\n", (A1), (A2), (A3));\ }\ } #endif /* USELOGFILE */ #endif /* Not both USELOGFILE and USESYSLOG */ #ifdef POSIX_THREADS #include /* * When multiple mutex's are grabed, they must be always be grabbed in * the same order, or deadlock can result. There are three levels * of mutex's involved in this API. If LL_mutex is grabbed, always grap * it first. If AL_mutex is grabbed, it may not be grabbed before * LL_mutex. If grabbed in a multi grab sequence, the mutex's protecting * the callback lists must always be grabbed last and release before calling * a vendor specific library function that might invoke a callback function * on the same thread. */ #define GRAB_MUTEX(M) grab_mutex(M) #define RELEASE_MUTEX(M) release_mutex(M) #define RELEASE_MUTEX_RETURN(M,RET) release_mutex(M); return(RET) #else #define GRAB_MUTEX(M) #define RELEASE_MUTEX(M) #define RELEASE_MUTEX_RETURN(M,RET) return(RET) #endif /* * Vendor library information */ typedef enum { HBA_LIBRARY_UNKNOWN, HBA_LIBRARY_LOADED, HBA_LIBRARY_NOT_LOADED } HBA_LIBRARY_STATUS; typedef struct hba_library_info { struct hba_library_info *next; char *LibraryName; void* hLibrary; /* Handle to a loaded DLL */ char *LibraryPath; HBA_ENTRYPOINTSV2 functionTable; /* Function pointers */ HBA_LIBRARY_STATUS status; /* info on this library */ HBA_UINT32 index; } HBA_LIBRARY_INFO, *PHBA_LIBRARY_INFO; #define ARE_WE_INITED() \ if (_hbaapi_librarylist == NULL) { \ return(HBA_STATUS_ERROR); \ } HBA_LIBRARY_INFO *_hbaapi_librarylist = NULL; HBA_UINT32 _hbaapi_total_library_count = 0; #ifdef POSIX_THREADS pthread_mutex_t _hbaapi_LL_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* POSIX_THREADS */ /* * Individual adapter (hba) information */ typedef struct hba_adapter_info { struct hba_adapter_info *next; HBA_STATUS GNstatus; /* status from GetAdapterNameFunc */ char *name; HBA_WWN nodeWWN; HBA_LIBRARY_INFO *library; HBA_UINT32 index; } HBA_ADAPTER_INFO; HBA_ADAPTER_INFO *_hbaapi_adapterlist = NULL; HBA_UINT32 _hbaapi_total_adapter_count = 0; #ifdef POSIX_THREADS pthread_mutex_t _hbaapi_AL_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* POSIX_THREADS */ /* * Call back registration */ typedef struct hba_vendorcallback_elem { struct hba_vendorcallback_elem *next; HBA_CALLBACKHANDLE vendorcbhandle; HBA_LIBRARY_INFO *lib_info; } HBA_VENDORCALLBACK_ELEM; /* * Each instance of HBA_ADAPTERCALLBACK_ELEM represents a call to one of * "register" functions that apply to a particular adapter. * HBA_ALLADAPTERSCALLBACK_ELEM is used just for HBA_RegisterForAdapterAddEvents */ typedef struct hba_adaptercallback_elem { struct hba_adaptercallback_elem *next; HBA_LIBRARY_INFO *lib_info; void *userdata; HBA_CALLBACKHANDLE vendorcbhandle; void (*callback)(); } HBA_ADAPTERCALLBACK_ELEM; typedef struct hba_alladapterscallback_elem { struct hba_alladapterscallback_elem *next; void *userdata; HBA_VENDORCALLBACK_ELEM *vendorhandlelist; void (*callback)(); } HBA_ALLADAPTERSCALLBACK_ELEM; HBA_ALLADAPTERSCALLBACK_ELEM *_hbaapi_adapteraddevents_callback_list = NULL; HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterevents_callback_list = NULL; HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportevents_callback_list = NULL; HBA_ADAPTERCALLBACK_ELEM *_hbaapi_adapterportstatevents_callback_list = NULL; HBA_ADAPTERCALLBACK_ELEM *_hbaapi_targetevents_callback_list = NULL; HBA_ADAPTERCALLBACK_ELEM *_hbaapi_linkevents_callback_list = NULL; #ifdef POSIX_THREADS /* mutex's to protect each list */ pthread_mutex_t _hbaapi_AAE_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t _hbaapi_AE_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t _hbaapi_APE_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t _hbaapi_APSE_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t _hbaapi_TE_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t _hbaapi_LE_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* POSIX_THREADS */ HBA_ADAPTERCALLBACK_ELEM **cb_lists_array[] = { &_hbaapi_adapterevents_callback_list, &_hbaapi_adapterportevents_callback_list, &_hbaapi_adapterportstatevents_callback_list, &_hbaapi_targetevents_callback_list, &_hbaapi_linkevents_callback_list, NULL}; /* * Common library internal. Mutex handling */ #ifdef POSIX_THREADS static void grab_mutex(pthread_mutex_t *mp) { int ret; if((ret = pthread_mutex_lock(mp)) != 0) { perror("pthread_mutex_lock - HBAAPI:"); DEBUG(0, "pthread_mutex_lock returned %d", ret, 0, 0); } } static void release_mutex(pthread_mutex_t *mp) { int ret; if((ret = pthread_mutex_unlock(mp)) != 0) { perror("pthread_mutex_unlock - HBAAPI:"); DEBUG(0, "pthread_mutex_unlock returned %d", ret, 0, 0); } } #endif /* * Common library internal. Check library and return vendorhandle */ static HBA_STATUS HBA_CheckLibrary(HBA_HANDLE handle, HBA_LIBRARY_INFO **lib_infopp, HBA_HANDLE *vendorhandle) { HBA_UINT32 libraryIndex; HBA_LIBRARY_INFO *lib_infop; if(_hbaapi_librarylist == NULL) { return(HBA_STATUS_ERROR); } libraryIndex = LIBRARY_NUM(handle); GRAB_MUTEX(&_hbaapi_LL_mutex); for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { if(lib_infop->index == libraryIndex) { if(lib_infop->status != HBA_LIBRARY_LOADED) { return HBA_STATUS_ERROR; } *lib_infopp = lib_infop; *vendorhandle = VENDOR_HANDLE(handle); /* caller will release the mutex */ return HBA_STATUS_OK; } } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_INVALID_HANDLE); } #define CHECKLIBRARY() \ status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle);\ if(status != HBA_STATUS_OK) { \ return(status); \ } /* *freevendorhandlelist is called with _hbaapi_LL_mutex already held */ static void freevendorhandlelist(HBA_VENDORCALLBACK_ELEM *vhlist) { HBA_VENDORCALLBACK_ELEM *vhlp; HBA_VENDORCALLBACK_ELEM *vnext; HBARemoveCallbackFunc registeredfunc; for(vhlp = vhlist; vhlp != NULL; vhlp = vnext) { vnext = vhlp->next; registeredfunc = vhlp->lib_info->functionTable.RemoveCallbackHandler; if(registeredfunc == NULL) { continue; } (registeredfunc)(vhlp->vendorcbhandle); free(vhlp); } } static HBA_STATUS local_remove_callback(HBA_CALLBACKHANDLE cbhandle) { HBA_ADAPTERCALLBACK_ELEM ***listp; HBA_ADAPTERCALLBACK_ELEM **lastp; HBA_ALLADAPTERSCALLBACK_ELEM **lap; HBA_ALLADAPTERSCALLBACK_ELEM *allcbp; HBA_ADAPTERCALLBACK_ELEM *cbp; HBARemoveCallbackFunc registeredfunc = NULL; HBA_VENDORCALLBACK_ELEM *vhlp; HBA_VENDORCALLBACK_ELEM *vnext; int found; HBA_STATUS status = HBA_STATUS_ERROR_INVALID_HANDLE; /* search through the simple lists first */ GRAB_MUTEX(&_hbaapi_AAE_mutex); GRAB_MUTEX(&_hbaapi_AE_mutex); GRAB_MUTEX(&_hbaapi_APE_mutex); GRAB_MUTEX(&_hbaapi_APSE_mutex); GRAB_MUTEX(&_hbaapi_TE_mutex); GRAB_MUTEX(&_hbaapi_LE_mutex); for(listp = cb_lists_array, found = 0; *listp != NULL; listp++) { lastp = *listp; for(cbp=**listp; cbp != NULL; cbp = cbp->next) { if(cbhandle != (HBA_CALLBACKHANDLE)cbp) { lastp = &(cbp->next); continue; } found = 1; registeredfunc = cbp->lib_info->functionTable.RemoveCallbackHandler; if(registeredfunc == NULL) { break; } (registeredfunc)(cbp->vendorcbhandle); *lastp = cbp->next; free(cbp); break; } } RELEASE_MUTEX(&_hbaapi_LE_mutex); RELEASE_MUTEX(&_hbaapi_TE_mutex); RELEASE_MUTEX(&_hbaapi_APSE_mutex); RELEASE_MUTEX(&_hbaapi_APE_mutex); RELEASE_MUTEX(&_hbaapi_AE_mutex); RELEASE_MUTEX(&_hbaapi_AAE_mutex); if(found != 0) { if(registeredfunc == NULL) { return HBA_STATUS_ERROR_NOT_SUPPORTED; } return HBA_STATUS_OK; } GRAB_MUTEX(&_hbaapi_AAE_mutex); /* if it wasnt in the simple lists, look in the list for adapteraddevents */ lap = &_hbaapi_adapteraddevents_callback_list; for(allcbp = _hbaapi_adapteraddevents_callback_list; allcbp != NULL; allcbp = allcbp->next) { if(cbhandle != (HBA_CALLBACKHANDLE)allcbp) { lap = &allcbp->next; continue; } for(vhlp = allcbp->vendorhandlelist; vhlp != NULL; vhlp = vnext) { vnext = vhlp->next; registeredfunc = vhlp->lib_info->functionTable.RemoveCallbackHandler; if(registeredfunc == NULL) { continue; } (registeredfunc)(vhlp->vendorcbhandle); free(vhlp); } *lap = allcbp->next; free(allcbp); status = HBA_STATUS_OK; break; } RELEASE_MUTEX(&_hbaapi_AAE_mutex); return(status); } #if defined(USESYSLOG) || defined(USELOGFILE) static char wwn_str1[17]; static char wwn_str2[17]; static char wwn_str3[17]; #define WWN2STR1(wwn) WWN2str(wwn_str1, (wwn)) #define WWN2STR2(wwn) WWN2str(wwn_str2, (wwn)) #define WWN2STR3(wwn) WWN2str(wwn_str3, (wwn)) static char * WWN2str(char *buf, HBA_WWN *wwn) { int j; unsigned char *pc = (unsigned char *)&(wwn->wwn[0]); buf[0] = '\0'; for (j=0; j<16; j+=2) { sprintf(&buf[j], "%02X", (int)*pc++); } return(buf); } #endif /* * Read in the config file and load all the specified vendor specific * libraries and perform the function registration exercise */ HBA_STATUS HBA_LoadLibrary() { HBARegisterLibraryFunc RegisterFunc; HBARegisterLibraryV2Func RegisterV2Func; HBALoadLibraryFunc LoadLibraryFunc; HBAGetVersionFunc GetVersionFunc; #ifdef POSIX_THREADS int ret; #endif HBA_STATUS status; HBA_UINT32 libversion; /* Open configuration file from known location */ FILE *hbaconf; char fullline[512]; /* line read from HBA.conf */ char *libraryname; /* Read in from file HBA.conf */ char *librarypath; /* Read in from file HBA.conf */ char hbaConfFilePath[256]; char *charPtr; HBA_LIBRARY_INFO *lib_infop; int duplicate = 0; if(_hbaapi_librarylist != NULL) { fprintf(stderr, "HBA_LoadLibrary: previously unfreed " "libraries exist, call HBA_FreeLibrary().\n"); return HBA_STATUS_ERROR; } strcpy(hbaConfFilePath, "/etc/hba.conf"); if ((hbaconf = fopen(hbaConfFilePath, "r")) == NULL) { printf("Cannot open %s\n", hbaConfFilePath); return HBA_STATUS_ERROR; } /* Read in each line and load library */ while ((hbaconf != NULL) && (fgets(fullline, sizeof(fullline), hbaconf))) { /* Skip the comments... */ if ((fullline[0] == '#') || (fullline[0] == '\n')) { continue; } /* grab first 'thing' in line (if its there)*/ if((libraryname = strtok(fullline, " \t\n")) != NULL) { if(strlen(libraryname) >= 64) { fprintf(stderr, "Library name(%s) in %s is > 64 characters\n", libraryname, hbaConfFilePath); } } /* grab second 'thing' in line (if its there)*/ if((librarypath = strtok(NULL, " \t\n")) != NULL) { if(strlen(librarypath) >= 256) { fprintf(stderr, "Library path(%s) in %s is > 256 characters\n", librarypath, hbaConfFilePath); } } /* there should be no more 'things' in the line */ if((charPtr = strtok(NULL, " \n\t")) != NULL) { fprintf(stderr, "Extraneous characters (\"%s\") in %s\n", charPtr, hbaConfFilePath); } /* Continue to the next line if library name or path is invalid */ if (libraryname == NULL || strlen(libraryname) == 0 || librarypath == NULL || (strlen(librarypath) == 0)) { continue; } /* Skip over duplicate library entries */ duplicate = 0; for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { if (strcmp(lib_infop->LibraryName, libraryname) == 0) { fprintf(stderr, "Skipping duplicate entry for Library " "name (%s) in %s\n", libraryname, hbaConfFilePath); duplicate = 1; break; } else if (strcmp(lib_infop->LibraryPath, librarypath) == 0) { fprintf(stderr, "Skipping duplicate entry for Library " "path (%s) in %s\n", librarypath, hbaConfFilePath); duplicate = 1; break; } } /* Duplicate found move to next */ if (duplicate) continue; /* * Special case.... * Look for loglevel */ if(strcmp(libraryname, "debuglevel") == 0) { _hbaapi_debuglevel = strtol(librarypath, NULL, 10); /* error handling does the right thing automagically */ continue; } lib_infop = (HBA_LIBRARY_INFO *)calloc(1, sizeof(HBA_LIBRARY_INFO)); if(lib_infop == NULL) { fprintf(stderr, "HBA_LoadLibrary: out of memeory\n"); return(HBA_STATUS_ERROR); } lib_infop->status = HBA_LIBRARY_NOT_LOADED; lib_infop->LibraryName = strdup(libraryname); lib_infop->LibraryPath = strdup(librarypath); lib_infop->index = _hbaapi_total_library_count; _hbaapi_total_library_count++; lib_infop->next = _hbaapi_librarylist; _hbaapi_librarylist = lib_infop; /* Load the DLL now */ if((lib_infop->hLibrary = dlopen(librarypath,RTLD_LAZY)) == NULL) { /*printf("unable to load library %s\n", librarypath); */ continue; } /* Call the registration function to get the list of pointers */ RegisterV2Func = (HBARegisterLibraryV2Func) dlsym(lib_infop->hLibrary, "HBA_RegisterLibraryV2"); if (RegisterV2Func != NULL) { /* Load the function points directly into * the table of functions */ status = ((RegisterV2Func)(&lib_infop->functionTable)); if (status != HBA_STATUS_OK) { /* library not loaded */ continue; } } else { /* Maybe the vendor library is only Rev1 */ RegisterFunc = (HBARegisterLibraryFunc) dlsym(lib_infop->hLibrary, "HBA_RegisterLibrary"); if(RegisterFunc == NULL) { /* This function is required */ fprintf(stderr, "HBA_LoadLibrary: vendor specific RegisterLibrary function not found. lib: %s\n", librarypath); DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary " "function not found. lib: %s\n", librarypath, 0, 0); continue; } /* Load the function points directly into * the table of functions */ status = ((RegisterFunc) ((HBA_ENTRYPOINTS *)(&lib_infop->functionTable))); if (status != HBA_STATUS_OK) { /* library not loaded */ fprintf(stderr, "HBA_LoadLibrary: vendor specific RegisterLibrary " "function encountered an error. lib: %s\n", librarypath); DEBUG(0, "HBA_LoadLibrary: vendor specific RegisterLibrary " "function encountered an error. lib: %s\n", librarypath, 0, 0); continue; } } /* successfully loaded library */ if((GetVersionFunc = lib_infop->functionTable.GetVersionHandler) == NULL) { continue; } libversion = ((GetVersionFunc)()); /* Check the version of this library before loading */ /* Actually... This wrapper is compatible with version 1 */ #ifdef NOTDEF /* save for a later time... when it matters */ if(libversion < HBA_LIBVERSION) { printf("Library version mismatch. Got %d expected %d.\n", libversion, HBA_LIBVERSION); continue; } #endif DEBUG(1, "%s libversion = %d", librarypath, libversion, 0); LoadLibraryFunc = lib_infop->functionTable.LoadLibraryHandler; if (LoadLibraryFunc == NULL) { /* this function is required */ fprintf(stderr, "HBA_LoadLibrary: vendor specific LoadLibrary " "function not found. lib: %s\n", librarypath); DEBUG(0, "HBA_LoadLibrary: vendor specific LoadLibrary " "function not found. lib: %s\n", librarypath, 0, 0); continue; } /* Initialize this library */ if((status = ((LoadLibraryFunc)())) != HBA_STATUS_OK) { /* maybe this should be a printf so that we CANNOT miss it */ fprintf(stderr, "HBA_LoadLibrary: Encounterd and error loading: %s", librarypath); DEBUG(0, "Encounterd and error loading: %s", librarypath, 0, 0); DEBUG(0, " HBA_STATUS: %d", status, 0, 0); continue; } /* successfully loaded library */ lib_infop->status = HBA_LIBRARY_LOADED; } fclose(hbaconf); #ifdef POSIX_THREADS ret = pthread_mutex_init(&_hbaapi_LL_mutex, NULL); if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_AL_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_AAE_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_AE_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_APE_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_APSE_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_TE_mutex, NULL); } if(ret == 0) { ret = pthread_mutex_init(&_hbaapi_LE_mutex, NULL); } if(ret != 0) { perror("pthread_mutec_init - HBA_LoadLibrary"); return(HBA_STATUS_ERROR); } #endif /* At least one lib must be loaded */ status = HBA_STATUS_ERROR; for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { if (lib_infop->status == HBA_LIBRARY_LOADED) { status = HBA_STATUS_OK; break; } } return status; } HBA_STATUS HBA_FreeLibrary() { HBAFreeLibraryFunc FreeLibraryFunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_LIBRARY_INFO *lib_next; HBA_ADAPTERCALLBACK_ELEM ***listp; HBA_ADAPTER_INFO *adapt_infop; HBA_ADAPTER_INFO *adapt_next; ARE_WE_INITED(); GRAB_MUTEX(&_hbaapi_LL_mutex); GRAB_MUTEX(&_hbaapi_AL_mutex); DEBUG(1, "HBA_FreeLibrary()", 0, 0, 0); for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_next) { lib_next = lib_infop->next; if (lib_infop->status == HBA_LIBRARY_LOADED) { FreeLibraryFunc = lib_infop->functionTable.FreeLibraryHandler; if (FreeLibraryFunc != NULL) { /* Free this library */ status = ((FreeLibraryFunc)()); } dlclose(lib_infop->hLibrary); /* Unload DLL from memory */ } free(lib_infop->LibraryName); free(lib_infop->LibraryPath); free(lib_infop); } _hbaapi_librarylist = NULL; /* OK, now all functions are disabled except for LoadLibrary, * Hope no other thread calls it before we have returned */ _hbaapi_total_library_count = 0; for(adapt_infop = _hbaapi_adapterlist; adapt_infop != NULL; adapt_infop = adapt_next) { adapt_next = adapt_infop->next; free(adapt_infop->name); free(adapt_infop); } _hbaapi_adapterlist = NULL; _hbaapi_total_adapter_count = 0; /* Free up the callbacks, this is not the most efficient, but it works */ while((volatile HBA_ADAPTERCALLBACK_ELEM *) _hbaapi_adapteraddevents_callback_list != NULL) { local_remove_callback((HBA_CALLBACKHANDLE) _hbaapi_adapteraddevents_callback_list); } for(listp = cb_lists_array; *listp != NULL; listp++) { while((volatile HBA_ADAPTERCALLBACK_ELEM ***)**listp != NULL) { local_remove_callback((HBA_CALLBACKHANDLE)**listp); } } RELEASE_MUTEX(&_hbaapi_AL_mutex); RELEASE_MUTEX(&_hbaapi_LL_mutex); #ifdef USESYSLOG closelog(); #endif #ifdef USELOGFILE if(_hbaapi_debug_fd != NULL) { fclose(_hbaapi_debug_fd); } _hbaapi_debug_fd = NULL; #endif #ifdef POSIX_THREADS /* this will unlock them as well, but who cares */ pthread_mutex_destroy(&_hbaapi_LE_mutex); pthread_mutex_destroy(&_hbaapi_TE_mutex); pthread_mutex_destroy(&_hbaapi_APSE_mutex); pthread_mutex_destroy(&_hbaapi_APE_mutex); pthread_mutex_destroy(&_hbaapi_AE_mutex); pthread_mutex_destroy(&_hbaapi_AAE_mutex); pthread_mutex_destroy(&_hbaapi_AL_mutex); pthread_mutex_destroy(&_hbaapi_LL_mutex); #endif return HBA_STATUS_OK; } /* * The API used to use fixed size tables as its primary data structure. * Indexing from 1 to N identified each adapters. Now the adapters are * on a linked list. There is a unique "index" foreach each adapter. * Adapters always keep their index, even if they are removed from the * hardware. The only time the indexing is reset is on HBA_FreeLibrary */ HBA_UINT32 HBA_GetNumberOfAdapters() { int j=0; HBA_LIBRARY_INFO *lib_infop; HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersFunc; HBAGetAdapterNameFunc GetAdapterNameFunc; HBA_BOOLEAN found_name; HBA_ADAPTER_INFO *adapt_infop; HBA_STATUS status; char adaptername[256]; int num_adapters; /* local */ if(_hbaapi_librarylist == NULL) { return (0); } GRAB_MUTEX(&_hbaapi_LL_mutex); /* pay attention to order */ GRAB_MUTEX(&_hbaapi_AL_mutex); for (lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { if (lib_infop->status != HBA_LIBRARY_LOADED) { continue; } GetNumberOfAdaptersFunc = lib_infop->functionTable.GetNumberOfAdaptersHandler; if (GetNumberOfAdaptersFunc == NULL) { continue; } num_adapters = ((GetNumberOfAdaptersFunc)()); DEBUG(1, "HBAAPI: num_adapters for %s = %d\n", lib_infop->LibraryName, num_adapters, 0); /* Also get the names of all the adapters here and cache */ GetAdapterNameFunc = lib_infop->functionTable.GetAdapterNameHandler; if(GetAdapterNameFunc == NULL) { continue; } for (j = 0; j < num_adapters; j++) { found_name = 0; status = (GetAdapterNameFunc)(j, (char *)&adaptername); if(status == HBA_STATUS_OK) { for(adapt_infop = _hbaapi_adapterlist; adapt_infop != NULL; adapt_infop = adapt_infop->next) { /* * check for duplicates, really, this may just be a second * call to this function * ??? how do we know when a name becomes stale? */ if(strcmp(adaptername, adapt_infop->name) == 0) { /* already got this one */ found_name++; break; } } if(found_name != 0) { continue; } } adapt_infop = (HBA_ADAPTER_INFO *) calloc(1, sizeof(HBA_ADAPTER_INFO)); if(adapt_infop == NULL) { fprintf(stderr, "HBA_GetNumberOfAdapters: calloc failed on sizeof:%ld\n", sizeof(HBA_ADAPTER_INFO)); RELEASE_MUTEX(&_hbaapi_AL_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count); } if((adapt_infop->GNstatus = status) == HBA_STATUS_OK) { adapt_infop->name = strdup(adaptername); } else { char dummyname[512]; sprintf(dummyname, "NULLADAPTER-%s-%03d", lib_infop->LibraryPath, _hbaapi_total_adapter_count); dummyname[255] = '\0'; adapt_infop->name = strdup(dummyname); } adapt_infop->library = lib_infop; adapt_infop->next = _hbaapi_adapterlist; adapt_infop->index = _hbaapi_total_adapter_count; _hbaapi_adapterlist = adapt_infop; _hbaapi_total_adapter_count++; } } RELEASE_MUTEX(&_hbaapi_AL_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, _hbaapi_total_adapter_count); } HBA_STATUS HBA_GetAdapterName( HBA_UINT32 adapterindex, char *adaptername) { HBA_ADAPTER_INFO *adapt_infop; HBA_STATUS ret = HBA_STATUS_ERROR_ILLEGAL_INDEX; /* * The adapter index is from old code, but we have * to support it. Go down the list looking for * the adapter */ ARE_WE_INITED(); GRAB_MUTEX(&_hbaapi_AL_mutex); *adaptername = '\0'; for(adapt_infop = _hbaapi_adapterlist; adapt_infop != NULL; adapt_infop = adapt_infop->next) { if(adapt_infop->index == adapterindex) { if(adapt_infop->name != NULL && adapt_infop->GNstatus == HBA_STATUS_OK) { strcpy(adaptername, adapt_infop->name); } else { *adaptername = '\0'; } ret = adapt_infop->GNstatus; break; } } DEBUG(2, "GetAdapterName for index:%d ->%s", adapterindex, adaptername, 0); RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, ret); } HBA_HANDLE HBA_OpenAdapter(char* adaptername) { HBA_HANDLE handle; HBAOpenAdapterFunc OpenAdapterFunc; HBA_ADAPTER_INFO *adapt_infop; HBA_LIBRARY_INFO *lib_infop; DEBUG(2, "OpenAdapter: %s", adaptername, 0, 0); if(_hbaapi_librarylist == NULL) { return(HBA_HANDLE_INVALID); } handle = HBA_HANDLE_INVALID; GRAB_MUTEX(&_hbaapi_AL_mutex); for(adapt_infop = _hbaapi_adapterlist; adapt_infop != NULL; adapt_infop = adapt_infop->next) { if (strcmp(adaptername, adapt_infop->name) != 0) { continue; } lib_infop = adapt_infop->library; OpenAdapterFunc = lib_infop->functionTable.OpenAdapterHandler; if (OpenAdapterFunc != NULL) { /* retrieve the vendor handle */ handle = (OpenAdapterFunc)(adaptername); if(handle != 0) { /* or this with the library index to get the common handle */ handle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle); } } break; } RELEASE_MUTEX_RETURN(&_hbaapi_AL_mutex, handle); } /* * This function ignores the list of known adapters and instead tries * each vendors open function to see if one of them * can open an adapter when referenced with a particular WWN */ HBA_STATUS HBA_OpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN nodeWWN) { HBA_HANDLE handle; HBA_LIBRARY_INFO *lib_infop; HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersFunc; HBAOpenAdapterByWWNFunc OpenAdapterFunc; HBA_STATUS status; DEBUG(2, "OpenAdapterByWWN: %s", WWN2STR1(&nodeWWN), 0, 0); ARE_WE_INITED(); *phandle = HBA_HANDLE_INVALID; GRAB_MUTEX(&_hbaapi_LL_mutex); for (lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { status = HBA_STATUS_ERROR_ILLEGAL_WWN; if (lib_infop->status != HBA_LIBRARY_LOADED) { continue; } GetNumberOfAdaptersFunc = lib_infop->functionTable.GetNumberOfAdaptersHandler; if (GetNumberOfAdaptersFunc == NULL) { continue; } /* look for new hardware */ (void) ((GetNumberOfAdaptersFunc)()); OpenAdapterFunc = lib_infop->functionTable.OpenAdapterByWWNHandler; if (OpenAdapterFunc == NULL) { continue; } /* * We do not know if the WWN is known by this vendor, * just try it */ if((status = (OpenAdapterFunc)(&handle, nodeWWN)) != HBA_STATUS_OK) { continue; } /* OK, make a vendor non-specific handle */ *phandle = HBA_HANDLE_FROM_LOCAL(lib_infop->index, handle); status = HBA_STATUS_OK; break; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } void HBA_RefreshAdapterConfiguration() { DEBUG(2, "HBA_RefreshAdapterConfiguration", 0, 0, 0); (void)HBA_GetNumberOfAdapters(); return; } HBA_UINT32 HBA_GetVersion() { DEBUG(2, "HBA_GetVersion", 0, 0, 0); return HBA_LIBVERSION; } /* * This function is VERY OS dependent. Wing it as best you can. */ HBA_UINT32 HBA_GetWrapperLibraryAttributes ( HBA_LIBRARYATTRIBUTES *attributes) { DEBUG(2, "HBA_GetWrapperLibraryAttributes", 0, 0, 0); memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES)); #if defined(SOLARIS) if((handle = dlopen("libHBAAPI.so", RTLD_NOW)) != NULL) { if(dlinfo(handle, RTLD_DI_LINKMAP, &map) >= 0) { for(mp = map; mp != NULL; mp = mp->l_next) { if(strlen(map->l_name) < 256) { strcpy(attributes->LibPath, map->l_lname); } } } } #endif #if defined(VENDOR) strcpy(attributes->VName, VENDOR); #else attributes->VName[0] = '\0'; #endif #if defined(VERSION) strcpy(attributes->VVersion, VERSION); #else attributes->VVersion[0] = '\0'; #endif #if defined(BUILD_DATE) if(strptime(BUILD_DATE, "%Y/%m/%d %T %Z", &(attributes->build_date)) == NULL) { memset(&attributes->build_date, 0, sizeof(struct tm)); } #else memset(&attributes->build_date, 0, sizeof(struct tm)); #endif return 2; } /* * Callback registation and handling */ HBA_STATUS HBA_RemoveCallback (HBA_CALLBACKHANDLE cbhandle) { HBA_STATUS status; DEBUG(2, "HBA_RemoveCallback", 0, 0, 0); ARE_WE_INITED(); GRAB_MUTEX(&_hbaapi_LL_mutex); status = local_remove_callback(cbhandle); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } /* Adapter Add Events *********************************************************/ static void adapteraddevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) { HBA_ALLADAPTERSCALLBACK_ELEM *cbp; DEBUG(3, "AddAdapterEvent, port:%s", WWN2STR1(&PortWWN), 0, 0); GRAB_MUTEX(&_hbaapi_AAE_mutex); for(cbp = _hbaapi_adapteraddevents_callback_list; cbp != NULL; cbp = cbp->next) { (*cbp->callback)(data, PortWWN, HBA_EVENT_ADAPTER_ADD); } RELEASE_MUTEX(&_hbaapi_AAE_mutex); } HBA_STATUS HBA_RegisterForAdapterAddEvents ( void (*callback) ( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_CALLBACKHANDLE *callbackHandle) { HBA_ALLADAPTERSCALLBACK_ELEM *cbp; HBA_VENDORCALLBACK_ELEM *vcbp; HBA_VENDORCALLBACK_ELEM *vendorhandlelist; HBARegisterForAdapterAddEventsFunc registeredfunc; HBA_STATUS status = HBA_STATUS_OK; HBA_STATUS failure = HBA_STATUS_OK; HBA_LIBRARY_INFO *lib_infop; int registered_cnt = 0; int vendor_cnt = 0; int not_supported_cnt = 0; int status_OK_bar_cnt = 0; int status_OK_cnt = 0; DEBUG(2, "HBA_RegisterForAdapterAddEvents", 0, 0, 0); ARE_WE_INITED(); cbp = (HBA_ALLADAPTERSCALLBACK_ELEM *) calloc(1, sizeof(HBA_ALLADAPTERSCALLBACK_ELEM)); *callbackHandle = (HBA_CALLBACKHANDLE) cbp; if(cbp == NULL) { fprintf(stderr, "HBA_RegisterForAdapterAddEvents: calloc failed for %ld bytes\n", sizeof(HBA_ALLADAPTERSCALLBACK_ELEM)); return HBA_STATUS_ERROR; } GRAB_MUTEX(&_hbaapi_LL_mutex); GRAB_MUTEX(&_hbaapi_AAE_mutex); cbp->callback = callback; cbp->next = _hbaapi_adapteraddevents_callback_list; _hbaapi_adapteraddevents_callback_list = cbp; /* Need to release the mutex now incase the vendor function invokes the * callback. We will grap the mutex later to attach the vendor handle list * to the callback structure */ RELEASE_MUTEX(&_hbaapi_AAE_mutex); /* * now create a list of vendors (vendor libraryies, NOT ADAPTERS) that have * successfully registerred */ vendorhandlelist = NULL; for(lib_infop = _hbaapi_librarylist; lib_infop != NULL; lib_infop = lib_infop->next) { vendor_cnt++; registeredfunc = lib_infop->functionTable.RegisterForAdapterAddEventsHandler; if(registeredfunc == NULL) { continue; } vcbp = (HBA_VENDORCALLBACK_ELEM *) calloc(1, sizeof(HBA_VENDORCALLBACK_ELEM)); if(vcbp == NULL) { fprintf(stderr, "HBA_RegisterForAdapterAddEvents: " "calloc failed for %ld bytes\n", sizeof(HBA_VENDORCALLBACK_ELEM)); freevendorhandlelist(vendorhandlelist); status = HBA_STATUS_ERROR; break; } registered_cnt++; status = (registeredfunc)(adapteraddevents_callback, userData, &vcbp->vendorcbhandle); if(status == HBA_STATUS_ERROR_NOT_SUPPORTED) { not_supported_cnt++; free(vcbp); continue; } else if (status != HBA_STATUS_OK) { status_OK_bar_cnt++; DEBUG(0, "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d", lib_infop->LibraryPath, status, 0); fprintf(stderr, "HBA_RegisterForAdapterAddEvents: Library->%s, Error->%d", lib_infop->LibraryPath, status); failure = status; free(vcbp); continue; } else { status_OK_cnt++; } vcbp->lib_info = lib_infop; vcbp->next = vendorhandlelist; vendorhandlelist = vcbp; } if(registered_cnt == 0) { status = HBA_STATUS_ERROR_NOT_SUPPORTED; freevendorhandlelist(vendorhandlelist); local_remove_callback((HBA_CALLBACKHANDLE) cbp); } else if (status_OK_cnt == 0 && not_supported_cnt != 0) { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } else if (status_OK_cnt == 0) { /* At least one vendor library registered this function, but no * vendor call succeeded */ local_remove_callback((HBA_CALLBACKHANDLE) cbp); status = failure; } else { /* we have had atleast some success, now finish up */ GRAB_MUTEX(&_hbaapi_AAE_mutex); /* this seems silly, but what if another thread called * the callback remove */ for(cbp = _hbaapi_adapteraddevents_callback_list; cbp != NULL; cbp = cbp->next) { if((HBA_CALLBACKHANDLE)cbp == *callbackHandle) { /* yup, its still there, hooray */ cbp->vendorhandlelist = vendorhandlelist; vendorhandlelist = NULL; break; } } RELEASE_MUTEX(&_hbaapi_AAE_mutex); if(vendorhandlelist != NULL) { /* bummer, somebody removed the callback before we finished * registration, probably will never happen */ freevendorhandlelist(vendorhandlelist); DEBUG(0, "HBA_RegisterForAdapterAddEvents: HBA_RemoveCallback was " "called for a handle before registration was finished.", 0, 0, 0); status = HBA_STATUS_ERROR; } else { status = HBA_STATUS_OK; } } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } /* Adapter Events (other than add) ********************************************/ static void adapterevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) { HBA_ADAPTERCALLBACK_ELEM *acbp; DEBUG(3, "AdapterEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN), eventType, 0); GRAB_MUTEX(&_hbaapi_AE_mutex); for(acbp = _hbaapi_adapterevents_callback_list; acbp != NULL; acbp = acbp->next) { if(data == (void *)acbp) { (*acbp->callback)(acbp->userdata, PortWWN, eventType); break; } } RELEASE_MUTEX(&_hbaapi_AE_mutex); } HBA_STATUS HBA_RegisterForAdapterEvents ( void (*callback) ( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_CALLBACKHANDLE *callbackHandle) { HBA_ADAPTERCALLBACK_ELEM *acbp; HBARegisterForAdapterEventsFunc registeredfunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; DEBUG(2, "HBA_RegisterForAdapterEvents", 0, 0, 0); CHECKLIBRARY(); /* we now have the _hbaapi_LL_mutex */ registeredfunc = lib_infop->functionTable.RegisterForAdapterEventsHandler; if(registeredfunc == NULL) { RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED); } /* * that allocated memory is used both as the handle for the * caller, and as userdata to the vendor call so that on * callback the specific registration may be recalled */ acbp = (HBA_ADAPTERCALLBACK_ELEM *) calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM)); if(acbp == NULL) { fprintf(stderr, "HBA_RegisterForAdapterEvents: calloc failed for %ld bytes\n", sizeof(HBA_ADAPTERCALLBACK_ELEM)); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR); } *callbackHandle = (HBA_CALLBACKHANDLE) acbp; acbp->callback = callback; acbp->userdata = userData; acbp->lib_info = lib_infop; status = (registeredfunc)(adapterevents_callback, (void *)acbp, vendorHandle, &acbp->vendorcbhandle); if(status != HBA_STATUS_OK) { free(acbp); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } GRAB_MUTEX(&_hbaapi_AE_mutex); acbp->next = _hbaapi_adapterevents_callback_list; _hbaapi_adapterevents_callback_list = acbp; RELEASE_MUTEX(&_hbaapi_AE_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK); } /* Adapter Port Events ********************************************************/ static void adapterportevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType, HBA_UINT32 fabricPortID) { HBA_ADAPTERCALLBACK_ELEM *acbp; DEBUG(3, "AdapterPortEvent, port:%s, eventType:%d fabricPortID:0X%06x", WWN2STR1(&PortWWN), eventType, fabricPortID); GRAB_MUTEX(&_hbaapi_APE_mutex); for(acbp = _hbaapi_adapterportevents_callback_list; acbp != NULL; acbp = acbp->next) { if(data == (void *)acbp) { (*acbp->callback)(acbp->userdata, PortWWN, eventType, fabricPortID); break; } } RELEASE_MUTEX(&_hbaapi_APE_mutex); } HBA_STATUS HBA_RegisterForAdapterPortEvents ( void (*callback) ( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType, HBA_UINT32 fabricPortID ), void *userData, HBA_HANDLE handle, HBA_WWN PortWWN, HBA_CALLBACKHANDLE *callbackHandle) { HBA_ADAPTERCALLBACK_ELEM *acbp; HBARegisterForAdapterPortEventsFunc registeredfunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; DEBUG(2, "HBA_RegisterForAdapterPortEvents for port: %s", WWN2STR1(&PortWWN), 0, 0); CHECKLIBRARY(); /* we now have the _hbaapi_LL_mutex */ registeredfunc = lib_infop->functionTable.RegisterForAdapterPortEventsHandler; if(registeredfunc == NULL) { RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED); } /* * that allocated memory is used both as the handle for the * caller, and as userdata to the vendor call so that on * callback the specific registration may be recalled */ acbp = (HBA_ADAPTERCALLBACK_ELEM *) calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM)); if(acbp == NULL) { fprintf(stderr, "HBA_RegisterForAdapterPortEvents: " "calloc failed for %ld bytes\n", sizeof(HBA_ADAPTERCALLBACK_ELEM)); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR); } *callbackHandle = (HBA_CALLBACKHANDLE) acbp; acbp->callback = callback; acbp->userdata = userData; acbp->lib_info = lib_infop; status = (registeredfunc)(adapterportevents_callback, (void *)acbp, vendorHandle, PortWWN, &acbp->vendorcbhandle); if(status != HBA_STATUS_OK) { free(acbp); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } GRAB_MUTEX(&_hbaapi_APE_mutex); acbp->next = _hbaapi_adapterportevents_callback_list; _hbaapi_adapterportevents_callback_list = acbp; RELEASE_MUTEX(&_hbaapi_APE_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK); } /* Adapter State Events *******************************************************/ static void adapterportstatevents_callback (void *data, HBA_WWN PortWWN, HBA_UINT32 eventType) { HBA_ADAPTERCALLBACK_ELEM *acbp; DEBUG(3, "AdapterPortStateEvent, port:%s, eventType:%d", WWN2STR1(&PortWWN), eventType, 0); GRAB_MUTEX(&_hbaapi_APSE_mutex); for(acbp = _hbaapi_adapterportstatevents_callback_list; acbp != NULL; acbp = acbp->next) { if(data == (void *)acbp) { (*acbp->callback)(acbp->userdata, PortWWN, eventType); return; } } } HBA_STATUS HBA_RegisterForAdapterPortStatEvents ( void (*callback) ( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTSTATISTICS stats, HBA_UINT32 statType, HBA_CALLBACKHANDLE *callbackHandle) { HBA_ADAPTERCALLBACK_ELEM *acbp; HBARegisterForAdapterPortStatEventsFunc registeredfunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; DEBUG(2, "HBA_RegisterForAdapterPortStatEvents for port: %s", WWN2STR1(&PortWWN), 0, 0); CHECKLIBRARY(); /* we now have the _hbaapi_LL_mutex */ registeredfunc = lib_infop->functionTable.RegisterForAdapterPortStatEventsHandler; if(registeredfunc == NULL) { RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED); } /* * that allocated memory is used both as the handle for the * caller, and as userdata to the vendor call so that on * callback the specific registration may be recalled */ acbp = (HBA_ADAPTERCALLBACK_ELEM *) calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM)); if(acbp == NULL) { fprintf(stderr, "HBA_RegisterForAdapterPortStatEvents: " "calloc failed for %ld bytes\n", sizeof(HBA_ADAPTERCALLBACK_ELEM)); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR); } *callbackHandle = (HBA_CALLBACKHANDLE) acbp; acbp->callback = callback; acbp->userdata = userData; acbp->lib_info = lib_infop; status = (registeredfunc)(adapterportstatevents_callback, (void *)acbp, vendorHandle, PortWWN, stats, statType, &acbp->vendorcbhandle); if(status != HBA_STATUS_OK) { free(acbp); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } GRAB_MUTEX(&_hbaapi_APSE_mutex); acbp->next = _hbaapi_adapterportstatevents_callback_list; _hbaapi_adapterportstatevents_callback_list = acbp; RELEASE_MUTEX(&_hbaapi_APSE_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK); } /* Target Events **************************************************************/ static void targetevents_callback (void *data, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT32 eventType) { HBA_ADAPTERCALLBACK_ELEM *acbp; DEBUG(3, "TargetEvent, hbaPort:%s, discoveredPort:%s eventType:%d", WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), eventType); GRAB_MUTEX(&_hbaapi_TE_mutex); for(acbp = _hbaapi_targetevents_callback_list; acbp != NULL; acbp = acbp->next) { if(data == (void *)acbp) { (*acbp->callback)(acbp->userdata, hbaPortWWN, discoveredPortWWN, eventType); break; } } RELEASE_MUTEX(&_hbaapi_TE_mutex); } HBA_STATUS HBA_RegisterForTargetEvents ( void (*callback) ( void *data, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT32 eventType ), void *userData, HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_CALLBACKHANDLE *callbackHandle, HBA_UINT32 allTargets) { HBA_ADAPTERCALLBACK_ELEM *acbp; HBARegisterForTargetEventsFunc registeredfunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; DEBUG(2, "HBA_RegisterForTargetEvents, hbaPort: %s, discoveredPort: %s", WWN2STR1(&hbaPortWWN), WWN2STR2(&discoveredPortWWN), 0); CHECKLIBRARY(); /* we now have the _hbaapi_LL_mutex */ registeredfunc = lib_infop->functionTable.RegisterForTargetEventsHandler; if(registeredfunc == NULL) { RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED); } /* * that allocated memory is used both as the handle for the * caller, and as userdata to the vendor call so that on * callback the specific registration may be recalled */ acbp = (HBA_ADAPTERCALLBACK_ELEM *) calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM)); if(acbp == NULL) { fprintf(stderr, "HBA_RegisterForTargetEvents: calloc failed for %ld bytes\n", sizeof(HBA_ADAPTERCALLBACK_ELEM)); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR); } *callbackHandle = (HBA_CALLBACKHANDLE) acbp; acbp->callback = callback; acbp->userdata = userData; acbp->lib_info = lib_infop; status = (registeredfunc)(targetevents_callback, (void *)acbp, vendorHandle, hbaPortWWN, discoveredPortWWN, &acbp->vendorcbhandle, allTargets); if(status != HBA_STATUS_OK) { free(acbp); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } GRAB_MUTEX(&_hbaapi_TE_mutex); acbp->next = _hbaapi_targetevents_callback_list; _hbaapi_targetevents_callback_list = acbp; RELEASE_MUTEX(&_hbaapi_TE_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK); } /* Link Events ****************************************************************/ static void linkevents_callback (void *data, HBA_WWN adapterWWN, HBA_UINT32 eventType, void *pRLIRBuffer, HBA_UINT32 RLIRBufferSize) { HBA_ADAPTERCALLBACK_ELEM *acbp; DEBUG(3, "LinkEvent, hbaWWN:%s, eventType:%d", WWN2STR1(&adapterWWN), eventType, 0); GRAB_MUTEX(&_hbaapi_LE_mutex); for(acbp = _hbaapi_linkevents_callback_list; acbp != NULL; acbp = acbp->next) { if(data == (void *)acbp) { (*acbp->callback)(acbp->userdata, adapterWWN, eventType, pRLIRBuffer, RLIRBufferSize); break; } } RELEASE_MUTEX(&_hbaapi_LE_mutex); } HBA_STATUS HBA_RegisterForLinkEvents ( void (*callback) ( void *data, HBA_WWN adapterWWN, HBA_UINT32 eventType, void *pRLIRBuffer, HBA_UINT32 RLIRBufferSize), void *userData, void *pRLIRBuffer, HBA_UINT32 RLIRBufferSize, HBA_HANDLE handle, HBA_CALLBACKHANDLE *callbackHandle) { HBA_ADAPTERCALLBACK_ELEM *acbp; HBARegisterForLinkEventsFunc registeredfunc; HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; DEBUG(2, "HBA_RegisterForLinkEvents", 0, 0, 0); CHECKLIBRARY(); /* we now have the _hbaapi_LL_mutex */ registeredfunc = lib_infop->functionTable.RegisterForLinkEventsHandler; if(registeredfunc == NULL) { RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR_NOT_SUPPORTED); } /* * that allocated memory is used both as the handle for the * caller, and as userdata to the vendor call so that on * callback the specific registration may be recalled */ acbp = (HBA_ADAPTERCALLBACK_ELEM *) calloc(1, sizeof(HBA_ADAPTERCALLBACK_ELEM)); if(acbp == NULL) { fprintf(stderr, "HBA_RegisterForLinkEvents: calloc failed for %ld bytes\n", sizeof(HBA_ADAPTERCALLBACK_ELEM)); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_ERROR); } *callbackHandle = (HBA_CALLBACKHANDLE) acbp; acbp->callback = callback; acbp->userdata = userData; acbp->lib_info = lib_infop; status = (registeredfunc)(linkevents_callback, (void *)acbp, pRLIRBuffer, RLIRBufferSize, vendorHandle, &acbp->vendorcbhandle); if(status != HBA_STATUS_OK) { free(acbp); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } GRAB_MUTEX(&_hbaapi_LE_mutex); acbp->next = _hbaapi_linkevents_callback_list; _hbaapi_linkevents_callback_list = acbp; RELEASE_MUTEX(&_hbaapi_LE_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, HBA_STATUS_OK); } /* * All of the functions below are almost passthru functions to the * vendor specific function */ void HBA_CloseAdapter(HBA_HANDLE handle) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBACloseAdapterFunc CloseAdapterFunc; DEBUG(2, "HBA_CloseAdapter", 0, 0, 0); status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle); if (status == HBA_STATUS_OK) { CloseAdapterFunc = lib_infop->functionTable.CloseAdapterHandler; if (CloseAdapterFunc != NULL) { ((CloseAdapterFunc)(vendorHandle)); } RELEASE_MUTEX(&_hbaapi_LL_mutex); } } HBA_STATUS HBA_GetAdapterAttributes ( HBA_HANDLE handle, HBA_ADAPTERATTRIBUTES *hbaattributes) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetAdapterAttributesFunc GetAdapterAttributesFunc; DEBUG(2, "HBA_GetAdapterAttributes", 0, 0, 0); CHECKLIBRARY(); GetAdapterAttributesFunc = lib_infop->functionTable.GetAdapterAttributesHandler; if (GetAdapterAttributesFunc != NULL) { status = ((GetAdapterAttributesFunc)(vendorHandle, hbaattributes)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetAdapterPortAttributes ( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTATTRIBUTES *portattributes) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetAdapterPortAttributesFunc GetAdapterPortAttributesFunc; DEBUG(2, "HBA_GetAdapterPortAttributes", 0, 0, 0); CHECKLIBRARY(); GetAdapterPortAttributesFunc = lib_infop->functionTable.GetAdapterPortAttributesHandler; if (GetAdapterPortAttributesFunc != NULL) { status = ((GetAdapterPortAttributesFunc) (vendorHandle, portindex, portattributes)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetPortStatistics ( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTSTATISTICS *portstatistics) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetPortStatisticsFunc GetPortStatisticsFunc; DEBUG(2, "HBA_GetPortStatistics", 0, 0, 0); CHECKLIBRARY(); GetPortStatisticsFunc = lib_infop->functionTable.GetPortStatisticsHandler; if (GetPortStatisticsFunc != NULL) { status = ((GetPortStatisticsFunc) (vendorHandle, portindex, portstatistics)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetDiscoveredPortAttributes ( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_UINT32 discoveredportindex, HBA_PORTATTRIBUTES *portattributes) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetDiscoveredPortAttributesFunc GetDiscoveredPortAttributesFunc; DEBUG(2, "HBA_GetDiscoveredPortAttributes", 0, 0, 0); CHECKLIBRARY(); GetDiscoveredPortAttributesFunc = lib_infop->functionTable.GetDiscoveredPortAttributesHandler; if (GetDiscoveredPortAttributesFunc != NULL) { status = ((GetDiscoveredPortAttributesFunc) (vendorHandle, portindex, discoveredportindex, portattributes)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetPortAttributesByWWN ( HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTATTRIBUTES *portattributes) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetPortAttributesByWWNFunc GetPortAttributesByWWNFunc; DEBUG(2, "HBA_GetPortAttributesByWWN: %s", WWN2STR1(&PortWWN), 0, 0); CHECKLIBRARY(); GetPortAttributesByWWNFunc = lib_infop->functionTable.GetPortAttributesByWWNHandler; if (GetPortAttributesByWWNFunc != NULL) { status = ((GetPortAttributesByWWNFunc) (vendorHandle, PortWWN, portattributes)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendCTPassThru ( HBA_HANDLE handle, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 RspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendCTPassThruFunc SendCTPassThruFunc; DEBUG(2, "HBA_SendCTPassThru", 0, 0, 0); CHECKLIBRARY(); SendCTPassThruFunc = lib_infop->functionTable.SendCTPassThruHandler; if (SendCTPassThruFunc != NULL) { status = (SendCTPassThruFunc) (vendorHandle, pReqBuffer, ReqBufferSize, pRspBuffer, RspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendCTPassThruV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendCTPassThruV2Func registeredfunc; DEBUG(2, "HBA_SendCTPassThruV2m hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendCTPassThruV2Handler; if (registeredfunc != NULL) { status = (registeredfunc) (vendorHandle, hbaPortWWN, pReqBuffer, ReqBufferSize, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetEventBuffer ( HBA_HANDLE handle, PHBA_EVENTINFO EventBuffer, HBA_UINT32 *EventBufferCount) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetEventBufferFunc GetEventBufferFunc; DEBUG(2, "HBA_GetEventBuffer", 0, 0, 0); CHECKLIBRARY(); GetEventBufferFunc = lib_infop->functionTable.GetEventBufferHandler; if (GetEventBufferFunc != NULL) { status = (GetEventBufferFunc) (vendorHandle, EventBuffer, EventBufferCount); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *pInfo) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASetRNIDMgmtInfoFunc SetRNIDMgmtInfoFunc; DEBUG(2, "HBA_SetRNIDMgmtInfo", 0, 0, 0); CHECKLIBRARY(); SetRNIDMgmtInfoFunc = lib_infop->functionTable.SetRNIDMgmtInfoHandler; if (SetRNIDMgmtInfoFunc != NULL) { status = (SetRNIDMgmtInfoFunc)(vendorHandle, pInfo); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *pInfo) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASetRNIDMgmtInfoFunc GetRNIDMgmtInfoFunc; DEBUG(2, "HBA_GetRNIDMgmtInfo", 0, 0, 0); CHECKLIBRARY(); GetRNIDMgmtInfoFunc = lib_infop->functionTable.GetRNIDMgmtInfoHandler; if (GetRNIDMgmtInfoFunc != NULL) { status = (GetRNIDMgmtInfoFunc)(vendorHandle, pInfo); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendRNID ( HBA_HANDLE handle, HBA_WWN wwn, HBA_WWNTYPE wwntype, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendRNIDFunc SendRNIDFunc; DEBUG(2, "HBA_SendRNID for wwn: %s", WWN2STR1(&wwn), 0, 0); CHECKLIBRARY(); SendRNIDFunc = lib_infop->functionTable.SendRNIDHandler; if (SendRNIDFunc != NULL) { status = ((SendRNIDFunc)(vendorHandle, wwn, wwntype, pRspBuffer, pRspBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendRNIDV2( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, HBA_UINT32 destFCID, HBA_UINT32 NodeIdDataFormat, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendRNIDV2Func registeredfunc; DEBUG(2, "HBA_SendRNIDV2, hbaPortWWN: %s", WWN2STR1(&hbaPortWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendRNIDV2Handler; if (registeredfunc != NULL) { status = (registeredfunc) (vendorHandle, hbaPortWWN, destWWN, destFCID, NodeIdDataFormat, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } void HBA_RefreshInformation (HBA_HANDLE handle) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBARefreshInformationFunc RefreshInformationFunc; DEBUG(2, "HBA_RefreshInformation", 0, 0, 0); status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle); if(status == HBA_STATUS_OK) { RefreshInformationFunc = lib_infop->functionTable.RefreshInformationHandler; if (RefreshInformationFunc != NULL) { ((RefreshInformationFunc)(vendorHandle)); } RELEASE_MUTEX(&_hbaapi_LL_mutex); } } void HBA_ResetStatistics (HBA_HANDLE handle, HBA_UINT32 portindex) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAResetStatisticsFunc ResetStatisticsFunc; DEBUG(2, "HBA_ResetStatistics", 0, 0, 0); status = HBA_CheckLibrary(handle, &lib_infop, &vendorHandle); if(status == HBA_STATUS_OK) { ResetStatisticsFunc = lib_infop->functionTable.ResetStatisticsHandler; if (ResetStatisticsFunc != NULL) { ((ResetStatisticsFunc)(vendorHandle, portindex)); } RELEASE_MUTEX(&_hbaapi_LL_mutex); } } HBA_STATUS HBA_GetFcpTargetMapping (HBA_HANDLE handle, PHBA_FCPTARGETMAPPING mapping) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetFcpTargetMappingFunc GetFcpTargetMappingFunc; DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0); CHECKLIBRARY(); GetFcpTargetMappingFunc = lib_infop->functionTable.GetFcpTargetMappingHandler; if (GetFcpTargetMappingFunc != NULL) { status = ((GetFcpTargetMappingFunc)(vendorHandle, mapping)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetFcpTargetMappingV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPTARGETMAPPINGV2 *pmapping) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetFcpTargetMappingV2Func registeredfunc; DEBUG(2, "HBA_GetFcpTargetMapping", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetFcpTargetMappingV2Handler; if (registeredfunc != NULL) { status = ((registeredfunc)(vendorHandle, hbaPortWWN, pmapping)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetFcpPersistentBinding (HBA_HANDLE handle, PHBA_FCPBINDING binding) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetFcpPersistentBindingFunc GetFcpPersistentBindingFunc; DEBUG(2, "HBA_GetFcpPersistentBinding", 0, 0, 0); CHECKLIBRARY(); GetFcpPersistentBindingFunc = lib_infop->functionTable.GetFcpPersistentBindingHandler; if (GetFcpPersistentBindingFunc != NULL) { status = ((GetFcpPersistentBindingFunc)(vendorHandle, binding)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_ScsiInquiryV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT64 fcLUN, HBA_UINT8 CDB_Byte1, HBA_UINT8 CDB_Byte2, void *pRspBuffer, HBA_UINT32 *pRspBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *pSenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAScsiInquiryV2Func ScsiInquiryV2Func; DEBUG(2, "HBA_ScsiInquiryV2 to discoveredPortWWN: %s", WWN2STR1(&discoveredPortWWN), 0, 0); CHECKLIBRARY(); ScsiInquiryV2Func = lib_infop->functionTable.ScsiInquiryV2Handler; if (ScsiInquiryV2Func != NULL) { status =((ScsiInquiryV2Func)( vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, CDB_Byte1, CDB_Byte2, pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer, pSenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendScsiInquiry ( HBA_HANDLE handle, HBA_WWN PortWWN, HBA_UINT64 fcLUN, HBA_UINT8 EVPD, HBA_UINT32 PageCode, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendScsiInquiryFunc SendScsiInquiryFunc; DEBUG(2, "HBA_SendScsiInquiry to PortWWN: %s", WWN2STR1(&PortWWN), 0, 0); CHECKLIBRARY(); SendScsiInquiryFunc = lib_infop->functionTable.ScsiInquiryHandler; if (SendScsiInquiryFunc != NULL) { status =((SendScsiInquiryFunc)( vendorHandle, PortWWN, fcLUN, EVPD, PageCode, pRspBuffer, RspBufferSize, pSenseBuffer, SenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_ScsiReportLUNsV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, void *pRespBuffer, HBA_UINT32 *pRespBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *pSenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAScsiReportLUNsV2Func ScsiReportLUNsV2Func; DEBUG(2, "HBA_ScsiReportLUNsV2 to discoveredPortWWN: %s", WWN2STR1(&discoveredPortWWN), 0, 0); CHECKLIBRARY(); ScsiReportLUNsV2Func = lib_infop->functionTable.ScsiReportLUNsV2Handler; if (ScsiReportLUNsV2Func != NULL) { status = ((ScsiReportLUNsV2Func)( vendorHandle, hbaPortWWN, discoveredPortWWN, pRespBuffer, pRespBufferSize, pScsiStatus, pSenseBuffer, pSenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendReportLUNs ( HBA_HANDLE handle, HBA_WWN portWWN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendReportLUNsFunc SendReportLUNsFunc; DEBUG(2, "HBA_SendReportLUNs to PortWWN: %s", WWN2STR1(&portWWN), 0, 0); CHECKLIBRARY(); SendReportLUNsFunc = lib_infop->functionTable.ReportLUNsHandler; if (SendReportLUNsFunc != NULL) { status = ((SendReportLUNsFunc)( vendorHandle, portWWN, pRspBuffer, RspBufferSize, pSenseBuffer, SenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_ScsiReadCapacityV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, HBA_UINT64 fcLUN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *SenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAScsiReadCapacityV2Func ScsiReadCapacityV2Func; DEBUG(2, "HBA_ScsiReadCapacityV2 to discoveredPortWWN: %s", WWN2STR1(&discoveredPortWWN), 0, 0); CHECKLIBRARY(); ScsiReadCapacityV2Func = lib_infop->functionTable.ScsiReadCapacityV2Handler; if (ScsiReadCapacityV2Func != NULL) { status =((ScsiReadCapacityV2Func)( vendorHandle, hbaPortWWN, discoveredPortWWN, fcLUN, pRspBuffer, pRspBufferSize, pScsiStatus, pSenseBuffer, SenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendReadCapacity ( HBA_HANDLE handle, HBA_WWN portWWN, HBA_UINT64 fcLUN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendReadCapacityFunc SendReadCapacityFunc; DEBUG(2, "HBA_SendReadCapacity to portWWN: %s", WWN2STR1(&portWWN), 0, 0); CHECKLIBRARY(); SendReadCapacityFunc = lib_infop->functionTable.ReadCapacityHandler; if (SendReadCapacityFunc != NULL) { status =((SendReadCapacityFunc) (vendorHandle, portWWN, fcLUN, pRspBuffer, RspBufferSize, pSenseBuffer, SenseBufferSize)); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendRPL ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN agent_wwn, HBA_UINT32 agent_domain, HBA_UINT32 portindex, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendRPLFunc registeredfunc; DEBUG(2, "HBA_SendRPL to agent_wwn: %s:%d", WWN2STR1(&agent_wwn), agent_domain, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendRPLHandler; if (registeredfunc != NULL) { status =(registeredfunc)( vendorHandle, hbaPortWWN, agent_wwn, agent_domain, portindex, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendRPS ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN agent_wwn, HBA_UINT32 agent_domain, HBA_WWN object_wwn, HBA_UINT32 object_port_number, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendRPSFunc registeredfunc; DEBUG(2, "HBA_SendRPS to agent_wwn: %s:%d", WWN2STR1(&agent_wwn), agent_domain, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendRPSHandler; if (registeredfunc != NULL) { status =(registeredfunc)( vendorHandle, hbaPortWWN, agent_wwn, agent_domain, object_wwn, object_port_number, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendSRL ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN wwn, HBA_UINT32 domain, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendSRLFunc registeredfunc; DEBUG(2, "HBA_SendSRL to wwn:%s domain:%d", WWN2STR1(&wwn), domain, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendSRLHandler; if (registeredfunc != NULL) { status =(registeredfunc)( vendorHandle, hbaPortWWN, wwn, domain, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendRLS ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendRLSFunc registeredfunc; DEBUG(2, "HBA_SendRLS dest_wwn: %s", WWN2STR(&destWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendRLSHandler; if (registeredfunc != NULL) { status =(registeredfunc)( vendorHandle, hbaPortWWN, destWWN, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SendLIRR ( HBA_HANDLE handle, HBA_WWN sourceWWN, HBA_WWN destWWN, HBA_UINT8 function, HBA_UINT8 type, void *pRspBuffer, HBA_UINT32 *pRspBufferSize) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASendLIRRFunc registeredfunc; DEBUG(2, "HBA_SendLIRR destWWN:%s", WWN2STR1(&destWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SendLIRRHandler; if (registeredfunc != NULL) { status =(registeredfunc)( vendorHandle, sourceWWN, destWWN, function, type, pRspBuffer, pRspBufferSize); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetBindingCapability( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pcapability) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetBindingCapabilityFunc registeredfunc; DEBUG(2, "HBA_GetBindingCapability", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetBindingCapabilityHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetBindingSupport ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pcapability) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetBindingSupportFunc registeredfunc; DEBUG(2, "HBA_GetBindingSupport", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetBindingSupportHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, pcapability); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SetBindingSupport( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY capability) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASetBindingSupportFunc registeredfunc; DEBUG(2, "HBA_SetBindingSupport", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SetBindingSupportHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, capability); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_SetPersistentBindingV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, const HBA_FCPBINDING2 *pbinding) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBASetPersistentBindingV2Func registeredfunc; DEBUG(2, "HBA_SetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.SetPersistentBindingV2Handler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetPersistentBindingV2 ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPBINDING2 *pbinding) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetPersistentBindingV2Func registeredfunc; DEBUG(2, "HBA_GetPersistentBindingV2 port: %s", WWN2STR1(&hbaPortWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetPersistentBindingV2Handler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_RemovePersistentBinding ( HBA_HANDLE handle, HBA_WWN hbaPortWWN, const HBA_FCPBINDING2 *pbinding) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBARemovePersistentBindingFunc registeredfunc; DEBUG(2, "HBA_RemovePersistentBinding", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.RemovePersistentBindingHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN, pbinding); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_RemoveAllPersistentBindings ( HBA_HANDLE handle, HBA_WWN hbaPortWWN) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBARemoveAllPersistentBindingsFunc registeredfunc; DEBUG(2, "HBA_RemoveAllPersistentBindings", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.RemoveAllPersistentBindingsHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, hbaPortWWN); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetFC4Statistics ( HBA_HANDLE handle, HBA_WWN portWWN, HBA_UINT8 FC4type, HBA_FC4STATISTICS *pstatistics) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetFC4StatisticsFunc registeredfunc; DEBUG(2, "HBA_GetFC4Statistics port: %s", WWN2STR1(&portWWN), 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetFC4StatisticsHandler; if (registeredfunc != NULL) { status =(registeredfunc) (vendorHandle, portWWN, FC4type, pstatistics); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_STATUS HBA_GetFCPStatistics ( HBA_HANDLE handle, const HBA_SCSIID *lunit, HBA_FC4STATISTICS *pstatistics) { HBA_STATUS status; HBA_LIBRARY_INFO *lib_infop; HBA_HANDLE vendorHandle; HBAGetFCPStatisticsFunc registeredfunc; DEBUG(2, "HBA_GetFCPStatistics", 0, 0, 0); CHECKLIBRARY(); registeredfunc = lib_infop->functionTable.GetFCPStatisticsHandler; if (registeredfunc != NULL) { status =(registeredfunc)(vendorHandle, lunit, pstatistics); } else { status = HBA_STATUS_ERROR_NOT_SUPPORTED; } RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, status); } HBA_UINT32 HBA_GetVendorLibraryAttributes ( HBA_UINT32 adapter_index, HBA_LIBRARYATTRIBUTES *attributes) { HBA_ADAPTER_INFO *adapt_infop; HBAGetVendorLibraryAttributesFunc registeredfunc; HBA_UINT32 ret = 0; DEBUG(2, "HBA_GetVendorLibraryAttributes adapterindex:%d", adapter_index, 0, 0); if(_hbaapi_librarylist == NULL) { DEBUG(1, "HBAAPI not loaded yet.", 0, 0, 0); return(0); } memset(attributes, 0, sizeof(HBA_LIBRARYATTRIBUTES)); GRAB_MUTEX(&_hbaapi_LL_mutex); GRAB_MUTEX(&_hbaapi_AL_mutex); for(adapt_infop = _hbaapi_adapterlist; adapt_infop != NULL; adapt_infop = adapt_infop->next) { if(adapt_infop->index == adapter_index) { registeredfunc = adapt_infop->library-> functionTable.GetVendorLibraryAttributesHandler; if(registeredfunc != NULL) { ret = (registeredfunc)(attributes); } else { /* Version 1 libary? */ HBAGetVersionFunc GetVersionFunc; GetVersionFunc = adapt_infop->library-> functionTable.GetVersionHandler; if(GetVersionFunc != NULL) { ret = ((GetVersionFunc)()); } #ifdef NOTDEF else { /* This should not happen, dont think its going to */ } #endif } if (attributes->LibPath[0] == '\0') { if(strlen(adapt_infop->library->LibraryPath) < 256) { strcpy(attributes->LibPath, adapt_infop->library->LibraryPath); } } break; } } RELEASE_MUTEX(&_hbaapi_AL_mutex); RELEASE_MUTEX_RETURN(&_hbaapi_LL_mutex, ret); } libhbaapi-2.2.9/hbaapitest.c000066400000000000000000000277661214751626200157570ustar00rootroot00000000000000/* * Description * hbaapitest.c - Sample application which uses the common library API for * HBA requests. * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is SNIA HBA API Sample Application * * The Initial Developer of the Original Code is: * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) * * Contributor(s): * *************************************************************************** */ #include #ifndef WIN32 #include /* Dynamic library support for Solaris */ #include #endif #include "hbaapi.h" /*** Came from JNI ********************************************************** ** Utility function that treats the passed value as an array of bytes, then ** formats and prints them in ASCII Hex format. This function will ** optionally insert spaces into the output string at specified intervals. ****************************************************************************/ void PrintHexString(void *Data, int Length, int Break) { int j; unsigned char *pc = (unsigned char *)Data; for (j=1; j<=Length; j++) { printf("%02X", (int)*pc++); if ( (Break != 0) && (!(j % Break))) { printf(" "); } } } /**** Came from JNI********************************************************** ** Utility function that formats and prints the World Wide Name. The WWN ** is assumed to be represented as a char (byte) array of length 8. ****************************************************************************/ void PrintWWN(unsigned char *pWwn) { PrintHexString(pWwn, 8, 0); } main() { int i, pi, j, dpi, ti, bi; HBA_STATUS retval; HBA_UINT32 hba_cnt; char namebuf[1028]; HBA_HANDLE hba_handle; HBA_ADAPTERATTRIBUTES hba_attrs; HBA_PORTATTRIBUTES hba_portattrs; HBA_PORTSTATISTICS hba_portstats; HBA_PORTATTRIBUTES hba_disc_pattrs; #define MAPENTRIES 512 union{ HBA_FCPTARGETMAPPING fcp_tmap; struct { HBA_UINT32 cnt; HBA_FCPSCSIENTRY entry[MAPENTRIES]; }fcp_tmapi; }MAPU; #define BINDENTRIES 512 union{ HBA_FCPBINDING fcp_tbind; struct { HBA_UINT32 cnt; HBA_FCPBINDINGENTRY entry[BINDENTRIES]; }fcp_tbindi; }BINDU; printf("HBA API Library version is %d\n", HBA_GetVersion()); retval = HBA_LoadLibrary(); if(retval != HBA_STATUS_OK) { perror("HBA_LoadLibrary"); exit(1); } hba_cnt = HBA_GetNumberOfAdapters(); printf("Number of HBA's is %d\n", hba_cnt); if(hba_cnt == 0) { fprintf(stderr, "not enough adapters\n"); exit(1); } for(i = 0; i < hba_cnt; i++) { if((retval = HBA_GetAdapterName(i, namebuf)) != HBA_STATUS_OK) { fprintf(stderr, "Failure of HBA_GetAdapterName: %d\n", retval); continue; } printf("\n********************************************" "\nAdapter number %d is named: %s\n", i, namebuf); if((hba_handle = HBA_OpenAdapter(namebuf)) == 0) { fprintf(stderr, "Failure of HBA_OpenAdapter\n"); perror("HBA_OpenAdapter"); continue; } if((retval = HBA_GetAdapterAttributes(hba_handle, &hba_attrs)) != HBA_STATUS_OK) { fprintf(stderr, "Failure of HBA_GetAdapterAttributes:%d\n", retval); goto close; } printf("Adapter Attributes\n"); printf(" Manufacturer:%s:\n", hba_attrs.Manufacturer); printf(" SerialNumber:%s:\n", hba_attrs.SerialNumber); printf(" Model:%s:\n", hba_attrs.Model); printf(" ModelDesc:%s:\n", hba_attrs.ModelDescription); printf(" NodeWWN:0x"); PrintWWN(hba_attrs.NodeWWN.wwn); printf("\n"); printf(" NodeSymName:%s:\n", hba_attrs.NodeSymbolicName); printf(" HardwareVersion:%s:\n", hba_attrs.HardwareVersion); printf(" DriverVersion:%s:\n", hba_attrs.DriverVersion); printf(" OptionROMVersion:%s:\n", hba_attrs.OptionROMVersion); printf(" FirmwareVersion:%s:\n", hba_attrs.FirmwareVersion); printf(" VendorSpecificID:%d:\n", hba_attrs.VendorSpecificID); printf(" NumberOfPorts:%d:\n", hba_attrs.NumberOfPorts); printf(" DriverName:%s:\n", hba_attrs.DriverName); for(pi = 0; pi < hba_attrs.NumberOfPorts; pi++) { retval = HBA_GetAdapterPortAttributes(hba_handle, pi, &hba_portattrs); if(retval != HBA_STATUS_OK) { fprintf(stderr, "Failure of HBA_GetAdapterPortAttributes for pi=%d," "status=%d\n", pi, retval); goto close; } printf(" PortIndex:%d\n", pi); printf(" Adapter Port Attributes\n"); printf(" NodeWWN:0x"); PrintWWN(hba_portattrs.NodeWWN.wwn); printf("\n"); printf(" PortWWN:0x"); PrintWWN(hba_portattrs.PortWWN.wwn); printf("\n"); printf(" PortFcId:0x%06lX\n", hba_portattrs.PortFcId); printf(" PortType:%d\n", hba_portattrs.PortType); printf(" PortState:%d\n", hba_portattrs.PortState); printf(" PortSupportedClassofService:%d\n", hba_portattrs.PortSupportedClassofService); printf(" PortSupportedFc4Types:"); for(j = 0; j < 32; j++) { printf(" %02X", hba_portattrs.PortSupportedFc4Types.bits[j]); } printf("\n"); printf(" PortActiveFc4Types:"); for(j = 0; j < 32; j++) { printf(" %02X", hba_portattrs.PortActiveFc4Types.bits[j]); } printf("\n"); printf(" PortSymbolicName:%s:\n", hba_portattrs.PortSymbolicName); printf(" OSDeviceName:%s:\n", hba_portattrs.OSDeviceName); printf(" PortSupportedSpeed:%d\n", hba_portattrs.PortSupportedSpeed); printf(" PortSpeed:%d\n", hba_portattrs.PortSpeed); printf(" PortMaxFrameSize:%d\n", hba_portattrs.PortMaxFrameSize); printf(" FabricName:0x"); PrintWWN(hba_portattrs.FabricName.wwn); printf("\n"); printf(" NumberofDiscoveredPorts:%d\n", hba_portattrs.NumberofDiscoveredPorts); retval = HBA_GetPortStatistics(hba_handle, pi, &hba_portstats); if(retval != HBA_STATUS_OK && retval != HBA_STATUS_ERROR_NOT_SUPPORTED) { fprintf(stderr, "Failure of HBA_GetPortStatistics for pi=%d," "status=%d\n", pi, retval); goto close; } printf(" Adapter Port Statistics:\n"); if(retval == HBA_STATUS_ERROR_NOT_SUPPORTED) { printf(" Port Statistics not supported by this HBA\n"); } else { printf(" SecondsSinceLastReset: %lld\n", hba_portstats.SecondsSinceLastReset); printf(" TxFrames: %lld\n", hba_portstats.TxFrames); printf(" TxWords: %lld\n", hba_portstats.TxWords); printf(" RxFrames: %lld\n", hba_portstats.RxFrames); printf(" RxWords: %lld\n", hba_portstats.RxWords); printf(" LIPCount: %lld\n", hba_portstats.LIPCount); printf(" NOSCount: %lld\n", hba_portstats.NOSCount); printf(" ErrorFrames: %lld\n", hba_portstats.ErrorFrames); printf(" DumpedFrames: %lld\n", hba_portstats.DumpedFrames); printf(" LinkFailureCount: %lld\n", hba_portstats.LinkFailureCount); printf(" LossOfSyncCount: %lld\n", hba_portstats.LossOfSyncCount); printf(" LossOfSignalCount: %lld\n", hba_portstats.LossOfSignalCount); printf(" PrimitiveSeqProtocolErrCount: %lld\n", hba_portstats.PrimitiveSeqProtocolErrCount); printf(" InvalidTxWordCount: %lld\n", hba_portstats.InvalidTxWordCount); printf(" InvalidCRCCount: %lld\n", hba_portstats.InvalidCRCCount); } for(dpi = 0; dpi < hba_portattrs.NumberofDiscoveredPorts; dpi++) { retval = HBA_GetDiscoveredPortAttributes(hba_handle, pi, dpi, &hba_disc_pattrs); if(retval != HBA_STATUS_OK) { fprintf(stderr, "Failure of HBA_GetDiscoveredPortAttributes\n" "for pi=%d, for dpi=%d, status=%d\n", pi, dpi, retval); goto close; } printf(" Discovered Port Attributes (index=%d)\n", dpi); printf(" NodeWWN:0x"); PrintWWN( hba_disc_pattrs.NodeWWN.wwn); printf("\n"); printf(" PortWWN:0x"); PrintWWN(hba_disc_pattrs.PortWWN.wwn); printf("\n"); printf(" PortFcId:0x%06lX\n", hba_disc_pattrs.PortFcId); printf(" PortType:%d\n", hba_disc_pattrs.PortType); printf(" PortState:%d\n", hba_disc_pattrs.PortState); printf(" PortSupportedClassofService:%d\n", hba_disc_pattrs.PortSupportedClassofService); printf(" PortSupportedFc4Types:"); for(j = 0; j < 32; j++) { printf(" %02X", hba_disc_pattrs.PortSupportedFc4Types.bits[j]); } printf("\n"); printf(" PortActiveFc4Types:"); for(j = 0; j < 32; j++) { printf(" %02X", hba_disc_pattrs.PortActiveFc4Types.bits[j]); } printf("\n"); printf(" PortSymbolicName:%s:\n", hba_disc_pattrs.PortSymbolicName); printf(" OSDeviceName:%s:\n", hba_disc_pattrs.OSDeviceName); printf(" PortSupportedSpeed:%d\n", hba_disc_pattrs.PortSupportedSpeed); printf(" PortSpeed:%d\n", hba_disc_pattrs.PortSpeed); printf(" PortMaxFrameSize:%d\n", hba_disc_pattrs.PortMaxFrameSize); printf(" FabricName:0x"); PrintWWN(hba_disc_pattrs.FabricName.wwn); printf("\n"); printf(" NumberofDiscoveredPorts:%d\n", hba_disc_pattrs.NumberofDiscoveredPorts); { char large_buf[1024]; char large_buf2[1024]; retval = HBA_SendReportLUNs(hba_handle, hba_disc_pattrs.PortWWN, large_buf, sizeof(large_buf), large_buf2, sizeof(large_buf2)); } } } MAPU.fcp_tmapi.cnt = MAPENTRIES; retval = HBA_GetFcpTargetMapping(hba_handle, &MAPU.fcp_tmap); if(retval != HBA_STATUS_OK) { fprintf(stderr, "failure of HBA_GetFcpTargetMapping, status=%d\n", retval); goto close; } printf("Target Mappings: %d\n", MAPU.fcp_tmap.NumberOfEntries); for(ti = 0; ti < MAPU.fcp_tmap.NumberOfEntries; ti++) { printf("scsiID:%s:c%ut%us%u\n", MAPU.fcp_tmap.entry[ti].ScsiId.OSDeviceName, MAPU.fcp_tmap.entry[ti].ScsiId.ScsiBusNumber, MAPU.fcp_tmap.entry[ti].ScsiId.ScsiTargetNumber, MAPU.fcp_tmap.entry[ti].ScsiId.ScsiOSLun); printf("FcpId: ID:%06x, NWWN:0x",MAPU.fcp_tmap.entry[ti].FcpId.FcId); PrintWWN(MAPU.fcp_tmap.entry[ti].FcpId.NodeWWN.wwn); printf(" PWWN:0x"); PrintWWN(MAPU.fcp_tmap.entry[ti].FcpId.PortWWN.wwn); printf(" FcpLun:0x%llX\n", MAPU.fcp_tmap.entry[ti].FcpId.FcpLun); printf("FcpId: ID:%06x, NWWN:0x",MAPU.fcp_tmap.entry[ti].FcpId.FcId); PrintWWN(MAPU.fcp_tmap.entry[ti].FcpId.NodeWWN.wwn); printf(" PWWN:0x"); PrintWWN(MAPU.fcp_tmap.entry[ti].FcpId.PortWWN.wwn); printf(" FcpLun:0x%llX\n\n", MAPU.fcp_tmap.entry[ti].FcpId.FcpLun); } BINDU.fcp_tbindi.cnt = BINDENTRIES; retval = HBA_GetFcpPersistentBinding(hba_handle, &BINDU.fcp_tbind); if(retval == HBA_STATUS_OK) { printf("Persistant Bindings: %d\n", BINDU.fcp_tbind.NumberOfEntries); for(bi = 0; bi < BINDU.fcp_tbind.NumberOfEntries; bi++) { printf("BindingType:%s\n", (BINDU.fcp_tbind.entry[bi].type == TO_D_ID)? "TO_D_ID" : "TO_WWN"); printf("scsiID:%s:c%ut%us%u\n", BINDU.fcp_tbind.entry[bi].ScsiId.OSDeviceName, BINDU.fcp_tbind.entry[bi].ScsiId.ScsiBusNumber, BINDU.fcp_tbind.entry[bi].ScsiId.ScsiTargetNumber, BINDU.fcp_tbind.entry[bi].ScsiId.ScsiOSLun); printf("FcpId: ID:%06x, NWWN:0x", BINDU.fcp_tbind.entry[bi].FcpId.FcId); PrintWWN(BINDU.fcp_tbind.entry[bi].FcpId.NodeWWN.wwn); printf(" PWWN:0x"); PrintWWN(BINDU.fcp_tbind.entry[bi].FcpId.PortWWN.wwn); printf(" FcpLun:0x%llX\n", BINDU.fcp_tbind.entry[bi].FcpId.FcpLun); printf("FcId:%d\n\n", BINDU.fcp_tbind.entry[bi].FcId); } } else if (retval == HBA_STATUS_ERROR_NOT_SUPPORTED) { printf("HBA_GetFcpPersistantBinding is not supported\n"); } else { fprintf(stderr, "failure of HBA_GetFcpPersistantBinding, status=%d\n", retval); goto close; } close: HBA_CloseAdapter(hba_handle); } } libhbaapi-2.2.9/hbasample.c000066400000000000000000000242741214751626200155560ustar00rootroot00000000000000/************************************************************************* * Description * hbasample.c - Implements a sample HBA API compliant vendor library * defining the entry points for the DLL application * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is SNIA HBA API Sample Vendor Specific Library * * The Initial Developer of the Original Code is: * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) * * Contributor(s): * Tuan Lam, QLogic Corp. (t_lam@qlc.com) * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com) * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) * ************************************************************************* */ #ifdef WIN32 #include #endif #include #include "hbaapi.h" #include "vendorhbaapi.h" #include "hbasample.h" /* Begin implementation */ #ifdef WIN32 BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } #endif /* * Two functions are exported. They both are used to register entry points. * Remember, this is a Rev2 Vendor specific library, but we might be * called by either a Rev2 or a Rev1. The Rev1 callers will call * HBA_RegisterLibrary. The Rev2 callers SHOULD call HBA_RegisterLibaryV2. * The size of the structure referenced in the Rev2 call is larger then in * the Rev1 call and the Rev1 sturcture is duplicated at the beginning of the * Rev2 structure */ /* * Rev1 Code will call this function and only get the Rev1 registration. * This prevents overrunning the data structure. */ HBASAMPLE_API HBA_STATUS HBA_RegisterLibrary(HBA_ENTRYPOINTS *entrypoints ) { entrypoints->GetVersionHandler = Sample_GetVersion; entrypoints->LoadLibraryHandler = Sample_LoadLibrary; entrypoints->FreeLibraryHandler = Sample_FreeLibrary; entrypoints->GetNumberOfAdaptersHandler = Sample_GetNumberOfAdapters; entrypoints->GetAdapterNameHandler = Sample_GetAdapterName; entrypoints->OpenAdapterHandler = Sample_OpenAdapter; entrypoints->OpenAdapterByWWNHandler = Sample_OpenAdapterByWWN; entrypoints->CloseAdapterHandler = Sample_CloseAdapter; entrypoints->GetAdapterAttributesHandler = Sample_GetAdapterAttributes; entrypoints->GetAdapterPortAttributesHandler = Sample_GetAdapterPortAttributes; entrypoints->GetPortStatisticsHandler = Sample_GetPortStatistics; entrypoints->GetDiscoveredPortAttributesHandler = Sample_GetDiscoveredPortAttributes; entrypoints->GetPortAttributesByWWNHandler = Sample_GetPortAttributesByWWN; entrypoints->RefreshInformationHandler = Sample_RefreshInformation; entrypoints->RegisterForAdapterEventsHandler = Sample_RegisterForAdapterEvents; /* There are a lot more entry points to register, however this is just * busy work. You get the idea. */ return 0; } /* * Here is were Rev2 callers will try first (all done by the wrapper library), * If the machine has not Rev2 vendor library, then obviosly, this function * will not be found. */ HBASAMPLE_API HBA_STATUS HBA_RegisterLibraryV2(HBA_ENTRYPOINTSV2 *entrypoints) { /* have the old function do the Rev1 part */ (void) HBA_RegisterLibrary((HBA_ENTRYPOINTS *)entrypoints); entrypoints->SendCTPassThruV2Handler = Sample_SendCTPassThruV2; /* so on and so forth */ return 0 } void Sample_RemoveCallback() { } HBA_STATUS Sample_LoadLibrary() { /* Vendor specific intialization ...*/ return HBA_STATUS_OK; } HBA_STATUS Sample_FreeLibrary() { /* Free up all resources any call to this library allocated */ return HBA_STATUS_OK; } HBA_UINT32 Sample_GetVersion() { return HBA_LIBVERSION; } HBA_UINT32 Sample_GetNumberOfAdapters() { return 1; } HBA_STATUS Sample_GetAdapterName(HBA_UINT32 adapterindex, char *adaptername) { if (adapterindex > 1) { return HBA_STATUS_ERROR_ILLEGAL_INDEX; } else { strcpy(adaptername, "org.snia.sample-1"); return HBA_STATUS_OK; } } HBA_HANDLE Sample_OpenAdapter(char* adaptername ){ /* * WARNING WARNING, Danger Will Robinson, * The wrapper library will mask the return of this function to * the lower 16 bits. Think of this function as returning * UINT16 */ HBA_HANDLE temp; temp = 0; if (strcmp(adaptername, "sample-adapter-1") == 0) { } return temp; } HBA_STATUS Sample_OpenAdapterByWWN(HBA_HANDLE handle, HBA_WWN wwn){ /* * WARNING WARNING, Danger Will Robinson, * The wrapper library will mask the handle of this function to * the lower 16 bits. Think of this HBA_HANDLE as UINT16 */ HBA_HANDLE temp; HBA_WWN twwn = {1,2,3,4,5,6,7,8}; if (memcmp(wwn, twwn) == 0) { return HBA_STATUS_OK; } return HBA_STATUS_ERROR_ILLEGAL_WWN; } void Sample_CloseAdapter( HBA_HANDLE handle ) { } HBA_STATUS Sample_GetAdapterAttributes( HBA_HANDLE handle, PHBA_ADAPTERATTRIBUTES hbaattributes ) { strcpy(hbaattributes->Manufacturer, "Emulex"); strcpy(hbaattributes->SerialNumber, "A12345"); strcpy(hbaattributes->Model, "QLA2200"); strcpy(hbaattributes->ModelDescription, "Agilent TachLite"); hbaattributes->NodeWWN.wwn[0] = 0x01; hbaattributes->NodeWWN.wwn[1] = 0x02; hbaattributes->NodeWWN.wwn[2] = 0x03; hbaattributes->NodeWWN.wwn[3] = 0x04; hbaattributes->NodeWWN.wwn[4] = 0x05; hbaattributes->NodeWWN.wwn[5] = 0x06; hbaattributes->NodeWWN.wwn[6] = 0x07; hbaattributes->NodeWWN.wwn[7] = 0x08; strcpy(hbaattributes->NodeSymbolicName, "HBA API Sample Driver"); strcpy(hbaattributes->HardwareVersion, "Hardware Version"); strcpy(hbaattributes->DriverVersion, "Driver Version"); strcpy(hbaattributes->OptionROMVersion, "Option ROM Version"); strcpy(hbaattributes->FirmwareVersion, "Firmware Version"); hbaattributes->VendorSpecificID = 0; hbaattributes->NumberOfPorts = 1; return HBA_STATUS_OK; } HBA_STATUS Sample_GetAdapterPortAttributes( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTATTRIBUTES *portattributes ) { if (portindex == 1) { /* WWN corresponding to 0001020304050708 */ portattributes->NodeWWN.wwn[0] = 0x01; portattributes->NodeWWN.wwn[1] = 0x02; portattributes->NodeWWN.wwn[2] = 0x03; portattributes->NodeWWN.wwn[3] = 0x04; portattributes->NodeWWN.wwn[4] = 0x05; portattributes->NodeWWN.wwn[5] = 0x06; portattributes->NodeWWN.wwn[6] = 0x07; portattributes->NodeWWN.wwn[7] = 0x08; portattributes->PortWWN.wwn[0] = 0x01; portattributes->PortWWN.wwn[1] = 0x02; portattributes->PortWWN.wwn[2] = 0x03; portattributes->PortWWN.wwn[3] = 0x04; portattributes->PortWWN.wwn[4] = 0x05; portattributes->PortWWN.wwn[5] = 0x06; portattributes->PortWWN.wwn[6] = 0x07; portattributes->PortWWN.wwn[7] = 0x08; portattributes->PortFcId = 0x00; portattributes->PortType = HBA_PORTTYPE_UNKNOWN; portattributes->PortState = HBA_PORTSTATE_ONLINE; portattributes->PortSupportedClassofService = 0x00; portattributes->PortSupportedFc4Types.bits[0] = 0x00; portattributes->PortActiveFc4Types.bits[0] = 0x00; strcpy(portattributes->OSDeviceName, "DeviceName"); portattributes->PortSpeed = HBA_PORTSPEED_1GBIT; portattributes->NumberofDiscoveredPorts = 0; return HBA_STATUS_OK; } else { return HBA_STATUS_ERROR_ILLEGAL_INDEX; } } HBA_STATUS Sample_GetPortStatistics( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTSTATISTICS *portstatistics ) { portstatistics->TxFrames = 0; portstatistics->RxFrames = 0; portstatistics->TxWords = 0; portstatistics->RxWords = 0; portstatistics->LIPCount = 0; portstatistics->NOSCount = 0; portstatistics->ErrorFrames = 0; portstatistics->DumpedFrames = 0; portstatistics->LinkFailureCount = 0; portstatistics->LossOfSyncCount = 0; portstatistics->LossOfSignalCount = 0; portstatistics->PrimitiveSeqProtocolErrCount = 0; portstatistics->InvalidTxWordCount = 0; portstatistics->InvalidCRCCount = 0; return HBA_STATUS_OK; } HBA_STATUS Sample_GetDiscoveredPortAttributes( HBA_HANDLE handle, HBA_UINT32 portindex, HBA_UINT32 discoveredportindex, HBA_PORTATTRIBUTES *portattributes ) { /* since this is a virtual driver with no discovered ports always return an error */ return HBA_STATUS_ERROR_ILLEGAL_INDEX; } HBA_STATUS Sample_GetPortAttributesByWWN( HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTATTRIBUTES *portattributes ) { return HBA_STATUS_ERROR_NOT_SUPPORTED; } void Sample_RefreshInformation(HBA_HANDLE handle) { } static void *eventhandlerdata; HBA_STATUS Sample_RegisterForAdapterEvents( (void (*callback)( void *data, HBA_WWN PortWWN, HBA_UINT32 eventType), void *userData, HBA_HANDLE handle, HBA_CALLBACKHANDLE *callbackHandle) { ptr = calloc(); ptr->userdata = userData; ptr->callbackfunc = callback; /* store away a pointer to this data, * the low level event handler (event below) * will magically find this data when the * event is delivery is necessary */ eventhandlerdata = ptr; /* give the caller something to remember this registion by */ /* this can be used later to deregister the call back */ *callbackHandle = ptr; } void event() { HBA_UINT64 port = 0x12345678; HBA_WWN PortWWN; ptr = eventhandlerdata; memcpy(&PortWWN, &port, 8); (*ptr->callvackfunc)(ptr->userdata, PortWWN, HBA_EVENT_ADAPTER_CHANGE); } /* * REV 2 functions */ HBA_STATUS Sample_HBAOpenAdapterByWWN(HBA_HANDLE *phandle, HBA_WWN wwn) { /* find out if it is a WWN to one of our hba's */ /* if it is, open it */ if(1 == 2) { *phandle = "123"; return(HBA_STATUS_OK); } else { return(HBA_STATUS_ERROR_ILLEGAL_WWN); } } HBA_STATUS Sample_HBA_GetFcpTargetMapping( HBA_HANDLE handle, HBA_FCPTARGETMAPPING *pmapping ) { } libhbaapi-2.2.9/hbasample.h000066400000000000000000000022621214751626200155540ustar00rootroot00000000000000/* * Description * hbasample.h - Header file for sample HBA API compliant vendor library * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is Header file for * SNIA HBA API Sample Vendor Specific Library * * The Initial Developer of the Original Code is: * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) * * Contributor(s): * *************************************************************************** */ #ifdef WIN32 #ifdef HBASAMPLE_EXPORTS #define HBASAMPLE_API __declspec(dllexport) #else #define HBASAMPLE_API __declspec(dllimport) #endif #else #define HBASAMPLE_API #endif HBASAMPLE_API HBA_STATUS HBA_RegisterLibrary( PHBA_ENTRYPOINTS entrypoints ); libhbaapi-2.2.9/libHBAAPI.spec000066400000000000000000000026231214751626200157370ustar00rootroot00000000000000Name: libHBAAPI Version: 2.2 Release: 1%{?dist} Summary: SNIA HBAAPI library Group: System Environment/Libraries License: SNIA URL: http://www.sourceforge.net/projects/hbaapi Source0: hbaapi_src_2.2.tgz Source1: hbaapi_build_2.2.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # BuildRequires: # Requires: %description The SNIA HBA API library %package devel Summary: Development files for %{name} Group: Development/Libraries Requires: %{name} = %{version}-%{release} pkgconfig %description devel The %{name}-devel package contains libraries and header files for developing applications that use %{name}. %prep %setup -q -n hbaapi_src_2.2 %setup -q -T -D -a 1 -n hbaapi_src_2.2 %build %configure --disable-static make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' %clean rm -rf $RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %doc readme.txt %config(noreplace) %{_sysconfdir}/hba.conf %{_libdir}/*.so.* %files devel %defattr(-,root,root,-) %{_includedir}/* %{_libdir}/*.so %{_libdir}/pkgconfig/*.pc %changelog * Tue Feb 24 2009 Chris Leech - 2.2-1 - initial packaging of hbaapi 2.2 libhbaapi-2.2.9/vendorhbaapi.h000066400000000000000000000314131214751626200162620ustar00rootroot00000000000000/****************************************************************************** * * Description * vendorhbaapi.h - incombination with hbaapi.h, defines interface to * vendor specific API * * License: * The contents of this file are subject to the SNIA Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * * /http://www.snia.org/English/Resources/Code/OpenSource.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is SNIA HBA API general header file * * The Initial Developer of the Original Code is: * Benjamin F. Kuo, Troika Networks, Inc. (benk@troikanetworks.com) * * Contributor(s): * Tuan Lam, QLogic Corp. (t_lam@qlc.com) * Dan Willie, Emulex Corp. (Dan.Willie@emulex.com) * Dixon Hutchinson, Legato Systems, Inc. (dhutchin@legato.com) * David Dillard, VERITAS Software Corp. (david.dillard@veritas.com) * ******************************************************************************* * * Changes: * 12/12/2001 Original revision, code split out of hbaapi.h * (for other changes... see the CVS logs) ******************************************************************************/ #ifdef __cplusplus extern "C" { #endif #ifndef VENDOR_HBA_API_H #define VENDOR_HBA_API_H /* 6.10.1 HBA Library Function Table */ typedef HBA_UINT32 (* HBAGetVersionFunc)(); typedef HBA_STATUS (* HBALoadLibraryFunc)(); typedef HBA_STATUS (* HBAFreeLibraryFunc)(); typedef HBA_UINT32 (* HBAGetNumberOfAdaptersFunc)(); typedef HBA_STATUS (* HBAGetAdapterNameFunc)(HBA_UINT32, char *); /* * Open Adapter.... the vendor function is limmited to 16 bits, * the wrapper library will mask off the upper 16. * Maybe typedef should be: * typedef HBA_UINT16 (* HBAOpenAdapterFunc)(char *); */ typedef HBA_HANDLE (* HBAOpenAdapterFunc)(char *); typedef HBA_STATUS (* HBAOpenAdapterByWWNFunc) (HBA_HANDLE *, HBA_WWN); typedef void (* HBACloseAdapterFunc)(HBA_HANDLE); typedef HBA_STATUS (* HBAGetAdapterAttributesFunc) (HBA_HANDLE, HBA_ADAPTERATTRIBUTES *); typedef HBA_STATUS (* HBAGetAdapterPortAttributesFunc) (HBA_HANDLE, HBA_UINT32, HBA_PORTATTRIBUTES *); typedef HBA_STATUS (* HBAGetPortStatisticsFunc) (HBA_HANDLE, HBA_UINT32, HBA_PORTSTATISTICS *); typedef HBA_STATUS (* HBAGetDiscoveredPortAttributesFunc) (HBA_HANDLE, HBA_UINT32, HBA_UINT32, HBA_PORTATTRIBUTES *); typedef HBA_STATUS (* HBAGetPortAttributesByWWNFunc) (HBA_HANDLE, HBA_WWN, HBA_PORTATTRIBUTES *); typedef HBA_STATUS (* HBASendCTPassThruV2Func) (HBA_HANDLE, HBA_WWN, void *, HBA_UINT32, void *, HBA_UINT32 *); typedef void (* HBARefreshInformationFunc)(HBA_HANDLE); typedef void (* HBARefreshAdapterConfigurationFunc) (); typedef void (* HBAResetStatisticsFunc)(HBA_HANDLE, HBA_UINT32); typedef HBA_STATUS (* HBAGetFcpTargetMappingV2Func) (HBA_HANDLE, HBA_WWN, HBA_FCPTARGETMAPPINGV2 *); typedef HBA_STATUS (* HBAGetBindingCapabilityFunc) (HBA_HANDLE, HBA_WWN, HBA_BIND_CAPABILITY *); typedef HBA_STATUS (* HBAGetBindingSupportFunc) (HBA_HANDLE, HBA_WWN, HBA_BIND_CAPABILITY *); typedef HBA_STATUS (* HBASetBindingSupportFunc) (HBA_HANDLE, HBA_WWN, HBA_BIND_CAPABILITY); typedef HBA_STATUS (* HBASetPersistentBindingV2Func) (HBA_HANDLE, HBA_WWN, const HBA_FCPBINDING2 *); typedef HBA_STATUS (* HBAGetPersistentBindingV2Func) (HBA_HANDLE, HBA_WWN, HBA_FCPBINDING2 *); typedef HBA_STATUS (* HBARemovePersistentBindingFunc) (HBA_HANDLE, HBA_WWN, const HBA_FCPBINDING2 *); typedef HBA_STATUS (* HBARemoveAllPersistentBindingsFunc) (HBA_HANDLE, HBA_WWN); typedef HBA_STATUS (* HBAGetEventBufferFunc) (HBA_HANDLE, HBA_EVENTINFO *, HBA_UINT32 *); typedef HBA_STATUS (* HBASetRNIDMgmtInfoFunc) (HBA_HANDLE, HBA_MGMTINFO *); typedef HBA_STATUS (* HBAGetRNIDMgmtInfoFunc) (HBA_HANDLE, HBA_MGMTINFO *); typedef HBA_STATUS (* HBASendRNIDV2Func) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT32, HBA_UINT32, void *, HBA_UINT32*); typedef HBA_STATUS (* HBAScsiInquiryV2Func) (HBA_HANDLE,HBA_WWN,HBA_WWN, HBA_UINT64, HBA_UINT8, HBA_UINT8, void *, HBA_UINT32 *, HBA_UINT8 *, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBAScsiReportLUNsV2Func) (HBA_HANDLE, HBA_WWN, HBA_WWN, void *, HBA_UINT32 *, HBA_UINT8 *, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBAScsiReadCapacityV2Func) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT64, void *, HBA_UINT32 *, HBA_UINT8 *, void *, HBA_UINT32 *); typedef HBA_UINT32 (* HBAGetVendorLibraryAttributesFunc) (HBA_LIBRARYATTRIBUTES *); typedef HBA_STATUS (* HBARemoveCallbackFunc) (HBA_CALLBACKHANDLE); typedef HBA_STATUS (* HBARegisterForAdapterAddEventsFunc) (void (*)(void *, HBA_WWN, HBA_UINT32), void *, HBA_CALLBACKHANDLE *); typedef HBA_STATUS (* HBARegisterForAdapterEventsFunc) (void (*)(void *, HBA_WWN, HBA_UINT32), void *, HBA_HANDLE, HBA_CALLBACKHANDLE *); typedef HBA_STATUS (* HBARegisterForAdapterPortEventsFunc) (void (*)(void *, HBA_WWN, HBA_UINT32, HBA_UINT32), void *, HBA_HANDLE, HBA_WWN, HBA_CALLBACKHANDLE *); typedef HBA_STATUS (* HBARegisterForAdapterPortStatEventsFunc) (void (*)(void *, HBA_WWN, HBA_UINT32), void *, HBA_HANDLE, HBA_WWN, HBA_PORTSTATISTICS, HBA_UINT32, HBA_CALLBACKHANDLE *); typedef HBA_STATUS (* HBARegisterForTargetEventsFunc) (void (*)(void *, HBA_WWN, HBA_WWN, HBA_UINT32), void *, HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_CALLBACKHANDLE *, HBA_UINT32 ); typedef HBA_STATUS (* HBARegisterForLinkEventsFunc) (void (*)(void *, HBA_WWN, HBA_UINT32, void *, HBA_UINT32), void *, void *, HBA_UINT32, HBA_HANDLE, HBA_CALLBACKHANDLE *); typedef HBA_STATUS (* HBASendRPLFunc) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT32, HBA_UINT32, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBASendRPSFunc) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT32, HBA_WWN, HBA_UINT32, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBASendSRLFunc) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT32, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBASendLIRRFunc) (HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT8, HBA_UINT8, void *, HBA_UINT32 *); typedef HBA_STATUS (* HBAGetFC4StatisticsFunc) (HBA_HANDLE, HBA_WWN, HBA_UINT8, HBA_FC4STATISTICS *); typedef HBA_STATUS (* HBAGetFCPStatisticsFunc) (HBA_HANDLE, const HBA_SCSIID *, HBA_FC4STATISTICS *); typedef HBA_STATUS (* HBASendRLSFunc) (HBA_HANDLE, HBA_WWN, HBA_WWN, void *, HBA_UINT32 *); /* Deprecated, but still supported functions */ typedef HBA_STATUS (* HBAGetFcpTargetMappingFunc) (HBA_HANDLE, HBA_FCPTARGETMAPPING *); typedef HBA_STATUS (* HBAGetFcpPersistentBindingFunc) (HBA_HANDLE, HBA_FCPBINDING *); typedef HBA_STATUS (* HBASendCTPassThruFunc) (HBA_HANDLE, void *, HBA_UINT32, void *, HBA_UINT32); typedef HBA_STATUS (* HBASendScsiInquiryFunc) (HBA_HANDLE, HBA_WWN,HBA_UINT64, HBA_UINT8, HBA_UINT32, void *, HBA_UINT32, void *, HBA_UINT32); typedef HBA_STATUS (* HBASendReportLUNsFunc) (HBA_HANDLE, HBA_WWN, void *, HBA_UINT32, void *, HBA_UINT32); typedef HBA_STATUS (* HBASendReadCapacityFunc) (HBA_HANDLE, HBA_WWN, HBA_UINT64, void *, HBA_UINT32, void *, HBA_UINT32); typedef HBA_STATUS (* HBASendRNIDFunc) (HBA_HANDLE, HBA_WWN, HBA_WWNTYPE, void *, HBA_UINT32 *); /* * This structure is needed since a Rev2 vendor library must still implement the * Rev1 Register function in case it is called by a Rev1 wapper library. Still * not STRICTLY neccesary, it provides clarity and keeps compilers happier */ typedef struct HBA_EntryPoints { HBAGetVersionFunc GetVersionHandler; HBALoadLibraryFunc LoadLibraryHandler; HBAFreeLibraryFunc FreeLibraryHandler; HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersHandler; HBAGetAdapterNameFunc GetAdapterNameHandler; HBAOpenAdapterFunc OpenAdapterHandler; HBACloseAdapterFunc CloseAdapterHandler; HBAGetAdapterAttributesFunc GetAdapterAttributesHandler; HBAGetAdapterPortAttributesFunc GetAdapterPortAttributesHandler; HBAGetPortStatisticsFunc GetPortStatisticsHandler; HBAGetDiscoveredPortAttributesFunc GetDiscoveredPortAttributesHandler; HBAGetPortAttributesByWWNFunc GetPortAttributesByWWNHandler; HBASendCTPassThruFunc SendCTPassThruHandler; HBARefreshInformationFunc RefreshInformationHandler; HBAResetStatisticsFunc ResetStatisticsHandler; HBAGetFcpTargetMappingFunc GetFcpTargetMappingHandler; HBAGetFcpPersistentBindingFunc GetFcpPersistentBindingHandler; HBAGetEventBufferFunc GetEventBufferHandler; HBASetRNIDMgmtInfoFunc SetRNIDMgmtInfoHandler; HBAGetRNIDMgmtInfoFunc GetRNIDMgmtInfoHandler; HBASendRNIDFunc SendRNIDHandler; HBASendScsiInquiryFunc ScsiInquiryHandler; HBASendReportLUNsFunc ReportLUNsHandler; HBASendReadCapacityFunc ReadCapacityHandler; } HBA_ENTRYPOINTS, *PHBA_ENTRYPOINTS; typedef struct HBA_EntryPointsV2 { /* These first elements MUST MUST MUST match HBA_ENTRYPOINTS */ HBAGetVersionFunc GetVersionHandler; HBALoadLibraryFunc LoadLibraryHandler; HBAFreeLibraryFunc FreeLibraryHandler; HBAGetNumberOfAdaptersFunc GetNumberOfAdaptersHandler; HBAGetAdapterNameFunc GetAdapterNameHandler; HBAOpenAdapterFunc OpenAdapterHandler; HBACloseAdapterFunc CloseAdapterHandler; HBAGetAdapterAttributesFunc GetAdapterAttributesHandler; HBAGetAdapterPortAttributesFunc GetAdapterPortAttributesHandler; HBAGetPortStatisticsFunc GetPortStatisticsHandler; HBAGetDiscoveredPortAttributesFunc GetDiscoveredPortAttributesHandler; HBAGetPortAttributesByWWNFunc GetPortAttributesByWWNHandler; /* Next function depricated but still supported */ HBASendCTPassThruFunc SendCTPassThruHandler; HBARefreshInformationFunc RefreshInformationHandler; HBAResetStatisticsFunc ResetStatisticsHandler; /* Next function depricated but still supported */ HBAGetFcpTargetMappingFunc GetFcpTargetMappingHandler; /* Next function depricated but still supported */ HBAGetFcpPersistentBindingFunc GetFcpPersistentBindingHandler; HBAGetEventBufferFunc GetEventBufferHandler; HBASetRNIDMgmtInfoFunc SetRNIDMgmtInfoHandler; HBAGetRNIDMgmtInfoFunc GetRNIDMgmtInfoHandler; /* Next function depricated but still supported */ HBASendRNIDFunc SendRNIDHandler; /* Next function depricated but still supported */ HBASendScsiInquiryFunc ScsiInquiryHandler; /* Next function depricated but still supported */ HBASendReportLUNsFunc ReportLUNsHandler; /* Next function depricated but still supported */ HBASendReadCapacityFunc ReadCapacityHandler; /* Rev 2 Functions */ HBAOpenAdapterByWWNFunc OpenAdapterByWWNHandler; HBAGetFcpTargetMappingV2Func GetFcpTargetMappingV2Handler; HBASendCTPassThruV2Func SendCTPassThruV2Handler; HBARefreshAdapterConfigurationFunc RefreshAdapterConfigurationHandler; HBAGetBindingCapabilityFunc GetBindingCapabilityHandler; HBAGetBindingSupportFunc GetBindingSupportHandler; HBASetBindingSupportFunc SetBindingSupportHandler; HBASetPersistentBindingV2Func SetPersistentBindingV2Handler; HBAGetPersistentBindingV2Func GetPersistentBindingV2Handler; HBARemovePersistentBindingFunc RemovePersistentBindingHandler; HBARemoveAllPersistentBindingsFunc RemoveAllPersistentBindingsHandler; HBASendRNIDV2Func SendRNIDV2Handler; HBAScsiInquiryV2Func ScsiInquiryV2Handler; HBAScsiReportLUNsV2Func ScsiReportLUNsV2Handler; HBAScsiReadCapacityV2Func ScsiReadCapacityV2Handler; HBAGetVendorLibraryAttributesFunc GetVendorLibraryAttributesHandler; HBARemoveCallbackFunc RemoveCallbackHandler; HBARegisterForAdapterAddEventsFunc RegisterForAdapterAddEventsHandler; HBARegisterForAdapterEventsFunc RegisterForAdapterEventsHandler; HBARegisterForAdapterPortEventsFunc RegisterForAdapterPortEventsHandler; HBARegisterForAdapterPortStatEventsFunc RegisterForAdapterPortStatEventsHandler; HBARegisterForTargetEventsFunc RegisterForTargetEventsHandler; HBARegisterForLinkEventsFunc RegisterForLinkEventsHandler; HBASendRPLFunc SendRPLHandler; HBASendRPSFunc SendRPSHandler; HBASendSRLFunc SendSRLHandler; HBASendLIRRFunc SendLIRRHandler; HBAGetFC4StatisticsFunc GetFC4StatisticsHandler; HBAGetFCPStatisticsFunc GetFCPStatisticsHandler; HBASendRLSFunc SendRLSHandler; } HBA_ENTRYPOINTSV2, *PHBA_ENTRYPOINTSV2; typedef HBA_STATUS (* HBARegisterLibraryFunc)(HBA_ENTRYPOINTS *); typedef HBA_STATUS (* HBARegisterLibraryV2Func)(HBA_ENTRYPOINTSV2 *); /* Function Prototypes */ HBA_API HBA_STATUS HBA_RegisterLibrary( HBA_ENTRYPOINTS *functionTable ); HBA_API HBA_STATUS HBA_RegisterLibraryV2( HBA_ENTRYPOINTSV2 *functionTable ); #endif /* VENDOR_HBA_API_H */ #ifdef __cplusplus } #endif