Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
elxu_common.h File Reference
#include "elxu_device.h"
#include "elxu_sli4.h"
#include "elxu_mbox.h"

Go to the source code of this file.

Data Structures

struct  cmd_options_t
 

Macros

#define ELXU_VERSION   STR_BE_MAJOR "." STR_BE_MINOR "." STR_BE_BUILD "." STR_BE_BRANCH
 
#define TRANSCEIVER_INFO_PAGE_SIZE   256
 
#define ARRAY_SIZE(x)   (sizeof(x) / sizeof(x[0]))
 
#define ROUNDUP(x, y)   ((((x) + ((y)-1)) / (y)) * (y))
 
#define LINKCFG_VALUE_NAME_MAX   256
 
#define LINKSPEED_VALUE_NAME_MAX   64
 
#define LINKTOPO_VALUE_NAME_MAX   16
 

Functions

static uint32_t addr32_lo (uintptr_t addr)
 
static uint32_t addr32_hi (uintptr_t addr)
 
void * zmalloc (uint32_t len)
 Allocates and zeroes memory to be used. More...
 
void zfree (void *p)
 Frees memory that has been allocated. More...
 
void elxu_display_device_list (char *hostname)
 Display the list of available devices. More...
 
void elxu_hba_list_info (elxu_device_t *device_p)
 Displays HBA List information. More...
 
int parse_wwn (char *wwn_in, uint64_t *wwn_out)
 Parse a WWN from a string into a 64-bit value. More...
 
char * format_wwn (uint64_t wwn_in)
 Format a 64-bit WWN for printing. More...
 
void dump8 (const char *label, void *buffer, uint32_t bufferLength)
 Print a buffer in hexadecimal and ASCII. More...
 
char * hex_dump (uint8_t *value, int size)
 Display a buffer in hexadecimal. More...
 
char * trimmed_string (uint8_t *string)
 Trim trailing non-printable characters from a string. More...
 
char * decode_entry_type (uint32_t entry_type)
 Return the name of a UFI entry type. More...
 
char * get_numa_node_map (uint32_t device_port)
 Return a string of cpu to numa node mapping . More...
 
char * get_physical_numa_node (char *bus_addr)
 Return the physical Numa Node location for an OCS port . More...
 
int parse_arguments (int argc, char **argv, cmd_options_t *options, int openflag, int expected_nonargs)
 Parse command line arguments. More...
 
void elxu_get_connection_info (elxu_device_t *device)
 Print iSCSI connection info for the given device. More...
 
elxu_device_t * os_open_device (elxu_device_name_t *devname)
 Open a device file. More...
 
void os_close_device (elxu_device_t *device)
 Close a device file. More...
 
int os_ioctl_device (elxu_device_t *device, int req, void *arg)
 Send an ioctl to an open device. More...
 
elxu_device_t * os_build_device_list (char *path)
 Build a list of devices. More...
 
elxu_device_t * os_build_device_list_uspace (char *hostname)
 
int os_remove_device (elxu_device_t *device)
 

Macro Details

#define ARRAY_SIZE (   x)    (sizeof(x) / sizeof(x[0]))

Definition at line 46 of file elxu_common.h.

#define ELXU_VERSION   STR_BE_MAJOR "." STR_BE_MINOR "." STR_BE_BUILD "." STR_BE_BRANCH

Definition at line 40 of file elxu_common.h.

#define LINKCFG_VALUE_NAME_MAX   256

Definition at line 95 of file elxu_common.h.

#define LINKSPEED_VALUE_NAME_MAX   64

Definition at line 97 of file elxu_common.h.

#define LINKTOPO_VALUE_NAME_MAX   16

Definition at line 99 of file elxu_common.h.

#define ROUNDUP (   x,
  y 
)    ((((x) + ((y)-1)) / (y)) * (y))

Definition at line 49 of file elxu_common.h.

#define TRANSCEIVER_INFO_PAGE_SIZE   256

