1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _PICLFRUTREE_H 28*0Sstevel@tonic-gate #define _PICLFRUTREE_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/param.h> 33*0Sstevel@tonic-gate #include <syslog.h> 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifdef __cplusplus 36*0Sstevel@tonic-gate extern "C" { 37*0Sstevel@tonic-gate #endif 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate typedef enum { 40*0Sstevel@tonic-gate NONE = 0x0, 41*0Sstevel@tonic-gate FRUTREE_INIT = 0x1, 42*0Sstevel@tonic-gate EVENTS = 0x2, 43*0Sstevel@tonic-gate HASHTABLE = 0x4, 44*0Sstevel@tonic-gate PERF_DATA = 0x8, 45*0Sstevel@tonic-gate EV_COMPLETION = 0x10, 46*0Sstevel@tonic-gate PRINT_ALL = 0xFF 47*0Sstevel@tonic-gate } frutree_debug_t; 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define FRUTREE_DEBUG0(lvl, fmt) \ 50*0Sstevel@tonic-gate if (lvl & frutree_debug) { \ 51*0Sstevel@tonic-gate syslog(LOG_DEBUG, fmt); \ 52*0Sstevel@tonic-gate } 53*0Sstevel@tonic-gate #define FRUTREE_DEBUG1(lvl, fmt, d1) \ 54*0Sstevel@tonic-gate if (lvl & frutree_debug) { \ 55*0Sstevel@tonic-gate syslog(LOG_DEBUG, fmt, d1); \ 56*0Sstevel@tonic-gate } 57*0Sstevel@tonic-gate #define FRUTREE_DEBUG2(lvl, fmt, d1, d2) \ 58*0Sstevel@tonic-gate if (lvl & frutree_debug) { \ 59*0Sstevel@tonic-gate syslog(LOG_DEBUG, fmt, d1, d2); \ 60*0Sstevel@tonic-gate } 61*0Sstevel@tonic-gate #define FRUTREE_DEBUG3(lvl, fmt, d1, d2, d3) \ 62*0Sstevel@tonic-gate if (lvl & frutree_debug) { \ 63*0Sstevel@tonic-gate syslog(LOG_DEBUG, fmt, d1, d2, d3); \ 64*0Sstevel@tonic-gate } 65*0Sstevel@tonic-gate #define FRUTREE_DEBUG4(lvl, fmt, d1, d2, d3, d4) \ 66*0Sstevel@tonic-gate if (lvl & frutree_debug) {\ 67*0Sstevel@tonic-gate syslog(LOG_DEBUG, fmt, d1, d2, d3, d4); \ 68*0Sstevel@tonic-gate } 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate /* environment variables to tune the variables */ 71*0Sstevel@tonic-gate #define FRUTREE_DEBUG "SUNW_FRUTREE_DEBUG" 72*0Sstevel@tonic-gate #define FRUTREE_POLL_TIMEOUT "SUNW_FRUTREE_POLL_TIMEOUT" 73*0Sstevel@tonic-gate #define FRUTREE_DRWAIT "SUNW_FRUTREE_DRWAIT_TIME" 74*0Sstevel@tonic-gate 75*0Sstevel@tonic-gate /* PICL defines */ 76*0Sstevel@tonic-gate #define PICL_NODE_CHASSIS "chassis" 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* Sanibel specific defines */ 79*0Sstevel@tonic-gate #define SANIBEL_PICLNODE_CPU "CPU" 80*0Sstevel@tonic-gate #define SANIBEL_PICLNODE_PARALLEL "ecpp" 81*0Sstevel@tonic-gate #define SANIBEL_NETWORK_LABEL "ENET" 82*0Sstevel@tonic-gate #define SANIBEL_CPCISLOT_TYPE "cpci" 83*0Sstevel@tonic-gate #define SANIBEL_NETWORK_PORT "network" 84*0Sstevel@tonic-gate #define SANIBEL_SERIAL_PORT "serial" 85*0Sstevel@tonic-gate #define SANIBEL_PARALLEL_PORT "parallel" 86*0Sstevel@tonic-gate #define SANIBEL_SCSI_SLOT "scsi" 87*0Sstevel@tonic-gate #define SANIBEL_IDE_SLOT "ide" 88*0Sstevel@tonic-gate #define SANIBEL_UNKNOWN_SLOT "unknown" 89*0Sstevel@tonic-gate #define DEVICE_CLASS_SCSI "scsi" 90*0Sstevel@tonic-gate #define DEVICE_CLASS_IDE "dada" 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate #define MAX_BUFSIZE 512 93*0Sstevel@tonic-gate #define SUPER_USER 0 94*0Sstevel@tonic-gate #define DEVFSADM_CMD "/usr/sbin/devfsadm -i" 95*0Sstevel@tonic-gate #define TEMP_DIR "/var/tmp/" 96*0Sstevel@tonic-gate #define PROBE_FILE "probed" 97*0Sstevel@tonic-gate #define NULLREAD (int (*)(ptree_rarg_t *, void *))0 98*0Sstevel@tonic-gate #define NULLWRITE (int (*)(ptree_warg_t *, const void *))0 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate #define PTREE_CREATE_PROP_FAILED \ 101*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in creating property:%s, "\ 102*0Sstevel@tonic-gate "under %s(error=%d)") 103*0Sstevel@tonic-gate #define PTREE_POST_PICLEVENT_ERR \ 104*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in posting picl event %s(%s)(error=%d)") 105*0Sstevel@tonic-gate #define PTREE_EVENT_HANDLING_ERR \ 106*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in handling %s event on %s(error=%d)") 107*0Sstevel@tonic-gate #define GET_LOC_STATE_ERR \ 108*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in getting state info for %s"\ 109*0Sstevel@tonic-gate "(location)(error=%d)") 110*0Sstevel@tonic-gate #define GET_FRU_STATE_ERR \ 111*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in getting state for %s(fru)(error=%d)") 112*0Sstevel@tonic-gate #define GET_FRU_COND_ERR \ 113*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in getting condition for %s(fru)(error=%d)") 114*0Sstevel@tonic-gate #define CONNECT_FAILED_ERR \ 115*0Sstevel@tonic-gate gettext("SUNW_frutree:Connect operation on %s failed(error=%d)") 116*0Sstevel@tonic-gate #define CONFIGURE_FAILED_ERR \ 117*0Sstevel@tonic-gate gettext("SUNW_frutree:Configure operation on %s failed(error=%d)") 118*0Sstevel@tonic-gate #define UNCONFIG_FAILED_ERR \ 119*0Sstevel@tonic-gate gettext("SUNW_frutree:Unconfigure operation on %s failed(error=%d)") 120*0Sstevel@tonic-gate #define DISCONNECT_FAILED_ERR \ 121*0Sstevel@tonic-gate gettext("SUNW_frutree:Disconnect operation on %s failed(error=%d)") 122*0Sstevel@tonic-gate #define PROBE_FRU_ERR \ 123*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in probing fru under %s(error=%d)") 124*0Sstevel@tonic-gate #define PTREE_UPDATE_PROP_ERR \ 125*0Sstevel@tonic-gate gettext("SUNW_frutree:Error updating %s of %s(error=%d)") 126*0Sstevel@tonic-gate #define PTREE_GET_PROPVAL_ERR \ 127*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in getting value of %s(%s)(error=%d)") 128*0Sstevel@tonic-gate #define PTREE_DEVICE_CREATE_ERR \ 129*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in creating nodes under %s(error=%d)") 130*0Sstevel@tonic-gate #define EVENT_NOT_HANDLED \ 131*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in handling %s on %s(error=%d)") 132*0Sstevel@tonic-gate #define ERROR_REINIT \ 133*0Sstevel@tonic-gate gettext("SUNW_frutree:Error in reinitializing %s") 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate typedef enum { 136*0Sstevel@tonic-gate NO_WAIT = 0, 137*0Sstevel@tonic-gate WAIT 138*0Sstevel@tonic-gate } frutree_wait_t; 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gate typedef uint8_t frutree_frustate_t; 141*0Sstevel@tonic-gate typedef uint8_t frutree_frucond_t; 142*0Sstevel@tonic-gate typedef uint8_t frutree_locstate_t; 143*0Sstevel@tonic-gate typedef uint8_t frutree_port_type_t; 144*0Sstevel@tonic-gate typedef uint8_t frutree_datatype_t; 145*0Sstevel@tonic-gate typedef uint8_t frutree_loctype_t; 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate /* valid fru states */ 148*0Sstevel@tonic-gate #define FRU_STATE_UNKNOWN 0x0 149*0Sstevel@tonic-gate #define FRU_STATE_CONFIGURED 0x1 150*0Sstevel@tonic-gate #define FRU_STATE_UNCONFIGURED 0x2 151*0Sstevel@tonic-gate #define FRU_STATE_CONFIGURING 0x3 152*0Sstevel@tonic-gate #define FRU_STATE_UNCONFIGURING 0x4 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate /* valid fru condition */ 155*0Sstevel@tonic-gate #define FRU_COND_UNKNOWN 0x0 156*0Sstevel@tonic-gate #define FRU_COND_FAILED 0x1 157*0Sstevel@tonic-gate #define FRU_COND_FAILING 0x2 158*0Sstevel@tonic-gate #define FRU_COND_OK 0x3 159*0Sstevel@tonic-gate #define FRU_COND_TESTING 0x4 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate /* port states */ 162*0Sstevel@tonic-gate #define PORT_STATE_DOWN 0x0 163*0Sstevel@tonic-gate #define PORT_STATE_UP 0x1 164*0Sstevel@tonic-gate #define PORT_STATE_UNKNOWN 0x2 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate /* port condition */ 167*0Sstevel@tonic-gate #define PORT_COND_OK 0x0 168*0Sstevel@tonic-gate #define PORT_COND_FAILING 0x1 169*0Sstevel@tonic-gate #define PORT_COND_FAILED 0x2 170*0Sstevel@tonic-gate #define PORT_COND_TESTING 0x3 171*0Sstevel@tonic-gate #define PORT_COND_UNKNOWN 0x4 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate /* port types */ 174*0Sstevel@tonic-gate #define NETWORK_PORT 0x0 175*0Sstevel@tonic-gate #define SERIAL_PORT 0x1 176*0Sstevel@tonic-gate #define PARALLEL_PORT 0x2 177*0Sstevel@tonic-gate #define UNKNOWN_PORT 0x4 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate /* location states */ 180*0Sstevel@tonic-gate #define LOC_STATE_UNKNOWN 0x0 181*0Sstevel@tonic-gate #define LOC_STATE_EMPTY 0x1 182*0Sstevel@tonic-gate #define LOC_STATE_CONNECTED 0x2 183*0Sstevel@tonic-gate #define LOC_STATE_DISCONNECTED 0x3 184*0Sstevel@tonic-gate #define LOC_STATE_CONNECTING 0x4 185*0Sstevel@tonic-gate #define LOC_STATE_DISCONNECTING 0x5 186*0Sstevel@tonic-gate 187*0Sstevel@tonic-gate /* types of nodes */ 188*0Sstevel@tonic-gate #define LOC_TYPE 0x0 189*0Sstevel@tonic-gate #define FRU_TYPE 0x1 190*0Sstevel@tonic-gate #define PORT_TYPE 0x2 191*0Sstevel@tonic-gate 192*0Sstevel@tonic-gate /* location managers */ 193*0Sstevel@tonic-gate #define CFGADM_AP 0x0 /* managed based on cfgadm data */ 194*0Sstevel@tonic-gate #define PLUGIN_PVT 0x1 /* managed by other plugin */ 195*0Sstevel@tonic-gate #define STATIC_LOC 0x2 /* managed based on libdevinfo */ 196*0Sstevel@tonic-gate #define UNKNOWN 0x3 /* unknown */ 197*0Sstevel@tonic-gate 198*0Sstevel@tonic-gate typedef struct conf_cache { 199*0Sstevel@tonic-gate char buf[MAX_BUFSIZE]; 200*0Sstevel@tonic-gate struct conf_cache *next; 201*0Sstevel@tonic-gate } frutree_cache_t; 202*0Sstevel@tonic-gate 203*0Sstevel@tonic-gate typedef struct { 204*0Sstevel@tonic-gate picl_nodehdl_t nodeh; 205*0Sstevel@tonic-gate picl_prophdl_t device_tblhdl; 206*0Sstevel@tonic-gate picl_prophdl_t env_tblhdl; 207*0Sstevel@tonic-gate frutree_cache_t *first; 208*0Sstevel@tonic-gate frutree_cache_t *last; 209*0Sstevel@tonic-gate boolean_t create_cache; 210*0Sstevel@tonic-gate } frutree_device_args_t; 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate typedef struct loc_node frutree_locnode_t; 213*0Sstevel@tonic-gate typedef struct fru_node frutree_frunode_t; 214*0Sstevel@tonic-gate typedef struct port_node frutree_portnode_t; 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate /* information on a particular location */ 217*0Sstevel@tonic-gate struct loc_node { 218*0Sstevel@tonic-gate picl_nodehdl_t locnodeh; /* handle of the loc node itself */ 219*0Sstevel@tonic-gate char *name; 220*0Sstevel@tonic-gate boolean_t cpu_node; 221*0Sstevel@tonic-gate boolean_t dr_in_progress; 222*0Sstevel@tonic-gate boolean_t autoconfig_enabled; 223*0Sstevel@tonic-gate frutree_loctype_t state_mgr; /* state manager */ 224*0Sstevel@tonic-gate frutree_locstate_t state; /* present state */ 225*0Sstevel@tonic-gate frutree_locstate_t prev_state; /* previous state */ 226*0Sstevel@tonic-gate pthread_mutex_t mutex; 227*0Sstevel@tonic-gate pthread_cond_t cond_cv; 228*0Sstevel@tonic-gate }; 229*0Sstevel@tonic-gate 230*0Sstevel@tonic-gate /* information on a particular port */ 231*0Sstevel@tonic-gate struct port_node { 232*0Sstevel@tonic-gate picl_nodehdl_t portnodeh; 233*0Sstevel@tonic-gate char *name; 234*0Sstevel@tonic-gate int state; 235*0Sstevel@tonic-gate int cond; 236*0Sstevel@tonic-gate uint8_t instance; 237*0Sstevel@tonic-gate char driver[MAXPATHLEN]; 238*0Sstevel@tonic-gate }; 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate /* information on a particular fru */ 241*0Sstevel@tonic-gate struct fru_node { 242*0Sstevel@tonic-gate /* variable data */ 243*0Sstevel@tonic-gate picl_nodehdl_t frunodeh; 244*0Sstevel@tonic-gate char *name; 245*0Sstevel@tonic-gate frutree_frustate_t state; 246*0Sstevel@tonic-gate frutree_frustate_t prev_state; 247*0Sstevel@tonic-gate frutree_frucond_t cond; 248*0Sstevel@tonic-gate frutree_frucond_t prev_cond; 249*0Sstevel@tonic-gate boolean_t cpu_node; 250*0Sstevel@tonic-gate boolean_t autoconfig_enabled; 251*0Sstevel@tonic-gate boolean_t dr_in_progress; 252*0Sstevel@tonic-gate boolean_t busy; 253*0Sstevel@tonic-gate frutree_loctype_t state_mgr; 254*0Sstevel@tonic-gate char fru_path[MAXPATHLEN]; 255*0Sstevel@tonic-gate pthread_mutex_t mutex; 256*0Sstevel@tonic-gate pthread_cond_t cond_cv; 257*0Sstevel@tonic-gate pthread_cond_t busy_cond_cv; 258*0Sstevel@tonic-gate }; 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gate #ifdef __cplusplus 261*0Sstevel@tonic-gate } 262*0Sstevel@tonic-gate #endif 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate #endif /* _PICLFRUTREE_H */ 265