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