Definition at line 43 of file elxu_common.h.

Function Details

static uint32_t addr32_hi ( uintptr_t  addr)
inlinestatic

Definition at line 59 of file elxu_common.h.

static uint32_t addr32_lo ( uintptr_t  addr)
inlinestatic

Definition at line 50 of file elxu_common.h.

char* decode_entry_type ( uint32_t  entry_type)

Return the name of a UFI entry type.

Description
Given an integer that represents an entry type in a UFI directory, this function returns a pointer to a constant string containing the name of that entry type.
Parameters
entry_typeThe type of the entry to lookup.
Returns
Returns a pointer to a constant string which is the name of the given entry type. If the entry type is not recognized the string "Unknown" will be returned.

Definition at line 474 of file elxu_common.c.

void dump8 ( const char *  label,
void *  buffer,
uint32_t  bufferLength 
)

Print a buffer in hexadecimal and ASCII.

Description
This function prints out a buffer of data in both hexadecimal and ASCII.
Parameters
labelLabel to be printed above the output.
bufferBuffer of binary data to be printed.
bufferLengthLength of buffer.
Returns
Returns nothing.

Definition at line 100 of file elxu_common.c.

void elxu_display_device_list ( char *  hostname)

Display the list of available devices.

Description
This function displays the list of available devices. It iterates over devices, starting with index 0. For each index it attempts to open the device. If the device is opened successfully then the information about that device is displayed. The loop terminates when any open fails.
Parameters
hostnamehostname in the case of the user space driver.
Returns
Returns nothing.

Definition at line 152 of file elxu_common.c.

void elxu_get_connection_info ( elxu_device_t *  device)

Print iSCSI connection info for the given device.

Description
This function prints iSCSI connection information for the given device. BSD does not support iSCSI connection info, so this function prints an error message and returns.
Parameters
deviceThe device for which to print connection info.
Returns
Returns nothing.

Definition at line 230 of file elxu_bsd.c.

void elxu_hba_list_info ( elxu_device_t *  device_p)

Displays HBA List information.

Description
Given an open device pointer, this function retrieves and displays information about the device. The actual handler is different depending on the driver.
Parameters
device_pA pointer to an elxu_device_t. The device should already have been opened with elxu_open_device.
Returns
Returns nothing.

Definition at line 188 of file elxu_common.c.

char* format_wwn ( uint64_t  wwn_in)

Format a 64-bit WWN for printing.

Description
Given a 64-bit WWN value, return a string in the format xx:xx:xx:xx:xx:xx:xx:xx
Parameters
wwn_inuint64_t containing the WWN
Returns
Returns a pointer to the formatted string

Definition at line 368 of file elxu_common.c.

char* get_numa_node_map ( uint32_t  device_port)

Return a string of cpu to numa node mapping .

Description
Given the port index for the ocs port, this function returns a pointer to a string containing the cpu to numa node mapping for that port
Parameters
device_portThe type of the port to list the cpu to numa node map.
Returns
Returns a pointer to a string which lists the cpu to numa node map for the given port. If the port is not recognized no value is returned.

Definition at line 537 of file elxu_common.c.

char* get_physical_numa_node ( char *  bus_addr)

Return the physical Numa Node location for an OCS port .

Description
Given the port index for the ocs port, this function returns a pointer to a string containing the value of the physical numa node the OCS port is associated with
Parameters
bus_addrThe bus address for the current OCS port
Returns
Returns a pointer to a string listing the Physical Numa Node port for the given port. If the bus address is not found a value of 'n/a' is listed.

Definition at line 658 of file elxu_common.c.

char* hex_dump ( uint8_t *  value,
int  size 
)

Display a buffer in hexadecimal.

