xref: /titanic_50/usr/src/lib/libipmi/common/libipmi.h (revision c533a883a71cff9ff32df1c53c31201e1cbf371f)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBIPMI_H
27 #define	_LIBIPMI_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/bmc_intf.h>
32 #include <sys/byteorder.h>
33 #include <sys/sysmacros.h>
34 
35 /*
36  * Private interfaces for communicating with attached services over IPMI.  This
37  * library is designed for system software communicating with Sun-supported
38  * service processors over /dev/bmc.  It is not a generic IPMI library.
39  *
40  * Documentation references refer to "Intelligent Platform Management Interface
41  * Specification Second Generation v2.0", document revision 1.0 with Februrary
42  * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision
43  * 3".
44  */
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 typedef struct ipmi_handle ipmi_handle_t;
51 
52 #pragma pack(1)
53 
54 /*
55  * Basic netfn definitions.  See section 5.1.
56  */
57 #define	IPMI_NETFN_APP			BMC_NETFN_APP
58 #define	IPMI_NETFN_STORAGE		BMC_NETFN_STORAGE
59 #define	IPMI_NETFN_SE			BMC_NETFN_SE
60 #define	IPMI_NETFN_OEM			0x2e
61 
62 /*
63  * Error definitions
64  */
65 #define	EIPMI_BASE	2000
66 
67 typedef enum {
68 	EIPMI_NOMEM = EIPMI_BASE,	/* memory allocation failure */
69 	EIPMI_BMC_OPEN_FAILED,		/* failed to open /dev/bmc */
70 	EIPMI_BMC_PUTMSG,		/* failed to send message to /dev/bmc */
71 	EIPMI_BMC_GETMSG,	/* failed to read response from /dev/bmc */
72 	EIPMI_BMC_RESPONSE,		/* response from /dev/bmc failed */
73 	EIPMI_INVALID_COMMAND,		/* invalid command */
74 	EIPMI_COMMAND_TIMEOUT,		/* command timeout */
75 	EIPMI_DATA_LENGTH_EXCEEDED,	/* maximum data length exceeded */
76 	EIPMI_SEND_FAILED,		/* failed to send BMC request */
77 	EIPMI_UNSPECIFIED,		/* unspecified BMC error */
78 	EIPMI_UNKNOWN,			/* unknown error */
79 	EIPMI_BAD_RESPONSE,		/* received unexpected response */
80 	EIPMI_BAD_RESPONSE_LENGTH,	/* unexpected response length */
81 	EIPMI_INVALID_RESERVATION,	/* invalid or cancelled reservation */
82 	EIPMI_NOT_PRESENT,		/* requested entity not present */
83 	EIPMI_INVALID_REQUEST,		/* malformed request data */
84 	EIPMI_BUSY,			/* service processor is busy */
85 	EIPMI_NOSPACE,			/* service processor is out of space */
86 	EIPMI_UNAVAILABLE,		/* service processor is unavailable */
87 	EIPMI_ACCESS			/* insufficient privileges */
88 } ipmi_errno_t;
89 
90 /*
91  * Basic library functions.
92  *
93  * The ipmi_handle is the primary interface to the library.  The library itself
94  * is not MT-safe, but it is safe within a single handle.  Multithreaded clients
95  * should either open multiple handles, or otherwise synchronize access to the
96  * same handle.
97  *
98  * There is a single command response buffer that is stored with the handle, to
99  * simplify memory management in the caller.  The memory referenced by a command
100  * response is only valid until the next command is issued.  The caller is
101  * responsible for making a copy of the response if it is needed.
102  */
103 extern ipmi_handle_t *ipmi_open(int *, char **);
104 extern void ipmi_close(ipmi_handle_t *);
105 
106 extern int ipmi_errno(ipmi_handle_t *);
107 extern const char *ipmi_errmsg(ipmi_handle_t *);
108 
109 /*
110  * Raw requests.  See section 5.
111  */
112 typedef struct ipmi_cmd {
113 	uint8_t		ic_netfn:6;
114 	uint8_t		ic_lun:2;
115 	uint8_t		ic_cmd;
116 	uint16_t	ic_dlen;
117 	void		*ic_data;
118 } ipmi_cmd_t;
119 
120 extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
121 
122 /*
123  * Retrieve basic information about the IPMI device.  See section 20.1 "Get
124  * Device ID Command".
125  */
126 #define	IPMI_CMD_GET_DEVICEID		0x01
127 
128 typedef struct ipmi_deviceid {
129 	uint8_t		id_devid;
130 	DECL_BITFIELD3(
131 	    id_dev_rev		:4,
132 	    __reserved		:3,
133 	    id_dev_sdrs		:1);
134 	DECL_BITFIELD2(
135 	    id_firm_major	:7,
136 	    id_dev_available	:1);
137 	uint8_t		id_firm_minor;
138 	uint8_t		id_ipmi_rev;
139 	uint8_t		id_dev_support;
140 	uint8_t		id_manufacturer[3];
141 	uint16_t	id_product;
142 } ipmi_deviceid_t;
143 
144 #define	IPMI_OEM_SUN		0x2a
145 #define	IPMI_PROD_SUN_ILOM	0x4701
146 
147 ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *);
148 
149 #define	ipmi_devid_manufacturer(dp)		\
150 	((dp)->id_manufacturer[0] |		\
151 	((dp)->id_manufacturer[1] << 8) |	\
152 	((dp)->id_manufacturer[2] << 16))
153 
154 const char *ipmi_firmware_version(ipmi_handle_t *);
155 
156 /*
157  * SEL (System Event Log) commands.  Currently the library only provides
158  * commands for reading the SEL.
159  */
160 
161 /*
162  * 31.2 Get SEL Info Command
163  */
164 #define	IPMI_CMD_GET_SEL_INFO		0x40
165 
166 typedef struct ipmi_sel_info {
167 	uint8_t		isel_version;
168 	uint16_t	isel_entries;
169 	uint16_t	isel_free;
170 	uint32_t	isel_add_ts;
171 	uint32_t	isel_erase_ts;
172 	DECL_BITFIELD6(
173 	    isel_supp_allocation	:1,
174 	    isel_supp_reserve		:1,
175 	    isel_supp_partial		:1,
176 	    isel_supp_delete		:1,
177 	    __reserved			:3,
178 	    isel_overflow		:1);
179 } ipmi_sel_info_t;
180 
181 extern ipmi_sel_info_t *ipmi_sel_get_info(ipmi_handle_t *);
182 extern boolean_t ipmi_sdr_changed(ipmi_handle_t *);
183 extern int ipmi_sdr_refresh(ipmi_handle_t *);
184 
185 /*
186  * 32.1 SEL Event Records
187  */
188 typedef struct ipmi_sel_event {
189 	uint16_t	isel_ev_next;
190 	uint16_t	isel_ev_recid;
191 	uint8_t		isel_ev_rectype;
192 	uint32_t	isel_ev_ts;
193 	DECL_BITFIELD2(
194 	    isel_ev_software	:1,
195 	    isel_ev_addr_or_id	:7);
196 	DECL_BITFIELD3(
197 	    isel_ev_lun		:2,
198 	    __reserved		:2,
199 	    isel_ev_channel	:4);
200 	uint8_t		isel_ev_rev;
201 	uint8_t		isel_ev_sensor_type;
202 	uint8_t		isel_ev_sensor_number;
203 	DECL_BITFIELD2(
204 	    isel_ev_type	:7,
205 	    isel_ev_dir		:1);
206 	uint8_t		isel_ev_data[3];
207 } ipmi_sel_event_t;
208 
209 #define	IPMI_EV_REV15		0x04
210 #define	IPMI_EV_REV1		0x03
211 
212 #define	IPMI_SEL_SYSTEM		0x02
213 #define	IPMI_SEL_OEMTS_LO	0xC0
214 #define	IPMI_SEL_OEMTS_HI	0xDF
215 #define	IPMI_SEL_OEM_LO		0xE0
216 #define	IPMI_SEL_OEM_HI		0xFF
217 
218 #define	IPMI_EV_ASSERT		0x0
219 #define	IPMI_EV_DEASSERT	0x1
220 
221 /*
222  * 32.2 OEM SEL Record (with timestamp)
223  */
224 typedef struct ipmi_sel_oem_ts {
225 	uint16_t	isel_oem_next;
226 	uint16_t	isel_oem_id;
227 	uint8_t		isel_oem_type;
228 	uint32_t	isel_oem_ts;
229 	uint8_t		isel_oem_devid[3];
230 	uint8_t		isel_oem_data[6];
231 } ipmi_sel_oem_ts_t;
232 
233 /*
234  * 32.3 OEM SEL Record (no timestamp)
235  */
236 typedef struct ipmi_sel_oem {
237 	uint16_t	isel_oem_next;
238 	uint16_t	isel_oem_id;
239 	uint8_t		isel_oem_type;
240 	uint8_t		isel_oem_data[13];
241 } ipmi_sel_oem_t;
242 
243 /*
244  * 29.7 Event Data Field Formats.  Consumers can cast the data field of the
245  * event record to the appropriate type depending on the sensor class.
246  */
247 
248 typedef struct ipmi_event_threshold {
249 	DECL_BITFIELD3(
250 	    iev_offset		:4,
251 	    iev_desc_byte3	:2,
252 	    iev_desc_byte2	:2);
253 	uint8_t		iev_reading;
254 	uint8_t		iev_threshold;
255 } ipmi_event_threshold_t;
256 
257 #define	IPMI_EV_DESC_UNSPECIFIED	0x00
258 #define	IPMI_EV_DESC_TRIGGER		0x01
259 #define	IPMI_EV_DESC_OEM		0x02
260 #define	IPMI_EV_DESC_SPECIFIC		0x03
261 
262 typedef struct ipmi_event_discrete {
263 	DECL_BITFIELD3(
264 	    iev_offset		:4,
265 	    iev_desc_byte3	:2,
266 	    iev_desc_byte2	:2);
267 	DECL_BITFIELD2(
268 	    iev_offset_type	:4,
269 	    iev_offset_severity	:4);
270 	uint8_t		iev_oem_code;
271 } ipmi_event_discrete_t;
272 
273 #define	IPMI_EV_DESC_PREVSTATE		0x01
274 #define	IPMI_EV_DESC_SPECIFIC		0x03
275 
276 typedef struct ipmi_event_oem {
277 	DECL_BITFIELD3(
278 	    iev_offset		:4,
279 	    iev_desc_byte3	:2,
280 	    iev_desc_byte2	:2);
281 	DECL_BITFIELD2(
282 	    iev_offset_type	:4,
283 	    iev_offset_severity	:4);
284 	uint8_t		iev_oem_code;
285 } ipmi_event_oem_t;
286 
287 /*
288  * Get SEL Entry Command.  See section 31.5.  We don't support partial reads, so
289  * this interface is quite a bit simpler than in the spec.  We default to
290  * returning event records, though the consumer should check the type field and
291  * cast it to the appropriate type if it is no IPMI_SEL_SYSTEM.
292  */
293 #define	IPMI_CMD_GET_SEL_ENTRY		0x43
294 
295 extern ipmi_sel_event_t *ipmi_sel_get_entry(ipmi_handle_t *, uint16_t);
296 
297 #define	IPMI_SEL_FIRST_ENTRY		0x0000
298 #define	IPMI_SEL_LAST_ENTRY		0xFFFF
299 
300 /*
301  * SEL time management.  See sections 31.10 and 31.11.
302  */
303 #define	IPMI_CMD_GET_SEL_TIME		0x48
304 #define	IPMI_CMD_SET_SEL_TIME		0x49
305 #define	IPMI_CMD_GET_SEL_UTC_OFFSET	0x5C
306 #define	IPMI_CMD_SET_SEL_UTC_OFFSET	0x5D
307 
308 extern int ipmi_sel_get_time(ipmi_handle_t *, uint32_t *);
309 extern int ipmi_sel_set_time(ipmi_handle_t *, uint32_t);
310 extern int ipmi_sel_get_utc_offset(ipmi_handle_t *, int *);
311 extern int ipmi_sel_set_utc_offset(ipmi_handle_t *, int);
312 
313 /*
314  * SDR (Sensor Device Record) requests.  A cache of the current SDR repository
315  * is kept as part of the IPMI handle and updated when necessary.  This does the
316  * work of processing the SDR names and providing an easy way to lookup
317  * individual records and iterate over all records.
318  */
319 
320 /*
321  * Get SDR Repository Info Command.  See section 33.9.
322  */
323 #define	IPMI_CMD_GET_SDR_INFO		0x20
324 
325 typedef struct ipmi_sdr_info {
326 	uint8_t		isi_version;
327 	uint16_t	isi_record_count;
328 	uint16_t	isi_free_space;
329 	uint32_t	isi_add_ts;
330 	uint32_t	isi_erase_ts;
331 	DECL_BITFIELD7(
332 	    isi_supp_allocation		:1,
333 	    isi_supp_reserve		:1,
334 	    isi_supp_partial		:1,
335 	    isi_supp_delete		:1,
336 	    __reserved			:1,
337 	    isi_modal			:2,
338 	    isi_overflow		:1);
339 } ipmi_sdr_info_t;
340 
341 extern ipmi_sdr_info_t *ipmi_sdr_get_info(ipmi_handle_t *);
342 
343 /*
344  * Reserve repository command.  See section 33.11.
345  */
346 #define	IPMI_CMD_RESERVE_SDR_REPOSITORY	0x22
347 
348 /*
349  * Get SDR command.  See section 33.12.  This command accesses the raw SDR
350  * repository.  Clients can also use the lookup functions to retrieve a
351  * particular SDR record by name.
352  *
353  * The list of possible types is indicated in the sub-chapters of section 43.
354  */
355 typedef struct ipmi_sdr {
356 	uint16_t	is_id;
357 	uint8_t		is_version;
358 	uint8_t		is_type;
359 	uint8_t		is_length;
360 	uint8_t		is_record[1];
361 } ipmi_sdr_t;
362 #define	IPMI_CMD_GET_SDR		0x23
363 
364 #define	IPMI_SDR_FIRST			0x0000
365 #define	IPMI_SDR_LAST			0xFFFF
366 
367 extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
368 
369 /*
370  * Full Sensor Record.  See 43.1
371  */
372 #define	IPMI_SDR_TYPE_FULL_SENSOR		0x01
373 
374 typedef struct ipmi_sdr_full_sensor {
375 	/* RECORD KEY BYTES */
376 	uint8_t		is_fs_owner;
377 	DECL_BITFIELD3(
378 	    is_fs_sensor_lun			:2,
379 	    __reserved1				:2,
380 	    is_fs_channel			:4);
381 	uint8_t		is_fs_number;
382 	/* RECORD BODY BYTES */
383 	uint8_t		is_fs_entity_id;
384 	DECL_BITFIELD2(
385 	    is_fs_entity_instance		:7,
386 	    is_fs_entity_logical		:1);
387 	DECL_BITFIELD8(
388 	    is_fs_sensor_scanning_enabled	:1,
389 	    is_fs_event_generation_enabled	:1,
390 	    is_fs_init_sensor_type		:1,
391 	    is_fs_init_hysteresis		:1,
392 	    is_fs_init_thresholds		:1,
393 	    is_fs_init_events			:1,
394 	    is_fs_init_scanning			:1,
395 	    is_fs_settable			:1);
396 	DECL_BITFIELD5(
397 	    is_fs_event_support			:2,
398 	    is_fs_threshold_support		:2,
399 	    is_fs_hysteresis_support		:2,
400 	    is_fs_rearm_support			:1,
401 	    is_fs_ignore			:1);
402 	uint8_t		is_fs_type;
403 	uint8_t		is_fs_reading_type;
404 	uint16_t	is_fs_assert_mask;
405 	uint16_t	is_fs_deassert_mask;
406 	uint16_t	is_fs_reading_mask;
407 	DECL_BITFIELD4(
408 	    is_fs_units_isprcnt			:1,
409 	    is_fs_mod_unit			:2,
410 	    is_fs_rate_unit			:3,
411 	    is_fs_analog_fmt			:2);
412 	uint8_t		is_fs_unit2;
413 	uint8_t		is_fs_unit3;
414 	/* Linearization */
415 	DECL_BITFIELD2(
416 	    is_fs_sensor_linear_type		:7,
417 	    __reserved2				:1);
418 	/* M, Tolerance */
419 	uint16_t	is_fs_mtol;
420 	/* B, Accuracy, R exp, B exp */
421 	uint32_t	is_fs_bacc;
422 	DECL_BITFIELD4(
423 	    is_fs_nominal_reading_spec		:1,
424 	    is_fs_normal_max_spec		:1,
425 	    is_fs_normal_min_spec		:1,
426 	    __reserved3				:5);
427 	uint8_t	is_fs_nominal_reading;
428 	uint8_t	is_fs_normal_maximum;
429 	uint8_t	is_fs_normal_minimum;
430 	uint8_t	is_fs_max;
431 	uint8_t	is_fs_min;
432 	uint8_t is_fs_upper_nonrecov;
433 	uint8_t	is_fs_upper_critical;
434 	uint8_t	is_fs_upper_noncrit;
435 	uint8_t	is_fs_lower_nonrecov;
436 	uint8_t	is_fs_lower_critical;
437 	uint8_t	is_fs_lower_noncrit;
438 	uint8_t		is_fs_hysteresis_positive;
439 	uint8_t		is_fs_hysteresis_negative;
440 	uint16_t	__reserved4;
441 	uint8_t		is_fs_oem;
442 	DECL_BITFIELD3(
443 	    is_fs_idlen				:5,
444 	    __reserved5				:1,
445 	    is_fs_idtype			:2);
446 	char		is_fs_idstring[1];
447 } ipmi_sdr_full_sensor_t;
448 
449 #define	IPMI_SDR_TYPE_COMPACT_SENSOR		0x02
450 
451 /*
452  * Compact Sensor Record.  See section 43.2
453  */
454 typedef struct ipmi_sdr_compact_sensor {
455 	/* RECORD KEY BYTES */
456 	uint8_t		is_cs_owner;
457 	DECL_BITFIELD3(
458 	    is_cs_sensor_lun			:2,
459 	    is_cs_fru_lun			:2,
460 	    is_cs_channel			:4);
461 	uint8_t		is_cs_number;
462 	/* RECORD BODY BYTES */
463 	uint8_t		is_cs_entity_id;
464 	DECL_BITFIELD2(
465 	    is_cs_entity_instance		:7,
466 	    is_cs_entity_logical		:1);
467 	DECL_BITFIELD8(
468 	    is_cs_sensor_scanning_enabled	:1,
469 	    is_cs_event_generation_enabled	:1,
470 	    is_cs_init_sensor_type		:1,
471 	    is_cs_init_hysteresis		:1,
472 	    __reserved1				:1,
473 	    is_cs_init_events			:1,
474 	    is_cs_init_scanning			:1,
475 	    is_cs_settable			:1);
476 	DECL_BITFIELD5(
477 	    is_cs_event_support			:2,
478 	    is_cs_threshold_support		:2,
479 	    is_cs_hysteresis_support		:2,
480 	    is_cs_rearm_support			:1,
481 	    is_cs_ignore			:1);
482 	uint8_t		is_cs_type;
483 	uint8_t		is_cs_reading_type;
484 	uint16_t	is_cs_assert_mask;
485 	uint16_t	is_cs_deassert_mask;
486 	uint16_t	is_cs_reading_mask;
487 	DECL_BITFIELD4(
488 	    is_cs_units_isprcnt			:1,
489 	    is_cs_mod_unit			:2,
490 	    is_cs_rate_unit			:3,
491 	    __reserved2				:2);
492 	uint8_t		is_cs_unit2;
493 	uint8_t		is_cs_unit3;
494 	DECL_BITFIELD3(
495 	    is_cs_share_count			:4,
496 	    is_cs_modifier_type			:2,
497 	    is_cs_direction			:2);
498 	DECL_BITFIELD2(
499 	    is_cs_modifier_offset		:7,
500 	    is_cs_sharing			:1);
501 	uint8_t		is_cs_hysteresis_positive;
502 	uint8_t		is_cs_hysteresis_negative;
503 	uint16_t	__reserved3;
504 	uint8_t		__reserved4;
505 	uint8_t		is_cs_oem;
506 	DECL_BITFIELD3(
507 	    is_cs_idlen				:5,
508 	    __reserved5				:1,
509 	    is_cs_idtype			:2);
510 	char		is_cs_idstring[1];
511 } ipmi_sdr_compact_sensor_t;
512 
513 /*
514  * Threshold sensor masks for is_cs_assert_mask and is_cs_deassert_mask.
515  */
516 #define	IPMI_SENSOR_RETURN_NONRECOV	0x4000
517 #define	IPMI_SENSOR_RETURN_CRIT		0x2000
518 #define	IPMI_SENSOR_RETURN_NONCRIT	0x1000
519 
520 #define	IPMI_SENSOR_MASK_UPPER_NONRECOV_HI	0x0800
521 #define	IPMI_SENSOR_MASK_UPPER_NONRECOV_LO	0x0400
522 #define	IPMI_SENSOR_MASK_UPPER_CRIT_HI		0x0200
523 #define	IPMI_SENSOR_MASK_UPPER_CRIT_LO		0x0100
524 #define	IPMI_SENSOR_MASK_UPPER_NONCRIT_HI	0x0080
525 #define	IPMI_SENSOR_MASK_UPPER_NONCRIT_LO	0x0040
526 #define	IPMI_SENSOR_MASK_LOWER_NONRECOV_HI	0x0020
527 #define	IPMI_SENSOR_MASK_LOWER_NONRECOV_LO	0x0010
528 #define	IPMI_SENSOR_MASK_LOWER_CRIT_HI		0x0008
529 #define	IPMI_SENSOR_MASK_LOWER_CRIT_LO		0x0004
530 #define	IPMI_SENSOR_MASK_LOWER_NONCRIT_HI	0x0002
531 #define	IPMI_SENSOR_MASK_LOWER_NONCRIT_LO	0x0001
532 
533 /*
534  * Threshold sensor masks for is_cs_reading_mask.
535  */
536 #define	IPMI_SENSOR_SETTABLE_UPPER_NONRECOV	0x2000
537 #define	IPMI_SENSOR_SETTABLE_UPPER_CRIT		0x1000
538 #define	IPMI_SENSOR_SETTABLE_UPPER_NONCRIT	0x0800
539 #define	IPMI_SENSOR_SETTABLE_LOWER_NONRECOV	0x0400
540 #define	IPMI_SENSOR_SETTABLE_LOWER_CRIT		0x0200
541 #define	IPMI_SENSOR_SETTABLE_LOWER_NONCRIT	0x0100
542 #define	IPMI_SENSOR_READABLE_UPPER_NONRECOV	0x0020
543 #define	IPMI_SENSOR_READABLE_UPPER_CRIT		0x0010
544 #define	IPMI_SENSOR_READABLE_UPPER_NONCRIT	0x0008
545 #define	IPMI_SENSOR_READABLE_LOWER_NONRECOV	0x0004
546 #define	IPMI_SENSOR_READABLE_LOWER_CRIT		0x0002
547 #define	IPMI_SENSOR_READABLE_LOWER_NONCRIT	0x0001
548 
549 /*
550  * Values for is_cs_reading_type.  See table 42-2.
551  */
552 #define	IPMI_RT_THRESHOLD			0x01
553 #define	IPMI_RT_USAGE				0x02
554 #define	IPMI_RT_STATE				0x03
555 #define	IPMI_RT_PREDFAIL			0x04
556 #define	IPMI_RT_LIMIT				0x05
557 #define	IPMI_RT_PERFORMANCE			0x06
558 #define	IPMI_RT_SEVERITY			0x07
559 #define	IPMI_RT_PRESENT				0x08
560 #define	IPMI_RT_ENABLED				0x09
561 #define	IPMI_RT_AVAILABILITY			0x0A
562 #define	IPMI_RT_REDUNDANCY			0x0B
563 #define	IPMI_RT_ACPI				0x0C
564 #define	IPMI_RT_SPECIFIC			0x6F
565 
566 /*
567  * Bitmasks based on above reading types.  See table 42-2
568  */
569 #define	IPMI_SR_THRESHOLD_LOWER_NONCRIT_LOW	0x0001
570 #define	IPMI_SR_THRESHOLD_LOWER_NONCRIT_HIGH	0x0002
571 #define	IPMI_SR_THRESHOLD_LOWER_CRIT_LOW	0x0004
572 #define	IPMI_SR_THRESHOLD_LOWER_CRIT_HIGH	0x0008
573 #define	IPMI_SR_THRESHOLD_LOWER_NONRECOV_LOW	0x0010
574 #define	IPMI_SR_THRESHOLD_LOWER_NONRECOV_HIGH	0x0020
575 #define	IPMI_SR_THRESHOLD_UPPER_NONCRIT_LOW	0x0040
576 #define	IPMI_SR_THRESHOLD_UPPER_NONCRIT_HIGH	0x0080
577 #define	IPMI_SR_THRESHOLD_UPPER_CRIT_LOW	0x0100
578 #define	IPMI_SR_THRESHOLD_UPPER_CRIT_HIGH	0x0200
579 #define	IPMI_SR_THRESHOLD_UPPER_NONRECOV_LOW	0x0400
580 #define	IPMI_SR_THRESHOLD_UPPER_NONRECOV_HIGH	0x0800
581 
582 #define	IPMI_SR_USAGE_IDLE			0x0001
583 #define	IPMI_SR_USAGE_ACTIVE			0x0002
584 #define	IPMI_SR_USAGE_BUSY			0x0004
585 
586 #define	IPMI_SR_STATE_DEASSERT			0x0001
587 #define	IPMI_SR_STATE_ASSERT			0x0002
588 
589 #define	IPMI_SR_PREDFAIL_DEASSERT		0x0001
590 #define	IPMI_SR_PREDFAIL_ASSERT			0x0002
591 
592 #define	IPMI_SR_LIMIT_NOTEXCEEDED		0x0001
593 #define	IPMI_SR_LIMIT_EXCEEDED			0x0002
594 
595 #define	IPMI_SR_PERFORMANCE_MET			0x0001
596 #define	IPMI_SR_PERFORMANCE_LAGS		0x0002
597 
598 #define	IPMI_SR_SEVERITY_TO_OK			0x0001
599 #define	IPMI_SR_SEVERITY_OK_TO_NONCRIT		0x0002
600 #define	IPMI_SR_SEVERITY_LESS_TO_CRIT		0x0004
601 #define	IPMI_SR_SEVERITY_LESS_TO_NONRECOV	0x0008
602 #define	IPMI_SR_SEVERITY_MORE_TO_NONCRIT	0x0010
603 #define	IPMI_SR_SEVERITY_NONRECOV_TO_CRIT	0x0020
604 #define	IPMI_SR_SEVERITY_TO_NONRECOV		0x0040
605 #define	IPMI_SR_SEVERITY_MONITOR		0x0080
606 #define	IPMI_SR_SEVERITY_INFO			0x0100
607 
608 #define	IPMI_SR_PRESENT_DEASSERT		0x0001
609 #define	IPMI_SR_PRESENT_ASSERT			0x0002
610 
611 #define	IPMI_SR_ENABLED_DEASSERT		0x0001
612 #define	IPMI_SR_ENABLED_ASSERT			0x0002
613 
614 #define	IPMI_SR_AVAILABILITY_RUNNING		0x0001
615 #define	IPMI_SR_AVAILABILITY_INTEST		0x0002
616 #define	IPMI_SR_AVAILABILITY_POWEROFF		0x0004
617 #define	IPMI_SR_AVAILABILITY_ONLINE		0x0008
618 #define	IPMI_SR_AVAILABILITY_OFFLINE		0x0010
619 #define	IPMI_SR_AVAILABILITY_OFFDUTY		0x0020
620 #define	IPMI_SR_AVAILABILITY_DEGRADED		0x0040
621 #define	IPMI_SR_AVAILABILITY_POWERSAVE		0x0080
622 #define	IPMI_SR_AVAILABILITY_INSTALLERR		0x0100
623 
624 #define	IPMI_SR_REDUNDANCY_FULL			0x0001
625 #define	IPMI_SR_REDUNDANCY_LOST			0x0002
626 #define	IPMI_SR_REDUNDANCY_DEGRADED		0x0004
627 #define	IPMI_SR_REDUNDANCY_NONE_MINIMAL		0x0008
628 #define	IPMI_SR_REDUNDANCY_NONE_REGAINED	0x0010
629 #define	IPMI_SR_REDUNDANCY_NONE_INSUFFFICIENT	0x0020
630 #define	IPMI_SR_REDUNDANCY_DEG_FROM_FULL	0x0040
631 #define	IPMI_SR_REDUNDANCY_DEG_FROM_NON		0x0080
632 
633 #define	IPMI_SR_ACPI_DO				0x0001
634 #define	IPMI_SR_ACPI_D1				0x0002
635 #define	IPMI_SR_ACPI_D2				0x0004
636 #define	IPMI_SR_ACPI_D3				0x0008
637 
638 /*
639  * Bitmasks for sensor-specific reading type (0x6F).  See section 42.2.
640  */
641 #define	IPMI_ST_RESERVED			0x00
642 #define	IPMI_ST_TEMP				0x01
643 #define	IPMI_ST_VOLTAGE				0x02
644 #define	IPMI_ST_CURRENT				0x03
645 #define	IPMI_ST_FAN				0x04
646 #define	IPMI_ST_PHYSICAL			0x05
647 
648 #define	IPMI_EV_PHYSICAL_GENERAL		0x0001
649 #define	IPMI_EV_PHYSICAL_BAY			0x0002
650 #define	IPMI_EV_PHYSICAL_CARD			0x0004
651 #define	IPMI_EV_PHYSICAL_PROCESSOR		0x0008
652 #define	IPMI_EV_PHYSICAL_LAN			0x0010
653 #define	IPMI_EV_PHYSICAL_DOCK			0x0020
654 #define	IPMI_EV_PHYSICAL_FAN			0x0040
655 
656 #define	IPMI_ST_PLATFORM			0x06
657 
658 #define	IPMI_EV_PLATFORM_SECURE			0x0001
659 #define	IPMI_EV_PLATFORM_USER_PASS		0x0002
660 #define	IPMI_EV_PLATFORM_SETUP_PASS		0x0004
661 #define	IPMI_EV_PLATFORM_NETWORK_PASS		0x0008
662 #define	IPMI_EV_PLATFORM_OTHER_PASS		0x0010
663 #define	IPMI_EV_PLATFORM_OUT_OF_BAND		0x0020
664 
665 #define	IPMI_ST_PROCESSOR			0x07
666 
667 #define	IPMI_EV_PROCESSOR_IERR			0x0001
668 #define	IPMI_EV_PROCESSOR_THERMAL		0x0002
669 #define	IPMI_EV_PROCESSOR_FRB1			0x0004
670 #define	IPMI_EV_PROCESSOR_FRB2			0x0008
671 #define	IPMI_EV_PROCESSOR_FRB3			0x0010
672 #define	IPMI_EV_PROCESSOR_CONFIG		0x0020
673 #define	IPMI_EV_PROCESSOR_SMBIOS		0x0040
674 #define	IPMI_EV_PROCESSOR_PRESENT		0x0080
675 #define	IPMI_EV_PROCESSOR_DISABLED		0x0100
676 #define	IPMI_EV_PROCESSOR_TERMINATOR		0x0200
677 #define	IPMI_EV_PROCESSOR_THROTTLED		0x0400
678 
679 #define	IPMI_ST_POWER_SUPPLY			0x08
680 
681 #define	IPMI_EV_POWER_SUPPLY_PRESENT		0x0001
682 #define	IPMI_EV_POWER_SUPPLY_FAILURE		0x0002
683 #define	IPMI_EV_POWER_SUPPLY_PREDFAIL		0x0004
684 #define	IPMI_EV_POWER_SUPPLY_INPUT_LOST		0x0008
685 #define	IPMI_EV_POWER_SUPPLY_INPUT_RANGE	0x0010
686 #define	IPMI_EV_POWER_SUPPLY_INPUT_RANGE_PRES	0x0020
687 #define	IPMI_EV_POWER_SUPPLY_CONFIG_ERR		0x0040
688 
689 #define	IPMI_ST_POWER_UNIT			0x09
690 
691 #define	IPMI_EV_POWER_UNIT_OFF			0x0001
692 #define	IPMI_EV_POWER_UNIT_CYCLE		0x0002
693 #define	IPMI_EV_POWER_UNIT_240_DOWN		0x0004
694 #define	IPMI_EV_POWER_UNIT_INTERLOCK_DOWN	0x0008
695 #define	IPMI_EV_POWER_UNIT_AC_LOST		0x0010
696 #define	IPMI_EV_POWER_UNIT_SOFT_FAILURE		0x0020
697 #define	IPMI_EV_POWER_UNIT_FAIL			0x0040
698 #define	IPMI_EV_POWER_UNIT_PREDFAIL		0x0080
699 
700 #define	IPMI_ST_COOLING				0x0A
701 #define	IPMI_ST_OTHER				0x0B
702 #define	IPMI_ST_MEMORY				0x0C
703 
704 #define	IPMI_EV_MEMORY_CE			0x0001
705 #define	IPMI_EV_MEMORY_UE			0x0002
706 #define	IPMI_EV_MEMORY_PARITY			0x0004
707 #define	IPMI_EV_MEMORY_SCRUB_FAIL		0x0008
708 #define	IPMI_EV_MEMORY_DISABLED			0x0010
709 #define	IPMI_EV_MEMORY_CE_LOG_LIMIT		0x0020
710 #define	IPMI_EV_MEMORY_PRESENT			0x0040
711 #define	IPMI_EV_MEMORY_CONFIG_ERR		0x0080
712 #define	IPMI_EV_MEMORY_SPARE			0x0100
713 #define	IPMI_EV_MEMORY_THROTTLED		0x0200
714 #define	IPMI_EV_MEMORY_OVERTEMP			0x0400
715 
716 #define	IPMI_ST_BAY				0x0D
717 
718 #define	IPMI_EV_BAY_PRESENT			0x0001
719 #define	IPMI_EV_BAY_FAULT			0x0002
720 #define	IPMI_EV_BAY_PREDFAIL			0x0004
721 #define	IPMI_EV_BAY_SPARE			0x0008
722 #define	IPMI_EV_BAY_CHECK			0x0010
723 #define	IPMI_EV_BAY_CRITICAL			0x0020
724 #define	IPMI_EV_BAY_FAILED			0x0040
725 #define	IPMI_EV_BAY_REBUILDING			0x0080
726 #define	IPMI_EV_BAY_ABORTED			0x0100
727 
728 #define	IPMI_ST_POST_RESIZE			0x0E
729 #define	IPMI_ST_FIRMWARE			0x0F
730 
731 #define	IPMI_EV_FIRMWARE_ERROR			0x0001
732 #define	IPMI_EV_FIRMWARE_HANG			0x0002
733 #define	IPMI_EV_FIRMWARE_PROGRESS		0x0004
734 
735 #define	IPMI_ST_EVENT_LOG			0x10
736 
737 #define	IPMI_EV_EVENT_LOG_CE			0x0001
738 #define	IPMI_EV_EVENT_LOG_TYPE			0x0002
739 #define	IPMI_EV_EVENT_LOG_RESET			0x0004
740 #define	IPMI_EV_EVENT_LOG_ALL			0x0008
741 #define	IPMI_EV_EVENT_LOG_FULL			0x0010
742 #define	IPMI_EV_EVENT_LOG_ALMOST_FULL		0x0020
743 
744 #define	IPMI_ST_WATCHDOG1			0x11
745 
746 #define	IPMI_EV_WATCHDOG_BIOS_RESET		0x0001
747 #define	IPMI_EV_WATCHDOG_OS_RESET		0x0002
748 #define	IPMI_EV_WATCHDOG_OS_SHUTDOWN		0x0004
749 #define	IPMI_EV_WATCHDOG_OS_PWR_DOWN		0x0008
750 #define	IPMI_EV_WATCHDOG_OS_PWR_CYCLE		0x0010
751 #define	IPMI_EV_WATCHDOG_OS_NMI_DIAG		0x0020
752 #define	IPMI_EV_WATCHDOG_EXPIRED		0x0040
753 #define	IPMI_EV_WATCHDOG_PRE_TIMEOUT_INT	0x0080
754 
755 #define	IPMI_ST_SYSTEM				0x12
756 
757 #define	IPMI_EV_STSTEM_RECONF			0x0001
758 #define	IPMI_EV_STSTEM_BOOT			0x0002
759 #define	IPMI_EV_STSTEM_UNKNOWN_HW_FAILURE	0x0004
760 #define	IPMI_EV_STSTEM_AUX_LOG_UPDATED		0x0008
761 #define	IPMI_EV_STSTEM_PEF_ACTION		0x0010
762 #define	IPMI_EV_SYSTEM_TIMETAMP_CLOCKSYNC	0x0020
763 
764 #define	IPMI_ST_CRITICAL			0x13
765 
766 #define	IPMI_EV_CRITICAL_EXT_NMI		0x0001
767 #define	IPMI_EV_CRITICAL_BUS_TIMOEOUT		0x0002
768 #define	IPMI_EV_CRITICAL_IO_NMI			0x0004
769 #define	IPMI_EV_CRITICAL_SW_NMI			0x0008
770 #define	IPMI_EV_CRITICAL_PCI_PERR		0x0010
771 #define	IPMI_EV_CRITICAL_PCI_SERR		0x0020
772 #define	IPMI_EV_CRITICAL_EISA_FAILSAFE		0x0040
773 #define	IPMI_EV_CRITICAL_BUS_CE			0x0080
774 #define	IPMI_EV_CRITICAL_BUS_UE			0x0100
775 #define	IPMI_EV_CRITICAL_FATAL_NMI		0x0200
776 #define	IPMI_EV_CRITICAL_BUS_FATAL_ERR		0x0400
777 #define	IPMI_EV_CRITICAL_BUS_DEGRADED		0x0800
778 
779 #define	IPMI_ST_BUTTON				0x14
780 
781 #define	IPMI_EV_BUTTON_PWR			0x0001
782 #define	IPMI_EV_BUTTON_SLEEP			0x0002
783 #define	IPMI_EV_BUTTON_RESET			0x0004
784 #define	IPMI_EV_BUTTON_FRU_LATCH		0x0008
785 #define	IPMI_EV_BUTTON_FRU_SERVICE		0x0010
786 
787 #define	IPMI_ST_MODULE				0x15
788 #define	IPMI_ST_MICROCONTROLLER			0x16
789 #define	IPMI_ST_CARD				0x17
790 #define	IPMI_ST_CHASSIS				0x18
791 
792 #define	IPMI_ST_CHIPSET				0x19
793 
794 #define	IPMI_EV_CHIPSET_PWR_CTL_FAIL		0x0001
795 
796 #define	IPMI_ST_FRU				0x1A
797 #define	IPMI_ST_CABLE				0x1B
798 
799 #define	IPMI_EV_CABLE_CONNECTED			0x0001
800 #define	IPMI_EV_CABLE_CONFIG_ERR		0x0002
801 
802 #define	IPMI_ST_TERMINATOR			0x1C
803 
804 #define	IPMI_ST_BOOT				0x1D
805 
806 #define	IPMI_EV_BOOT_BIOS_PWR_UP		0x0001
807 #define	IPMI_EV_BOOT_BIOS_HARD_RESET		0x0002
808 #define	IPMI_EV_BOOT_BIOS_WARM_RESET		0x0004
809 #define	IPMI_EV_BOOT_PXE_BOOT			0x0008
810 #define	IPMI_EV_BOOT_DIAG_BOOT			0x0010
811 #define	IPMI_EV_BOOT_OS_HARD_RESET		0x0020
812 #define	IPMI_EV_BOOT_OS_WARM_RESET		0x0040
813 #define	IPMI_EV_BOOT_SYS_RESTART		0x0080
814 
815 #define	IPMI_ST_BOOT_ERROR			0x1E
816 
817 #define	IPMI_EV_BOOT_ERROR_NOMEDIA		0x0001
818 #define	IPMI_EV_BOOT_ERROR_NON_BOOTABLE_DISK	0x0002
819 #define	IPMI_EV_BOOT_ERROR_NO_PXE_SERVER	0x0004
820 #define	IPMI_EV_BOOT_ERROR_INV_BOOT_SECT	0x0008
821 #define	IPMI_EV_BOOT_ERROR_USR_SELECT_TIMEOUT	0x0010
822 
823 #define	IPMI_ST_BOOT_OS				0x1F
824 
825 #define	IPMI_EV_BOOT_OS_A_DRV_BOOT_COMPLETE	0x0001
826 #define	IPMI_EV_BOOT_OS_C_DRV_BOOT_COMPLETE	0x0002
827 #define	IPMI_EV_BOOT_OS_PXE_BOOT_COMPLETE	0x0004
828 #define	IPMI_EV_BOOT_OS_DIAG_BOOT_COMPLETE	0x0008
829 #define	IPMI_EV_BOOT_OS_CDROM_BOOT_COMPLETE	0x0010
830 #define	IPMI_EV_BOOT_OS_ROM_BOOT_COMPLETE	0x0020
831 #define	IPMI_EV_BOOT_OS_UNSPEC_BOOT_COMPLETE	0x0040
832 
833 #define	IPMI_ST_OS_SHUTDOWN			0x20
834 
835 #define	IPMI_EV_OS_SHUTDOWN_LOADING		0x0001
836 #define	IPMI_EV_OS_SHUTDOWN_CRASH		0x0002
837 #define	IPMI_EV_OS_STOP_GRACEFUL		0x0004
838 #define	IPMI_EV_OS_SHUTDOWN_GRACEFUL		0x0008
839 #define	IPMI_EV_OS_SHUTDOWN_PEF			0x0010
840 #define	IPMI_EV_OS_SHUTDOWN_BMC			0x0020
841 
842 #define	IPMI_ST_SLOT				0x21
843 
844 #define	IPMI_EV_SLOT_FAULT_ASSERTED		0x0001
845 #define	IPMI_EV_SLOT_IDENTIFY_ASSERTED		0x0002
846 #define	IPMI_EV_SLOT_CONNECTED			0x0004
847 #define	IPMI_EV_SLOT_INSTALL_READY		0x0008
848 #define	IPMI_EV_SLOT_REMOVE_READY		0x0010
849 #define	IPMI_EV_SLOT_PWR_OFF			0x0020
850 #define	IPMI_EV_SLOT_REMOVED			0x0040
851 #define	IPMI_EV_SLOT_INTERLOCK_ASSERTED		0x0080
852 #define	IPMI_EV_SLOT_DISABLED			0x0100
853 #define	IPMI_EV_SLOT_SPARE_DEVICE		0x0200
854 
855 #define	IPMI_ST_ACPI				0x22
856 
857 #define	IPMI_EV_ACPI_PSTATE_S0_G0		0x0001
858 #define	IPMI_EV_ACPI_PSTATE_S1			0x0002
859 #define	IPMI_EV_ACPI_PSTATE_S2			0x0004
860 #define	IPMI_EV_ACPI_PSTATE_S3			0x0008
861 #define	IPMI_EV_ACPI_PSTATE_S4			0x0010
862 #define	IPMI_EV_ACPI_PSTATE_S5_G2_SOFT_OFF	0x0020
863 #define	IPMI_EV_ACPI_PSTATE_S4_S5_SOFT_OFF	0x0040
864 #define	IPMI_EV_ACPI_PSATTE_G3_MECH_OFF		0x0080
865 #define	IPMI_EV_ACPI_PSTATE_S1_S2_S3_SLEEP	0x0100
866 #define	IPMI_EV_ACPI_PSTATE_G1_SLEEP		0x0200
867 #define	IPMI_EV_ACPI_PSTATE_S5_OVERRIDE		0x0400
868 #define	IPMI_EV_ACPI_PSTATE_LEGACY_ON		0x0800
869 #define	IPMI_EV_ACPI_PSTATE_LEGACY_OFF		0x1000
870 #define	IPMI_EV_ACPI_PSTATE_UNKNOWN		0x2000
871 
872 #define	IPMI_ST_WATCHDOG2			0x23
873 
874 #define	IPMI_EV_WATCHDOG2_EXPIRED		0x0001
875 #define	IPMI_EV_WATCHDOG2_HARD_RESET		0x0002
876 #define	IPMI_EV_WATCHDOG2_PWR_DOWN		0x0004
877 #define	IPMI_EV_WATCHDOG2_PWR_CYCLE		0x0008
878 #define	IPMI_EV_WATCHDOG2_RESERVED1		0x0010
879 #define	IPMI_EV_WATCHDOG2_RESERVED2		0x0020
880 #define	IPMI_EV_WATCHDOG2_RESERVED3		0x0040
881 #define	IPMI_EV_WATCHDOG2_RESERVED4		0x0080
882 #define	IPMI_EV_WATCHDOG2_TIMEOUT_INT		0x0100
883 
884 #define	IPMI_ST_ALERT				0x24
885 
886 #define	IPMI_EV_ALERT_PLAT_PAGE			0x0001
887 #define	IPMI_EV_ALERT_PLAT_LAN_ALERT		0x0002
888 #define	IPMI_EV_ALERT_PLAT_EVT_TRAP		0x0004
889 #define	IPMI_EV_ALERT_PLAT_SNMP_TRAP		0x0008
890 
891 #define	IPMI_ST_PRESENCE			0x25
892 
893 #define	IPMI_EV_PRESENCE_PRESENT		0x0001
894 #define	IPMI_EV_PRESENCE_ABSENT			0x0002
895 #define	IPMI_EV_PRESENCE_DISABLED		0x0004
896 
897 #define	IPMI_ST_ASIC				0x26
898 
899 #define	IPMI_ST_LAN				0x27
900 
901 #define	IPMI_EV_LAN_HEARTBEAT_LOST		0x0001
902 #define	IPMI_EV_LAN_HEARTBEAT			0x0002
903 
904 #define	IPMI_ST_HEALTH				0x28
905 
906 #define	IPMI_EV_HEALTH_SENSOR_ACC_DEGRADED	0x0001
907 #define	IPMI_EV_HEALTH_CNTLR_ACC_DEGRADED	0x0002
908 #define	IPMI_EV_HEALTH_CNTLR_OFFLINE		0x0004
909 #define	IPMI_EV_HEALTH_CNTLR_UNAVAIL		0x0008
910 #define	IPMI_EV_HEALTH_SENSOR_FAILURE		0x0010
911 #define	IPMI_EV_HEALTH_FRU_FAILURE		0x0020
912 
913 #define	IPMI_ST_BATTERY				0x29
914 
915 #define	IPMI_EV_BATTERY_LOW			0x0001
916 #define	IPMI_EV_BATTERY_FAILED			0x0002
917 #define	IPMI_EV_BATTERY_PRESENCE		0x0004
918 
919 #define	IPMI_ST_AUDIT				0x2A
920 
921 #define	IPMI_EV_AUDIT_SESSION_ACTIVATED		0x0001
922 #define	IPMI_EV_AUDIT_SESSION_DEACTIVATED	0x0002
923 
924 #define	IPMI_ST_VERSION				0x2B
925 
926 #define	IPMI_EV_VERSION_HW_CHANGE		0x0001
927 #define	IPMI_EV_VERSION_SW_CHANGE		0x0002
928 #define	IPMI_EV_VERSION_HW_INCOMPATIBLE		0x0004
929 #define	IPMI_EV_VERSION_SW_INCOMPATIBLE		0x0008
930 #define	IPMI_EV_VERSION_HW_INVAL		0x0010
931 #define	IPMI_EV_VERSION_SW_INVAL		0x0020
932 #define	IPMI_EV_VERSION_HW_CHANGE_SUCCESS	0x0040
933 #define	IPMI_EV_VERSION_SW_CHANGE_SUCCESS	0x0080
934 
935 #define	IPMI_ST_FRU_STATE			0x2C
936 
937 #define	IPMI_EV_FRU_STATE_NOT_INSTALLED		0x0001
938 #define	IPMI_EV_FRU_STATE_INACTIVE		0x0002
939 #define	IPMI_EV_FRU_STATE_ACT_REQ		0x0004
940 #define	IPMI_EV_FRU_STATE_ACT_INPROGRESS	0x0008
941 #define	IPMI_EV_FRU_STATE_ACTIVE		0x0010
942 #define	IPMI_EV_FRU_STATE_DEACT_REQ		0x0020
943 #define	IPMI_EV_FRU_STATE_DEACT_INPROGRESS	0x0040
944 #define	IPMI_EV_FRU_STATE_COMM_LOST		0x0080
945 
946 /*
947  * Constants for unit type codes.  See Table 43-15.
948  */
949 #define	IPMI_UNITS_UNSPECIFIED			0x00
950 #define	IPMI_UNITS_DEGREES_C			0x01
951 #define	IPMI_UNITS_DEGREES_F			0x02
952 #define	IPMI_UNITS_DEGREES_K			0x03
953 #define	IPMI_UNITS_VOLTS			0x04
954 #define	IPMI_UNITS_AMPS				0x05
955 #define	IPMI_UNITS_WATTS			0x06
956 #define	IPMI_UNITS_JOULES			0x07
957 #define	IPMI_UNITS_COULOMBS			0x08
958 #define	IPMI_UNITS_VA				0x09
959 #define	IPMI_UNITS_NITS				0x0A
960 #define	IPMI_UNITS_LUMEN			0x0B
961 #define	IPMI_UNITS_LUX				0x0C
962 #define	IPMI_UNITS_CANDELA			0x0D
963 #define	IPMI_UNITS_KPA				0x0E
964 #define	IPMI_UNITS_PSI				0x0F
965 
966 #define	IPMI_UNITS_NEWTON			0x10
967 #define	IPMI_UNITS_CFM				0x11
968 #define	IPMI_UNITS_RPM				0x12
969 #define	IPMI_UNITS_HZ				0x13
970 #define	IPMI_UNITS_MICROSEC			0x14
971 #define	IPMI_UNITS_MILLISEC			0x15
972 #define	IPMI_UNITS_SECS				0x16
973 #define	IPMI_UNITS_MIN				0x17
974 #define	IPMI_UNITS_HOUR				0x18
975 #define	IPMI_UNITS_DAY				0x19
976 #define	IPMI_UNITS_WEEK				0x1A
977 #define	IPMI_UNITS_MIL				0x1B
978 #define	IPMI_UNITS_INCHES			0x1C
979 #define	IPMI_UNITS_FEET				0x1D
980 #define	IPMI_UNITS_CUB_INCH			0x1E
981 #define	IPMI_UNITS_CUB_FEET			0x1F
982 
983 #define	IPMI_UNITS_MM				0x20
984 #define	IPMI_UNITS_CM				0x21
985 #define	IPMI_UNITS_METERS			0x22
986 #define	IPMI_UNITS_CUB_CM			0x23
987 #define	IPMI_UNITS_CUB_METER			0x24
988 #define	IPMI_UNITS_LITERS			0x25
989 #define	IPMI_UNITS_FLUID_OUNCE			0x26
990 #define	IPMI_UNITS_RADIANS			0x27
991 #define	IPMI_UNITS_STERADIANS			0x28
992 #define	IPMI_UNITS_REVOLUTIONS			0x29
993 #define	IPMI_UNITS_CYCLES			0x2A
994 #define	IPMI_UNITS_GRAVITIES			0x2B
995 #define	IPMI_UNITS_OUNCE			0x2C
996 #define	IPMI_UNITS_POUND			0x2D
997 #define	IPMI_UNITS_FOOT_POUND			0x2E
998 #define	IPMI_UNITS_OZ_INCH			0x2F
999 
1000 #define	IPMI_UNITS_GAUSS			0x30
1001 #define	IPMI_UNITS_GILBERTS			0x31
1002 #define	IPMI_UNITS_HENRY			0x32
1003 #define	IPMI_UNITS_MILHENRY			0x33
1004 #define	IPMI_UNITS_FARAD			0x34
1005 #define	IPMI_UNITS_MICROFARAD			0x35
1006 #define	IPMI_UNITS_OHMS				0x36
1007 #define	IPMI_UNITS_SIEMENS			0x37
1008 #define	IPMI_UNITS_MOLE				0x38
1009 #define	IPMI_UNITS_BECQUEREL			0x39
1010 #define	IPMI_UNITS_PPM				0x3A
1011 /* 0x3B is reserved */
1012 #define	IPMI_UNITS_DECIBELS			0x3C
1013 #define	IPMI_UNITS_DBA				0x3D
1014 #define	IPMI_UNITS_DBC				0x3E
1015 #define	IPMI_UNITS_GRAY				0x3F
1016 
1017 #define	IPMI_UNITS_SIEVERT			0x40
1018 #define	IPMI_UNITS_COLOR_TEMP_K			0x41
1019 #define	IPMI_UNITS_BIT				0x42
1020 #define	IPMI_UNITS_KILOBIT			0x43
1021 #define	IPMI_UNITS_MEGABIT			0x44
1022 #define	IPMI_UNITS_GIGABIT			0x45
1023 #define	IPMI_UNITS_BYTE				0x46
1024 #define	IPMI_UNITS_KILOBYTE			0x47
1025 #define	IPMI_UNITS_MEGABYTE			0x48
1026 #define	IPMI_UNITS_GIGABYTE			0x49
1027 #define	IPMI_UNITS_WORD				0x4A
1028 #define	IPMI_UNITS_DWORD			0x4B
1029 #define	IPMI_UNITS_QWORD			0x4C
1030 #define	IPMI_UNITS_MEMLINE			0x4D
1031 #define	IPMI_UNITS_HIT				0x4E
1032 #define	IPMI_UNITS_MISS				0x4F
1033 
1034 #define	IPMI_UNITS_RETRY			0x50
1035 #define	IPMI_UNITS_RESET			0x51
1036 #define	IPMI_UNITS_OVERFLOW			0x52
1037 #define	IPMI_UNITS_UNDERRUN			0x53
1038 #define	IPMI_UNITS_COLLISION			0x54
1039 #define	IPMI_UNITS_PACKETS			0x55
1040 #define	IPMI_UNITS_MESSAGES			0x56
1041 #define	IPMI_UNITS_CHARACTERS			0x57
1042 #define	IPMI_UNITS_ERROR			0x58
1043 #define	IPMI_UNITS_CE				0x59
1044 #define	IPMI_UNITS_UE				0x5A
1045 #define	IPMI_UNITS_FATAL_ERROR			0x5B
1046 #define	IPMI_UNITS_GRAMS			0x5C
1047 
1048 /*
1049  * Event-Only Record.  See section 43.3.
1050  */
1051 
1052 #define	IPMI_SDR_TYPE_EVENT_ONLY		0x03
1053 
1054 typedef struct ipmi_sdr_event_only {
1055 	/* RECORD KEY BYTES */
1056 	uint8_t		is_eo_owner;
1057 	DECL_BITFIELD3(
1058 	    is_eo_sensor_lun			:2,
1059 	    is_eo_fru_lun			:2,
1060 	    is_eo_channel			:4);
1061 	uint8_t		is_eo_number;
1062 	/* RECORD BODY BYTES */
1063 	uint8_t		is_eo_entity_id;
1064 	DECL_BITFIELD2(
1065 	    is_eo_entity_instance		:7,
1066 	    is_eo_entity_logical		:1);
1067 	uint8_t		is_eo_sensor_type;
1068 	uint8_t		is_eo_reading_type;
1069 	DECL_BITFIELD3(
1070 	    is_eo_share_count			:4,
1071 	    is_eo_modifier_type			:2,
1072 	    is_eo_direction			:2);
1073 	DECL_BITFIELD2(
1074 	    is_eo_modifier_offset		:7,
1075 	    is_eo_sharing			:1);
1076 	uint8_t		__reserved;
1077 	uint8_t		is_eo_oem;
1078 	DECL_BITFIELD3(
1079 	    is_eo_idlen				:5,
1080 	    __reserved1				:1,
1081 	    is_eo_idtype			:2);
1082 	char		is_eo_idstring[1];
1083 } ipmi_sdr_event_only_t;
1084 
1085 /*
1086  * Entity Association Record.  See section 43.4.
1087  */
1088 
1089 #define	IPMI_SDR_TYPE_ENTITY_ASSOCIATION	0x08
1090 
1091 typedef struct ipmi_sdr_entity_association {
1092 	/* RECORD KEY BYTES */
1093 	uint8_t		is_ea_entity_id;
1094 	uint8_t		is_ea_entity_instance;
1095 	DECL_BITFIELD4(
1096 	    __reserved		:5,
1097 	    is_ea_presence	:1,
1098 	    is_ea_record_link	:1,
1099 	    is_ea_range		:1);
1100 	/* RECORD BODY BYTES */
1101 	struct {
1102 		uint8_t		is_ea_sub_id;
1103 		uint8_t		is_ea_sub_instance;
1104 	} is_ea_sub[4];
1105 } ipmi_sdr_entity_association_t;
1106 
1107 /*
1108  * Device-relative Entity Association Record.  See section 43.5.
1109  */
1110 
1111 #define	IPMI_SDR_TYPE_DEVICE_RELATIVE		0x09
1112 
1113 typedef struct ipmi_sdr_device_relative {
1114 	/* RECORD KEY BYTES */
1115 	uint8_t		is_dr_entity_id;
1116 	uint8_t		is_dr_entity_instance;
1117 	DECL_BITFIELD2(
1118 	    __reserved1			:1,
1119 	    is_dr_slaveaddr		:7);
1120 	DECL_BITFIELD2(
1121 	    __reserved2			:4,
1122 	    is_dr_channel		:4);
1123 	DECL_BITFIELD4(
1124 	    __reserved			:5,
1125 	    is_dr_presence		:1,
1126 	    is_dr_record_link		:1,
1127 	    is_dr_range			:1);
1128 	/* RECORD BODY BYTES */
1129 	struct {
1130 		DECL_BITFIELD2(
1131 		    __reserved3		:1,
1132 		    is_dr_sub_slaveaddr	:7);
1133 		DECL_BITFIELD2(
1134 		    __reserved4		:4,
1135 		    is_dr_sub_channel	:4);
1136 		uint8_t		is_ea_sub_id;
1137 		uint8_t		is_ea_sub_instance;
1138 	} is_ea_sub[4];
1139 } ipmi_sdr_device_relative_t;
1140 
1141 /*
1142  * Generic Device Locator Record.  See section 43.7.
1143  */
1144 
1145 #define	IPMI_SDR_TYPE_GENERIC_LOCATOR		0x10
1146 
1147 typedef struct ipmi_sdr_generic_locator {
1148 	/* RECORD KEY BYTES */
1149 	DECL_BITFIELD2(
1150 	    __reserved1		:1,
1151 	    is_gl_accessaddr	:7);
1152 	DECL_BITFIELD2(
1153 	    is_gl_channel_msb	:1,
1154 	    is_gl_slaveaddr	:7);
1155 	DECL_BITFIELD3(
1156 	    is_gl_bus		:3,
1157 	    is_gl_lun		:2,
1158 	    is_gl_channel	:3);
1159 	/* RECORD BODY BYTES */
1160 	DECL_BITFIELD2(
1161 	    is_gl_span		:3,
1162 	    __reserved2		:5);
1163 	uint8_t		__reserved3;
1164 	uint8_t		is_gl_type;
1165 	uint8_t		is_gl_modifier;
1166 	uint8_t		is_gl_entity;
1167 	uint8_t		is_gl_instance;
1168 	uint8_t		is_gl_oem;
1169 	DECL_BITFIELD3(
1170 	    is_gl_idlen		:5,
1171 	    __reserved4		:1,
1172 	    is_gl_idtype	:2);
1173 	char		is_gl_idstring[1];
1174 } ipmi_sdr_generic_locator_t;
1175 
1176 /*
1177  * FRU Device Locator Record.  See section 43.8.
1178  */
1179 
1180 #define	IPMI_SDR_TYPE_FRU_LOCATOR		0x11
1181 
1182 typedef struct ipmi_sdr_fru_locator {
1183 	/* RECORD KEY BYTES */
1184 	DECL_BITFIELD2(
1185 	    __reserved1		:1,
1186 	    is_fl_accessaddr	:7);
1187 	union {
1188 		struct {
1189 			uint8_t	_is_fl_devid;
1190 		} _logical;
1191 		struct {
1192 			DECL_BITFIELD2(
1193 			    __reserved		:1,
1194 			    _is_fl_slaveaddr	:7);
1195 		} _nonintelligent;
1196 	} _devid_or_slaveaddr;
1197 	DECL_BITFIELD4(
1198 	    is_fl_bus		:3,
1199 	    is_fl_lun		:2,
1200 	    __reserved2		:2,
1201 	    is_fl_logical	:1);
1202 	DECL_BITFIELD2(
1203 	    __reserved3		:4,
1204 	    is_fl_channel	:4);
1205 	/* RECORD BODY BYTES */
1206 	uint8_t		__reserved4;
1207 	uint8_t		is_fl_type;
1208 	uint8_t		is_fl_modifier;
1209 	uint8_t		is_fl_entity;
1210 	uint8_t		is_fl_instance;
1211 	uint8_t		is_fl_oem;
1212 	DECL_BITFIELD3(
1213 	    is_fl_idlen		:5,
1214 	    __reserved5		:1,
1215 	    is_fl_idtype	:2);
1216 	char		is_fl_idstring[1];
1217 } ipmi_sdr_fru_locator_t;
1218 
1219 #define	is_fl_devid	_devid_or_slaveaddr._logical._is_fl_devid
1220 #define	is_fl_slaveaddr	_devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr
1221 
1222 /*
1223  * Management Controller Device Locator Record.  See section 43.9
1224  */
1225 
1226 #define	IPMI_SDR_TYPE_MANAGEMENT_LOCATOR	0x12
1227 
1228 typedef struct ipmi_sdr_management_locator {
1229 	/* RECORD KEY BYTES */
1230 	DECL_BITFIELD2(
1231 	    __reserved1			:1,
1232 	    is_ml_devaddr		:7);
1233 	DECL_BITFIELD2(
1234 	    is_ml_channel		:4,
1235 	    __reserved2			:4);
1236 	/* RECORD BODY BYTES */
1237 	DECL_BITFIELD7(
1238 	    is_ml_init_message		:2,
1239 	    is_ml_init_log		:1,
1240 	    is_ml_init_controller_log	:1,
1241 	    __reserved3			:1,
1242 	    is_ml_static		:1,
1243 	    is_ml_acpi_device		:1,
1244 	    is_ml_acpi_system		:1);
1245 	DECL_BITFIELD8(
1246 	    is_ml_supp_sensor		:1,
1247 	    is_ml_supp_sdr		:1,
1248 	    is_ml_supp_sel		:1,
1249 	    is_ml_supp_fru		:1,
1250 	    is_ml_supp_event_receiver	:1,
1251 	    is_ml_supp_event_generator	:1,
1252 	    is_ml_supp_bridge		:1,
1253 	    is_ml_supp_chassis		:1);
1254 	uint8_t		__reserved4;
1255 	uint16_t	__reserved5;
1256 	uint8_t		is_ml_entity_id;
1257 	uint8_t		is_ml_entity_instance;
1258 	uint8_t		is_ml_oem;
1259 	DECL_BITFIELD3(
1260 	    is_ml_idlen		:5,
1261 	    __reserved6		:1,
1262 	    is_ml_idtype	:2);
1263 	char		is_ml_idstring[1];
1264 } ipmi_sdr_management_locator_t;
1265 
1266 #define	IPMI_MESSAGE_INIT_ENABLE		0x0
1267 #define	IPMI_MESSAGE_INIT_DISABLE		0x1
1268 #define	IPMI_MESSAGE_INIT_NONE			0x2
1269 
1270 /*
1271  *  Management Controller Confirmation Record.  See section 43.10
1272  */
1273 
1274 #define	IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION	0x13
1275 
1276 typedef struct ipmi_sdr_management_confirmation {
1277 	/* RECORD KEY BYTES */
1278 	DECL_BITFIELD2(
1279 	    __reserved1		:1,
1280 	    is_mc_slaveaddr	:7);
1281 	uint8_t		is_mc_deviceid;
1282 	DECL_BITFIELD2(
1283 	    is_mc_dev_revision	:4,
1284 	    is_mc_channel	:4);
1285 	/* RECORD BODY BYTES */
1286 	DECL_BITFIELD2(
1287 	    is_mc_major_rev	:7,
1288 	    __reserved2		:1);
1289 	uint8_t		is_mc_minor_rev;
1290 	uint8_t		is_mc_impi_ver;
1291 	uint8_t		is_mc_manufacturer[3];
1292 	uint16_t	is_mc_product;
1293 	uint8_t		is_mc_guid[16];
1294 } ipmi_sdr_management_confirmation_t;
1295 
1296 /*
1297  * BMC Message Channel Info Record.  See esction 43.11.
1298  */
1299 
1300 #define	IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL	0x14
1301 
1302 typedef struct ipmi_sdr_bmc_channel {
1303 	/* RECORD BODY BYTES */
1304 	struct {
1305 		DECL_BITFIELD3(
1306 		    is_bc_protocol	:4,
1307 		    is_bc_receive_lun	:3,
1308 		    is_bc_transmit	:1);
1309 	} is_bc_channel[8];
1310 	uint8_t		is_bc_interrupt_type;
1311 	uint8_t		is_bc_buffer_type;
1312 	uint8_t		__reserved;
1313 } ipmi_sdr_bmc_channel_t;
1314 
1315 /*
1316  * OEM Record.  See ction 43.12.
1317  */
1318 
1319 #define	IPMI_SDR_TYPE_OEM			0xC0
1320 
1321 typedef struct ipmi_sdr_oem {
1322 	uint8_t		is_oem_manufacturer[3];
1323 	uint8_t		is_oem_data[1];
1324 } ipmi_sdr_oem_t;
1325 
1326 /*
1327  * Iterate over the SDR repository.  This function does the work of parsing the
1328  * name when available, and keeping the repository in a consistent state.
1329  */
1330 extern int ipmi_sdr_iter(ipmi_handle_t *,
1331     int (*)(ipmi_handle_t *, const char *, ipmi_sdr_t *, void *), void *);
1332 
1333 /*
1334  * Lookup the given sensor type by name.  These functions automatically read in
1335  * and cache the complete SDR repository.
1336  */
1337 extern ipmi_sdr_t *ipmi_sdr_lookup(ipmi_handle_t *, const char *);
1338 extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *,
1339     const char *);
1340 extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
1341     const char *);
1342 extern ipmi_sdr_compact_sensor_t *ipmi_sdr_lookup_compact_sensor(
1343     ipmi_handle_t *, const char *);
1344 extern ipmi_sdr_full_sensor_t *ipmi_sdr_lookup_full_sensor(
1345     ipmi_handle_t *, const char *);
1346 
1347 /*
1348  * Entity ID codes.  See table 43.13.
1349  */
1350 #define	IPMI_ET_UNSPECIFIED		0x00
1351 #define	IPMI_ET_OTHER			0x01
1352 #define	IPMI_ET_UNKNOWN			0x02
1353 #define	IPMI_ET_PROCESSOR		0x03
1354 #define	IPMI_ET_DISK			0x04
1355 #define	IPMI_ET_PERIPHERAL		0x05
1356 #define	IPMI_ET_MANAGEMENT_MODULE	0x06
1357 #define	IPMI_ET_MOTHERBOARD		0x07
1358 #define	IPMI_ET_MEMORY_MODULE		0x08
1359 #define	IPMI_ET_PROCESSOR_MODULE	0x09
1360 #define	IPMI_ET_PSU			0x0A
1361 #define	IPMI_ET_CARD			0x0B
1362 #define	IPMI_ET_FRONT_PANEL		0x0C
1363 #define	IPMI_ET_BACK_PANEL		0x0D
1364 #define	IPMI_ET_POWER_BOARD		0x0E
1365 #define	IPMI_ET_BACKPLANE		0x0F
1366 #define	IPMI_ET_EXPANSION_BOARD		0x10
1367 #define	IPMI_ET_OTHER_BOARD		0x11
1368 #define	IPMI_ET_PROCESSOR_BOARD		0x12
1369 #define	IPMI_ET_POWER_DOMAIN		0x13
1370 #define	IPMI_ET_POWER_CONVERTER		0x14
1371 #define	IPMI_ET_POWER_MANAGEMENT	0x15
1372 #define	IPMI_ET_BACK_CHASSIS		0x16
1373 #define	IPMI_ET_SYSTEM_CHASSIS		0x17
1374 #define	IPMI_ET_SUB_CHASSIS		0x18
1375 #define	IPMI_ET_OTHER_CHASSIS		0x19
1376 #define	IPMI_ET_DISK_BAY		0x1A
1377 #define	IPMI_ET_PERIPHERAL_BAY		0x1B
1378 #define	IPMI_ET_DEVICE_BAY		0x1C
1379 #define	IPMI_ET_FAN			0x1D
1380 #define	IPMI_ET_COOLING_DOMAIN		0x1E
1381 #define	IPMI_ET_CABLE			0x1F
1382 #define	IPMI_ET_MEMORY_DEVICE		0x20
1383 #define	IPMI_ET_MANAGEMENT_SOFTWARE	0x21
1384 #define	IPMI_ET_SYSTEM_FIRMWARE		0x22
1385 #define	IPMI_ET_OS			0x23
1386 #define	IPMI_ET_SYSTEM_BUS		0x24
1387 #define	IPMI_ET_GROUP			0x25
1388 #define	IPMI_ET_REMOTE			0x26
1389 #define	IPMI_ET_ENVIRONMENT		0x27
1390 #define	IPMI_ET_BATTERY			0x28
1391 #define	IPMI_ET_BLADE			0x29
1392 #define	IPMI_ET_SWITCH			0x2A
1393 #define	IPMI_ET_PROCMEM_MODULE		0x2B
1394 #define	IPMI_ET_IO_MODULE		0x2C
1395 #define	IPMI_ET_PROCIO_MODULE		0x2D
1396 #define	IPMI_ET_CONTROLLER_FIRMWARE	0x2E
1397 #define	IPMI_ET_CHANNEL			0x2F
1398 #define	IPMI_ET_PCI			0x30
1399 #define	IPMI_ET_PCIE			0x31
1400 #define	IPMI_ET_SCSI			0x32
1401 #define	IPMI_ET_SATA_SAS		0x33
1402 #define	IPMI_ET_FSB			0x34
1403 #define	IPMI_ET_RTC			0x35
1404 
1405 /*
1406  * Get Sensor Reading.  See section 35.14.
1407  */
1408 
1409 #define	IPMI_CMD_GET_SENSOR_READING	0x2d
1410 
1411 typedef struct ipmi_sensor_reading {
1412 	uint8_t		isr_reading;
1413 	DECL_BITFIELD4(
1414 	    __reserved1			:5,
1415 	    isr_state_unavailable	:1,
1416 	    isr_scanning_enabled	:1,
1417 	    isr_event_enabled		:1);
1418 	uint16_t	isr_state;
1419 } ipmi_sensor_reading_t;
1420 
1421 #define	IPMI_SENSOR_THRESHOLD_LOWER_NONCRIT		0x0001
1422 #define	IPMI_SENSOR_THRESHOLD_LOWER_CRIT		0x0002
1423 #define	IPMI_SENSOR_THRESHOLD_LOWER_NONRECOV		0x0004
1424 #define	IPMI_SENSOR_THRESHOLD_UPPER_NONCRIT		0x0008
1425 #define	IPMI_SENSOR_THRESHOLD_UPPER_CRIT		0x0010
1426 #define	IPMI_SENSOR_THRESHOLD_UPPER_NONRECOV		0x0020
1427 
1428 extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
1429 
1430 /*
1431  * Set Sensor Reading.  See section 35.14.
1432  */
1433 #define	IPMI_CMD_SET_SENSOR_READING	0x30
1434 
1435 #define	IPMI_SENSOR_OP_CLEAR	0x3	/* clear '0' bits */
1436 #define	IPMI_SENSOR_OP_SET	0x2	/* set '1' bits */
1437 #define	IPMI_SENSOR_OP_EXACT	0x1	/* set bits exactly */
1438 
1439 typedef struct ipmi_set_sensor_reading {
1440 	uint8_t		iss_id;
1441 	DECL_BITFIELD5(
1442 	    iss_set_reading		:1,
1443 	    __reserved			:1,
1444 	    iss_deassrt_op		:2,
1445 	    iss_assert_op		:2,
1446 	    iss_data_bytes		:2);
1447 	uint8_t		iss_sensor_reading;
1448 	uint16_t	iss_assert_state;	/* optional */
1449 	uint16_t	iss_deassert_state;	/* optional */
1450 	uint8_t		iss_event_data1;	/* optional */
1451 	uint8_t		iss_event_data2;	/* optional */
1452 	uint8_t		iss_event_data3;	/* optional */
1453 } ipmi_set_sensor_reading_t;
1454 
1455 extern int ipmi_set_sensor_reading(ipmi_handle_t *,
1456     ipmi_set_sensor_reading_t *);
1457 
1458 /*
1459  * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec.
1460  *
1461  * Payloads for these two commands are described in Sections 34.1 and 34.2 of
1462  * the spec, respectively.
1463  */
1464 #define	IPMI_CMD_GET_FRU_INV_AREA	0x10
1465 #define	IPMI_CMD_READ_FRU_DATA		0x11
1466 
1467 /*
1468  * Structs to hold the FRU Common Header and the FRU Product Info Area, as
1469  * described in the IPMI Platform Management FRU Information Storage
1470  * Definition (v1.1).
1471  */
1472 typedef struct ipmi_fru_hdr
1473 {
1474 	uint8_t		ifh_format;
1475 	uint8_t		ifh_int_use_off;
1476 	uint8_t		ifh_chassis_info_off;
1477 	uint8_t		ifh_board_info_off;
1478 	uint8_t		ifh_product_info_off;
1479 	uint8_t		ifh_multi_rec_off;
1480 	uint8_t		ifh_pad;
1481 	uint8_t		ifh_chksum;
1482 } ipmi_fru_hdr_t;
1483 
1484 /*
1485  * Because only 6 bits are used to specify the length of each field in the FRU
1486  * product and board info areas, the biggest string we would ever need to hold
1487  * would be 63 chars plus a NULL.
1488  */
1489 #define	FRU_INFO_MAXLEN	64
1490 
1491 typedef struct ipmi_fru_brd_info
1492 {
1493 	char	ifbi_manuf_date[3];
1494 	char	ifbi_manuf_name[FRU_INFO_MAXLEN];
1495 	char	ifbi_board_name[FRU_INFO_MAXLEN];
1496 	char	ifbi_product_serial[FRU_INFO_MAXLEN];
1497 	char	ifbi_part_number[FRU_INFO_MAXLEN];
1498 } ipmi_fru_brd_info_t;
1499 
1500 typedef struct ipmi_fru_prod_info
1501 {
1502 	char	ifpi_manuf_name[FRU_INFO_MAXLEN];
1503 	char	ifpi_product_name[FRU_INFO_MAXLEN];
1504 	char	ifpi_part_number[FRU_INFO_MAXLEN];
1505 	char	ifpi_product_version[FRU_INFO_MAXLEN];
1506 	char	ifpi_product_serial[FRU_INFO_MAXLEN];
1507 	char	ifpi_asset_tag[FRU_INFO_MAXLEN];
1508 } ipmi_fru_prod_info_t;
1509 
1510 extern int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **);
1511 extern int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *);
1512 extern int ipmi_fru_parse_product(ipmi_handle_t *, char *,
1513     ipmi_fru_prod_info_t *);
1514 
1515 /*
1516  * Routines to convert from entity and sensors defines into text strings.
1517  */
1518 void ipmi_entity_name(uint8_t, char *, size_t);
1519 void ipmi_sensor_type_name(uint8_t, char *, size_t);
1520 void ipmi_sensor_reading_name(uint8_t, uint8_t, char *, size_t);
1521 
1522 /*
1523  * Entity management.  IPMI has a notion of 'entities', but these are not
1524  * directly accessible from any commands.  Instead, their existence is inferred
1525  * from examining the SDR repository.  Since this is rather unwieldy, and
1526  * iterating over entities is a common operation, libipmi provides an entity
1527  * abstraction that hides the implementation details.  This handles entity
1528  * groupings as well as SDR associations.
1529  */
1530 typedef struct ipmi_entity {
1531 	uint8_t		ie_type;
1532 	uint8_t		ie_instance;
1533 	uint8_t		ie_children;
1534 	boolean_t	ie_logical;
1535 } ipmi_entity_t;
1536 
1537 extern int ipmi_entity_iter(ipmi_handle_t *, int (*)(ipmi_handle_t *,
1538     ipmi_entity_t *, void *), void *);
1539 extern int ipmi_entity_iter_sdr(ipmi_handle_t *, ipmi_entity_t *,
1540     int (*)(ipmi_handle_t *, ipmi_entity_t *, const char *, ipmi_sdr_t *,
1541     void *), void *);
1542 extern int ipmi_entity_iter_children(ipmi_handle_t *, ipmi_entity_t *,
1543     int (*)(ipmi_handle_t *, ipmi_entity_t *, void *), void *);
1544 extern ipmi_entity_t *ipmi_entity_lookup(ipmi_handle_t *, uint8_t,
1545     uint8_t);
1546 extern ipmi_entity_t *ipmi_entity_lookup_sdr(ipmi_handle_t *, const char *);
1547 extern ipmi_entity_t *ipmi_entity_parent(ipmi_handle_t *, ipmi_entity_t *);
1548 extern int ipmi_entity_present(ipmi_handle_t *, ipmi_entity_t *, boolean_t *);
1549 extern int ipmi_entity_present_sdr(ipmi_handle_t *, ipmi_sdr_t *, boolean_t *);
1550 
1551 /*
1552  * User management.  The raw functions are private to libipmi, and only the
1553  * higher level abstraction (ipmi_user_t) is exported to consumers of the
1554  * library.
1555  */
1556 
1557 #define	IPMI_USER_PRIV_CALLBACK		0x1
1558 #define	IPMI_USER_PRIV_USER		0x2
1559 #define	IPMI_USER_PRIV_OPERATOR		0x3
1560 #define	IPMI_USER_PRIV_ADMIN		0x4
1561 #define	IPMI_USER_PRIV_OEM		0x5
1562 #define	IPMI_USER_PRIV_NONE		0xf
1563 
1564 typedef struct ipmi_user {
1565 	uint8_t		iu_uid;
1566 	char		*iu_name;
1567 	boolean_t	iu_enabled;
1568 	boolean_t	iu_ipmi_msg_enable;
1569 	boolean_t	iu_link_auth_enable;
1570 	uint8_t		iu_priv;
1571 } ipmi_user_t;
1572 
1573 extern int ipmi_user_iter(ipmi_handle_t *,
1574     int (*)(ipmi_user_t *, void *), void *);
1575 extern ipmi_user_t *ipmi_user_lookup_name(ipmi_handle_t *, const char *);
1576 extern ipmi_user_t *ipmi_user_lookup_id(ipmi_handle_t *, uint8_t);
1577 extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *);
1578 
1579 /*
1580  * The remaining functions are private to the implementation of the Sun ILOM
1581  * service processor.  These function first check the manufacturer from the IPMI
1582  * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun
1583  * devices.
1584  */
1585 
1586 /*
1587  * Sun OEM LED requests.
1588  */
1589 
1590 #define	IPMI_SUNOEM_LED_MODE_OFF	0
1591 #define	IPMI_SUNOEM_LED_MODE_ON		1
1592 #define	IPMI_SUNOEM_LED_MODE_STANDBY	2
1593 #define	IPMI_SUNOEM_LED_MODE_SLOW	3
1594 #define	IPMI_SUNOEM_LED_MODE_FAST	4
1595 
1596 /*
1597  * These functions take a SDR record and construct the appropriate form of the
1598  * above commands.
1599  */
1600 extern int ipmi_sunoem_led_set(ipmi_handle_t *,
1601     ipmi_sdr_generic_locator_t *, uint8_t);
1602 extern int ipmi_sunoem_led_get(ipmi_handle_t *,
1603     ipmi_sdr_generic_locator_t *, uint8_t *);
1604 
1605 /*
1606  * Sun OEM uptime.  Note that the underlying command returns the uptime in big
1607  * endian form.  This wrapper automatically converts to the appropriate native
1608  * form.
1609  */
1610 
1611 #define	IPMI_CMD_SUNOEM_UPTIME		0x08
1612 
1613 extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *);
1614 
1615 /*
1616  * Sun OEM FRU update.  The FRU information is managed through a generic
1617  * identifier, and then a type-specific data portion.  The wrapper function will
1618  * automatically fill in the data length field according to which type is
1619  * specified.
1620  */
1621 
1622 #define	IPMI_CMD_SUNOEM_FRU_UPDATE	0x16
1623 
1624 #define	IPMI_SUNOEM_FRU_DIMM	0x00
1625 #define	IPMI_SUNOEM_FRU_CPU	0x01
1626 #define	IPMI_SUNOEM_FRU_BIOS	0x02
1627 #define	IPMI_SUNOEM_FRU_DISK	0x03
1628 
1629 typedef struct ipmi_sunoem_fru {
1630 	uint8_t				isf_type;
1631 	uint8_t				isf_id;
1632 	uint8_t				isf_datalen;
1633 	union {
1634 		struct {
1635 			uint8_t		isf_data[128];
1636 		} dimm;
1637 		struct {
1638 			uint32_t	isf_thermtrip;
1639 			uint32_t	isf_eax;
1640 			char		isf_product[48];
1641 		} cpu;
1642 		struct {
1643 			char		isf_part[16];
1644 			char		isf_version[16];
1645 		} bios;
1646 		struct {
1647 			char		isf_manufacturer[16];
1648 			char		isf_model[28];
1649 			char		isf_serial[20];
1650 			char		isf_version[8];
1651 			char		isf_capacity[16];
1652 		} disk;
1653 	} isf_data;
1654 } ipmi_sunoem_fru_t;
1655 
1656 int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *);
1657 
1658 #pragma pack()
1659 
1660 #ifdef	__cplusplus
1661 }
1662 #endif
1663 
1664 #endif	/* _LIBIPMI_H */
1665