vlib.h File Reference

Central header file for the library. More...

`#include "config.h"`
`#include <execinfo.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdarg.h>`
`#include <unistd.h>`
`#include <stdio.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <sys/ioctl.h>`
`#include <sys/time.h>`
`#include <fcntl.h>`
`#include <signal.h>`
`#include <errno.h>`
`#include <pthread.h>`
`#include <time.h>`
`#include <stdint.h>`
`#include <dirent.h>`
`#include <sys/socket.h>`
`#include <linux/netlink.h>`
`#include <scsi/scsi_netlink_fc.h>`
`#include <hbaapi.h>`
`#include "vlib_aux.h"`
`#include "vlib_sysfs.h"`
`#include "vlib_sg.h"`
`#include "vlib_sg_io.h"`
`#include "vlib_events.h"`
`#include "vlib_sfhelper.h"`

Go to the source code of this file.

## Data Structures

struct | vlib_event
| Event data structure used in the library. More...
struct | vlib_event_queue
| Event queue data structure used in the library. More...
struct | block
| Block structure used to hold all needed data for growable arrays. More...
struct | vlib_unit
| Represenation of an FCP unit in the library. More...
struct | vlib_port
| Representation of a FC port in the library. More...
struct | vlib_adapter_ident
| Identification of an adapter in the library. More...
struct | vlib_adapter
| Represenation of an adapter in the library. More...
struct | vlib_data
| Primary data structure used in the library. More...

## Macros

#define | _GNU_SOURCE
#define | HBAAPI_LIBRARY_VERSION 2
| This is a phase 2 HBA API library.
#define | HBAAPI_LIBRARY_FINAL 0
| Define as 1 if this library implements the final FC-HBA, which is not yet the case.
#define | HBAAPI_LIBRARY_REVISION VERSION
| Revision of this library.
#define | VLIB_ENV_LOG_LEVEL "LIB_ZFCP_HBAAPI_LOG_LEVEL"
| Environment variable to enable logging.
#define | VLIB_ENV_LOG_FILE "LIB_ZFCP_HBAAPI_LOG_FILE"
| Environment variable specifying the file which is used for logging.
#define | VLIB_ADAPTERNAME_PREFIX "com.ibm-FICON-FCP-"
| Prefix used to concatednate an adapter name.
#define | VLIB_ADAPTERNAME_LEN 256
| Maximal lenght of an adapter name as used in this libary.
#define | VLIB_INVALID_HANDLE 0
| This is the value of an invalid handle as used in this library.
#define | REPORTLUNS_WLUN 0xc101000000000000
| This is the value the report luns well known lun.
#define | VLIB_PERROR(errnum, fmt, args...) vlib_print_error(errnum, __func__, __FILE__, __LINE__, fmt, ##args)
| To log errors in the library, this macro is used which invokes vlib_print_error().
#define | VLIB_LOG(fmt, args...) vlib_print_error(0, __func__, __FILE__, __LINE__, fmt, ##args)
| To log messages in the library, this macro is used.
#define | vlib_bt()
| Print a stack backtrace.
#define | VLIB_MUTEX_LOCK(mutex)
| To lock a mutex, this macro is used, which checks for errors.
#define | VLIB_MUTEX_UNLOCK(mutex)
| To unlock a mutex, this macro is used, which checks for errors.

## Functions

static void | vlib_print_error (int errnum, const char *function, const char *file, int line, char *fmt,...)
| This is a wrapper for the usage of strerror_r().

## Variables

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

## Detailed Description

Central header file for the library.

Contains typedefs, structure definitions, some inline functions and macros needed in the library.

## Macro Definition Documentation

## _GNU_SOURCE

#define _GNU_SOURCE

This implies definition of _XOPEN_SOURCE. It is needed for strptime().

## vlib_bt

#define vlib_bt | ( |  | ) |

Print a stack backtrace.

Note
  This needs -rdynamic to work.
  This function is only defined if HBAAPI_BACKTRACE is defined.

## VLIB_MUTEX_LOCK

#define VLIB_MUTEX_LOCK | ( |  | mutex | ) |

Value:
do { \
int __ret; \
__ret = pthread_mutex_lock(mutex); \
if (__ret == EDEADLK) { \
VLIB_LOG("BUG: VLIB_MUTEX_LOCK: deadlock detected!\n"); \
vlib_bt(); \
exit(1); \
} else if (__ret == EINVAL) { \
VLIB_LOG("BUG: VLIB_MUTEX_LOCK: mutex not properly " \
"initialized\n"); \
vlib_bt(); \
exit(1); \
} \
} while (0)

To lock a mutex, this macro is used, which checks for errors.

Note
  The programm is exited if:
  - mutex is not properly initialized or
  - a deadlock situation is encountered and HBAAPI_BACKTRACE is defined.

## VLIB_MUTEX_UNLOCK

#define VLIB_MUTEX_UNLOCK | ( |  | mutex | ) |

Value:
do { \
int __ret; \
__ret = pthread_mutex_unlock(mutex); \
if (__ret == EPERM) { \
VLIB_LOG("BUG: VLIB_MUTEX_UNLOCK: thread does not own " \
"mutex!\n"); \
vlib_bt(); \
exit(1); \
} else if (__ret == EINVAL) { \
VLIB_LOG("BUG: VLIB_MUTEX_UNLOCK: " \
"mutex not properly initialized\n"); \
vlib_bt(); \
exit(1); \
} \
} while (0)

To unlock a mutex, this macro is used, which checks for errors.

Note
  The programm is exited if:
  - mutex is not properly initialized or
  - mutex is not own by this thread and HBAAPI_BACKTRACE is defined.

## Variable Documentation

## vlib_data

struct vlib_data vlib_data

extern

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.