1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM #ifndef _CFGA_FP_H 27*7836SJohn.Forte@Sun.COM #define _CFGA_FP_H 28*7836SJohn.Forte@Sun.COM 29*7836SJohn.Forte@Sun.COM 30*7836SJohn.Forte@Sun.COM 31*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 32*7836SJohn.Forte@Sun.COM extern "C" { 33*7836SJohn.Forte@Sun.COM #endif 34*7836SJohn.Forte@Sun.COM 35*7836SJohn.Forte@Sun.COM #include <sys/types.h> 36*7836SJohn.Forte@Sun.COM #include <sys/mkdev.h> 37*7836SJohn.Forte@Sun.COM #include <stddef.h> 38*7836SJohn.Forte@Sun.COM #include <locale.h> 39*7836SJohn.Forte@Sun.COM #include <ctype.h> 40*7836SJohn.Forte@Sun.COM #include <stdio.h> 41*7836SJohn.Forte@Sun.COM #include <stdlib.h> 42*7836SJohn.Forte@Sun.COM #include <string.h> 43*7836SJohn.Forte@Sun.COM #include <fcntl.h> 44*7836SJohn.Forte@Sun.COM #include <unistd.h> 45*7836SJohn.Forte@Sun.COM #include <errno.h> 46*7836SJohn.Forte@Sun.COM #include <locale.h> 47*7836SJohn.Forte@Sun.COM #include <langinfo.h> 48*7836SJohn.Forte@Sun.COM #include <time.h> 49*7836SJohn.Forte@Sun.COM #include <stdarg.h> 50*7836SJohn.Forte@Sun.COM #include <sys/mman.h> 51*7836SJohn.Forte@Sun.COM #include <sys/ioctl.h> 52*7836SJohn.Forte@Sun.COM #include <sys/dditypes.h> 53*7836SJohn.Forte@Sun.COM #include <sys/modctl.h> 54*7836SJohn.Forte@Sun.COM #include <libdevinfo.h> 55*7836SJohn.Forte@Sun.COM #include <libdevice.h> 56*7836SJohn.Forte@Sun.COM #include <librcm.h> 57*7836SJohn.Forte@Sun.COM #include <dirent.h> 58*7836SJohn.Forte@Sun.COM #include <strings.h> 59*7836SJohn.Forte@Sun.COM 60*7836SJohn.Forte@Sun.COM 61*7836SJohn.Forte@Sun.COM #include <sys/ioctl.h> 62*7836SJohn.Forte@Sun.COM #include <sys/byteorder.h> 63*7836SJohn.Forte@Sun.COM #include <sys/scsi/scsi.h> 64*7836SJohn.Forte@Sun.COM #include <strings.h> 65*7836SJohn.Forte@Sun.COM #include <sys/vfstab.h> 66*7836SJohn.Forte@Sun.COM #include <sys/stat.h> 67*7836SJohn.Forte@Sun.COM #include <setjmp.h> 68*7836SJohn.Forte@Sun.COM #include <signal.h> 69*7836SJohn.Forte@Sun.COM #include <hbaapi.h> 70*7836SJohn.Forte@Sun.COM #include <sys/fibre-channel/fcio.h> 71*7836SJohn.Forte@Sun.COM #include <sys/fibre-channel/ulp/fcp_util.h> 72*7836SJohn.Forte@Sun.COM 73*7836SJohn.Forte@Sun.COM #include <sys/uio.h> 74*7836SJohn.Forte@Sun.COM #include <sys/param.h> 75*7836SJohn.Forte@Sun.COM 76*7836SJohn.Forte@Sun.COM #include <synch.h> 77*7836SJohn.Forte@Sun.COM #include <thread.h> 78*7836SJohn.Forte@Sun.COM 79*7836SJohn.Forte@Sun.COM #include <limits.h> 80*7836SJohn.Forte@Sun.COM #include <ftw.h> 81*7836SJohn.Forte@Sun.COM 82*7836SJohn.Forte@Sun.COM #define CFGA_PLUGIN_LIB 83*7836SJohn.Forte@Sun.COM #include <config_admin.h> 84*7836SJohn.Forte@Sun.COM 85*7836SJohn.Forte@Sun.COM #if !defined(DEBUG) 86*7836SJohn.Forte@Sun.COM #define NDEBUG 1 87*7836SJohn.Forte@Sun.COM #else 88*7836SJohn.Forte@Sun.COM #undef NDEBUG 89*7836SJohn.Forte@Sun.COM #endif 90*7836SJohn.Forte@Sun.COM 91*7836SJohn.Forte@Sun.COM #include <assert.h> 92*7836SJohn.Forte@Sun.COM 93*7836SJohn.Forte@Sun.COM /* Return/error codes */ 94*7836SJohn.Forte@Sun.COM typedef enum { 95*7836SJohn.Forte@Sun.COM FPCFGA_ERR = -2, 96*7836SJohn.Forte@Sun.COM FPCFGA_LIB_ERR = -1, 97*7836SJohn.Forte@Sun.COM FPCFGA_OK = 0, 98*7836SJohn.Forte@Sun.COM FPCFGA_ACCESS_OK, 99*7836SJohn.Forte@Sun.COM FPCFGA_NACK, 100*7836SJohn.Forte@Sun.COM FPCFGA_BUSY, 101*7836SJohn.Forte@Sun.COM FPCFGA_SYSTEM_BUSY, 102*7836SJohn.Forte@Sun.COM FPCFGA_APID_NOCONFIGURE, 103*7836SJohn.Forte@Sun.COM FPCFGA_APID_NOACCESS, 104*7836SJohn.Forte@Sun.COM FPCFGA_APID_NOEXIST, 105*7836SJohn.Forte@Sun.COM FPCFGA_OPNOTSUPP, 106*7836SJohn.Forte@Sun.COM FPCFGA_PRIV, 107*7836SJohn.Forte@Sun.COM FPCFGA_UNLOCKED, 108*7836SJohn.Forte@Sun.COM FPCFGA_NO_REC, 109*7836SJohn.Forte@Sun.COM FPCFGA_OP_INTR, 110*7836SJohn.Forte@Sun.COM FPCFGA_DB_INVAL, 111*7836SJohn.Forte@Sun.COM FPCFGA_CONF_OK_UPD_REP_FAILED, 112*7836SJohn.Forte@Sun.COM FPCFGA_UNCONF_OK_UPD_REP_FAILED, 113*7836SJohn.Forte@Sun.COM FPCFGA_INVALID_PATH, 114*7836SJohn.Forte@Sun.COM FPCFGA_VHCI_GET_PATHLIST_FAILED, 115*7836SJohn.Forte@Sun.COM FPCFGA_XPORT_NOT_IN_PHCI_LIST, 116*7836SJohn.Forte@Sun.COM FPCFGA_UNKNOWN_ERR, 117*7836SJohn.Forte@Sun.COM FPCFGA_FCP_TGT_SEND_SCSI_FAILED, 118*7836SJohn.Forte@Sun.COM FPCFGA_FCP_SEND_SCSI_DEV_NOT_TGT 119*7836SJohn.Forte@Sun.COM } fpcfga_ret_t; 120*7836SJohn.Forte@Sun.COM 121*7836SJohn.Forte@Sun.COM /* Commands used internally */ 122*7836SJohn.Forte@Sun.COM typedef enum { 123*7836SJohn.Forte@Sun.COM FPCFGA_INVAL_CMD = -1, 124*7836SJohn.Forte@Sun.COM FPCFGA_DEV_OP = 0, 125*7836SJohn.Forte@Sun.COM FPCFGA_BUS_OP, 126*7836SJohn.Forte@Sun.COM FPCFGA_STAT_FC_DEV, 127*7836SJohn.Forte@Sun.COM FPCFGA_STAT_FCA_PORT, 128*7836SJohn.Forte@Sun.COM FPCFGA_STAT_ALL, 129*7836SJohn.Forte@Sun.COM FPCFGA_GET_DEVPATH, 130*7836SJohn.Forte@Sun.COM FPCFGA_INSERT_DEV, 131*7836SJohn.Forte@Sun.COM FPCFGA_REMOVE_DEV, 132*7836SJohn.Forte@Sun.COM FPCFGA_REPLACE_DEV, 133*7836SJohn.Forte@Sun.COM FPCFGA_WALK_NODE, 134*7836SJohn.Forte@Sun.COM FPCFGA_WALK_MINOR, 135*7836SJohn.Forte@Sun.COM FPCFGA_BUS_QUIESCE, 136*7836SJohn.Forte@Sun.COM FPCFGA_BUS_UNQUIESCE, 137*7836SJohn.Forte@Sun.COM FPCFGA_BUS_GETSTATE, 138*7836SJohn.Forte@Sun.COM FPCFGA_DEV_GETSTATE, 139*7836SJohn.Forte@Sun.COM FPCFGA_BUS_CONFIGURE, 140*7836SJohn.Forte@Sun.COM FPCFGA_BUS_UNCONFIGURE, 141*7836SJohn.Forte@Sun.COM FPCFGA_DEV_CONFIGURE, 142*7836SJohn.Forte@Sun.COM FPCFGA_DEV_UNCONFIGURE, 143*7836SJohn.Forte@Sun.COM FPCFGA_DEV_REMOVE, 144*7836SJohn.Forte@Sun.COM FPCFGA_RESET_DEV, 145*7836SJohn.Forte@Sun.COM FPCFGA_RESET_BUS, 146*7836SJohn.Forte@Sun.COM FPCFGA_RESET_ALL, 147*7836SJohn.Forte@Sun.COM FPCFGA_READ, 148*7836SJohn.Forte@Sun.COM FPCFGA_WRITE 149*7836SJohn.Forte@Sun.COM } fpcfga_cmd_t; 150*7836SJohn.Forte@Sun.COM 151*7836SJohn.Forte@Sun.COM typedef enum { 152*7836SJohn.Forte@Sun.COM FPCFGA_TERMINATE = 0, 153*7836SJohn.Forte@Sun.COM FPCFGA_CONTINUE 154*7836SJohn.Forte@Sun.COM } fpcfga_recur_t; 155*7836SJohn.Forte@Sun.COM 156*7836SJohn.Forte@Sun.COM 157*7836SJohn.Forte@Sun.COM /* Structures for tree walking code */ 158*7836SJohn.Forte@Sun.COM 159*7836SJohn.Forte@Sun.COM typedef struct { 160*7836SJohn.Forte@Sun.COM uint_t flags; 161*7836SJohn.Forte@Sun.COM int (*fcn)(di_node_t node, void *argp); 162*7836SJohn.Forte@Sun.COM } walk_node_t; 163*7836SJohn.Forte@Sun.COM 164*7836SJohn.Forte@Sun.COM typedef struct { 165*7836SJohn.Forte@Sun.COM const char *nodetype; 166*7836SJohn.Forte@Sun.COM int (*fcn)(di_node_t node, di_minor_t minor, void *argp); 167*7836SJohn.Forte@Sun.COM } walk_minor_t; 168*7836SJohn.Forte@Sun.COM 169*7836SJohn.Forte@Sun.COM typedef union { 170*7836SJohn.Forte@Sun.COM walk_node_t node_args; 171*7836SJohn.Forte@Sun.COM walk_minor_t minor_args; 172*7836SJohn.Forte@Sun.COM } walkmode_t; 173*7836SJohn.Forte@Sun.COM 174*7836SJohn.Forte@Sun.COM typedef struct { 175*7836SJohn.Forte@Sun.COM uint_t flags; 176*7836SJohn.Forte@Sun.COM walkmode_t walkmode; 177*7836SJohn.Forte@Sun.COM } walkarg_t; 178*7836SJohn.Forte@Sun.COM 179*7836SJohn.Forte@Sun.COM typedef struct { 180*7836SJohn.Forte@Sun.COM char *phys; 181*7836SJohn.Forte@Sun.COM char *log; 182*7836SJohn.Forte@Sun.COM fpcfga_ret_t ret; 183*7836SJohn.Forte@Sun.COM int match_minor; 184*7836SJohn.Forte@Sun.COM int l_errno; 185*7836SJohn.Forte@Sun.COM } pathm_t; 186*7836SJohn.Forte@Sun.COM 187*7836SJohn.Forte@Sun.COM typedef struct ldata_list { 188*7836SJohn.Forte@Sun.COM cfga_list_data_t ldata; 189*7836SJohn.Forte@Sun.COM struct ldata_list *next; 190*7836SJohn.Forte@Sun.COM } ldata_list_t; 191*7836SJohn.Forte@Sun.COM 192*7836SJohn.Forte@Sun.COM typedef struct { 193*7836SJohn.Forte@Sun.COM struct cfga_confirm *confp; 194*7836SJohn.Forte@Sun.COM struct cfga_msg *msgp; 195*7836SJohn.Forte@Sun.COM } prompt_t; 196*7836SJohn.Forte@Sun.COM 197*7836SJohn.Forte@Sun.COM typedef struct luninfo_list { 198*7836SJohn.Forte@Sun.COM int lunnum; 199*7836SJohn.Forte@Sun.COM uint_t node_state; 200*7836SJohn.Forte@Sun.COM uint_t lun_flag; 201*7836SJohn.Forte@Sun.COM char *path; 202*7836SJohn.Forte@Sun.COM struct luninfo_list *next; 203*7836SJohn.Forte@Sun.COM } luninfo_list_t; 204*7836SJohn.Forte@Sun.COM 205*7836SJohn.Forte@Sun.COM typedef struct { 206*7836SJohn.Forte@Sun.COM char *xport_phys; 207*7836SJohn.Forte@Sun.COM char *dyncomp; 208*7836SJohn.Forte@Sun.COM uint_t flags; 209*7836SJohn.Forte@Sun.COM luninfo_list_t *lunlist; /* Singly linked list */ 210*7836SJohn.Forte@Sun.COM } apid_t; 211*7836SJohn.Forte@Sun.COM 212*7836SJohn.Forte@Sun.COM /* Report luns names */ 213*7836SJohn.Forte@Sun.COM #define FP_SCMD_REPORT_LUN 0xA0 214*7836SJohn.Forte@Sun.COM #define DEFAULT_NUM_LUN 1024 215*7836SJohn.Forte@Sun.COM #define REPORT_LUN_HDR_SIZE 8 216*7836SJohn.Forte@Sun.COM #define SAM_LUN_SIZE 8 217*7836SJohn.Forte@Sun.COM 218*7836SJohn.Forte@Sun.COM #ifdef _BIG_ENDIAN 219*7836SJohn.Forte@Sun.COM #define htonll(x) (x) 220*7836SJohn.Forte@Sun.COM #define ntohll(x) (x) 221*7836SJohn.Forte@Sun.COM #else 222*7836SJohn.Forte@Sun.COM #define htonll(x) ((((unsigned long long)htonl(x)) << 32) + htonl(x >> 32)) 223*7836SJohn.Forte@Sun.COM #define ntohll(x) ((((unsigned long long)ntohl(x)) << 32) + ntohl(x >> 32)) 224*7836SJohn.Forte@Sun.COM #endif 225*7836SJohn.Forte@Sun.COM 226*7836SJohn.Forte@Sun.COM typedef struct report_lun_resp { 227*7836SJohn.Forte@Sun.COM uint32_t num_lun; 228*7836SJohn.Forte@Sun.COM uint32_t reserved; 229*7836SJohn.Forte@Sun.COM longlong_t lun_string[DEFAULT_NUM_LUN]; 230*7836SJohn.Forte@Sun.COM } report_lun_resp_t; 231*7836SJohn.Forte@Sun.COM 232*7836SJohn.Forte@Sun.COM /* 233*7836SJohn.Forte@Sun.COM * Hardware options acceptable for fp plugin. 234*7836SJohn.Forte@Sun.COM * list related options are handled by getsupopts() and set to 235*7836SJohn.Forte@Sun.COM * index of array. 236*7836SJohn.Forte@Sun.COM */ 237*7836SJohn.Forte@Sun.COM #define OPT_DEVINFO_FORCE 0 238*7836SJohn.Forte@Sun.COM #define OPT_SHOW_SCSI_LUN 1 239*7836SJohn.Forte@Sun.COM #define OPT_FCP_DEV 2 240*7836SJohn.Forte@Sun.COM #define OPT_DISABLE_RCM 0 241*7836SJohn.Forte@Sun.COM #define OPT_FORCE_UPDATE_REP 1 242*7836SJohn.Forte@Sun.COM #define OPT_NO_UPDATE_REP 2 243*7836SJohn.Forte@Sun.COM #define OPT_REMOVE_UNUSABLE_SCSI_LUN 3 244*7836SJohn.Forte@Sun.COM #define OPT_REMOVE_UNUSABLE_FCP_DEV 4 245*7836SJohn.Forte@Sun.COM 246*7836SJohn.Forte@Sun.COM /* walk tree flag */ 247*7836SJohn.Forte@Sun.COM #define FLAG_PATH_INFO_WALK 0x00000001 248*7836SJohn.Forte@Sun.COM 249*7836SJohn.Forte@Sun.COM /* apid_t flags */ 250*7836SJohn.Forte@Sun.COM #define FLAG_DISABLE_RCM 0x00000001 251*7836SJohn.Forte@Sun.COM #define FLAG_FORCE_UPDATE_REP 0x00000010 252*7836SJohn.Forte@Sun.COM #define FLAG_NO_UPDATE_REP 0x00000100 253*7836SJohn.Forte@Sun.COM #define FLAG_DYN_AP_CONFIGURED 0x00001000 254*7836SJohn.Forte@Sun.COM #define FLAG_DEVINFO_FORCE 0x00010000 255*7836SJohn.Forte@Sun.COM #define FLAG_FCP_DEV 0x00100000 256*7836SJohn.Forte@Sun.COM #define FLAG_REMOVE_UNUSABLE_FCP_DEV 0x01000000 257*7836SJohn.Forte@Sun.COM 258*7836SJohn.Forte@Sun.COM /* apid_t lun flags */ 259*7836SJohn.Forte@Sun.COM #define FLAG_SKIP_RCMOFFLINE 0x00000001 260*7836SJohn.Forte@Sun.COM #define FLAG_SKIP_RCMREMOVE 0x00000010 261*7836SJohn.Forte@Sun.COM #define FLAG_SKIP_ONLINEOTHERS 0x00000100 262*7836SJohn.Forte@Sun.COM 263*7836SJohn.Forte@Sun.COM /* define for peripheral qualifier mask */ 264*7836SJohn.Forte@Sun.COM #define FP_PERI_QUAL_MASK 0xE0 265*7836SJohn.Forte@Sun.COM 266*7836SJohn.Forte@Sun.COM /* Message ids */ 267*7836SJohn.Forte@Sun.COM typedef enum { 268*7836SJohn.Forte@Sun.COM 269*7836SJohn.Forte@Sun.COM /* ERRORS */ 270*7836SJohn.Forte@Sun.COM ERR_UNKNOWN = -1, 271*7836SJohn.Forte@Sun.COM ERR_OP_FAILED, 272*7836SJohn.Forte@Sun.COM ERR_CMD_INVAL, 273*7836SJohn.Forte@Sun.COM ERR_NOT_BUSAPID, 274*7836SJohn.Forte@Sun.COM ERR_APID_INVAL, 275*7836SJohn.Forte@Sun.COM ERR_NOT_BUSOP, 276*7836SJohn.Forte@Sun.COM ERR_NOT_DEVOP, 277*7836SJohn.Forte@Sun.COM ERR_UNAVAILABLE, 278*7836SJohn.Forte@Sun.COM ERR_CTRLR_CRIT, 279*7836SJohn.Forte@Sun.COM ERR_BUS_GETSTATE, 280*7836SJohn.Forte@Sun.COM ERR_BUS_NOTCONNECTED, 281*7836SJohn.Forte@Sun.COM ERR_BUS_CONNECTED, 282*7836SJohn.Forte@Sun.COM ERR_BUS_QUIESCE, 283*7836SJohn.Forte@Sun.COM ERR_BUS_UNQUIESCE, 284*7836SJohn.Forte@Sun.COM ERR_BUS_CONFIGURE, 285*7836SJohn.Forte@Sun.COM ERR_BUS_UNCONFIGURE, 286*7836SJohn.Forte@Sun.COM ERR_DEV_CONFIGURE, 287*7836SJohn.Forte@Sun.COM ERR_DEV_UNCONFIGURE, 288*7836SJohn.Forte@Sun.COM ERR_FCA_CONFIGURE, 289*7836SJohn.Forte@Sun.COM ERR_FCA_UNCONFIGURE, 290*7836SJohn.Forte@Sun.COM ERR_DEV_REPLACE, 291*7836SJohn.Forte@Sun.COM ERR_DEV_INSERT, 292*7836SJohn.Forte@Sun.COM ERR_DEV_GETSTATE, 293*7836SJohn.Forte@Sun.COM ERR_RESET, 294*7836SJohn.Forte@Sun.COM ERR_LIST, 295*7836SJohn.Forte@Sun.COM ERR_FC, 296*7836SJohn.Forte@Sun.COM ERR_FC_GET_DEVLIST, 297*7836SJohn.Forte@Sun.COM ERR_FC_GET_FIRST_DEV, 298*7836SJohn.Forte@Sun.COM ERR_FC_GET_NEXT_DEV, 299*7836SJohn.Forte@Sun.COM ERRARG_FC_DEV_MAP_INIT, 300*7836SJohn.Forte@Sun.COM ERRARG_FC_PROP_LOOKUP_BYTES, 301*7836SJohn.Forte@Sun.COM ERRARG_FC_INQUIRY, 302*7836SJohn.Forte@Sun.COM ERRARG_FC_REP_LUNS, 303*7836SJohn.Forte@Sun.COM ERRARG_FC_TOPOLOGY, 304*7836SJohn.Forte@Sun.COM ERRARG_PATH_TOO_LONG, 305*7836SJohn.Forte@Sun.COM ERRARG_INVALID_PATH, 306*7836SJohn.Forte@Sun.COM ERRARG_OPENDIR, 307*7836SJohn.Forte@Sun.COM ERRARG_VHCI_GET_PATHLIST, 308*7836SJohn.Forte@Sun.COM ERRARG_XPORT_NOT_IN_PHCI_LIST, 309*7836SJohn.Forte@Sun.COM ERR_SIG_STATE, 310*7836SJohn.Forte@Sun.COM ERR_MAYBE_BUSY, 311*7836SJohn.Forte@Sun.COM ERR_BUS_DEV_MISMATCH, 312*7836SJohn.Forte@Sun.COM ERR_GET_DEVLIST, 313*7836SJohn.Forte@Sun.COM ERR_MEM_ALLOC, 314*7836SJohn.Forte@Sun.COM ERR_DEVCTL_OFFLINE, 315*7836SJohn.Forte@Sun.COM ERR_UPD_REP, 316*7836SJohn.Forte@Sun.COM ERR_CONF_OK_UPD_REP, 317*7836SJohn.Forte@Sun.COM ERR_UNCONF_OK_UPD_REP, 318*7836SJohn.Forte@Sun.COM ERR_PARTIAL_SUCCESS, 319*7836SJohn.Forte@Sun.COM ERR_HBA_LOAD_LIBRARY, 320*7836SJohn.Forte@Sun.COM ERR_MATCHING_HBA_PORT, 321*7836SJohn.Forte@Sun.COM ERR_NO_ADAPTER_FOUND, 322*7836SJohn.Forte@Sun.COM 323*7836SJohn.Forte@Sun.COM /* Errors with arguments */ 324*7836SJohn.Forte@Sun.COM ERRARG_OPT_INVAL, 325*7836SJohn.Forte@Sun.COM ERRARG_HWCMD_INVAL, 326*7836SJohn.Forte@Sun.COM ERRARG_DEVINFO, 327*7836SJohn.Forte@Sun.COM ERRARG_NOT_IN_DEVLIST, 328*7836SJohn.Forte@Sun.COM ERRARG_NOT_IN_DEVINFO, 329*7836SJohn.Forte@Sun.COM ERRARG_DI_GET_PROP, 330*7836SJohn.Forte@Sun.COM ERRARG_DC_DDEF_ALLOC, 331*7836SJohn.Forte@Sun.COM ERRARG_DC_BYTE_ARRAY, 332*7836SJohn.Forte@Sun.COM ERRARG_DC_BUS_ACQUIRE, 333*7836SJohn.Forte@Sun.COM ERRARG_BUS_DEV_CREATE, 334*7836SJohn.Forte@Sun.COM ERRARG_BUS_DEV_CREATE_UNKNOWN, 335*7836SJohn.Forte@Sun.COM ERRARG_DEV_ACQUIRE, 336*7836SJohn.Forte@Sun.COM ERRARG_DEV_REMOVE, 337*7836SJohn.Forte@Sun.COM 338*7836SJohn.Forte@Sun.COM /* RCM Errors */ 339*7836SJohn.Forte@Sun.COM ERR_RCM_HANDLE, 340*7836SJohn.Forte@Sun.COM ERRARG_RCM_SUSPEND, 341*7836SJohn.Forte@Sun.COM ERRARG_RCM_RESUME, 342*7836SJohn.Forte@Sun.COM ERRARG_RCM_OFFLINE, 343*7836SJohn.Forte@Sun.COM ERRARG_RCM_ONLINE, 344*7836SJohn.Forte@Sun.COM ERRARG_RCM_REMOVE, 345*7836SJohn.Forte@Sun.COM ERRARG_RCM_INFO, 346*7836SJohn.Forte@Sun.COM 347*7836SJohn.Forte@Sun.COM /* Commands */ 348*7836SJohn.Forte@Sun.COM CMD_INSERT_DEV, 349*7836SJohn.Forte@Sun.COM CMD_REMOVE_DEV, 350*7836SJohn.Forte@Sun.COM CMD_REPLACE_DEV, 351*7836SJohn.Forte@Sun.COM CMD_RESET_DEV, 352*7836SJohn.Forte@Sun.COM CMD_RESET_BUS, 353*7836SJohn.Forte@Sun.COM CMD_RESET_ALL, 354*7836SJohn.Forte@Sun.COM 355*7836SJohn.Forte@Sun.COM /* help messages */ 356*7836SJohn.Forte@Sun.COM MSG_HELP_HDR, 357*7836SJohn.Forte@Sun.COM MSG_HELP_USAGE, 358*7836SJohn.Forte@Sun.COM 359*7836SJohn.Forte@Sun.COM /* Hotplug messages */ 360*7836SJohn.Forte@Sun.COM MSG_INSDEV, 361*7836SJohn.Forte@Sun.COM MSG_RMDEV, 362*7836SJohn.Forte@Sun.COM MSG_REPLDEV, 363*7836SJohn.Forte@Sun.COM 364*7836SJohn.Forte@Sun.COM /* Hotplugging confirmation prompts */ 365*7836SJohn.Forte@Sun.COM CONF_QUIESCE_1, 366*7836SJohn.Forte@Sun.COM CONF_QUIESCE_2, 367*7836SJohn.Forte@Sun.COM CONF_UNQUIESCE, 368*7836SJohn.Forte@Sun.COM 369*7836SJohn.Forte@Sun.COM /* Misc. */ 370*7836SJohn.Forte@Sun.COM WARN_DISCONNECT 371*7836SJohn.Forte@Sun.COM } msgid_t; 372*7836SJohn.Forte@Sun.COM 373*7836SJohn.Forte@Sun.COM typedef struct { 374*7836SJohn.Forte@Sun.COM msgid_t str_id; 375*7836SJohn.Forte@Sun.COM fpcfga_cmd_t cmd; 376*7836SJohn.Forte@Sun.COM fpcfga_ret_t (*fcn)(fpcfga_cmd_t, apid_t *, prompt_t *, char **); 377*7836SJohn.Forte@Sun.COM } hw_cmd_t; 378*7836SJohn.Forte@Sun.COM 379*7836SJohn.Forte@Sun.COM typedef struct { 380*7836SJohn.Forte@Sun.COM msgid_t msgid; 381*7836SJohn.Forte@Sun.COM int nargs; /* Number of arguments following msgid */ 382*7836SJohn.Forte@Sun.COM int intl; /* Flag: if 1, internationalize */ 383*7836SJohn.Forte@Sun.COM const char *msgstr; 384*7836SJohn.Forte@Sun.COM } msgcvt_t; 385*7836SJohn.Forte@Sun.COM 386*7836SJohn.Forte@Sun.COM 387*7836SJohn.Forte@Sun.COM #define SLASH "/" 388*7836SJohn.Forte@Sun.COM #define CFGA_DEV_DIR "/dev/cfg" 389*7836SJohn.Forte@Sun.COM #define DEV_DIR "/dev" 390*7836SJohn.Forte@Sun.COM #define DEVICES_DIR "/devices" 391*7836SJohn.Forte@Sun.COM #define DEV_DSK "/dev/dsk" 392*7836SJohn.Forte@Sun.COM #define DEV_RDSK "/dev/rdsk" 393*7836SJohn.Forte@Sun.COM #define DEV_RMT "/dev/rmt" 394*7836SJohn.Forte@Sun.COM #define DSK_DIR "dsk" 395*7836SJohn.Forte@Sun.COM #define RDSK_DIR "rdsk" 396*7836SJohn.Forte@Sun.COM #define RMT_DIR "rmt" 397*7836SJohn.Forte@Sun.COM 398*7836SJohn.Forte@Sun.COM 399*7836SJohn.Forte@Sun.COM #define DYN_SEP "::" 400*7836SJohn.Forte@Sun.COM #define LUN_COMP_SEP "," 401*7836SJohn.Forte@Sun.COM #define MINOR_SEP ":" 402*7836SJohn.Forte@Sun.COM 403*7836SJohn.Forte@Sun.COM #define S_FREE(x) (((x) != NULL) ? (free(x), (x) = NULL) : (void *)0) 404*7836SJohn.Forte@Sun.COM #define S_STR(x) (((x) == NULL) ? "" : (x)) 405*7836SJohn.Forte@Sun.COM 406*7836SJohn.Forte@Sun.COM 407*7836SJohn.Forte@Sun.COM #define IS_STUB_NODE(s) (di_instance(s) == -1 && \ 408*7836SJohn.Forte@Sun.COM di_nodeid(s) == (DI_PROM_NODEID)) 409*7836SJohn.Forte@Sun.COM 410*7836SJohn.Forte@Sun.COM #define GET_MSG_STR(i) (str_tbl[msg_idx(i)].msgstr) 411*7836SJohn.Forte@Sun.COM 412*7836SJohn.Forte@Sun.COM #define GET_DYN(a) (((a) != NULL) ? strstr((a), DYN_SEP) : (void *)0) 413*7836SJohn.Forte@Sun.COM #define GET_LUN_DYN(a) (((a) != NULL) ? strstr((a), LUN_COMP_SEP) : (void *)0) 414*7836SJohn.Forte@Sun.COM 415*7836SJohn.Forte@Sun.COM /* 416*7836SJohn.Forte@Sun.COM * The following macro removes the separator from the dynamic component. 417*7836SJohn.Forte@Sun.COM */ 418*7836SJohn.Forte@Sun.COM #define DYN_TO_DYNCOMP(a) ((a) + strlen(DYN_SEP)) 419*7836SJohn.Forte@Sun.COM #define LUN_DYN_TO_LUNCOMP(a) ((a) + strlen(LUN_COMP_SEP)) 420*7836SJohn.Forte@Sun.COM 421*7836SJohn.Forte@Sun.COM /* 422*7836SJohn.Forte@Sun.COM * Property names 423*7836SJohn.Forte@Sun.COM */ 424*7836SJohn.Forte@Sun.COM #define PORT_WWN_PROP "port-wwn" 425*7836SJohn.Forte@Sun.COM #define LUN_GUID_PROP "client-guid" 426*7836SJohn.Forte@Sun.COM #define LUN_PROP "lun" 427*7836SJohn.Forte@Sun.COM 428*7836SJohn.Forte@Sun.COM #define WWN_S_LEN 17 /* NULL terminated string */ 429*7836SJohn.Forte@Sun.COM #define WWN_SIZE 8 430*7836SJohn.Forte@Sun.COM /* Constants used for repository updates */ 431*7836SJohn.Forte@Sun.COM #define ADD_ENTRY 0 432*7836SJohn.Forte@Sun.COM #define REMOVE_ENTRY 1 433*7836SJohn.Forte@Sun.COM 434*7836SJohn.Forte@Sun.COM #define FAB_REPOSITORY_DIR "/etc/cfg/fp" 435*7836SJohn.Forte@Sun.COM #define FAB_REPOSITORY "/etc/cfg/fp/fabric_WWN_map" 436*7836SJohn.Forte@Sun.COM #define TMP_FAB_REPOSITORY "/etc/cfg/fp/fabric_WWN_map.tmp" 437*7836SJohn.Forte@Sun.COM #define OLD_FAB_REPOSITORY "/etc/cfg/fp/fabric_WWN_map.old" 438*7836SJohn.Forte@Sun.COM 439*7836SJohn.Forte@Sun.COM /* MPXIO VHCI root dir */ 440*7836SJohn.Forte@Sun.COM #define SCSI_VHCI_ROOT "/devices/scsi_vhci/" 441*7836SJohn.Forte@Sun.COM #define SCSI_VHCI_DRVR "scsi_vhci" 442*7836SJohn.Forte@Sun.COM #define HBA_MAX_RETRIES 10 443*7836SJohn.Forte@Sun.COM 444*7836SJohn.Forte@Sun.COM /* Function prototypes */ 445*7836SJohn.Forte@Sun.COM 446*7836SJohn.Forte@Sun.COM fpcfga_ret_t get_report_lun_data(const char *xport_phys, 447*7836SJohn.Forte@Sun.COM const char *dyncomp, int *num_luns, report_lun_resp_t **resp_buf, 448*7836SJohn.Forte@Sun.COM struct scsi_extended_sense *sense, int *l_errnop); 449*7836SJohn.Forte@Sun.COM /* Functions in cfga_cs.c */ 450*7836SJohn.Forte@Sun.COM fpcfga_ret_t 451*7836SJohn.Forte@Sun.COM dev_change_state(cfga_cmd_t, apid_t *, la_wwn_t *, cfga_flags_t, char **, 452*7836SJohn.Forte@Sun.COM HBA_HANDLE handle, HBA_PORTATTRIBUTES portAttrs); 453*7836SJohn.Forte@Sun.COM fpcfga_ret_t 454*7836SJohn.Forte@Sun.COM fca_change_state(cfga_cmd_t, apid_t *, cfga_flags_t, char **); 455*7836SJohn.Forte@Sun.COM 456*7836SJohn.Forte@Sun.COM /* Functions in cfga_rep.c */ 457*7836SJohn.Forte@Sun.COM int update_fabric_wwn_list(int, const char *, char **); 458*7836SJohn.Forte@Sun.COM 459*7836SJohn.Forte@Sun.COM fpcfga_ret_t dev_insert(fpcfga_cmd_t cmd, apid_t *apidp, prompt_t *argsp, 460*7836SJohn.Forte@Sun.COM char **errstring); 461*7836SJohn.Forte@Sun.COM fpcfga_ret_t dev_replace(fpcfga_cmd_t cmd, apid_t *apidp, prompt_t *argsp, 462*7836SJohn.Forte@Sun.COM char **errstring); 463*7836SJohn.Forte@Sun.COM fpcfga_ret_t dev_remove(fpcfga_cmd_t cmd, apid_t *apidp, prompt_t *argsp, 464*7836SJohn.Forte@Sun.COM char **errstring); 465*7836SJohn.Forte@Sun.COM fpcfga_ret_t reset_common(fpcfga_cmd_t cmd, apid_t *apidp, prompt_t *argsp, 466*7836SJohn.Forte@Sun.COM char **errstring); 467*7836SJohn.Forte@Sun.COM 468*7836SJohn.Forte@Sun.COM 469*7836SJohn.Forte@Sun.COM /* List related routines */ 470*7836SJohn.Forte@Sun.COM fpcfga_ret_t do_list(apid_t *apidp, fpcfga_cmd_t cmd, 471*7836SJohn.Forte@Sun.COM ldata_list_t **ldatalistp, int *nelem, char **errstring); 472*7836SJohn.Forte@Sun.COM fpcfga_ret_t do_list_FCP_dev(const char *ap_id, uint_t flags, fpcfga_cmd_t cmd, 473*7836SJohn.Forte@Sun.COM ldata_list_t **llpp, int *nelemp, char **errstring); 474*7836SJohn.Forte@Sun.COM fpcfga_ret_t list_ext_postprocess(ldata_list_t **ldatalistp, int nelem, 475*7836SJohn.Forte@Sun.COM cfga_list_data_t **ap_id_list, int *nlistp, char **errstring); 476*7836SJohn.Forte@Sun.COM int stat_path_info_node(di_node_t root, void *arg, int *l_errnop); 477*7836SJohn.Forte@Sun.COM 478*7836SJohn.Forte@Sun.COM /* Conversion routines */ 479*7836SJohn.Forte@Sun.COM fpcfga_ret_t make_xport_logid(const char *xport_phys, char **xport_logpp, 480*7836SJohn.Forte@Sun.COM int *l_errnop); 481*7836SJohn.Forte@Sun.COM fpcfga_ret_t dyn_apid_to_path(const char *xport_phys, const char *dyncomp, 482*7836SJohn.Forte@Sun.COM struct luninfo_list **lunlistpp, int *l_errnop); 483*7836SJohn.Forte@Sun.COM void cvt_lawwn_to_dyncomp(const la_wwn_t *pwwn, char **dyncomp, int *l_errnop); 484*7836SJohn.Forte@Sun.COM int cvt_dyncomp_to_lawwn(const char *dyncomp, la_wwn_t *port_wwn); 485*7836SJohn.Forte@Sun.COM fpcfga_ret_t make_dyncomp_from_dinode(const di_node_t node, char **dyncompp, 486*7836SJohn.Forte@Sun.COM int *l_errnop); 487*7836SJohn.Forte@Sun.COM fpcfga_ret_t make_portwwn_luncomp_from_dinode(const di_node_t node, 488*7836SJohn.Forte@Sun.COM char **dyncompp, int **luncompp, int *l_errnop); 489*7836SJohn.Forte@Sun.COM fpcfga_ret_t make_portwwn_luncomp_from_pinode(const di_path_t pinode, 490*7836SJohn.Forte@Sun.COM char **dyncompp, int **luncompp, int *l_errnop); 491*7836SJohn.Forte@Sun.COM fpcfga_ret_t construct_nodepath_from_dinode(const di_node_t node, 492*7836SJohn.Forte@Sun.COM char **node_pathp, int *l_errnop); 493*7836SJohn.Forte@Sun.COM u_longlong_t wwnConversion(uchar_t *wwn); 494*7836SJohn.Forte@Sun.COM 495*7836SJohn.Forte@Sun.COM 496*7836SJohn.Forte@Sun.COM /* Functions in cfga_rcm.c */ 497*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_offline(char *, char **, cfga_flags_t); 498*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_online(char *, char **, cfga_flags_t); 499*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_remove(char *, char **, cfga_flags_t); 500*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_suspend(char *, char *, char **, cfga_flags_t); 501*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_resume(char *, char *, char **, cfga_flags_t); 502*7836SJohn.Forte@Sun.COM fpcfga_ret_t fp_rcm_info(char *, char **, char **); 503*7836SJohn.Forte@Sun.COM 504*7836SJohn.Forte@Sun.COM /* Utility routines */ 505*7836SJohn.Forte@Sun.COM fpcfga_ret_t physpath_to_devlink(const char *basedir, char *xport_phys, 506*7836SJohn.Forte@Sun.COM char **xport_logpp, int *l_errnop, int match_minor); 507*7836SJohn.Forte@Sun.COM fpcfga_ret_t recurse_dev(const char *basedir, void *arg, 508*7836SJohn.Forte@Sun.COM fpcfga_recur_t (*fcn)(const char *lpath, void *arg)); 509*7836SJohn.Forte@Sun.COM fpcfga_ret_t apidt_create(const char *ap_id, apid_t *apidp, 510*7836SJohn.Forte@Sun.COM char **errstring); 511*7836SJohn.Forte@Sun.COM void apidt_free(apid_t *apidp); 512*7836SJohn.Forte@Sun.COM cfga_err_t err_cvt(fpcfga_ret_t err); 513*7836SJohn.Forte@Sun.COM void list_free(ldata_list_t **llpp); 514*7836SJohn.Forte@Sun.COM int known_state(di_node_t node); 515*7836SJohn.Forte@Sun.COM 516*7836SJohn.Forte@Sun.COM fpcfga_ret_t devctl_cmd(const char *ap_id, fpcfga_cmd_t cmd, 517*7836SJohn.Forte@Sun.COM uint_t *statep, int *l_errnop); 518*7836SJohn.Forte@Sun.COM fpcfga_ret_t invoke_cmd(const char *func, apid_t *apidt, prompt_t *prp, 519*7836SJohn.Forte@Sun.COM char **errstring); 520*7836SJohn.Forte@Sun.COM 521*7836SJohn.Forte@Sun.COM void cfga_err(char **errstring, int use_errno, ...); 522*7836SJohn.Forte@Sun.COM void cfga_msg(struct cfga_msg *msgp, ...); 523*7836SJohn.Forte@Sun.COM char *cfga_str(int append_newline, ...); 524*7836SJohn.Forte@Sun.COM int msg_idx(msgid_t msgid); 525*7836SJohn.Forte@Sun.COM fpcfga_ret_t walk_tree(const char *physpath, void *arg, uint_t init_flags, 526*7836SJohn.Forte@Sun.COM walkarg_t *up, fpcfga_cmd_t cmd, int *l_errnop); 527*7836SJohn.Forte@Sun.COM int hba_dev_cmp(const char *hba, const char *dev); 528*7836SJohn.Forte@Sun.COM int dev_cmp(const char *dev1, const char *dev2, int match_minor); 529*7836SJohn.Forte@Sun.COM char *pathdup(const char *path, int *l_errnop); 530*7836SJohn.Forte@Sun.COM int getPortAttrsByWWN(HBA_HANDLE handle, HBA_WWN wwn, 531*7836SJohn.Forte@Sun.COM HBA_PORTATTRIBUTES *attrs); 532*7836SJohn.Forte@Sun.COM int getDiscPortAttrs(HBA_HANDLE handle, int portIndex, 533*7836SJohn.Forte@Sun.COM int discIndex, HBA_PORTATTRIBUTES *attrs); 534*7836SJohn.Forte@Sun.COM int getAdapterPortAttrs(HBA_HANDLE handle, int portIndex, 535*7836SJohn.Forte@Sun.COM HBA_PORTATTRIBUTES *attrs); 536*7836SJohn.Forte@Sun.COM int getAdapterAttrs(HBA_HANDLE handle, HBA_ADAPTERATTRIBUTES *attrs); 537*7836SJohn.Forte@Sun.COM fpcfga_ret_t findMatchingAdapterPort(char *portPath, 538*7836SJohn.Forte@Sun.COM HBA_HANDLE *matchingHandle, int *matchingPortIndex, 539*7836SJohn.Forte@Sun.COM HBA_PORTATTRIBUTES *matchingPortAttrs, char **errstring); 540*7836SJohn.Forte@Sun.COM 541*7836SJohn.Forte@Sun.COM extern msgcvt_t str_tbl[]; 542*7836SJohn.Forte@Sun.COM 543*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 544*7836SJohn.Forte@Sun.COM } 545*7836SJohn.Forte@Sun.COM #endif 546*7836SJohn.Forte@Sun.COM 547*7836SJohn.Forte@Sun.COM #endif /* _CFGA_FP_H */ 548