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