xref: /titanic_44/usr/src/lib/libipmi/common/libipmi.h (revision 1af98250c8b03bdc43d8ac3aac6390221d75b92e)
19113a79cSeschrock /*
29113a79cSeschrock  * CDDL HEADER START
39113a79cSeschrock  *
49113a79cSeschrock  * The contents of this file are subject to the terms of the
59113a79cSeschrock  * Common Development and Distribution License (the "License").
69113a79cSeschrock  * You may not use this file except in compliance with the License.
79113a79cSeschrock  *
89113a79cSeschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99113a79cSeschrock  * or http://www.opensolaris.org/os/licensing.
109113a79cSeschrock  * See the License for the specific language governing permissions
119113a79cSeschrock  * and limitations under the License.
129113a79cSeschrock  *
139113a79cSeschrock  * When distributing Covered Code, include this CDDL HEADER in each
149113a79cSeschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159113a79cSeschrock  * If applicable, add the following below this CDDL HEADER, with the
169113a79cSeschrock  * fields enclosed by brackets "[]" replaced with your own identifying
179113a79cSeschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
189113a79cSeschrock  *
199113a79cSeschrock  * CDDL HEADER END
209113a79cSeschrock  */
219113a79cSeschrock /*
229113a79cSeschrock  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
239113a79cSeschrock  * Use is subject to license terms.
249113a79cSeschrock  */
259113a79cSeschrock 
269113a79cSeschrock #ifndef	_LIBIPMI_H
279113a79cSeschrock #define	_LIBIPMI_H
289113a79cSeschrock 
299113a79cSeschrock #pragma ident	"%Z%%M%	%I%	%E% SMI"
309113a79cSeschrock 
319113a79cSeschrock #include <sys/bmc_intf.h>
329113a79cSeschrock #include <sys/byteorder.h>
339113a79cSeschrock 
349113a79cSeschrock /*
359113a79cSeschrock  * Private interfaces for communicating with attached services over IPMI.  This
369113a79cSeschrock  * library is designed for system software communicating with Sun-supported
379113a79cSeschrock  * service processors over /dev/bmc.  It is not a generic IPMI library.
389113a79cSeschrock  *
399113a79cSeschrock  * Documentation references refer to "Intelligent Platform Management Interface
409113a79cSeschrock  * Specification Second Generation v2.0", document revision 1.0 with Februrary
419113a79cSeschrock  * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision
429113a79cSeschrock  * 3".
439113a79cSeschrock  */
449113a79cSeschrock 
459113a79cSeschrock #ifdef	__cplusplus
469113a79cSeschrock extern "C" {
479113a79cSeschrock #endif
489113a79cSeschrock 
499113a79cSeschrock typedef struct ipmi_handle ipmi_handle_t;
509113a79cSeschrock 
519113a79cSeschrock #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
529113a79cSeschrock #error  One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
539113a79cSeschrock #endif
549113a79cSeschrock 
559113a79cSeschrock #pragma pack(1)
569113a79cSeschrock 
579113a79cSeschrock /*
589113a79cSeschrock  * Basic netfn definitions.  See section 5.1.
599113a79cSeschrock  */
609113a79cSeschrock #define	IPMI_NETFN_APP			BMC_NETFN_APP
619113a79cSeschrock #define	IPMI_NETFN_STORAGE		BMC_NETFN_STORAGE
629113a79cSeschrock #define	IPMI_NETFN_SE			BMC_NETFN_SE
639113a79cSeschrock #define	IPMI_NETFN_OEM			0x2e
649113a79cSeschrock 
659113a79cSeschrock /*
669113a79cSeschrock  * Error definitions
679113a79cSeschrock  */
689113a79cSeschrock #define	EIPMI_BASE	2000
699113a79cSeschrock 
709113a79cSeschrock enum {
719113a79cSeschrock 	EIPMI_NOMEM = EIPMI_BASE,	/* memory allocation failure */
729113a79cSeschrock 	EIPMI_BMC_OPEN_FAILED,		/* failed to open /dev/bmc */
739113a79cSeschrock 	EIPMI_BMC_PUTMSG,		/* putmsg() failed */
749113a79cSeschrock 	EIPMI_BMC_GETMSG,		/* getmsg() failed */
759113a79cSeschrock 	EIPMI_BMC_RESPONSE,		/* response from /dev/bmc failed */
769113a79cSeschrock 	EIPMI_INVALID_COMMAND,		/* invalid command */
779113a79cSeschrock 	EIPMI_COMMAND_TIMEOUT,		/* command timeout */
789113a79cSeschrock 	EIPMI_DATA_LENGTH_EXCEEDED,	/* maximum data length exceeded */
799113a79cSeschrock 	EIPMI_SEND_FAILED,		/* failed to send BMC request */
809113a79cSeschrock 	EIPMI_UNSPECIFIED,		/* unspecified error */
819113a79cSeschrock 	EIPMI_UNKNOWN,			/* unknown error */
829113a79cSeschrock 	EIPMI_BAD_RESPONSE,		/* received unexpected response */
839113a79cSeschrock 	EIPMI_BAD_RESPONSE_LENGTH,	/* unexpected response length */
849113a79cSeschrock 	EIPMI_INVALID_RESERVATION,	/* invalid reservation */
859113a79cSeschrock 	EIPMI_NOT_PRESENT,		/* requested entity not present */
869113a79cSeschrock 	EIPMI_INVALID_REQUEST,		/* malformed request */
879113a79cSeschrock 	EIPMI_BUSY,			/* SP is busy */
889113a79cSeschrock 	EIPMI_NOSPACE,			/* SP is out of space */
899113a79cSeschrock 	EIPMI_UNAVAILABLE,		/* SP is present but unavailable */
909113a79cSeschrock 	EIPMI_ACCESS			/* insufficient privileges */
919113a79cSeschrock };
929113a79cSeschrock 
939113a79cSeschrock /*
949113a79cSeschrock  * Basic library functions.
959113a79cSeschrock  *
969113a79cSeschrock  * The ipmi_handle is the primary interface to the library.  The library itself
979113a79cSeschrock  * is not MT-safe, but it is safe within a single handle.  Multithreaded clients
989113a79cSeschrock  * should either open multiple handles, or otherwise synchronize access to the
999113a79cSeschrock  * same handle.
1009113a79cSeschrock  *
1019113a79cSeschrock  * There is a single command response buffer that is stored with the handle, to
1029113a79cSeschrock  * simplify memory management in the caller.  The memory referenced by a command
1039113a79cSeschrock  * response is only valid until the next command is issued.  The caller is
1049113a79cSeschrock  * responsible for making a copy of the response if it is needed.
1059113a79cSeschrock  */
1069113a79cSeschrock extern ipmi_handle_t *ipmi_open(int *, char **);
1079113a79cSeschrock extern void ipmi_close(ipmi_handle_t *);
1089113a79cSeschrock 
1099113a79cSeschrock extern int ipmi_errno(ipmi_handle_t *);
1109113a79cSeschrock extern const char *ipmi_errmsg(ipmi_handle_t *);
1119113a79cSeschrock 
1129113a79cSeschrock /*
1139113a79cSeschrock  * Raw requests.  See section 5.
1149113a79cSeschrock  */
1159113a79cSeschrock typedef struct ipmi_cmd {
1169113a79cSeschrock 	uint8_t		ic_netfn:6;
1179113a79cSeschrock 	uint8_t		ic_lun:2;
1189113a79cSeschrock 	uint8_t		ic_cmd;
1199113a79cSeschrock 	uint16_t	ic_dlen;
1209113a79cSeschrock 	void		*ic_data;
1219113a79cSeschrock } ipmi_cmd_t;
1229113a79cSeschrock 
1239113a79cSeschrock extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
1249113a79cSeschrock 
1259113a79cSeschrock /*
1269113a79cSeschrock  * Retrieve basic information about the IPMI device.  See section 20.1 "Get
1279113a79cSeschrock  * Device ID Command".
1289113a79cSeschrock  */
1299113a79cSeschrock #define	IPMI_CMD_GET_DEVICEID		0x01
1309113a79cSeschrock 
1319113a79cSeschrock typedef struct ipmi_deviceid {
1329113a79cSeschrock 	uint8_t		id_devid;
1339113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
1349113a79cSeschrock 	uint8_t		id_dev_rev:4;
1359113a79cSeschrock 	uint8_t		__reserved:3;
1369113a79cSeschrock 	uint8_t		id_dev_sdrs:1;
1379113a79cSeschrock #else
1389113a79cSeschrock 	uint8_t		id_dev_sdrs:1;
1399113a79cSeschrock 	uint8_t		__reserved:3;
1409113a79cSeschrock 	uint8_t		id_dev_rev:4;
1419113a79cSeschrock #endif
142a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH)
1439113a79cSeschrock 	uint8_t		id_firm_major:7;
1449113a79cSeschrock 	uint8_t		id_dev_available:1;
1459113a79cSeschrock #else
1469113a79cSeschrock 	uint8_t		id_dev_available:1;
1479113a79cSeschrock 	uint8_t		id_firm_major:7;
1489113a79cSeschrock #endif
1499113a79cSeschrock 	uint8_t		id_firm_minor;
1509113a79cSeschrock 	uint8_t		id_ipmi_rev;
1519113a79cSeschrock 	uint8_t		id_dev_support;
1529113a79cSeschrock 	uint8_t		id_manufacturer[3];
1539113a79cSeschrock 	uint16_t	id_product;
1549113a79cSeschrock } ipmi_deviceid_t;
1559113a79cSeschrock 
1569113a79cSeschrock #define	IPMI_OEM_SUN	0x2a
1579113a79cSeschrock 
1589113a79cSeschrock ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *);
1599113a79cSeschrock 
1609113a79cSeschrock #define	ipmi_devid_manufacturer(dp)		\
1619113a79cSeschrock 	((dp)->id_manufacturer[0] |		\
1629113a79cSeschrock 	((dp)->id_manufacturer[1] << 8) |	\
1639113a79cSeschrock 	((dp)->id_manufacturer[2] << 16))
1649113a79cSeschrock 
1659113a79cSeschrock /*
1669113a79cSeschrock  * SDR (Sensor Device Record) requests.  A cache of the current SDR repository
1679113a79cSeschrock  * is kept as part of the IPMI handle and updated when necessary.  Routines to
1689113a79cSeschrock  * access the raw SDR repository are also provided.
1699113a79cSeschrock  */
1709113a79cSeschrock 
1719113a79cSeschrock /*
1729113a79cSeschrock  * Reserve repository command.  See section 33.11.
1739113a79cSeschrock  */
1749113a79cSeschrock #define	IPMI_CMD_RESERVE_SDR_REPOSITORY	0x22
1759113a79cSeschrock 
1769113a79cSeschrock /*
1779113a79cSeschrock  * Get SDR command.  See section 33.12.  This command accesses the raw SDR
1789113a79cSeschrock  * repository.  Clients can also use the lookup functions to retrieve a
1799113a79cSeschrock  * particular SDR record by name.
1809113a79cSeschrock  *
1819113a79cSeschrock  * The list of possible types is indicated in the sub-chapters of section 43.
1829113a79cSeschrock  */
1839113a79cSeschrock typedef struct ipmi_sdr {
1849113a79cSeschrock 	uint16_t	is_id;
1859113a79cSeschrock 	uint8_t		is_version;
1869113a79cSeschrock 	uint8_t		is_type;
1879113a79cSeschrock 	uint8_t		is_length;
1889113a79cSeschrock 	uint8_t		is_record[1];
1899113a79cSeschrock } ipmi_sdr_t;
1909113a79cSeschrock #define	IPMI_CMD_GET_SDR		0x23
1919113a79cSeschrock 
1929113a79cSeschrock #define	IPMI_SDR_FIRST			0x0000
1939113a79cSeschrock #define	IPMI_SDR_LAST			0xFFFF
1949113a79cSeschrock 
1959113a79cSeschrock extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
1969113a79cSeschrock 
1979113a79cSeschrock /*
1989113a79cSeschrock  * Generic Device Locator Record.  See section 43.7.
1999113a79cSeschrock  */
2009113a79cSeschrock 
2019113a79cSeschrock #define	IPMI_SDR_TYPE_GENERIC_LOCATOR		0x10
2029113a79cSeschrock 
2039113a79cSeschrock typedef struct ipmi_sdr_generic_locator {
2049113a79cSeschrock 	/* RECORD KEY BYTES */
2059113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2069113a79cSeschrock 	uint8_t		__reserved1:1;
2079113a79cSeschrock 	uint8_t		is_gl_accessaddr:7;
2089113a79cSeschrock 	uint8_t		is_gl_channel_msb:1;
2099113a79cSeschrock 	uint8_t		is_gl_slaveaddr:7;
2109113a79cSeschrock 	uint8_t		is_gl_bus:3;
2119113a79cSeschrock 	uint8_t		is_gl_lun:2;
2129113a79cSeschrock 	uint8_t		is_gl_channel:3;
2139113a79cSeschrock #else
2149113a79cSeschrock 	uint8_t		is_gl_accessaddr:7;
2159113a79cSeschrock 	uint8_t		__reserved1:1;
2169113a79cSeschrock 	uint8_t		is_gl_slaveaddr:7;
2179113a79cSeschrock 	uint8_t		is_gl_channel_msb:1;
2189113a79cSeschrock 	uint8_t		is_gl_channel:3;
2199113a79cSeschrock 	uint8_t		is_gl_lun:2;
2209113a79cSeschrock 	uint8_t		is_gl_bus:3;
2219113a79cSeschrock #endif
2229113a79cSeschrock 	/* RECORD BODY BYTES */
2239113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2249113a79cSeschrock 	uint8_t		is_gl_span:3;
2259113a79cSeschrock 	uint8_t		__reserved2:5;
2269113a79cSeschrock #else
2279113a79cSeschrock 	uint8_t		__reserved2:5;
2289113a79cSeschrock 	uint8_t		is_gl_span:3;
2299113a79cSeschrock #endif
2309113a79cSeschrock 	uint8_t		__reserved3;
2319113a79cSeschrock 	uint8_t		is_gl_type;
2329113a79cSeschrock 	uint8_t		is_gl_modifier;
2339113a79cSeschrock 	uint8_t		is_gl_entity;
2349113a79cSeschrock 	uint8_t		is_gl_instance;
2359113a79cSeschrock 	uint8_t		is_gl_oem;
2369113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2379113a79cSeschrock 	uint8_t		is_gl_idlen:6;
2389113a79cSeschrock 	uint8_t		is_gl_idtype:2;
2399113a79cSeschrock #else
2409113a79cSeschrock 	uint8_t		is_gl_idtype:2;
2419113a79cSeschrock 	uint8_t		is_gl_idlen:6;
2429113a79cSeschrock #endif
2439113a79cSeschrock 	char		is_gl_idstring[1];
2449113a79cSeschrock } ipmi_sdr_generic_locator_t;
2459113a79cSeschrock 
2469113a79cSeschrock /*
2479113a79cSeschrock  * FRU Device Locator Record.  See section 43.8.
2489113a79cSeschrock  */
2499113a79cSeschrock 
2509113a79cSeschrock #define	IPMI_SDR_TYPE_FRU_LOCATOR		0x11
2519113a79cSeschrock 
2529113a79cSeschrock typedef struct ipmi_sdr_fru_locator {
2539113a79cSeschrock 	/* RECORD KEY BYTES */
2549113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2559113a79cSeschrock 	uint8_t		__reserved1:1;
2569113a79cSeschrock 	uint8_t		is_fl_accessaddr:7;
2579113a79cSeschrock #else
2589113a79cSeschrock 	uint8_t		is_fl_accessaddr:7;
2599113a79cSeschrock 	uint8_t		__reserved1:1;
2609113a79cSeschrock #endif
2619113a79cSeschrock 	union {
2629113a79cSeschrock 		struct {
2639113a79cSeschrock 			uint8_t	_is_fl_devid;
2649113a79cSeschrock 		} _logical;
2659113a79cSeschrock 		struct {
2669113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2679113a79cSeschrock 			uint8_t	__reserved:1;
2689113a79cSeschrock 			uint8_t	_is_fl_slaveaddr:7;
2699113a79cSeschrock #else
2709113a79cSeschrock 			uint8_t	_is_fl_slaveaddr:7;
2719113a79cSeschrock 			uint8_t	__reserved:1;
2729113a79cSeschrock #endif
2739113a79cSeschrock 		} _nonintelligent;
2749113a79cSeschrock 	} _devid_or_slaveaddr;
2759113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2769113a79cSeschrock 	uint8_t		is_fl_bus:3;
2779113a79cSeschrock 	uint8_t		is_fl_lun:2;
2789113a79cSeschrock 	uint8_t		__reserved2:2;
2799113a79cSeschrock 	uint8_t		is_fl_logical:1;
2809113a79cSeschrock 	uint8_t		__reserved3:4;
2819113a79cSeschrock 	uint8_t		is_fl_channel:4;
2829113a79cSeschrock #else
2839113a79cSeschrock 	uint8_t		is_fl_logical:1;
2849113a79cSeschrock 	uint8_t		__reserved2:2;
2859113a79cSeschrock 	uint8_t		is_fl_lun:2;
2869113a79cSeschrock 	uint8_t		is_fl_bus:3;
2879113a79cSeschrock 	uint8_t		is_fl_channel:4;
2889113a79cSeschrock 	uint8_t		__reserved3:4;
2899113a79cSeschrock #endif
2909113a79cSeschrock 	/* RECORD BODY BYTES */
2919113a79cSeschrock 	uint8_t		__reserved4;
2929113a79cSeschrock 	uint8_t		is_fl_type;
2939113a79cSeschrock 	uint8_t		is_fl_modifier;
2949113a79cSeschrock 	uint8_t		is_fl_entity;
2959113a79cSeschrock 	uint8_t		is_fl_instance;
2969113a79cSeschrock 	uint8_t		is_fl_oem;
2979113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
2989113a79cSeschrock 	uint8_t		is_fl_idlen:6;
2999113a79cSeschrock 	uint8_t		is_fl_idtype:2;
3009113a79cSeschrock #else
3019113a79cSeschrock 	uint8_t		is_fl_idtype:2;
3029113a79cSeschrock 	uint8_t		is_fl_idlen:6;
3039113a79cSeschrock #endif
3049113a79cSeschrock 	char		is_fl_idstring[1];
3059113a79cSeschrock } ipmi_sdr_fru_locator_t;
3069113a79cSeschrock 
3079113a79cSeschrock #define	is_fl_devid	_devid_or_slaveaddr._logical._is_fl_devid
3089113a79cSeschrock #define	is_fl_slaveaddr	_devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr
3099113a79cSeschrock 
3109113a79cSeschrock /*
3119113a79cSeschrock  * The remaining SDR types do not have an associated structure, yet.
3129113a79cSeschrock  */
3139113a79cSeschrock #define	IPMI_SDR_TYPE_FULL_SENSOR		0x01
3149113a79cSeschrock #define	IPMI_SDR_TYPE_COMPACT_SENSOR		0x02
3159113a79cSeschrock #define	IPMI_SDR_TYPE_EVENT_ONLY		0x03
3169113a79cSeschrock #define	IPMI_SDR_TYPE_ENTITY_ASSOCIATION	0x08
3179113a79cSeschrock #define	IPMI_SDR_TYPE_DEVICE_RELATIVE		0x09
3189113a79cSeschrock #define	IPMI_SDR_TYPE_MANAGEMENT_DEVICE		0x12
3199113a79cSeschrock #define	IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION	0x13
3209113a79cSeschrock #define	IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL	0x14
3219113a79cSeschrock #define	IPMI_SDR_TYPE_OEM			0xC0
3229113a79cSeschrock 
3239113a79cSeschrock /*
3249113a79cSeschrock  * Lookup the given sensor type by name.  These functions automatically read in
3259113a79cSeschrock  * and cache the complete SDR repository.
3269113a79cSeschrock  */
3279113a79cSeschrock extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *,
3289113a79cSeschrock     const char *);
3299113a79cSeschrock extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
3309113a79cSeschrock     const char *);
3319113a79cSeschrock 
3329113a79cSeschrock /*
3339113a79cSeschrock  * Get Sensor Reading.  See section 35.14.
3349113a79cSeschrock  */
3359113a79cSeschrock 
3369113a79cSeschrock #define	IPMI_CMD_GET_SENSOR_READING	0x2d
3379113a79cSeschrock 
3389113a79cSeschrock typedef struct ipmi_sensor_reading {
3399113a79cSeschrock 	uint8_t		isr_reading;
3409113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
3419113a79cSeschrock 	uint8_t		__reserved1:5;
3429113a79cSeschrock 	uint8_t		isr_state_unavailable:1;
3439113a79cSeschrock 	uint8_t		isr_scanning_disabled:1;
3449113a79cSeschrock 	uint8_t		isr_event_disabled:1;
3459113a79cSeschrock #else
3469113a79cSeschrock 	uint8_t		isr_event_disabled:1;
3479113a79cSeschrock 	uint8_t		isr_scanning_disabled:1;
3489113a79cSeschrock 	uint8_t		isr_state_unavailable:1;
3499113a79cSeschrock 	uint8_t		__reserved1:5;
3509113a79cSeschrock #endif
3519113a79cSeschrock 	uint16_t	isr_state;
3529113a79cSeschrock } ipmi_sensor_reading_t;
3539113a79cSeschrock 
3549113a79cSeschrock extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
3559113a79cSeschrock 
3569113a79cSeschrock /*
3579113a79cSeschrock  * Set Sensor Reading.  See section 35.14.
3589113a79cSeschrock  */
3599113a79cSeschrock #define	IPMI_CMD_SET_SENSOR_READING	0x30
3609113a79cSeschrock 
3619113a79cSeschrock #define	IPMI_SENSOR_OP_CLEAR	0x3	/* clear '0' bits */
3629113a79cSeschrock #define	IPMI_SENSOR_OP_SET	0x2	/* set '1' bits */
3639113a79cSeschrock #define	IPMI_SENSOR_OP_EXACT	0x1	/* set bits exactly */
3649113a79cSeschrock 
3659113a79cSeschrock typedef struct ipmi_set_sensor_reading {
3669113a79cSeschrock 	uint8_t		iss_id;
3679113a79cSeschrock #if defined(_BIT_FIELDS_LTOH)
3689113a79cSeschrock 	uint8_t		iss_set_reading:1;
3699113a79cSeschrock 	uint8_t		__reserved:1;
3709113a79cSeschrock 	uint8_t		iss_deassrt_op:2;
3719113a79cSeschrock 	uint8_t		iss_assert_op:2;
3729113a79cSeschrock 	uint8_t		iss_data_bytes:2;
3739113a79cSeschrock #else
3749113a79cSeschrock 	uint8_t		iss_data_bytes:2;
3759113a79cSeschrock 	uint8_t		iss_assert_op:2;
3769113a79cSeschrock 	uint8_t		iss_deassrt_op:2;
3779113a79cSeschrock 	uint8_t		__reserved:1;
3789113a79cSeschrock 	uint8_t		iss_set_reading:1;
3799113a79cSeschrock #endif
3809113a79cSeschrock 	uint8_t		iss_sensor_reading;
3819113a79cSeschrock 	uint16_t	iss_assert_state;	/* optional */
3829113a79cSeschrock 	uint16_t	iss_deassert_state;	/* optional */
3839113a79cSeschrock 	uint8_t		iss_event_data1;	/* optional */
3849113a79cSeschrock 	uint8_t		iss_event_data2;	/* optional */
3859113a79cSeschrock 	uint8_t		iss_event_data3;	/* optional */
3869113a79cSeschrock } ipmi_set_sensor_reading_t;
3879113a79cSeschrock 
3889113a79cSeschrock extern int ipmi_set_sensor_reading(ipmi_handle_t *,
3899113a79cSeschrock     ipmi_set_sensor_reading_t *);
3909113a79cSeschrock 
3919113a79cSeschrock /*
3924557a2a1Srobj  * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec.
3934557a2a1Srobj  *
3944557a2a1Srobj  * Payloads for these two commands are described in Sections 34.1 and 34.2 of
3954557a2a1Srobj  * the spec, respectively.
3964557a2a1Srobj  */
3974557a2a1Srobj #define	IPMI_CMD_GET_FRU_INV_AREA	0x10
3984557a2a1Srobj #define	IPMI_CMD_READ_FRU_DATA		0x11
3994557a2a1Srobj 
4004557a2a1Srobj /*
4014557a2a1Srobj  * Structs to hold the FRU Common Header and the FRU Product Info Area, as
4024557a2a1Srobj  * described in the IPMI Platform Management FRU Information Storage
4034557a2a1Srobj  * Definition (v1.1).
4044557a2a1Srobj  */
4054557a2a1Srobj typedef struct ipmi_fru_hdr
4064557a2a1Srobj {
4074557a2a1Srobj 	uint8_t		ifh_format;
4084557a2a1Srobj 	uint8_t		ifh_int_use_off;
4094557a2a1Srobj 	uint8_t		ifh_chassis_info_off;
4104557a2a1Srobj 	uint8_t		ifh_board_info_off;
4114557a2a1Srobj 	uint8_t		ifh_product_info_off;
4124557a2a1Srobj 	uint8_t		ifh_multi_rec_off;
4134557a2a1Srobj 	uint8_t		ifh_pad;
4144557a2a1Srobj 	uint8_t		ifh_chksum;
4154557a2a1Srobj } ipmi_fru_hdr_t;
4164557a2a1Srobj 
4174557a2a1Srobj /*
4184557a2a1Srobj  * Because only 6 bits are used to specify the length of each field in the FRU
4194557a2a1Srobj  * product and board info areas, the biggest string we would ever need to hold
4204557a2a1Srobj  * would be 63 chars plus a NULL.
4214557a2a1Srobj  */
4224557a2a1Srobj #define	FRU_INFO_MAXLEN	64
4234557a2a1Srobj 
4244557a2a1Srobj typedef struct ipmi_fru_brd_info
4254557a2a1Srobj {
4264557a2a1Srobj 	char	ifbi_manuf_date[3];
4274557a2a1Srobj 	char	ifbi_manuf_name[FRU_INFO_MAXLEN];
4284557a2a1Srobj 	char	ifbi_board_name[FRU_INFO_MAXLEN];
4294557a2a1Srobj 	char	ifbi_product_serial[FRU_INFO_MAXLEN];
4304557a2a1Srobj 	char	ifbi_part_number[FRU_INFO_MAXLEN];
4314557a2a1Srobj } ipmi_fru_brd_info_t;
4324557a2a1Srobj 
4334557a2a1Srobj typedef struct ipmi_fru_prod_info
4344557a2a1Srobj {
4354557a2a1Srobj 	char	ifpi_manuf_name[FRU_INFO_MAXLEN];
4364557a2a1Srobj 	char	ifpi_product_name[FRU_INFO_MAXLEN];
4374557a2a1Srobj 	char	ifpi_part_number[FRU_INFO_MAXLEN];
4384557a2a1Srobj 	char	ifpi_product_version[FRU_INFO_MAXLEN];
4394557a2a1Srobj 	char	ifpi_product_serial[FRU_INFO_MAXLEN];
4404557a2a1Srobj 	char	ifpi_asset_tag[FRU_INFO_MAXLEN];
4414557a2a1Srobj } ipmi_fru_prod_info_t;
4424557a2a1Srobj 
4434557a2a1Srobj int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **);
4444557a2a1Srobj int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *);
4454557a2a1Srobj int ipmi_fru_parse_product(ipmi_handle_t *, char *, ipmi_fru_prod_info_t *);
4464557a2a1Srobj 
4474557a2a1Srobj /*
448*1af98250Seschrock  * User management.  The raw functions are private to libipmi, and only the
449*1af98250Seschrock  * higher level abstraction (ipmi_user_t) is exported to consumers of the
450*1af98250Seschrock  * library.
451*1af98250Seschrock  */
452*1af98250Seschrock 
453*1af98250Seschrock #define	IPMI_USER_PRIV_CALLBACK		0x1
454*1af98250Seschrock #define	IPMI_USER_PRIV_USER		0x2
455*1af98250Seschrock #define	IPMI_USER_PRIV_OPERATOR		0x3
456*1af98250Seschrock #define	IPMI_USER_PRIV_ADMIN		0x4
457*1af98250Seschrock #define	IPMI_USER_PRIV_OEM		0x5
458*1af98250Seschrock #define	IPMI_USER_PRIV_NONE		0xf
459*1af98250Seschrock 
460*1af98250Seschrock typedef struct ipmi_user {
461*1af98250Seschrock 	uint8_t		iu_uid;
462*1af98250Seschrock 	char		*iu_name;
463*1af98250Seschrock 	boolean_t	iu_enabled;
464*1af98250Seschrock 	boolean_t	iu_ipmi_msg_enable;
465*1af98250Seschrock 	boolean_t	iu_link_auth_enable;
466*1af98250Seschrock 	uint8_t		iu_priv;
467*1af98250Seschrock 	struct ipmi_user *iu_next;
468*1af98250Seschrock } ipmi_user_t;
469*1af98250Seschrock 
470*1af98250Seschrock extern int ipmi_user_iter(ipmi_handle_t *,
471*1af98250Seschrock     int (*)(ipmi_user_t *, void *), void *);
472*1af98250Seschrock extern ipmi_user_t *ipmi_user_lookup_name(ipmi_handle_t *, const char *);
473*1af98250Seschrock extern ipmi_user_t *ipmi_user_lookup_id(ipmi_handle_t *, uint8_t);
474*1af98250Seschrock extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *);
475*1af98250Seschrock 
476*1af98250Seschrock /*
4779113a79cSeschrock  * The remaining functions are private to the implementation of the Sun ILOM
4789113a79cSeschrock  * service processor.  These function first check the manufacturer from the IPMI
4799113a79cSeschrock  * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun
4809113a79cSeschrock  * devices.
4819113a79cSeschrock  */
4829113a79cSeschrock 
4839113a79cSeschrock /*
4849113a79cSeschrock  * Sun OEM LED requests.
4859113a79cSeschrock  */
4869113a79cSeschrock 
4879113a79cSeschrock #define	IPMI_CMD_SUNOEM_LED_GET		0x21
4889113a79cSeschrock #define	IPMI_CMD_SUNOEM_LED_SET		0x22
4899113a79cSeschrock 
4909113a79cSeschrock typedef struct ipmi_cmd_sunoem_led_set {
491a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH)
492a10acbd6Seschrock 	uint8_t		ic_sls_channel_msb:1;	/* device slave address */
493a10acbd6Seschrock 	uint8_t		ic_sls_slaveaddr:7;	/* (from SDR record) */
494a10acbd6Seschrock #else
495a10acbd6Seschrock 	uint8_t		ic_sls_slaveaddr:7;
496a10acbd6Seschrock 	uint8_t		ic_sls_channel_msb:1;
497a10acbd6Seschrock #endif
4989113a79cSeschrock 	uint8_t		ic_sls_type;		/* led type */
499a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH)
500a10acbd6Seschrock 	uint8_t		__reserved:1;		/* device access address */
501a10acbd6Seschrock 	uint8_t		ic_sls_accessaddr:7;	/* (from SDR record) */
502a10acbd6Seschrock #else
503a10acbd6Seschrock 	uint8_t		ic_sls_accessaddr:7;
504a10acbd6Seschrock 	uint8_t		__reserved:1;
505a10acbd6Seschrock #endif
5069113a79cSeschrock 	uint8_t		ic_sls_hwinfo;		/* OEM hardware info */
5079113a79cSeschrock 	uint8_t		ic_sls_mode;		/* LED mode */
5089113a79cSeschrock 	uint8_t		ic_sls_force;		/* force direct access */
5099113a79cSeschrock 	uint8_t		ic_sls_role;		/* BMC authorization */
5109113a79cSeschrock } ipmi_cmd_sunoem_led_set_t;
5119113a79cSeschrock 
5129113a79cSeschrock typedef struct ipmi_cmd_sunoem_led_get {
513a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH)
514a10acbd6Seschrock 	uint8_t		ic_slg_channel_msb:1;	/* device slave address */
515a10acbd6Seschrock 	uint8_t		ic_slg_slaveaddr:7;	/* (from SDR record) */
516a10acbd6Seschrock #else
517a10acbd6Seschrock 	uint8_t		ic_slg_slaveaddr:7;
518a10acbd6Seschrock 	uint8_t		ic_slg_channel_msb:1;
519a10acbd6Seschrock #endif
5209113a79cSeschrock 	uint8_t		ic_slg_type;		/* led type */
521a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH)
522a10acbd6Seschrock 	uint8_t		__reserved:1;		/* device access address */
523a10acbd6Seschrock 	uint8_t		ic_slg_accessaddr:7;	/* (from SDR record) */
524a10acbd6Seschrock #else
525a10acbd6Seschrock 	uint8_t		ic_slg_accessaddr:7;
526a10acbd6Seschrock 	uint8_t		__reserved:1;
527a10acbd6Seschrock #endif
5289113a79cSeschrock 	uint8_t		ic_slg_hwinfo;		/* OEM hardware info */
5299113a79cSeschrock 	uint8_t		ic_slg_force;		/* force direct access */
5309113a79cSeschrock } ipmi_cmd_sunoem_led_get_t;
5319113a79cSeschrock 
5329113a79cSeschrock #define	IPMI_SUNOEM_LED_TYPE_OK2RM	0
5339113a79cSeschrock #define	IPMI_SUNOEM_LED_TYPE_SERVICE	1
5349113a79cSeschrock #define	IPMI_SUNOEM_LED_TYPE_ACT	2
5359113a79cSeschrock #define	IPMI_SUNOEM_LED_TYPE_LOCATE	3
5369113a79cSeschrock #define	IPMI_SUNOEM_LED_TYPE_ANY	0xFF
5379113a79cSeschrock 
5389113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_OFF	0
5399113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_ON		1
5409113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_STANDBY	2
5419113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_SLOW	3
5429113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_FAST	4
5439113a79cSeschrock 
5449113a79cSeschrock /*
5459113a79cSeschrock  * These functions take a SDR record and construct the appropriate form of the
5469113a79cSeschrock  * above commands.
5479113a79cSeschrock  */
5489113a79cSeschrock extern int ipmi_sunoem_led_set(ipmi_handle_t *,
5499113a79cSeschrock     ipmi_sdr_generic_locator_t *, uint8_t);
5509113a79cSeschrock extern int ipmi_sunoem_led_get(ipmi_handle_t *,
5519113a79cSeschrock     ipmi_sdr_generic_locator_t *, uint8_t *);
5529113a79cSeschrock 
5539113a79cSeschrock /*
5549113a79cSeschrock  * Sun OEM uptime.  Note that the underlying command returns the uptime in big
5559113a79cSeschrock  * endian form.  This wrapper automatically converts to the appropriate native
5569113a79cSeschrock  * form.
5579113a79cSeschrock  */
5589113a79cSeschrock 
5599113a79cSeschrock #define	IPMI_CMD_SUNOEM_UPTIME		0x08
5609113a79cSeschrock 
5619113a79cSeschrock extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *);
5629113a79cSeschrock 
5639113a79cSeschrock /*
5649113a79cSeschrock  * Sun OEM FRU update.  The FRU information is managed through a generic
5659113a79cSeschrock  * identifier, and then a type-specific data portion.  The wrapper function will
5669113a79cSeschrock  * automatically fill in the data length field according to which type is
5679113a79cSeschrock  * specified.
5689113a79cSeschrock  */
5699113a79cSeschrock 
5709113a79cSeschrock #define	IPMI_CMD_SUNOEM_FRU_UPDATE	0x16
5719113a79cSeschrock 
5729113a79cSeschrock #define	IPMI_SUNOEM_FRU_DIMM	0x00
5739113a79cSeschrock #define	IPMI_SUNOEM_FRU_CPU	0x01
5749113a79cSeschrock #define	IPMI_SUNOEM_FRU_BIOS	0x02
5759113a79cSeschrock #define	IPMI_SUNOEM_FRU_DISK	0x03
5769113a79cSeschrock 
5779113a79cSeschrock typedef struct ipmi_sunoem_fru {
5789113a79cSeschrock 	uint8_t				isf_type;
5799113a79cSeschrock 	uint8_t				isf_id;
5809113a79cSeschrock 	uint8_t				isf_datalen;
5819113a79cSeschrock 	union {
5829113a79cSeschrock 		struct {
5839113a79cSeschrock 			uint8_t		isf_data[128];
5849113a79cSeschrock 		} dimm;
5859113a79cSeschrock 		struct {
5869113a79cSeschrock 			uint32_t	isf_thermtrip;
5879113a79cSeschrock 			uint32_t	isf_eax;
5889113a79cSeschrock 			char		isf_product[48];
5899113a79cSeschrock 		} cpu;
5909113a79cSeschrock 		struct {
5919113a79cSeschrock 			char		isf_part[16];
5929113a79cSeschrock 			char		isf_version[16];
5939113a79cSeschrock 		} bios;
5949113a79cSeschrock 		struct {
5959113a79cSeschrock 			char		isf_manufacturer[16];
5969113a79cSeschrock 			char		isf_model[28];
5979113a79cSeschrock 			char		isf_serial[20];
5989113a79cSeschrock 			char		isf_version[8];
5999113a79cSeschrock 			char		isf_capacity[16];
6009113a79cSeschrock 		} disk;
6019113a79cSeschrock 	} isf_data;
6029113a79cSeschrock } ipmi_sunoem_fru_t;
6039113a79cSeschrock 
6049113a79cSeschrock int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *);
6059113a79cSeschrock 
6069113a79cSeschrock #pragma pack()
6079113a79cSeschrock 
6089113a79cSeschrock #ifdef	__cplusplus
6099113a79cSeschrock }
6109113a79cSeschrock #endif
6119113a79cSeschrock 
6129113a79cSeschrock #endif	/* _LIBIPMI_H */
613