xref: /titanic_50/usr/src/lib/fm/topo/libtopo/common/libtopo.h (revision 9a4611f412a6b1f7a0bc7d53d2bb046a95daa4bc)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _LIBTOPO_H
28 #define	_LIBTOPO_H
29 
30 #include <sys/nvpair.h>
31 #include <stdio.h>
32 #include <libdevinfo.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	TOPO_VERSION	1	/* Library ABI Interface Version */
39 
40 typedef struct topo_hdl topo_hdl_t;
41 typedef struct topo_node tnode_t;
42 typedef struct topo_walk topo_walk_t;
43 typedef int32_t topo_instance_t;
44 typedef uint32_t topo_version_t;
45 
46 typedef struct topo_list {
47 	struct topo_list *l_prev;
48 	struct topo_list *l_next;
49 } topo_list_t;
50 
51 typedef struct topo_faclist {
52 	topo_list_t	tf_list;
53 	tnode_t		*tf_node;
54 } topo_faclist_t;
55 
56 /*
57  * The following functions, error codes and data structures are private
58  * to libtopo snapshot consumers and enumerator modules.
59  */
60 extern topo_hdl_t *topo_open(int, const char *, int *);
61 extern void topo_close(topo_hdl_t *);
62 extern char *topo_snap_hold(topo_hdl_t *, const char *, int *);
63 extern char *topo_snap_hold_no_forceload(topo_hdl_t *, const char *, int *);
64 extern void topo_snap_release(topo_hdl_t *);
65 
66 /*
67  * Snapshot walker support
68  */
69 typedef int (*topo_walk_cb_t)(topo_hdl_t *, tnode_t *, void *);
70 
71 extern topo_walk_t *topo_walk_init(topo_hdl_t *, const char *, topo_walk_cb_t,
72     void *, int *);
73 extern int topo_walk_step(topo_walk_t *, int);
74 extern void topo_walk_fini(topo_walk_t *);
75 extern di_node_t topo_hdl_devinfo(topo_hdl_t *);
76 extern di_prom_handle_t topo_hdl_prominfo(topo_hdl_t *);
77 
78 /*
79  * Walk status returned from walker
80  */
81 #define	TOPO_WALK_ERR		-1
82 #define	TOPO_WALK_NEXT		0
83 #define	TOPO_WALK_TERMINATE	1
84 
85 /*
86  * Types of walks: depth-first (child) or breadth-first (sibling)
87  */
88 #define	TOPO_WALK_CHILD		0x0001
89 #define	TOPO_WALK_SIBLING	0x0002
90 
91 /*
92  * FMRI helper routines
93  */
94 extern int topo_fmri_present(topo_hdl_t *, nvlist_t *, int *);
95 extern int topo_fmri_replaced(topo_hdl_t *, nvlist_t *, int *);
96 extern int topo_fmri_contains(topo_hdl_t *, nvlist_t *, nvlist_t *, int *);
97 extern int topo_fmri_expand(topo_hdl_t *, nvlist_t *, int *);
98 extern int topo_fmri_unusable(topo_hdl_t *, nvlist_t *, int *);
99 extern int topo_fmri_service_state(topo_hdl_t *, nvlist_t *, int *);
100 extern int topo_fmri_retire(topo_hdl_t *, nvlist_t *, int *);
101 extern int topo_fmri_unretire(topo_hdl_t *, nvlist_t *, int *);
102 extern int topo_fmri_nvl2str(topo_hdl_t *, nvlist_t *, char **, int *);
103 extern int topo_fmri_str2nvl(topo_hdl_t *, const char *, nvlist_t **, int *);
104 extern int topo_fmri_asru(topo_hdl_t *, nvlist_t *, nvlist_t **, int *);
105 extern int topo_fmri_fru(topo_hdl_t *, nvlist_t *, nvlist_t **,
106     int *);
107 extern int topo_fmri_label(topo_hdl_t *, nvlist_t *, char **, int *);
108 extern int topo_fmri_serial(topo_hdl_t *, nvlist_t *, char **, int *);
109 extern int topo_fmri_compare(topo_hdl_t *, nvlist_t *, nvlist_t *, int *);
110 extern int topo_fmri_facility(topo_hdl_t *, nvlist_t *, const char *,
111     uint32_t, topo_walk_cb_t, void *, int *);
112 
113 /*
114  * Private utility functions for fmd
115  */
116 extern ulong_t topo_fmri_strhash(topo_hdl_t *, const char *);
117 extern boolean_t topo_fmri_strcmp(topo_hdl_t *, const char *, const char *);
118 
119 /*
120  * Topo node utilities: callable from topo_walk_step() callback or module
121  * enumeration, topo_mod_enumerate()
122  */
123 extern char *topo_node_name(tnode_t *);
124 extern topo_instance_t topo_node_instance(tnode_t *);
125 extern tnode_t *topo_node_parent(tnode_t *);
126 extern void *topo_node_private(tnode_t *);
127 extern int topo_node_flags(tnode_t *);
128 extern int topo_node_asru(tnode_t *, nvlist_t **, nvlist_t *, int *);
129 extern int topo_node_fru(tnode_t *, nvlist_t **, nvlist_t *, int *);
130 extern int topo_node_resource(tnode_t *, nvlist_t **, int *);
131 extern int topo_node_label(tnode_t *, char **, int *);
132 extern tnode_t *topo_node_lookup(tnode_t *, const char *, topo_instance_t);
133 extern int topo_method_invoke(tnode_t *node, const char *, topo_version_t,
134     nvlist_t *, nvlist_t **, int *);
135 extern boolean_t topo_method_supported(tnode_t *, const char *,
136     topo_version_t);
137 extern int topo_node_facility(topo_hdl_t *, tnode_t *, const char *,
138     uint32_t, topo_faclist_t *, int *);
139 
140 /*
141  * Node flags: denotes type of node
142  */
143 #define	TOPO_NODE_DEFAULT	0
144 #define	TOPO_NODE_FACILITY	1
145 
146 #define	TOPO_FAC_TYPE_SENSOR	"sensor"
147 #define	TOPO_FAC_TYPE_INDICATOR	"indicator"
148 
149 /*
150  * Topo property get functions
151  */
152 extern int topo_prop_get_int32(tnode_t *, const char *, const char *,
153     int32_t *, int *);
154 extern int topo_prop_get_uint32(tnode_t *, const char *, const char *,
155     uint32_t *, int *);
156 extern int topo_prop_get_int64(tnode_t *, const char *, const char *,
157     int64_t *, int *);
158 extern int topo_prop_get_uint64(tnode_t *, const char *, const char *,
159     uint64_t *, int *);
160 extern int topo_prop_get_double(tnode_t *, const char *, const char *,
161     double *, int *);
162 extern int topo_prop_get_string(tnode_t *, const char *, const char *,
163     char **, int *);
164 extern int topo_prop_get_fmri(tnode_t *, const char *, const char *,
165     nvlist_t **, int *);
166 extern int topo_prop_get_int32_array(tnode_t *, const char *, const char *,
167     int32_t **, uint_t *, int *);
168 extern int topo_prop_get_uint32_array(tnode_t *, const char *, const char *,
169     uint32_t **, uint_t *, int *);
170 extern int topo_prop_get_int64_array(tnode_t *, const char *, const char *,
171     int64_t **, uint_t *, int *);
172 extern int topo_prop_get_uint64_array(tnode_t *, const char *, const char *,
173     uint64_t **, uint_t *, int *);
174 extern int topo_prop_get_string_array(tnode_t *, const char *, const char *,
175     char ***, uint_t *, int *);
176 extern int topo_prop_get_fmri_array(tnode_t *, const char *, const char *,
177     nvlist_t ***, uint_t *, int *);
178 
179 /*
180  * Topo property set functions
181  */
182 extern int topo_prop_set_int32(tnode_t *, const char *, const char *, int,
183     int32_t, int *);
184 extern int topo_prop_set_uint32(tnode_t *, const char *, const char *, int,
185     uint32_t, int *);
186 extern int topo_prop_set_int64(tnode_t *, const char *, const char *,
187     int, int64_t, int *);
188 extern int topo_prop_set_uint64(tnode_t *, const char *, const char *,
189     int, uint64_t, int *);
190 extern int topo_prop_set_double(tnode_t *, const char *, const char *,
191     int, double, int *);
192 extern int topo_prop_set_string(tnode_t *, const char *, const char *,
193     int, const char *, int *);
194 extern int topo_prop_set_fmri(tnode_t *, const char *, const char *,
195     int, const nvlist_t *, int *);
196 extern int topo_prop_set_int32_array(tnode_t *, const char *, const char *, int,
197     int32_t *, uint_t, int *);
198 extern int topo_prop_set_uint32_array(tnode_t *, const char *, const char *,
199     int, uint32_t *, uint_t, int *);
200 extern int topo_prop_set_int64_array(tnode_t *, const char *, const char *,
201     int, int64_t *, uint_t, int *);
202 extern int topo_prop_set_uint64_array(tnode_t *, const char *, const char *,
203     int, uint64_t *, uint_t, int *);
204 extern int topo_prop_set_string_array(tnode_t *, const char *, const char *,
205     int, const char **, uint_t, int *);
206 extern int topo_prop_set_fmri_array(tnode_t *, const char *, const char *,
207     int, const nvlist_t **, uint_t, int *);
208 
209 #define	TOPO_PROP_IMMUTABLE	0
210 #define	TOPO_PROP_MUTABLE	0x01
211 #define	TOPO_PROP_NONVOLATILE	0x02
212 
213 /* Protocol property group and property names */
214 #define	TOPO_PGROUP_PROTOCOL	"protocol"	/* Required property group */
215 #define	TOPO_PROP_RESOURCE	"resource"	/* resource FMRI */
216 #define	TOPO_PROP_ASRU		"ASRU"		/* ASRU FMRI */
217 #define	TOPO_PROP_FRU		"FRU"		/* FRU FMRI */
218 #define	TOPO_PROP_MOD		"module"	/* software module FMRI */
219 #define	TOPO_PROP_PKG		"package"	/* software package FMRI */
220 #define	TOPO_PROP_LABEL		"label"		/*  property LABEL */
221 
222 #define	TOPO_METH_FAC_ENUM	"fac_enum"
223 
224 /*
225  * System property group
226  */
227 #define	TOPO_PGROUP_SYSTEM	"system"
228 #define	TOPO_PROP_ISA		"isa"
229 #define	TOPO_PROP_MACHINE	"machine"
230 
231 #define	TOPO_PGROUP_IPMI	"ipmi"
232 
233 /*
234  * These enum definitions are used to define a set of error tags associated with
235  * libtopo error conditions occuring during the adminstration of
236  * properties, invocation of methods and fmri-based queries.  The shell script
237  * mkerror.sh is used to parse this file and create a corresponding topo_error.c
238  * source file.
239  *
240  * If you do something other than add a new error tag here, you may need to
241  * update the mkerror shell script as it is based upon simple regexps.
242  */
243 typedef enum topo_prop_errno {
244     ETOPO_PROP_UNKNOWN = 3000, /* unknown topo prop error */
245     ETOPO_PROP_NOENT,   /* undefined property or property group */
246     ETOPO_PROP_DEFD,    /* static property already defined */
247     ETOPO_PROP_NOMEM,   /* memory limit exceeded during property allocation */
248     ETOPO_PROP_TYPE,    /* invalid property type */
249     ETOPO_PROP_NAME,    /* invalid property name */
250     ETOPO_PROP_NOINHERIT, /* can not inherit property */
251     ETOPO_PROP_NVL,	/* malformed property nvlist */
252     ETOPO_PROP_METHOD,	/* get property method failed */
253     ETOPO_PROP_END	/* end of prop errno list (to ease auto-merge) */
254 } topo_prop_errno_t;
255 
256 typedef enum topo_method_errno {
257     ETOPO_METHOD_UNKNOWN = 3100, /* unknown topo method error */
258     ETOPO_METHOD_INVAL,		/* invalid method registration */
259     ETOPO_METHOD_NOTSUP,	/* method not supported */
260     ETOPO_METHOD_FAIL,		/* method failed */
261     ETOPO_METHOD_VEROLD,	/* app is compiled to use obsolete method */
262     ETOPO_METHOD_VERNEW,	/* app is compiled to use obsolete method */
263     ETOPO_METHOD_NOMEM,		/* memory limit exceeded during method op */
264     ETOPO_METHOD_DEFD,		/* method op already defined */
265     ETOPO_METHOD_END		/* end of method errno list */
266 } topo_method_errno_t;
267 
268 typedef enum topo_fmri_errno {
269     ETOPO_FMRI_UNKNOWN = 3200, /* unknown topo fmri error */
270     ETOPO_FMRI_NVL,		/* nvlist allocation failure for FMRI */
271     ETOPO_FMRI_VERSION,		/* invalid FMRI scheme version */
272     ETOPO_FMRI_MALFORM,		/* malformed FMRI */
273     ETOPO_FMRI_NOMEM,		/* memory limit exceeded */
274     ETOPO_FMRI_END		/* end of fmri errno list */
275 } topo_fmri_errno_t;
276 
277 typedef enum topo_hdl_errno {
278     ETOPO_HDL_UNKNOWN = 3300,	/* unknown topo handle error */
279     ETOPO_HDL_ABIVER,		/* handle opened with invalid ABI version */
280     ETOPO_HDL_SNAP,		/* snapshot already taken */
281     ETOPO_HDL_INVAL,		/* invalid argument specified */
282     ETOPO_HDL_UUID,		/* uuid already set */
283     ETOPO_HDL_NOMEM,		/* memory limit exceeded */
284     ETOPO_HDL_END		/* end of handle errno list */
285 } topo_hdl_errno_t;
286 
287 extern const char *topo_strerror(int);
288 extern void topo_hdl_strfree(topo_hdl_t *, char *);
289 extern void topo_debug_set(topo_hdl_t *, const char *, const char *);
290 
291 /*
292  * The following functions and data structures to support property
293  * observability are private to the fmtopo command.
294  */
295 
296 /*
297  * Each topology node advertises the name and data stability of each of its
298  * modules and properties. (see attributes(5)).
299  */
300 
301 /*
302  * Topo stability attributes
303  */
304 typedef enum topo_stability {
305 	TOPO_STABILITY_UNKNOWN = 0,	/* private to libtopo */
306 	TOPO_STABILITY_INTERNAL,	/* private to libtopo */
307 	TOPO_STABILITY_PRIVATE,		/* private to Sun */
308 	TOPO_STABILITY_OBSOLETE,	/* scheduled for removal */
309 	TOPO_STABILITY_EXTERNAL,	/* not controlled by Sun */
310 	TOPO_STABILITY_UNSTABLE,	/* new or rapidly changing */
311 	TOPO_STABILITY_EVOLVING,	/* less rapidly changing */
312 	TOPO_STABILITY_STABLE,		/* mature interface from Sun */
313 	TOPO_STABILITY_STANDARD		/* industry standard */
314 } topo_stability_t;
315 
316 #define	TOPO_STABILITY_MAX	TOPO_STABILITY_STANDARD	/* max valid stab */
317 
318 typedef struct topo_pgroup_info {
319 	const char *tpi_name;		/* property group name */
320 	topo_stability_t tpi_namestab;	/* stability of group name */
321 	topo_stability_t tpi_datastab;	/* stability of all property values */
322 	topo_version_t tpi_version;	/* version of pgroup definition */
323 } topo_pgroup_info_t;
324 
325 extern topo_stability_t topo_name2stability(const char *);
326 extern const char *topo_stability2name(topo_stability_t);
327 extern void topo_pgroup_destroy(tnode_t *, const char *);
328 extern topo_pgroup_info_t *topo_pgroup_info(tnode_t *, const char *, int *);
329 
330 typedef enum {
331 	TOPO_TYPE_INVALID = 0,
332 	TOPO_TYPE_BOOLEAN,	/* boolean */
333 	TOPO_TYPE_INT32,	/* int32_t */
334 	TOPO_TYPE_UINT32,	/* uint32_t */
335 	TOPO_TYPE_INT64,	/* int64_t */
336 	TOPO_TYPE_UINT64,	/* uint64_t */
337 	TOPO_TYPE_STRING,	/* const char* */
338 	TOPO_TYPE_TIME,		/* uint64_t */
339 	TOPO_TYPE_SIZE,		/* uint64_t */
340 	TOPO_TYPE_FMRI,		/* nvlist_t */
341 	TOPO_TYPE_INT32_ARRAY,	/* array of int32_t */
342 	TOPO_TYPE_UINT32_ARRAY,	/* array of uint32_t */
343 	TOPO_TYPE_INT64_ARRAY,	/* array of int64_t */
344 	TOPO_TYPE_UINT64_ARRAY,	/* array of uint64_t */
345 	TOPO_TYPE_STRING_ARRAY,	/* array of const char* */
346 	TOPO_TYPE_FMRI_ARRAY,	/* array of nvlist_t */
347 	TOPO_TYPE_DOUBLE	/* double */
348 } topo_type_t;
349 
350 extern nvlist_t *topo_prop_getprops(tnode_t *, int *err);
351 extern int topo_prop_getprop(tnode_t *, const char *, const char *,
352     nvlist_t *, nvlist_t **, int *);
353 extern int topo_prop_getpgrp(tnode_t *, const char *, nvlist_t **, int *);
354 extern int topo_prop_setprop(tnode_t *, const char *, nvlist_t *,
355     int, nvlist_t *, int *);
356 extern int topo_fmri_getprop(topo_hdl_t *, nvlist_t *, const char *,
357     const char *, nvlist_t *,  nvlist_t **, int *);
358 extern int topo_fmri_getpgrp(topo_hdl_t *, nvlist_t *, const char *,
359     nvlist_t **, int *);
360 extern int topo_fmri_setprop(topo_hdl_t *, nvlist_t *, const char *,
361     nvlist_t *, int, nvlist_t *, int *);
362 
363 /* Property node NVL names used in topo_prop_getprops */
364 #define	TOPO_PROP_GROUP		"property-group"
365 #define	TOPO_PROP_GROUP_NAME	"property-group-name"
366 #define	TOPO_PROP_GROUP_DSTAB	"property-group-data-stability"
367 #define	TOPO_PROP_GROUP_NSTAB	"property-group-name-stability"
368 #define	TOPO_PROP_GROUP_VERSION	"property-group-version"
369 #define	TOPO_PROP_VAL		"property"
370 #define	TOPO_PROP_VAL_NAME	"property-name"
371 #define	TOPO_PROP_VAL_VAL	"property-value"
372 #define	TOPO_PROP_VAL_TYPE	"property-type"
373 #define	TOPO_PROP_FLAG		"property-flag"
374 
375 /*
376  * ARGS list used in topo property methods
377  */
378 #define	TOPO_PROP_ARGS	"args"
379 #define	TOPO_PROP_PARGS	"private-args"
380 
381 extern int topo_xml_print(topo_hdl_t *, FILE *, const char *scheme, int *);
382 
383 extern void *topo_hdl_alloc(topo_hdl_t *, size_t);
384 extern void *topo_hdl_zalloc(topo_hdl_t *, size_t);
385 extern void topo_hdl_free(topo_hdl_t *, void *, size_t);
386 extern int topo_hdl_nvalloc(topo_hdl_t *, nvlist_t **, uint_t);
387 extern int topo_hdl_nvdup(topo_hdl_t *, nvlist_t *, nvlist_t **);
388 extern char *topo_hdl_strdup(topo_hdl_t *, const char *);
389 
390 /*
391  * Interfaces for converting sensor/indicator types, units, states, etc to
392  * a string
393  */
394 void topo_sensor_type_name(uint32_t type, char *buf, size_t len);
395 void topo_sensor_units_name(uint8_t type, char *buf, size_t len);
396 void topo_led_type_name(uint8_t type, char *buf, size_t len);
397 void topo_led_state_name(uint8_t type, char *buf, size_t len);
398 void topo_sensor_state_name(uint32_t sensor_type, uint8_t state, char *buf,
399     size_t len);
400 
401 /*
402  * Defines for standard properties for sensors and indicators
403  */
404 #define	TOPO_PGROUP_FACILITY	"facility"
405 
406 #define	TOPO_SENSOR_READING	"reading"
407 #define	TOPO_SENSOR_STATE	"state"
408 #define	TOPO_SENSOR_CLASS	"sensor-class"
409 #define	TOPO_FACILITY_TYPE	"type"
410 #define	TOPO_SENSOR_UNITS	"units"
411 #define	TOPO_LED_MODE		"mode"
412 
413 /*
414  * Sensor Classes
415  *
416  * The "sensor-class" property in the "facility" propgroup on
417  * facility nodes of type "sensor" should be set to one of these
418  * two values.
419  *
420  * Threshold sensors provide an analog sensor reading via the
421  * "reading" property in the facility propgroup.  They will also
422  * provide one or more discrete states via the "state" property
423  * in the facility propgroup.
424  *
425  * Discrete sensors will not provide an analog reading by will
426  * provide one or more discrete states via the "state" property
427  * in the facility propgroup.
428  */
429 #define	TOPO_SENSOR_CLASS_THRESHOLD	"threshold"
430 #define	TOPO_SENSOR_CLASS_DISCRETE	"discrete"
431 
432 /*
433  * Sensor unit types.  We're using the unit types and corresponding
434  * codes described in the IPMI 2.0 spec as a reference as it seems to be a
435  * reasonably comprehensive list.  This also simplifies the IPMI provider code
436  * since the unit type codes will map exactly to what libtopo uses (so no
437  * conversion necessary).
438  */
439 typedef enum topo_sensor_unit {
440 	TOPO_SENSOR_UNITS_UNSPECIFIED = 0,
441 	TOPO_SENSOR_UNITS_DEGREES_C,
442 	TOPO_SENSOR_UNITS_DEGREES_F,
443 	TOPO_SENSOR_UNITS_DEGREES_K,
444 	TOPO_SENSOR_UNITS_VOLTS,
445 	TOPO_SENSOR_UNITS_AMPS,
446 	TOPO_SENSOR_UNITS_WATTS,
447 	TOPO_SENSOR_UNITS_JOULES,
448 	TOPO_SENSOR_UNITS_COULOMBS,
449 	TOPO_SENSOR_UNITS_VA,
450 	TOPO_SENSOR_UNITS_NITS,
451 	TOPO_SENSOR_UNITS_LUMEN,
452 	TOPO_SENSOR_UNITS_LUX,
453 	TOPO_SENSOR_UNITS_CANDELA,
454 	TOPO_SENSOR_UNITS_KPA,
455 	TOPO_SENSOR_UNITS_PSI,
456 
457 	TOPO_SENSOR_UNITS_NEWTON,
458 	TOPO_SENSOR_UNITS_CFM,
459 	TOPO_SENSOR_UNITS_RPM,
460 	TOPO_SENSOR_UNITS_HZ,
461 	TOPO_SENSOR_UNITS_MICROSEC,
462 	TOPO_SENSOR_UNITS_MILLISEC,
463 	TOPO_SENSOR_UNITS_SECS,
464 	TOPO_SENSOR_UNITS_MIN,
465 	TOPO_SENSOR_UNITS_HOUR,
466 	TOPO_SENSOR_UNITS_DAY,
467 	TOPO_SENSOR_UNITS_WEEK,
468 	TOPO_SENSOR_UNITS_MIL,
469 	TOPO_SENSOR_UNITS_INCHES,
470 	TOPO_SENSOR_UNITS_FEET,
471 	TOPO_SENSOR_UNITS_CUB_INCH,
472 	TOPO_SENSOR_UNITS_CUB_FEET,
473 
474 	TOPO_SENSOR_UNITS_MM,
475 	TOPO_SENSOR_UNITS_CM,
476 	TOPO_SENSOR_UNITS_METERS,
477 	TOPO_SENSOR_UNITS_CUB_CM,
478 	TOPO_SENSOR_UNITS_CUB_METER,
479 	TOPO_SENSOR_UNITS_LITERS,
480 	TOPO_SENSOR_UNITS_FLUID_OUNCE,
481 	TOPO_SENSOR_UNITS_RADIANS,
482 	TOPO_SENSOR_UNITS_STERADIANS,
483 	TOPO_SENSOR_UNITS_REVOLUTIONS,
484 	TOPO_SENSOR_UNITS_CYCLES,
485 	TOPO_SENSOR_UNITS_GRAVITIES,
486 	TOPO_SENSOR_UNITS_OUNCE,
487 	TOPO_SENSOR_UNITS_POUND,
488 	TOPO_SENSOR_UNITS_FOOT_POUND,
489 	TOPO_SENSOR_UNITS_OZ_INCH,
490 
491 	TOPO_SENSOR_UNITS_GAUSS,
492 	TOPO_SENSOR_UNITS_GILBERTS,
493 	TOPO_SENSOR_UNITS_HENRY,
494 	TOPO_SENSOR_UNITS_MILHENRY,
495 	TOPO_SENSOR_UNITS_FARAD,
496 	TOPO_SENSOR_UNITS_MICROFARAD,
497 	TOPO_SENSOR_UNITS_OHMS,
498 	TOPO_SENSOR_UNITS_SIEMENS,
499 	TOPO_SENSOR_UNITS_MOLE,
500 	TOPO_SENSOR_UNITS_BECQUEREL,
501 	TOPO_SENSOR_UNITS_PPM,
502 	TOPO_SENSOR_UNITS_RESERVED1,
503 	TOPO_SENSOR_UNITS_DECIBELS,
504 	TOPO_SENSOR_UNITS_DBA,
505 	TOPO_SENSOR_UNITS_DBC,
506 	TOPO_SENSOR_UNITS_GRAY,
507 
508 	TOPO_SENSOR_UNITS_SIEVERT,
509 	TOPO_SENSOR_UNITS_COLOR_TEMP_K,
510 	TOPO_SENSOR_UNITS_BIT,
511 	TOPO_SENSOR_UNITS_KILOBIT,
512 	TOPO_SENSOR_UNITS_MEGABIT,
513 	TOPO_SENSOR_UNITS_GIGABIT,
514 	TOPO_SENSOR_UNITS_BYTE,
515 	TOPO_SENSOR_UNITS_KILOBYTE,
516 	TOPO_SENSOR_UNITS_MEGABYTE,
517 	TOPO_SENSOR_UNITS_GIGABYTE,
518 	TOPO_SENSOR_UNITS_WORD,
519 	TOPO_SENSOR_UNITS_DWORD,
520 	TOPO_SENSOR_UNITS_QWORD,
521 	TOPO_SENSOR_UNITS_MEMLINE,
522 	TOPO_SENSOR_UNITS_HIT,
523 	TOPO_SENSOR_UNITS_MISS,
524 
525 	TOPO_SENSOR_UNITS_RETRY,
526 	TOPO_SENSOR_UNITS_RESET,
527 	TOPO_SENSOR_UNITS_OVERFLOW,
528 	TOPO_SENSOR_UNITS_UNDERRUN,
529 	TOPO_SENSOR_UNITS_COLLISION,
530 	TOPO_SENSOR_UNITS_PACKETS,
531 	TOPO_SENSOR_UNITS_MESSAGES,
532 	TOPO_SENSOR_UNITS_CHARACTERS,
533 	TOPO_SENSOR_UNITS_ERROR,
534 	TOPO_SENSOR_UNITS_CE,
535 	TOPO_SENSOR_UNITS_UE,
536 	TOPO_SENSOR_UNITS_FATAL_ERROR,
537 	TOPO_SENSOR_UNITS_GRAMS
538 } topo_sensor_unit_t;
539 
540 /*
541  * These defines are used by the topo_method_sensor_failure to indicate
542  * whether the source of a sensor failure is believed to be the result of an
543  * internal failure, external condition or unknown
544  */
545 #define	TOPO_SENSOR_ERRSRC_UNKNOWN	0
546 #define	TOPO_SENSOR_ERRSRC_INTERNAL	1
547 #define	TOPO_SENSOR_ERRSRC_EXTERNAL	2
548 
549 /*
550  * Sensor Types amd the associated sensor-type-specific states
551  *
552  * These are used to decode the type and state properties in the facility
553  * propgroup on facility nodes of type sensor.
554  *
555  * Again we're basically using the same defines as for IPMI as it's serves
556  * as a good starting point and simplifies the IPMI provider code.  Of course
557  * other facility providers will need to convert from their native codes
558  * to the topo code when they set the type and state properties.
559  */
560 #define	TOPO_SENSOR_TYPE_RESERVED			0x0000
561 #define	TOPO_SENSOR_TYPE_TEMP				0x0001
562 #define	TOPO_SENSOR_TYPE_VOLTAGE			0x0002
563 #define	TOPO_SENSOR_TYPE_CURRENT			0x0003
564 #define	TOPO_SENSOR_TYPE_FAN				0x0004
565 #define	TOPO_SENSOR_TYPE_PHYSICAL			0x0005
566 
567 #define	TOPO_SENSOR_STATE_PHYSICAL_GENERAL		0x0001
568 #define	TOPO_SENSOR_STATE_PHYSICAL_BAY			0x0002
569 #define	TOPO_SENSOR_STATE_PHYSICAL_CARD			0x0004
570 #define	TOPO_SENSOR_STATE_PHYSICAL_PROCESSOR		0x0008
571 #define	TOPO_SENSOR_STATE_PHYSICAL_LAN			0x0010
572 #define	TOPO_SENSOR_STATE_PHYSICAL_DOCK			0x0020
573 #define	TOPO_SENSOR_STATE_PHYSICAL_FAN			0x0040
574 
575 #define	TOPO_SENSOR_TYPE_PLATFORM			0x0006
576 
577 #define	TOPO_SENSOR_STATE_PLATFORM_SECURE		0x0001
578 #define	TOPO_SENSOR_STATE_PLATFORM_USER_PASS		0x0002
579 #define	TOPO_SENSOR_STATE_PLATFORM_SETUP_PASS		0x0004
580 #define	TOPO_SENSOR_STATE_PLATFORM_NETWORK_PASS		0x0008
581 #define	TOPO_SENSOR_STATE_PLATFORM_OTHER_PASS		0x0010
582 #define	TOPO_SENSOR_STATE_PLATFORM_OUT_OF_BAND		0x0020
583 
584 #define	TOPO_SENSOR_TYPE_PROCESSOR			0x0007
585 
586 #define	TOPO_SENSOR_STATE_PROCESSOR_IERR		0x0001
587 #define	TOPO_SENSOR_STATE_PROCESSOR_THERMAL		0x0002
588 #define	TOPO_SENSOR_STATE_PROCESSOR_FRB1		0x0004
589 #define	TOPO_SENSOR_STATE_PROCESSOR_FRB2		0x0008
590 #define	TOPO_SENSOR_STATE_PROCESSOR_FRB3		0x0010
591 #define	TOPO_SENSOR_STATE_PROCESSOR_CONFIG		0x0020
592 #define	TOPO_SENSOR_STATE_PROCESSOR_SMBIOS		0x0040
593 #define	TOPO_SENSOR_STATE_PROCESSOR_PRESENT		0x0080
594 #define	TOPO_SENSOR_STATE_PROCESSOR_DISABLED		0x0100
595 #define	TOPO_SENSOR_STATE_PROCESSOR_TERMINATOR		0x0200
596 #define	TOPO_SENSOR_STATE_PROCESSOR_THROTTLED		0x0400
597 
598 #define	TOPO_SENSOR_TYPE_POWER_SUPPLY			0x0008
599 
600 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_PRESENT		0x0001
601 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_FAILURE		0x0002
602 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_PREDFAIL		0x0004
603 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_LOST	0x0008
604 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE	0x0010
605 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE_PRES	0x0020
606 #define	TOPO_SENSOR_STATE_POWER_SUPPLY_CONFIG_ERR	0x0040
607 
608 #define	TOPO_SENSOR_TYPE_POWER_UNIT			0x0009
609 
610 #define	TOPO_SENSOR_STATE_POWER_UNIT_OFF		0x0001
611 #define	TOPO_SENSOR_STATE_POWER_UNIT_CYCLE		0x0002
612 #define	TOPO_SENSOR_STATE_POWER_UNIT_240_DOWN		0x0004
613 #define	TOPO_SENSOR_STATE_POWER_UNIT_INTERLOCK_DOWN	0x0008
614 #define	TOPO_SENSOR_STATE_POWER_UNIT_AC_LOST		0x0010
615 #define	TOPO_SENSOR_STATE_POWER_UNIT_SOFT_FAILURE	0x0020
616 #define	TOPO_SENSOR_STATE_POWER_UNIT_FAIL		0x0040
617 #define	TOPO_SENSOR_STATE_POWER_UNIT_PREDFAIL		0x0080
618 
619 #define	TOPO_SENSOR_TYPE_COOLING			0x000A
620 #define	TOPO_SENSOR_TYPE_OTHER				0x000B
621 
622 #define	TOPO_SENSOR_TYPE_MEMORY				0x000C
623 
624 #define	TOPO_SENSOR_STATE_MEMORY_CE			0x0001
625 #define	TOPO_SENSOR_STATE_MEMORY_UE			0x0002
626 #define	TOPO_SENSOR_STATE_MEMORY_PARITY			0x0004
627 #define	TOPO_SENSOR_STATE_MEMORY_SCRUB_FAIL		0x0008
628 #define	TOPO_SENSOR_STATE_MEMORY_DISABLED		0x0010
629 #define	TOPO_SENSOR_STATE_MEMORY_CE_LOG_LIMIT		0x0020
630 #define	TOPO_SENSOR_STATE_MEMORY_PRESENT		0x0040
631 #define	TOPO_SENSOR_STATE_MEMORY_CONFIG_ERR		0x0080
632 #define	TOPO_SENSOR_STATE_MEMORY_SPARE			0x0100
633 #define	TOPO_SENSOR_STATE_MEMORY_THROTTLED		0x0200
634 #define	TOPO_SENSOR_STATE_MEMORY_OVERTEMP		0x0400
635 
636 #define	TOPO_SENSOR_TYPE_BAY				0x000D
637 
638 #define	TOPO_SENSOR_STATE_BAY_PRESENT			0x0001
639 #define	TOPO_SENSOR_STATE_BAY_FAULT			0x0002
640 #define	TOPO_SENSOR_STATE_BAY_PREDFAIL			0x0004
641 #define	TOPO_SENSOR_STATE_BAY_SPARE			0x0008
642 #define	TOPO_SENSOR_STATE_BAY_CHECK			0x0010
643 #define	TOPO_SENSOR_STATE_BAY_CRITICAL			0x0020
644 #define	TOPO_SENSOR_STATE_BAY_FAILED			0x0040
645 #define	TOPO_SENSOR_STATE_BAY_REBUILDING		0x0080
646 #define	TOPO_SENSOR_STATE_BAY_ABORTED			0x0100
647 
648 #define	TOPO_SENSOR_TYPE_POST_RESIZE			0x000E
649 
650 #define	TOPO_SENSOR_TYPE_FIRMWARE			0x000F
651 
652 #define	TOPO_SENSOR_STATE_FIRMWARE_ERROR		0x0001
653 #define	TOPO_SENSOR_STATE_FIRMWARE_HANG			0x0002
654 #define	TOPO_SENSOR_STATE_FIRMWARE_PROGRESS		0x0004
655 
656 #define	TOPO_SENSOR_TYPE_EVENT_LOG			0x0010
657 
658 #define	TOPO_SENSOR_STATE_EVENT_LOG_CE			0x0001
659 #define	TOPO_SENSOR_STATE_EVENT_LOG_TYPE		0x0002
660 #define	TOPO_SENSOR_STATE_EVENT_LOG_RESET		0x0004
661 #define	TOPO_SENSOR_STATE_EVENT_LOG_ALL			0x0008
662 #define	TOPO_SENSOR_STATE_EVENT_LOG_FULL		0x0010
663 #define	TOPO_SENSOR_STATE_EVENT_LOG_ALMOST_FULL		0x0020
664 
665 #define	TOPO_SENSOR_TYPE_WATCHDOG1			0x0011
666 
667 #define	TOPO_SENSOR_STATE_WATCHDOG_BIOS_RESET		0x0001
668 #define	TOPO_SENSOR_STATE_WATCHDOG_OS_RESET		0x0002
669 #define	TOPO_SENSOR_STATE_WATCHDOG_OS_SHUTDOWN		0x0004
670 #define	TOPO_SENSOR_STATE_WATCHDOG_OS_PWR_DOWN		0x0008
671 #define	TOPO_SENSOR_STATE_WATCHDOG_OS_PWR_CYCLE		0x0010
672 #define	TOPO_SENSOR_STATE_WATCHDOG_OS_NMI_DIAG		0x0020
673 #define	TOPO_SENSOR_STATE_WATCHDOG_EXPIRED		0x0040
674 #define	TOPO_SENSOR_STATE_WATCHDOG_PRE_TIMEOUT_INT	0x0080
675 
676 #define	TOPO_SENSOR_TYPE_SYSTEM				0x0012
677 
678 #define	TOPO_SENSOR_STATE_SYSTEM_RECONF			0x0001
679 #define	TOPO_SENSOR_STATE_SYSTEM_BOOT			0x0002
680 #define	TOPO_SENSOR_STATE_SYSTEM_UNKNOWN_HW_FAILURE	0x0004
681 #define	TOPO_SENSOR_STATE_SYSTEM_AUX_LOG_UPDATED	0x0008
682 #define	TOPO_SENSOR_STATE_SYSTEM_PEF_ACTION		0x0010
683 #define	TOPO_SENSOR_STATE_SYSTEM_TIMETAMP_CLOCKSYNC	0x0020
684 
685 #define	TOPO_SENSOR_TYPE_CRITICAL			0x0013
686 
687 #define	TOPO_SENSOR_STATE_CRITICAL_EXT_NMI		0x0001
688 #define	TOPO_SENSOR_STATE_CRITICAL_BUS_TIMEOUT		0x0002
689 #define	TOPO_SENSOR_STATE_CRITICAL_IO_NMI		0x0004
690 #define	TOPO_SENSOR_STATE_CRITICAL_SW_NMI		0x0008
691 #define	TOPO_SENSOR_STATE_CRITICAL_PCI_PERR		0x0010
692 #define	TOPO_SENSOR_STATE_CRITICAL_PCI_SERR		0x0020
693 #define	TOPO_SENSOR_STATE_CRITICAL_EISA_FAILSAFE	0x0040
694 #define	TOPO_SENSOR_STATE_CRITICAL_BUS_CE		0x0080
695 #define	TOPO_SENSOR_STATE_CRITICAL_BUS_UE		0x0100
696 #define	TOPO_SENSOR_STATE_CRITICAL_FATAL_NMI		0x0200
697 #define	TOPO_SENSOR_STATE_CRITICAL_BUS_FATAL_ERR	0x0400
698 #define	TOPO_SENSOR_STATE_CRITICAL_BUS_DEGRADED		0x0800
699 
700 #define	TOPO_SENSOR_TYPE_BUTTON				0x0014
701 
702 #define	TOPO_SENSOR_STATE_BUTTON_PWR			0x0001
703 #define	TOPO_SENSOR_STATE_BUTTON_SLEEP			0x0002
704 #define	TOPO_SENSOR_STATE_BUTTON_RESET			0x0004
705 #define	TOPO_SENSOR_STATE_BUTTON_FRU_LATCH		0x0008
706 #define	TOPO_SENSOR_STATE_BUTTON_FRU_SERVICE		0x0010
707 
708 #define	TOPO_SENSOR_TYPE_MODULE				0x0015
709 #define	TOPO_SENSOR_TYPE_MICROCONTROLLER		0x0016
710 #define	TOPO_SENSOR_TYPE_CARD				0x0017
711 #define	TOPO_SENSOR_TYPE_CHASSIS			0x0018
712 
713 #define	TOPO_SENSOR_TYPE_CHIPSET			0x0019
714 
715 #define	TOPO_SENSOR_STATE_CHIPSET_PWR_CTL_FAIL		0x0001
716 
717 #define	TOPO_SENSOR_TYPE_FRU				0x001A
718 
719 #define	TOPO_SENSOR_TYPE_CABLE				0x001B
720 
721 #define	TOPO_SENSOR_STATE_CABLE_CONNECTED		0x0001
722 #define	TOPO_SENSOR_STATE_CABLE_CONFIG_ERR		0x0002
723 
724 #define	TOPO_SENSOR_TYPE_TERMINATOR			0x001C
725 
726 #define	TOPO_SENSOR_TYPE_BOOT_STATE			0x001D
727 
728 #define	TOPO_SENSOR_STATE_BOOT_STATE_BIOS_PWR_UP	0x0001
729 #define	TOPO_SENSOR_STATE_BOOT_STATE_BIOS_HARD_RESET	0x0002
730 #define	TOPO_SENSOR_STATE_BOOT_STATE_BIOS_WARM_RESET	0x0004
731 #define	TOPO_SENSOR_STATE_BOOT_STATE_PXE_BOOT		0x0008
732 #define	TOPO_SENSOR_STATE_BOOT_STATE_DIAG_BOOT		0x0010
733 #define	TOPO_SENSOR_STATE_BOOT_STATE_OS_HARD_RESET	0x0020
734 #define	TOPO_SENSOR_STATE_BOOT_STATE_OS_WARM_RESET	0x0040
735 #define	TOPO_SENSOR_STATE_BOOT_STATE_SYS_RESTART	0x0080
736 
737 #define	TOPO_SENSOR_TYPE_BOOT_ERROR			0x001E
738 
739 #define	TOPO_SENSOR_STATE_BOOT_ERROR_NOMEDIA		0x0001
740 #define	TOPO_SENSOR_STATE_BOOT_ERROR_NON_BOOTABLE_DISK	0x0002
741 #define	TOPO_SENSOR_STATE_BOOT_ERROR_NO_PXE_SERVER	0x0004
742 #define	TOPO_SENSOR_STATE_BOOT_ERROR_INV_BOOT_SECT	0x0008
743 #define	TOPO_SENSOR_STATE_BOOT_ERROR_USR_SELECT_TIMEOUT	0x0010
744 
745 #define	TOPO_SENSOR_TYPE_BOOT_OS			0x001F
746 
747 #define	TOPO_SENSOR_STATE_BOOT_OS_A_DRV_BOOT_COMPLETE	0x0001
748 #define	TOPO_SENSOR_STATE_BOOT_OS_C_DRV_BOOT_COMPLETE	0x0002
749 #define	TOPO_SENSOR_STATE_BOOT_OS_PXE_BOOT_COMPLETE	0x0004
750 #define	TOPO_SENSOR_STATE_BOOT_OS_DIAG_BOOT_COMPLETE	0x0008
751 #define	TOPO_SENSOR_STATE_BOOT_OS_CDROM_BOOT_COMPLETE	0x0010
752 #define	TOPO_SENSOR_STATE_BOOT_OS_ROM_BOOT_COMPLETE	0x0020
753 #define	TOPO_SENSOR_STATE_BOOT_OS_UNSPEC_BOOT_COMPLETE	0x0040
754 
755 #define	TOPO_SENSOR_TYPE_OS_SHUTDOWN			0x0020
756 
757 #define	TOPO_SENSOR_STATE_OS_SHUTDOWN_LOADING		0x0001
758 #define	TOPO_SENSOR_STATE_OS_SHUTDOWN_CRASH		0x0002
759 #define	TOPO_SENSOR_STATE_OS_STOP_GRACEFUL		0x0004
760 #define	TOPO_SENSOR_STATE_OS_SHUTDOWN_GRACEFUL		0x0008
761 #define	TOPO_SENSOR_STATE_OS_SHUTDOWN_PEF		0x0010
762 #define	TOPO_SENSOR_STATE_OS_SHUTDOWN_BMC		0x0020
763 
764 #define	TOPO_SENSOR_TYPE_SLOT				0x0021
765 
766 #define	TOPO_SENSOR_STATE_SLOT_FAULT_ASSERTED		0x0001
767 #define	TOPO_SENSOR_STATE_SLOT_IDENTIFY_ASSERTED	0x0002
768 #define	TOPO_SENSOR_STATE_SLOT_CONNECTED		0x0004
769 #define	TOPO_SENSOR_STATE_SLOT_INSTALL_READY		0x0008
770 #define	TOPO_SENSOR_STATE_SLOT_REMOVE_READY		0x0010
771 #define	TOPO_SENSOR_STATE_SLOT_PWR_OFF			0x0020
772 #define	TOPO_SENSOR_STATE_SLOT_REMOVED			0x0040
773 #define	TOPO_SENSOR_STATE_SLOT_INTERLOCK_ASSERTED	0x0080
774 #define	TOPO_SENSOR_STATE_SLOT_DISABLED			0x0100
775 #define	TOPO_SENSOR_STATE_SLOT_SPARE_DEVICE		0x0200
776 
777 #define	TOPO_SENSOR_TYPE_ACPI				0x0022
778 
779 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S0_G0		0x0001
780 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S1		0x0002
781 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S2		0x0004
782 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S3		0x0008
783 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S4		0x0010
784 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S5_G2_SOFT_OFF	0x0020
785 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S4_S5_SOFT_OFF	0x0040
786 #define	TOPO_SENSOR_STATE_ACPI_PSATTE_G3_MECH_OFF	0x0080
787 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S1_S2_S3_SLEEP	0x0100
788 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_G1_SLEEP		0x0200
789 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_S5_OVERRIDE	0x0400
790 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_LEGACY_ON		0x0800
791 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_LEGACY_OFF	0x1000
792 #define	TOPO_SENSOR_STATE_ACPI_PSTATE_UNKNOWN		0x2000
793 
794 #define	TOPO_SENSOR_TYPE_WATCHDOG2			0x0023
795 
796 #define	TOPO_SENSOR_STATE_WATCHDOG2_EXPIRED		0x0001
797 #define	TOPO_SENSOR_STATE_WATCHDOG2_HARD_RESET		0x0002
798 #define	TOPO_SENSOR_STATE_WATCHDOG2_PWR_DOWN		0x0004
799 #define	TOPO_SENSOR_STATE_WATCHDOG2_PWR_CYCLE		0x0008
800 #define	TOPO_SENSOR_STATE_WATCHDOG2_RESERVED1		0x0010
801 #define	TOPO_SENSOR_STATE_WATCHDOG2_RESERVED2		0x0020
802 #define	TOPO_SENSOR_STATE_WATCHDOG2_RESERVED3		0x0040
803 #define	TOPO_SENSOR_STATE_WATCHDOG2_RESERVED4		0x0080
804 #define	TOPO_SENSOR_STATE_WATCHDOG2_TIMEOUT_INT		0x0100
805 
806 #define	TOPO_SENSOR_TYPE_ALERT				0x0024
807 
808 #define	TOPO_SENSOR_STATE_ALERT_PLAT_PAGE		0x0001
809 #define	TOPO_SENSOR_STATE_ALERT_PLAT_LAN_ALERT		0x0002
810 #define	TOPO_SENSOR_STATE_ALERT_PLAT_EVT_TRAP		0x0004
811 #define	TOPO_SENSOR_STATE_ALERT_PLAT_SNMP_TRAP		0x0008
812 
813 #define	TOPO_SENSOR_TYPE_PRESENCE			0x0025
814 
815 #define	TOPO_SENSOR_STATE_PRESENCE_PRESENT		0x0001
816 #define	TOPO_SENSOR_STATE_PRESENCE_ABSENT		0x0002
817 #define	TOPO_SENSOR_STATE_PRESENCE_DISABLED		0x0004
818 
819 #define	TOPO_SENSOR_TYPE_ASIC				0x0026
820 
821 #define	TOPO_SENSOR_TYPE_LAN				0x0027
822 
823 #define	TOPO_SENSOR_STATE_LAN_HEARTBEAT_LOST		0x0001
824 #define	TOPO_SENSOR_STATE_LAN_HEARTBEAT			0x0002
825 
826 #define	TOPO_SENSOR_TYPE_HEALTH				0x0028
827 
828 #define	TOPO_SENSOR_STATE_HEALTH_SENSOR_ACC_DEGRADED	0x0001
829 #define	TOPO_SENSOR_STATE_HEALTH_CNTLR_ACC_DEGRADED	0x0002
830 #define	TOPO_SENSOR_STATE_HEALTH_CNTLR_OFFLINE		0x0004
831 #define	TOPO_SENSOR_STATE_HEALTH_CNTLR_UNAVAIL		0x0008
832 #define	TOPO_SENSOR_STATE_HEALTH_SENSOR_FAILURE		0x0010
833 #define	TOPO_SENSOR_STATE_HEALTH_FRU_FAILURE		0x0020
834 
835 #define	TOPO_SENSOR_TYPE_BATTERY			0x0029
836 
837 #define	TOPO_SENSOR_STATE_BATTERY_LOW			0x0001
838 #define	TOPO_SENSOR_STATE_BATTERY_FAILED		0x0002
839 #define	TOPO_SENSOR_STATE_BATTERY_PRESENCE		0x0004
840 
841 #define	TOPO_SENSOR_TYPE_AUDIT				0x002A
842 
843 #define	TOPO_SENSOR_STATE_AUDIT_SESSION_ACTIVATED	0x0001
844 #define	TOPO_SENSOR_STATE_AUDIT_SESSION_DEACTIVATED	0x0002
845 
846 #define	TOPO_SENSOR_TYPE_VERSION			0x002B
847 
848 #define	TOPO_SENSOR_STATE_VERSION_HW_CHANGE		0x0001
849 #define	TOPO_SENSOR_STATE_VERSION_SW_CHANGE		0x0002
850 #define	TOPO_SENSOR_STATE_VERSION_HW_INCOMPATIBLE	0x0004
851 #define	TOPO_SENSOR_STATE_VERSION_SW_INCOMPATIBLE	0x0008
852 #define	TOPO_SENSOR_STATE_VERSION_HW_INVAL		0x0010
853 #define	TOPO_SENSOR_STATE_VERSION_SW_INVAL		0x0020
854 #define	TOPO_SENSOR_STATE_VERSION_HW_CHANGE_SUCCESS	0x0040
855 #define	TOPO_SENSOR_STATE_VERSION_SW_CHANGE_SUCCESS	0x0080
856 
857 #define	TOPO_SENSOR_TYPE_FRU_STATE			0x002C
858 
859 #define	TOPO_SENSOR_STATE_FRU_STATE_NOT_INSTALLED	0x0001
860 #define	TOPO_SENSOR_STATE_FRU_STATE_INACTIVE		0x0002
861 #define	TOPO_SENSOR_STATE_FRU_STATE_ACT_REQ		0x0004
862 #define	TOPO_SENSOR_STATE_FRU_STATE_ACT_INPROGRESS	0x0008
863 #define	TOPO_SENSOR_STATE_FRU_STATE_ACTIVE		0x0010
864 #define	TOPO_SENSOR_STATE_FRU_STATE_DEACT_REQ		0x0020
865 #define	TOPO_SENSOR_STATE_FRU_STATE_DEACT_INPROGRESS	0x0040
866 #define	TOPO_SENSOR_STATE_FRU_STATE_COMM_LOST		0x0080
867 
868 /*
869  * We simplify the IPMI sensor type code defines by combining the generic
870  * and sensor-specific codes into a single range.  Because there's overlap
871  * between the two ranges we offset the generic type codes by 0x0100
872  * which allows ample room in the hole for future expansion of the table to
873  * accomodate either additions to the IPMI spec or to support new sensor types
874  * for alternate provider modules.
875  */
876 #define	TOPO_SENSOR_TYPE_THRESHOLD_STATE		0x0101
877 
878 #define	TOPO_SENSOR_STATE_THRESH_LOWER_NONCRIT		0x0001
879 #define	TOPO_SENSOR_STATE_THRESH_LOWER_CRIT		0x0002
880 #define	TOPO_SENSOR_STATE_THRESH_LOWER_NONREC		0x0004
881 #define	TOPO_SENSOR_STATE_THRESH_UPPER_NONCRIT		0x0008
882 #define	TOPO_SENSOR_STATE_THRESH_UPPER_CRIT		0x0010
883 #define	TOPO_SENSOR_STATE_THRESH_UPPER_NONREC		0x0020
884 
885 #define	TOPO_SENSOR_TYPE_GENERIC_USAGE			0x0102
886 
887 #define	TOPO_SENSOR_STATE_GENERIC_USAGE_IDLE		0x0001
888 #define	TOPO_SENSOR_STATE_GENERIC_USAGE_ACTIVE		0x0002
889 #define	TOPO_SENSOR_STATE_GENERIC_USAGE_BUSY		0x0004
890 
891 #define	TOPO_SENSOR_TYPE_GENERIC_STATE			0x0103
892 
893 #define	TOPO_SENSOR_STATE_GENERIC_STATE_DEASSERTED	0x0001
894 #define	TOPO_SENSOR_STATE_GENERIC_STATE_ASSERTED	0x0002
895 
896 #define	TOPO_SENSOR_TYPE_GENERIC_PREDFAIL		0x0104
897 
898 #define	TOPO_SENSOR_STATE_GENERIC_PREDFAIL_DEASSERTED	0x0001
899 #define	TOPO_SENSOR_STATE_GENERIC_PREDFAIL_ASSERTED	0x0002
900 
901 #define	TOPO_SENSOR_TYPE_GENERIC_LIMIT			0x0105
902 
903 #define	TOPO_SENSOR_STATE_GENERIC_LIMIT_NOT_EXCEEDED	0x0001
904 #define	TOPO_SENSOR_STATE_GENERIC_LIMIT_EXCEEDED	0x0002
905 
906 #define	TOPO_SENSOR_TYPE_GENERIC_PERFORMANCE		0x0106
907 
908 #define	TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_MET	0x0001
909 #define	TOPO_SENSOR_STATE_GENERIC_PERFORMANCE_LAGS	0x0002
910 
911 #define	TOPO_SENSOR_TYPE_SEVERITY			0x0107
912 
913 #define	TOPO_SENSOR_STATE_SEVERITY_OK			0x0001
914 #define	TOPO_SENSOR_STATE_SEVERITY_NONCRIT_GOING_HIGH	0x0002
915 #define	TOPO_SENSOR_STATE_SEVERITY_CRIT_GOING_HIGH	0x0004
916 #define	TOPO_SENSOR_STATE_SEVERITY_NONREC_GOING_HIGH	0x0008
917 #define	TOPO_SENSOR_STATE_SEVERITY_NONCRIT_GOING_LOW	0x0010
918 #define	TOPO_SENSOR_STATE_SEVERITY_CRIT_GOING_LOW	0x0020
919 #define	TOPO_SENSOR_STATE_SEVERITY_NONREC_GOING_LOW	0x0020
920 #define	TOPO_SENSOR_STATE_SEVERITY_MONITOR		0x0040
921 #define	TOPO_SENSOR_STATE_SEVERITY_INFORMATIONAL	0x0080
922 
923 #define	TOPO_SENSOR_TYPE_GENERIC_PRESENCE		0x0108
924 
925 #define	TOPO_SENSOR_STATE_GENERIC_PRESENCE_DEASSERTED	0x0001
926 #define	TOPO_SENSOR_STATE_GENERIC_PRESENCE_ASSERTED	0x0002
927 
928 #define	TOPO_SENSOR_TYPE_GENERIC_AVAILABILITY		0x0109
929 
930 #define	TOPO_SENSOR_STATE_GENERIC_AVAIL_DEASSERTED	0x0001
931 #define	TOPO_SENSOR_STATE_GENERIC_AVAIL_ASSERTED	0x0002
932 
933 #define	TOPO_SENSOR_TYPE_GENERIC_STATUS			0x010A
934 
935 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_RUNNING	0x0001
936 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_IN_TEST	0x0002
937 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_POWER_OFF	0x0004
938 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_ONLINE		0x0008
939 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_OFFLINE	0x0010
940 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_OFF_DUTY	0x0020
941 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_DEGRADED	0x0040
942 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_POWER_SAVE	0x0080
943 #define	TOPO_SENSOR_STATE_GENERIC_STATUS_INSTALL_ERR	0x0100
944 
945 #define	TOPO_SENSOR_TYPE_GENERIC_REDUNDANCY		0x010B
946 
947 /*
948  * ACPI power state
949  */
950 #define	TOPO_SENSOR_TYPE_GENERIC_ACPI			0x010C
951 
952 #define	TOPO_SENSOR_STATE_GENERIC_ACPI_D0		0x0001
953 #define	TOPO_SENSOR_STATE_GENERIC_ACPI_D1		0x0002
954 #define	TOPO_SENSOR_STATE_GENERIC_ACPI_D2		0x0004
955 #define	TOPO_SENSOR_STATE_GENERIC_ACPI_D3		0x0008
956 
957 /*
958  * These sensor types don't exist in the IPMI spec, but allow consumers to
959  * associate discrete sensors with component failure.  The 'ok' sensor is the
960  * inverse of the 'failure' sensor.  Note that the values intentionally mimic
961  * TOPO_SENSOR_TYPE_GENERIC_STATE, so that you can use existing IPMI sensors
962  * but just change the type to get semantically meaningful behavior.
963  */
964 #define	TOPO_SENSOR_TYPE_GENERIC_FAILURE		0x010D
965 
966 #define	TOPO_SENSOR_STATE_GENERIC_FAIL_DEASSERTED	0x0001
967 #define	TOPO_SENSOR_STATE_GENERIC_FAIL_NONRECOV		0x0002
968 #define	TOPO_SENSOR_STATE_GENERIC_FAIL_CRITICAL		0x0004
969 
970 #define	TOPO_SENSOR_TYPE_GENERIC_OK			0x010E
971 
972 #define	TOPO_SENSOR_STATE_GENERIC_OK_DEASSERTED		0x0001
973 #define	TOPO_SENSOR_STATE_GENERIC_OK_ASSERTED		0x0002
974 
975 /*
976  * Indicator modes and types
977  */
978 typedef enum topo_led_state {
979 	TOPO_LED_STATE_OFF = 0,
980 	TOPO_LED_STATE_ON
981 } topo_led_state_t;
982 
983 #define	TOPO_FAC_TYPE_ANY	0xFFFFFFFF
984 
985 /*
986  * This list is limited to the set of LED's that we're likely to manage through
987  * FMA.  Thus is does not include things like power or activity LED's
988  */
989 typedef enum topo_led_type {
990 	TOPO_LED_TYPE_SERVICE = 0,
991 	TOPO_LED_TYPE_LOCATE,
992 	TOPO_LED_TYPE_OK2RM,
993 	TOPO_LED_TYPE_PRESENT
994 } topo_led_type_t;
995 
996 
997 #ifdef __cplusplus
998 }
999 #endif
1000 
1001 #endif /* _LIBTOPO_H */
1002