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