ZFCP HBA API Library
1
|
Auxiliary functions used in the library. More...
#include "vlib.h"
Functions | |
static int | block_assertSize (struct block *block, const size_t size, const size_t num, const size_t grow) |
Assert that there is space for at least num elements in the block. More... | |
static void * | block_addItem (struct block *block, size_t size, size_t grow) |
Add a new item to a block. More... | |
void | block_free (struct block *block) |
Free the array contained in a struct block. More... | |
struct vlib_adapter * | getAdapterByIndex (uint32_t index) |
Get an adapter by its index. More... | |
struct vlib_adapter * | getAdapterByHandle (HBA_HANDLE handle, HBA_STATUS *status) |
Get an adapter by its handle. More... | |
struct vlib_adapter * | getAdapterByDevid (devid_t devid) |
Get an adapter by its devid. More... | |
struct vlib_adapter * | getAdapterByHostNo (unsigned short host) |
Get an adapter by SCSI Host number as in sysfs. More... | |
struct vlib_port * | getPortByIndex (const struct vlib_adapter *adapter, const uint32_t index) |
Get a port by its index. More... | |
struct vlib_port * | getPortByWWPN (const struct vlib_adapter *adapter, const wwn_t wwpn) |
Get a port by its WWPN. More... | |
struct vlib_unit * | getUnitByIndex (const struct vlib_port *port, const uint32_t index) |
Get an unit by its index. More... | |
struct vlib_unit * | getUnitByFcLun (const struct vlib_port *port, uint64_t fcLun) |
Get an unit by its fclun. More... | |
static struct vlib_unit * | getUnitFromRepos (struct vlib_port *port, struct vlib_unit *unit) |
Check if an unit specified in an unit event is already stored in the repository. More... | |
int | addUnitToRepos (struct vlib_port *port, struct vlib_unit *unit) |
Add a unit to the repository. More... | |
static struct vlib_port * | getPortFromRepos (struct vlib_adapter *adapter, char *sysfs_name) |
Check if a port specified is already stored in the repository. More... | |
int | addPortToRepos (struct vlib_adapter *adapter, struct vlib_port *port) |
Add a port from to the repository. More... | |
static struct vlib_adapter * | getAdapterFromRepos (char *bus_dev_name) |
Check if an adapter specified in an event is already stored in the repository. More... | |
int | addAdapterToRepos (struct vlib_adapter *adapter) |
Add an adapter to the repository. More... | |
int | updateAdapter (struct vlib_adapter *adapter) |
Update information about ports and units of an adapter. More... | |
int | revalidateAdapters (void) |
Revalidate adapters in the repository. More... | |
int | findIndexByName (char *name) |
Find an adapter index by name. More... | |
HBA_HANDLE | openAdapterByIndex (HBA_UINT32 index) |
Open an adapter by index. More... | |
void | doCloseAdapter (struct vlib_adapter *adapter) |
Close an adapter in the repository. More... | |
void | closeAllAdapters (void) |
Close all adapters in the repository. More... | |
HBA_PORTTYPE | vlibCharToIntPortType (char *portType) |
Map the result of a port type string from sysfs to an int. More... | |
HBA_PORTSTATE | vlibCharToIntPortState (char *portState) |
Map the result of a port state string from sysfs to an int. More... | |
HBA_PORTSPEED | vlibIntToSymbolPortSpeed (int speed) |
Maps the result of a port speed int to the HBA_PORTSPEED int. More... | |
HBA_PORTSPEED | vlibCharToIntPortSpeed (char *pS) |
Map the result of a port speed string to the HBA_PORTSPEED int. More... | |
int | vlibCOStoFlag (int class) |
Maps the number of a class of service to its bit flag according to FC-GS-4. More... | |
HBA_COS | vlibCharToIntCOS (char *s) |
Map the result of a class of service string to an int. More... | |
char * | getSgDevFromPort (struct vlib_port *port) |
Get the first sg device from an adapter. More... | |
char * | getAttachedWLUN (struct vlib_adapter *adapter, struct vlib_port *port) |
Try to attach the report luns wlun and return its name as in "/dev". More... | |
void | detachWLUN (struct vlib_adapter *adapter, struct vlib_port *port) |
Try to detach lun 0. More... | |
Auxiliary functions used in the library.
int addAdapterToRepos | ( | struct vlib_adapter * | adapter | ) |
Add an adapter to the repository.
*adapter | adapter |
If the adapter specified in the event is already stored in the repository it is marked as valid.
References vlib_data::adapters, block_addItem(), vlib_adapter_ident::bus_dev_name, getAdapterFromRepos(), vlib_adapter::ident, and vlib_adapter::isInvalid.
int addPortToRepos | ( | struct vlib_adapter * | adapter, |
struct vlib_port * | port | ||
) |
Add a port from to the repository.
*adapter | to which the port data should be added, if NULL is passed the adapter should be identified by the data in the event |
*port | port to be added |
If the port specified in the event is already stored in the repository it is marked as valid.
References block_addItem(), getPortFromRepos(), vlib_port::isInvalid, vlib_port::name, and vlib_adapter::ports.
Add a unit to the repository.
*port | to which the unit data should be added, if NULL is passed the port should be identified by the data in the event |
*unit | unit to be aded |
If the unit specified in the event is already stored in the repository it is marked as valid.
References block_addItem(), getUnitFromRepos(), vlib_unit::isInvalid, and vlib_port::units.
|
static |
Add a new item to a block.
*block | pointer to struct block (contains array of elements of passed size) |
size | of the contained structure |
grow | chunk size (The array grows by chunks of size (grow * size).) |
If the new item does not fit in the array, the array is enlarged.
References block_assertSize(), block::data, and block::used.
Referenced by addAdapterToRepos(), addPortToRepos(), and addUnitToRepos().
|
static |
Assert that there is space for at least num elements in the block.
*block | pointer to struct block (contains array of elements of passed size) |
size | of the contained structure |
num | minimum number of elements in the block |
grow | chunk size (The array grows by chunks of size (grow * size).) |
References block::allocated, block::data, and VLIB_PERROR.
Referenced by block_addItem().
void block_free | ( | struct block * | block | ) |
Free the array contained in a struct block.
*block | pointer to a struct block |
References block::allocated, block::data, and block::used.
Referenced by closeAllAdapters(), and doCloseAdapter().
void closeAllAdapters | ( | void | ) |
Close all adapters in the repository.
This function frees all allocated memory for the adapters.
References vlib_data::adapters, block_free(), doCloseAdapter(), getAdapterByIndex(), and block::used.
void detachWLUN | ( | struct vlib_adapter * | adapter, |
struct vlib_port * | port | ||
) |
Try to detach lun 0.
adapter* | Pointer to an adapter |
port* | Pointer to a port |
References vlib_unit::channel, getUnitByIndex(), vlib_unit::host, revalidateUnits(), and vlib_unit::target.
void doCloseAdapter | ( | struct vlib_adapter * | adapter | ) |
Close an adapter in the repository.
*adapter | pointer to the adapter to be closed |
This function frees all allocated memory for the ports and units of this adapter and invalidates the adapter handle.
References block_free(), getPortByIndex(), vlib_adapter::handle, vlib_adapter::ports, vlib_port::units, block::used, and VLIB_INVALID_HANDLE.
Referenced by closeAllAdapters(), HBA_CloseAdapter(), and revalidateAdapters().
int findIndexByName | ( | char * | name | ) |
Find an adapter index by name.
name | the name of the adapter |
References vlib_data::adapters, getAdapterByIndex(), vlib_adapter::isInvalid, block::used, VLIB_ADAPTERNAME_LEN, and VLIB_ADAPTERNAME_PREFIX.
struct vlib_adapter* getAdapterByDevid | ( | devid_t | devid | ) |
Get an adapter by its devid.
devid | of the adapter |
References vlib_data::adapters, vlib_adapter_ident::devid, getAdapterByIndex(), vlib_adapter::ident, and block::used.
struct vlib_adapter* getAdapterByHandle | ( | HBA_HANDLE | handle, |
HBA_STATUS * | status | ||
) |
Get an adapter by its handle.
handle | of the adapter |
*status | pointer to return error status code |
If NULL is returned *status contains an error status code which should be checked by the calling function. If non-NULL is returned *status is HBA_STATUS_OK. Possible error status codes are:
References vlib_adapter::handle, and VLIB_INVALID_HANDLE.
Referenced by HBA_CloseAdapter(), HBA_GetFcpTargetMappingV2(), and HBA_RefreshInformation().
struct vlib_adapter* getAdapterByHostNo | ( | unsigned short | host | ) |
Get an adapter by SCSI Host number as in sysfs.
SCSI | host number of the adapter |
References vlib_data::adapters, getAdapterByIndex(), vlib_adapter_ident::host, vlib_adapter::ident, and block::used.
struct vlib_adapter* getAdapterByIndex | ( | uint32_t | index | ) |
Get an adapter by its index.
index | of the adapter |
References vlib_data::adapters, block::data, and block::used.
Referenced by closeAllAdapters(), findIndexByName(), getAdapterByDevid(), getAdapterByHostNo(), getAdapterFromRepos(), invalidateAllAdapters(), openAdapterByIndex(), and revalidateAdapters().
|
static |
Check if an adapter specified in an event is already stored in the repository.
*bus_dev_name | name of adapter as in the sysfs bus dev name |
References vlib_data::adapters, vlib_adapter_ident::bus_dev_name, getAdapterByIndex(), vlib_adapter::ident, and block::used.
Referenced by addAdapterToRepos().
char* getAttachedWLUN | ( | struct vlib_adapter * | adapter, |
struct vlib_port * | port | ||
) |
Try to attach the report luns wlun and return its name as in "/dev".
adapter* | Pointer to an adapter |
port* | Pointer to a port |
References vlib_adapter_ident::bus_dev_name, vlib_adapter::ident, REPORTLUNS_WLUN, and vlib_port::wwpn.
struct vlib_port* getPortByIndex | ( | const struct vlib_adapter * | adapter, |
const uint32_t | index | ||
) |
Get a port by its index.
*adapter | to which the port belongs |
index | of the port |
References block::data, vlib_adapter::ports, and block::used.
Referenced by doCloseAdapter(), getPortByWWPN(), getPortFromRepos(), and updateAdapter().
struct vlib_port* getPortByWWPN | ( | const struct vlib_adapter * | adapter, |
const wwn_t | wwpn | ||
) |
Get a port by its WWPN.
*adapter | to which the port belongs |
wwpn | of the port |
References getPortByIndex(), vlib_adapter::ports, block::used, and vlib_port::wwpn.
|
static |
Check if a port specified is already stored in the repository.
*adapter | to which this port belongs |
*port | the new port for whose existence is checked |
References getPortByIndex(), vlib_port::name, vlib_adapter::ports, and block::used.
Referenced by addPortToRepos().
char* getSgDevFromPort | ( | struct vlib_port * | port | ) |
Get the first sg device from an adapter.
port* | Pointer to a port |
References getUnitByIndex(), revalidateUnits(), and vlib_unit::sg_dev.
Get an unit by its fclun.
*port | to which the unit belongs |
index | of the unit |
References vlib_unit::fcLun, getUnitByIndex(), vlib_port::units, and block::used.
Get an unit by its index.
*port | to which the unit belongs |
index | of the unit |
References block::data, vlib_port::units, and block::used.
Referenced by detachWLUN(), getSgDevFromPort(), getUnitByFcLun(), and getUnitFromRepos().
|
static |
Check if an unit specified in an unit event is already stored in the repository.
*port | to which this unit belongs |
*event | unit add event |
References vlib_unit::fcLun, getUnitByIndex(), vlib_port::units, and block::used.
Referenced by addUnitToRepos().
HBA_HANDLE openAdapterByIndex | ( | HBA_UINT32 | index | ) |
Open an adapter by index.
index | of the adapter |
If compiled as a vendor library, we shall only use the lower 16 Bit of the handle.
References getAdapterByIndex(), vlib_adapter::handle, and VLIB_INVALID_HANDLE.
int revalidateAdapters | ( | void | ) |
Revalidate adapters in the repository.
Port and unit configuration data is only updated if it was already generated before. Generation of port and unit configuration information is triggered in HBA_GetAdapterPortAttributes() and HBA_GetFcpTargetMapping(), resp.
References vlib_data::adapters, block::allocated, doCloseAdapter(), getAdapterByIndex(), vlib_adapter::isInvalid, vlib_adapter::ports, updateAdapter(), and block::used.
int updateAdapter | ( | struct vlib_adapter * | adapter | ) |
Update information about ports and units of an adapter.
*adapter | to be updated |
References getPortByIndex(), vlib_adapter::isInvalid, vlib_adapter::ports, sysfs_createAndReadConfigPorts(), sysfs_getUnitsFromPort(), and block::used.
Referenced by HBA_RefreshInformation(), and revalidateAdapters().
HBA_COS vlibCharToIntCOS | ( | char * | s | ) |
Map the result of a class of service string to an int.
char* | containing the class of service string |
References vlibCOStoFlag().
HBA_PORTSPEED vlibCharToIntPortSpeed | ( | char * | pS | ) |
Map the result of a port speed string to the HBA_PORTSPEED int.
char* | containing the port speed string |
References vlibIntToSymbolPortSpeed().
HBA_PORTSTATE vlibCharToIntPortState | ( | char * | portState | ) |
Map the result of a port state string from sysfs to an int.
char* | containing the port state |
HBA_PORTTYPE vlibCharToIntPortType | ( | char * | portType | ) |
Map the result of a port type string from sysfs to an int.
char* | containing the port type |
int vlibCOStoFlag | ( | int | class | ) |
Maps the number of a class of service to its bit flag according to FC-GS-4.
int | holding the class number |
Referenced by vlibCharToIntCOS().
HBA_PORTSPEED vlibIntToSymbolPortSpeed | ( | int | speed | ) |
Maps the result of a port speed int to the HBA_PORTSPEED int.
int | holding the port speed |
Referenced by vlibCharToIntPortSpeed().