Description
The buffer pointed to by value is displayed in hexadecimal. The bytes are displayed as two digit hexadecimal values separated by spaces. The result is termintated with a NULL.
Parameters
valueA pointer to an array of bytes to be printed.
sizeThe size of the array. The maximum size that can be handled is 25 bytes. Values larger than 25 will result in only the first 25 bytes being printed.
Returns
Returns a pointer to a static character string with the hexadecimal values.

Definition at line 401 of file elxu_common.c.

elxu_device_t* os_build_device_list_uspace ( char *  hostname)

Definition at line 123 of file elxu_bsd.c.

void os_close_device ( elxu_device_t *  device)

Close a device file.

Description
This function closes an open device file.
Parameters
deviceA pointer to an elxu_device_t to be closed.
Returns
Returns nothing.

Definition at line 187 of file elxu_bsd.c.

int os_ioctl_device ( elxu_device_t *  device,
int  req,
void *  arg 
)

Send an ioctl to an open device.

Description
This function sends an ioctl to an open device.
Parameters
deviceA pointer to the device.
reqThe request to be sent to the device.
argThe argument to be sent to the device.
Returns
Returns 0 on success; non-zero on failure.

Definition at line 211 of file elxu_bsd.c.

elxu_device_t* os_open_device ( elxu_device_name_t *  devname)

Open a device file.

Description
This function opens a device file on BSD. The input is an elxu_device_name_t which contains a device index and a hostname. If the hostname is non-NULL then the request is for a userspace driver, and the hostname is the host one which the driver is running. This is not supported on BSD. If the hostname is NULL then the index field specifies which device file to open.
Parameters
devnameAn elxu_device_name_t structure that specifies the device to be opened.
Returns
Returns a pointer to an elxu_device_t on success; NULL on failure.

Definition at line 148 of file elxu_bsd.c.

int os_remove_device ( elxu_device_t *  device)

Definition at line 193 of file elxu_bsd.c.

int parse_arguments ( int  argc,
char **  argv,
cmd_options_t *  options,
int  openflag,
int  expected_nonargs 
)

Parse command line arguments.

Description
Given the argc and argv parameters from the main program, function parses the command line arguments and stores the results in the cmd_options_t structure.
Parameters
argcCount of arguments.
argvArray of pointers to argument strings.
optionsPointer to array into which the results will be stored.
openflagIf TRUE the device specified by the options should be opened.
expected_nonargsExpected number of extra arguments.
Returns
Returns 0 on success; non-zero on failure.

Definition at line 5572 of file elxu_commands.c.

int parse_wwn ( char *  wwn_in,
uint64_t *  wwn_out 
)

Parse a WWN from a string into a 64-bit value.

Description
Given a pointer to a string, parse the string into a 64-bit WWN value. The format of the string must be xx:xx:xx:xx:xx:xx:xx:xx
Parameters
wwn_inPointer to the string to be parsed.
wwn_outPointer to uint64_t in which to put the parsed result.
Returns
Returns 0 if successful; non-zero if the WWN is malformed and couldn't be parsed

Definition at line 327 of file elxu_common.c.

char* trimmed_string ( uint8_t *  string)

Trim trailing non-printable characters from a string.

Description
Given a pointer to a string, this function returns a copy of the string up to the first non-printable character found. The largest string that can be returned is 2047 characters plus the terminating NULL.
Parameters
stringA pointer to the string to be trimmed.
Returns
Returns a pointer to a static copy of the input string up to the first non-printable character, or the first 2047 characters if no non-printable character is found in that range.

Definition at line 437 of file elxu_common.c.

void zfree ( void *  p)

Frees memory that has been allocated.

Description
Free memory that was allocated with malloc or zmalloc. If the pointer is NULL no action is taken.
Parameters
pThe pointer to the memory to be freed.

Definition at line 80 of file elxu_common.c.

void* zmalloc ( uint32_t  len)

Allocates and zeroes memory to be used.

Parameters
lenThe amount of memory to be zeroed and allocated.
Returns
Returns a pointer to the allocated memory or NULL on failure.

Definition at line 63 of file elxu_common.c.