Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
elxu_common.c File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <ctype.h>
#include <ocs_ioctl.h>
#include "elxu_common.h"
#include "elxu_mgmt.h"

Go to the source code of this file.

Macros

#define NUMNODE   256
 
#define NODERESULT   40
 
#define NUMCPU   36
 
#define CPULIST   16
 
#define NNODELIST   16
 
#define NODELEN   12
 
#define NPATHLEN   65
 
#define NUMDEVID   10
 
#define DEVBUFF   8
 

Functions

static void hba_list_info_ocs (elxu_device_t *device_p)
 
static void hba_list_info_pt (elxu_device_t *device_p)
 
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 dump8 (const char *label, void *buffer, uint32_t bufferLength)
 Print a buffer in hexadecimal and ASCII. 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...
 
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...
 

Macro Details

#define CPULIST   16
#define DEVBUFF   8
#define NNODELIST   16
#define NODELEN   12
#define NODERESULT   40
#define NPATHLEN   65
#define NUMCPU   36
#define NUMDEVID   10
#define NUMNODE   256

Function Details

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_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.

static void hba_list_info_ocs ( elxu_device_t *  device_p)
static

Definition at line 199 of file elxu_common.c.

static void hba_list_info_pt ( elxu_device_t *  device_p)
static

Definition at line 287 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.

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.