/* * Copyright (c) 2011-2015, Emulex * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #ifndef __ELXU_COMMON_H__ #define __ELXU_COMMON_H__ #include "elxu_device.h" #include "elxu_sli4.h" #include "elxu_mbox.h" #define ELXU_VERSION STR_BE_MAJOR "." STR_BE_MINOR "." STR_BE_BUILD "." STR_BE_BRANCH #define TRANSCEIVER_INFO_PAGE_SIZE 256 #if !defined(ARRAY_SIZE) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif #define ROUNDUP(x,y) ((((x) + ((y)-1)) / (y)) * (y)) static inline uint32_t addr32_lo(uintptr_t addr) { #if defined(__LP64__) return (uint32_t)(addr & 0xffffffffUL); #else return addr; #endif } static inline uint32_t addr32_hi(uintptr_t addr) { #if defined(__LP64__) return (uint32_t)(addr >> 32); #else return 0; #endif } typedef struct cmd_options_s { elxu_device_t *device; char *file; int cc; int clof; int clrc; char *wwnn; char *wwpn; int initiator; int target; int ecd_test; int fdb_dump; int fat; int efd; int ecd; int saved; int wqes; int cqes; int mqes; int rqes; int eqes; int qentries; int clr_saved; int sfp_diag_data; int sfp_xceiver_data; int loopback_type; int retry_count; #define LINKCFG_VALUE_NAME_MAX 256 char linkcfg[LINKCFG_VALUE_NAME_MAX]; #define LINKSPEED_VALUE_NAME_MAX 64 char linkspeed[LINKSPEED_VALUE_NAME_MAX]; #define LINKTOPO_VALUE_NAME_MAX 16 char linktopology[LINKTOPO_VALUE_NAME_MAX]; char *connection_handle; char *connection_id; char *hostname; int bufsize; char *profile_id; char *protocol_name; int chap_type; /* CHAP type indicates incoming/outgoing */ int vlan_id; int trunk_mode; char *hba_identifier; char *port_identifier; } cmd_options_t; /* The following functions are general to the utility and not specific * to any OS, HBA, or driver. */ extern void *zmalloc (uint32_t len); extern void zfree (void *p); extern void elxu_display_device_list(char *hostname); extern void elxu_hba_list_info (elxu_device_t *device_p); extern int parse_wwn(char *wwn_in, uint64_t *wwn_out); extern char * format_wwn(uint64_t wwn_in); extern void dump8 (const char *label, void *buffer, uint32_t bufferLength); char *hex_dump(uint8_t *value, int size); extern char *trimmed_string(uint8_t *string); extern char *decode_entry_type(uint32_t entry_type); extern char *get_numa_node_map(uint32_t device_port); extern char *get_physical_numa_node(char *bus_addr); extern int parse_arguments(int argc, char**argv, cmd_options_t *options, int openflag, int expected_nonargs); /* The following functions have OS specific versions - they're defined in * either elxu_linux.c or elxu_bsd.c, not in elxu_common.c. Any function * that must exist for both Linux and BSD, and which has different implementations * for Linux and BSD, should be declared here and defined in both elxu_linux.c * and elxu_bsd.c. */ extern void elxu_get_connection_info(elxu_device_t *device); extern elxu_device_t* os_open_device(elxu_device_name_t *devname); extern void os_close_device(elxu_device_t *device); extern int os_ioctl_device(elxu_device_t *device, int req, void *arg); extern elxu_device_t* os_build_device_list(char *path); extern elxu_device_t *os_build_device_list_uspace(char *hostname); extern int os_remove_device(elxu_device_t *device); #endif