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