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