vlib.c File Reference

Implementations of most HBA API functions (all except event handling functions). More...

`#include "vlib.h"`

## Functions

static HBA_UINT32 | _GetVendorLibraryAttributes (HBA_LIBRARYATTRIBUTES *)
| Internal function to report the attributes of the libary.
HBA_UINT32 | HBA_GetVersion (void)
| Return the version of the HBA API specification with which this library is compliant.
void | _initvlib (void)
| Initialization function of this library.
void | _finivlib (void)
| Finalization function of this library.
HBA_STATUS | HBA_LoadLibrary (void)
| Perform initialization of library.
HBA_STATUS | HBA_FreeLibrary (void)
| Free system resources that library has used.
HBA_UINT32 | HBA_GetWrapperLibraryAttributes (HBA_LIBRARYATTRIBUTES *attributes)
| Return attributes of the OS specific HBA API library.
HBA_UINT32 | HBA_GetVendorLibraryAttributes (HBA_UINT32 adapter_index, HBA_LIBRARYATTRIBUTES *attributes)
| Return attributes of the vendor specific HBA API library.
HBA_UINT32 | HBA_GetNumberOfAdapters (void)
| Return number of adapters.
void | HBA_RefreshInformation (HBA_HANDLE handle)
| Refresh information of an adapter.
void | HBA_RefreshAdapterConfiguration (void)
| Refresh information about configured adapters.
void | HBA_ResetStatistics (HBA_HANDLE handle, HBA_UINT32 portindex)
| According to FC-HBA this function is obsolete.
HBA_STATUS | HBA_GetAdapterName (HBA_UINT32 adapterindex, char *pAdaptername)
| Return name that identifies an adapter.
HBA_HANDLE | HBA_OpenAdapter (char *pAdaptername)
| Open an adapter.
HBA_STATUS | HBA_OpenAdapterByWWN (HBA_HANDLE *pHandle, HBA_WWN wwn)
void | HBA_CloseAdapter (HBA_HANDLE handle)
| Close an open adapter.
HBA_STATUS | HBA_GetAdapterAttributes (HBA_HANDLE handle, HBA_ADAPTERATTRIBUTES *pAdapterattributes)
| Return attributes for an adapter.
HBA_STATUS | HBA_GetAdapterPortAttributes (HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTATTRIBUTES *pPortattributes)
| Return attributes for an adapter port.
HBA_STATUS | HBA_GetDiscoveredPortAttributes (HBA_HANDLE handle, HBA_UINT32 portindex, HBA_UINT32 discoveredportindex, HBA_PORTATTRIBUTES *pPortattributes)
| Return attributes of an discovered port.
HBA_STATUS | HBA_GetPortAttributesByWWN (HBA_HANDLE handle, HBA_WWN PortWWN, HBA_PORTATTRIBUTES *pPortattributes)
HBA_STATUS | HBA_GetPortStatistics (HBA_HANDLE handle, HBA_UINT32 portindex, HBA_PORTSTATISTICS *pPortstatistics)
| Return statistics of an adapter port.
HBA_STATUS | HBA_GetFC4Statistics (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_UINT8 FC4type, HBA_FC4STATISTICS *statistics)
HBA_STATUS | HBA_GetBindingCapability (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pFlags)
HBA_STATUS | HBA_GetBindingSupport (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY *pFlags)
HBA_STATUS | HBA_SetBindingSupport (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_BIND_CAPABILITY flags)
HBA_STATUS | HBA_GetFcpTargetMapping (HBA_HANDLE handle, HBA_FCPTARGETMAPPING *pMapping)
| Retrieve mappings between OS SCSI targets/units and FCP targets/units.
HBA_STATUS | HBA_GetFcpTargetMappingV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPTARGETMAPPINGV2 *pMappingV2)
| Retrieve mappings between OS SCSI targets/units and FCP targets/units.
HBA_STATUS | HBA_GetFcpPersistentBinding (HBA_HANDLE handle, HBA_FCPBINDING *pBinding)
HBA_STATUS | HBA_GetPersistentBindingV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPBINDING2 *binding)
HBA_STATUS | HBA_SetPersistentBindingV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPBINDING2 *binding)
HBA_STATUS | HBA_RemovePersistentBinding (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_FCPBINDING2 *binding)
HBA_STATUS | HBA_RemoveAllPersistentBindings (HBA_HANDLE handle, HBA_WWN hbaPortWWN)
HBA_STATUS | HBA_GetFCPStatistics (HBA_HANDLE handle, const HBA_SCSIID *lunit, HBA_FC4STATISTICS *statistics)
static 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 | 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)
| Send a SCSI INQUIRY command to a FCP LUN.
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)
| Send a SCSI INQUIRY command to a FCP LUN.
static HBA_STATUS | _HBA_SendReportLUNs (HBA_HANDLE handle, HBA_WWN portWWN, void *pRspBuffer, HBA_UINT32 *RspBufferSize, void *pSenseBuffer, HBA_UINT32 *SenseBufferSize)
HBA_STATUS | HBA_SendReportLUNs (HBA_HANDLE handle, HBA_WWN portWWN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize)
| Send a SCSI REPORT LUNS command to a target.
HBA_STATUS | HBA_ScsiReportLUNsV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN discoveredPortWWN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize, HBA_UINT8 *pScsiStatus, void *pSenseBuffer, HBA_UINT32 *pSenseBufferSize)
| Send a SCSI REPORT LUNS command to a target.
static 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 | HBA_SendReadCapacity (HBA_HANDLE handle, HBA_WWN portWWN, HBA_UINT64 fcLUN, void *pRspBuffer, HBA_UINT32 RspBufferSize, void *pSenseBuffer, HBA_UINT32 SenseBufferSize)
| Send a SCSI READ CAPACITY command to a FCP LUN.
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 *pSenseBufferSize)
| Send a SCSI READ CAPACITY command to a FCP LUN.
HBA_STATUS | HBA_SendCTPassThru (HBA_HANDLE handle, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 RspBufferSize)
| Send a CT pass thru - a CT frame constructed in userspace directly to the HBA / SAN.
HBA_STATUS | HBA_SendCTPassThruV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
| Send a CT pass thru - a CT frame constructed in userspace directly to the HBA / SAN.
HBA_STATUS | HBA_SetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *info)
HBA_STATUS | HBA_GetRNIDMgmtInfo (HBA_HANDLE handle, HBA_MGMTINFO *pInfo)
HBA_STATUS | HBA_SendRNID (HBA_HANDLE handle, HBA_WWN wwn, HBA_WWNTYPE wwntype, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
| Send a RNID ELS to a port.
HBA_STATUS | HBA_SendRNIDV2 (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, HBA_UINT32 destFCID, HBA_UINT32 NodeIdDataFormat, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
| Send a RNID ELS to a port.
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 | 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 | HBA_SendSRL (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN wwn, HBA_UINT32 domain, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
HBA_STATUS | HBA_SendLIRR (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, HBA_UINT8 function, HBA_UINT8 type, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
HBA_STATUS | HBA_SendRLS (HBA_HANDLE handle, HBA_WWN hbaPortWWN, HBA_WWN destWWN, void *pRspBuffer, HBA_UINT32 *pRspBufferSize)
HBA_STATUS | HBA_GetEventBuffer (HBA_HANDLE handle, HBA_EVENTINFO *pEventBuffer, HBA_UINT32 *pEventCount)
| Return events for an adapter from the event queue.

## Variables

struct vlib_data | vlib_data
| Global variable that holds almost all information needed in the library.

## Detailed Description

Implementations of most HBA API functions (all except event handling functions).

Note
  We only include vlib.h which in turn should include all other necessary header files.

This file contains the implementations of most HBA API library functions. Implementations of event handling HBA API routines can be found in files vlib_events.c and vlib_callbacks.c.

See also
  vlib_events.c vlib_callbacks.c

## Function Documentation

## _GetVendorLibraryAttributes()

static HBA_UINT32 _GetVendorLibraryAttributes | ( | HBA_LIBRARYATTRIBUTES * | attributes | ) |

static

Internal function to report the attributes of the libary.

Parameters

  attributes | used to return library attributes

Returns
  - 2 (compliant to FC-HBA)

References HBAAPI_LIBRARY_FINAL, HBAAPI_LIBRARY_REVISION, and HBAAPI_LIBRARY_VERSION.

Referenced by HBA_GetVendorLibraryAttributes(), and HBA_GetWrapperLibraryAttributes().

## _HBA_SendReadCapacity()

static HBA_STATUS _HBA_SendReadCapacity | ( | HBA_HANDLE | handle,
|  | HBA_WWN | portWWN,
|  | HBA_UINT64 | fcLUN,
|  | void * | pRspBuffer,
|  | HBA_UINT32 * | RspBufferSize,
|  | void * | pSenseBuffer,
|  | HBA_UINT32 * | SenseBufferSize
| ) |  |

static

Is to be called by both, HBA_SendReadCapacity and HBA_ScsiReadCapacityV2. The difference is that HBA_SendReadCapacity does not care for the return value of RspBufferSize while HBA_ScsiReadCapacityV2 does. See the calls to this function underneath.

References getAdapterByHandle(), getPortByWWPN(), getUnitByFcLun(), vlib_data::mutex, revalidateRepository(), vlib_unit::sg_dev, vlib_HBA_WWN_to_wwn(), VLIB_MUTEX_LOCK, and VLIB_MUTEX_UNLOCK.

Referenced by HBA_ScsiReadCapacityV2(), and HBA_SendReadCapacity().

## _HBA_SendReportLUNs()

static HBA_STATUS _HBA_SendReportLUNs | ( | HBA_HANDLE | handle,
|  | HBA_WWN | portWWN,
|  | void * | pRspBuffer,
|  | HBA_UINT32 * | RspBufferSize,
|  | void * | pSenseBuffer,
|  | HBA_UINT32 * | SenseBufferSize
| ) |  |

static

Is to be called by both, HBA_SendReportLUNs and HBA_ScsiReportLUNsV2. The difference is that HBA_SendReportLUNs does not care for the return value of RspBufferSize while HBA_ScsiReportLUNsV2 does. See the calls to this function underneath.

References detachWLUN(), getAdapterByHandle(), getAttachedWLUN(), getPortByWWPN(), getSgDevFromPort(), vlib_data::mutex, vlib_HBA_WWN_to_wwn(), VLIB_MUTEX_LOCK, VLIB_MUTEX_UNLOCK, and vlib_port::wwpn.

Referenced by HBA_ScsiReportLUNsV2(), and HBA_SendReportLUNs().

## _HBA_SendScsiInquiry()

static 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
| ) |  |

static

Is to be called by both, HBA_SendScsiInquiry and HBA_ScsiInquiryV2. The difference is that HBA_SendScsiInquiry does not care for the return value of RspBufferSize while HBA_ScsiInquiryV2 does. See the calls to this function underneath.

References getAdapterByHandle(), getPortByWWPN(), getUnitByFcLun(), vlib_data::mutex, vlib_unit::sg_dev, vlib_HBA_WWN_to_wwn(), VLIB_MUTEX_LOCK, and VLIB_MUTEX_UNLOCK.

Referenced by HBA_ScsiInquiryV2(), and HBA_SendScsiInquiry().

## Variable Documentation

## vlib_data

struct vlib_data vlib_data

Global variable that holds almost all information needed in the library.

All data except some data needed for event handling is stored in this variable. To be thread safe, access to this variable must be locked using vlib_data.mutex. vlib_data.mutex is initialized in the initialization function and is destroyed in the finalization function of the library.