Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
elxu_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 #ifndef __ELXU_COMMON_H__
34 #define __ELXU_COMMON_H__
35 
36 #include "elxu_device.h"
37 #include "elxu_sli4.h"
38 #include "elxu_mbox.h"
39 
40 #define ELXU_VERSION STR_BE_MAJOR "." STR_BE_MINOR "." STR_BE_BUILD "." STR_BE_BRANCH
41 
42 
43 #define TRANSCEIVER_INFO_PAGE_SIZE 256
44 
45 #if !defined(ARRAY_SIZE)
46 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
47 #endif
48 
49 #define ROUNDUP(x,y) ((((x) + ((y)-1)) / (y)) * (y))
50 static inline uint32_t addr32_lo(uintptr_t addr)
51 {
52 #if defined(__LP64__)
53  return (uint32_t)(addr & 0xffffffffUL);
54 #else
55  return addr;
56 #endif
57 }
58 
59 static inline uint32_t addr32_hi(uintptr_t addr)
60 {
61 #if defined(__LP64__)
62  return (uint32_t)(addr >> 32);
63 #else
64  return 0;
65 #endif
66 }
67 
68 typedef struct cmd_options_s {
70  char *file;
71  int cc;
72  int clof;
73  int clrc;
74  char *wwnn;
75  char *wwpn;
76  int initiator;
77  int target;
78  int ecd_test;
79  int fdb_dump;
80  int fat;
81  int efd;
82  int ecd;
83  int saved;
84  int wqes;
85  int cqes;
86  int mqes;
87  int rqes;
88  int eqes;
89  int qentries;
90  int clr_saved;
95 #define LINKCFG_VALUE_NAME_MAX 256
96  char linkcfg[LINKCFG_VALUE_NAME_MAX];
97 #define LINKSPEED_VALUE_NAME_MAX 64
98  char linkspeed[LINKSPEED_VALUE_NAME_MAX];
99 #define LINKTOPO_VALUE_NAME_MAX 16
100  char linktopology[LINKTOPO_VALUE_NAME_MAX];
103  char *hostname;
104  int bufsize;
105  char *profile_id;
107  int chap_type; /* CHAP type indicates incoming/outgoing */
108  int vlan_id;
112 } cmd_options_t;
113 
114 /* The following functions are general to the utility and not specific
115  * to any OS, HBA, or driver.
116  */
117 extern void *zmalloc (uint32_t len);
118 extern void zfree (void *p);
119 extern void elxu_display_device_list(char *hostname);
120 extern void elxu_hba_list_info (elxu_device_t *device_p);
121 extern int parse_wwn(char *wwn_in, uint64_t *wwn_out);
122 extern char * format_wwn(uint64_t wwn_in);
123 extern void dump8 (const char *label, void *buffer, uint32_t bufferLength);
124 char *hex_dump(uint8_t *value, int size);
125 extern char *trimmed_string(uint8_t *string);
126 extern char *decode_entry_type(uint32_t entry_type);
127 extern char *get_numa_node_map(uint32_t device_port);
128 extern char *get_physical_numa_node(char *bus_addr);
129 extern int parse_arguments(int argc, char**argv, cmd_options_t *options, int openflag, int expected_nonargs);
130 
131 /* The following functions have OS specific versions - they're defined in
132  * either elxu_linux.c or elxu_bsd.c, not in elxu_common.c. Any function
133  * that must exist for both Linux and BSD, and which has different implementations
134  * for Linux and BSD, should be declared here and defined in both elxu_linux.c
135  * and elxu_bsd.c.
136  */
137 extern void elxu_get_connection_info(elxu_device_t *device);
139 extern void os_close_device(elxu_device_t *device);
140 extern int os_ioctl_device(elxu_device_t *device, int req, void *arg);
141 extern elxu_device_t* os_build_device_list(char *path);
142 extern elxu_device_t *os_build_device_list_uspace(char *hostname);
143 extern int os_remove_device(elxu_device_t *device);
144 
145 #endif
char * connection_handle
Definition: elxu_common.h:101
char * trimmed_string(uint8_t *string)
Trim trailing non-printable characters from a string.
Definition: elxu_common.c:437
int parse_wwn(char *wwn_in, uint64_t *wwn_out)
Parse a WWN from a string into a 64-bit value.
Definition: elxu_common.c:327
static uint32_t addr32_lo(uintptr_t addr)
Definition: elxu_common.h:50
void elxu_display_device_list(char *hostname)
Display the list of available devices.
Definition: elxu_common.c:152
elxu_device_t * os_build_device_list(char *path)
Definition: elxu_bsd.c:71
elxu_device_t * device
Definition: elxu_common.h:69
char * get_physical_numa_node(char *bus_addr)
Return the physical Numa Node location for an OCS port .
Definition: elxu_common.c:658
char * hba_identifier
Definition: elxu_common.h:110
void os_close_device(elxu_device_t *device)
Close a device file.
Definition: elxu_bsd.c:187
int os_ioctl_device(elxu_device_t *device, int req, void *arg)
Send an ioctl to an open device.
Definition: elxu_bsd.c:211
device name specifier This structure is used to describe the type and name of the device ioctl connec...
Definition: elxu_device.h:113
void * zmalloc(uint32_t len)
Allocates and zeroes memory to be used.
Definition: elxu_common.c:63
char * format_wwn(uint64_t wwn_in)
Format a 64-bit WWN for printing.
Definition: elxu_common.c:368
void zfree(void *p)
Frees memory that has been allocated.
Definition: elxu_common.c:80
char * hostname
Definition: elxu_common.h:103
char * port_identifier
Definition: elxu_common.h:111
char * protocol_name
Definition: elxu_common.h:106
char * profile_id
Definition: elxu_common.h:105
int sfp_xceiver_data
Definition: elxu_common.h:92
#define LINKCFG_VALUE_NAME_MAX
Definition: elxu_common.h:95
#define LINKSPEED_VALUE_NAME_MAX
Definition: elxu_common.h:97
char * connection_id
Definition: elxu_common.h:102
char * decode_entry_type(uint32_t entry_type)
Return the name of a UFI entry type.
Definition: elxu_common.c:474
void elxu_get_connection_info(elxu_device_t *device)
Print iSCSI connection info for the given device.
Definition: elxu_bsd.c:230
#define LINKTOPO_VALUE_NAME_MAX
Definition: elxu_common.h:99
static uint32_t addr32_hi(uintptr_t addr)
Definition: elxu_common.h:59
elxu_device_t * os_open_device(elxu_device_name_t *devname)
Open a device file.
Definition: elxu_bsd.c:148
void dump8(const char *label, void *buffer, uint32_t bufferLength)
Print a buffer in hexadecimal and ASCII.
Definition: elxu_common.c:100
elxu_device_t * os_build_device_list_uspace(char *hostname)
Definition: elxu_bsd.c:123
char * hex_dump(uint8_t *value, int size)
Display a buffer in hexadecimal.
Definition: elxu_common.c:401
char * get_numa_node_map(uint32_t device_port)
Return a string of cpu to numa node mapping .
Definition: elxu_common.c:537
void elxu_hba_list_info(elxu_device_t *device_p)
Displays HBA List information.
Definition: elxu_common.c:188
int parse_arguments(int argc, char **argv, cmd_options_t *options, int openflag, int expected_nonargs)
Parse command line arguments.
int os_remove_device(elxu_device_t *device)
Definition: elxu_bsd.c:193