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