xref: /titanic_50/usr/src/lib/libipmi/common/libipmi.h (revision 2c32020f848d8e5619a1f441a92f0ee4aca1b297)
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>
33*2c32020fSeschrock #include <sys/sysmacros.h>
349113a79cSeschrock 
359113a79cSeschrock /*
369113a79cSeschrock  * Private interfaces for communicating with attached services over IPMI.  This
379113a79cSeschrock  * library is designed for system software communicating with Sun-supported
389113a79cSeschrock  * service processors over /dev/bmc.  It is not a generic IPMI library.
399113a79cSeschrock  *
409113a79cSeschrock  * Documentation references refer to "Intelligent Platform Management Interface
419113a79cSeschrock  * Specification Second Generation v2.0", document revision 1.0 with Februrary
429113a79cSeschrock  * 15, 2006 Markup from "IPMI v2.0 Addenda, Errata, and Clarifications Revision
439113a79cSeschrock  * 3".
449113a79cSeschrock  */
459113a79cSeschrock 
469113a79cSeschrock #ifdef	__cplusplus
479113a79cSeschrock extern "C" {
489113a79cSeschrock #endif
499113a79cSeschrock 
509113a79cSeschrock typedef struct ipmi_handle ipmi_handle_t;
519113a79cSeschrock 
529113a79cSeschrock #pragma pack(1)
539113a79cSeschrock 
549113a79cSeschrock /*
559113a79cSeschrock  * Basic netfn definitions.  See section 5.1.
569113a79cSeschrock  */
579113a79cSeschrock #define	IPMI_NETFN_APP			BMC_NETFN_APP
589113a79cSeschrock #define	IPMI_NETFN_STORAGE		BMC_NETFN_STORAGE
599113a79cSeschrock #define	IPMI_NETFN_SE			BMC_NETFN_SE
609113a79cSeschrock #define	IPMI_NETFN_OEM			0x2e
619113a79cSeschrock 
629113a79cSeschrock /*
639113a79cSeschrock  * Error definitions
649113a79cSeschrock  */
659113a79cSeschrock #define	EIPMI_BASE	2000
669113a79cSeschrock 
679113a79cSeschrock enum {
689113a79cSeschrock 	EIPMI_NOMEM = EIPMI_BASE,	/* memory allocation failure */
699113a79cSeschrock 	EIPMI_BMC_OPEN_FAILED,		/* failed to open /dev/bmc */
709113a79cSeschrock 	EIPMI_BMC_PUTMSG,		/* putmsg() failed */
719113a79cSeschrock 	EIPMI_BMC_GETMSG,		/* getmsg() failed */
729113a79cSeschrock 	EIPMI_BMC_RESPONSE,		/* response from /dev/bmc failed */
739113a79cSeschrock 	EIPMI_INVALID_COMMAND,		/* invalid command */
749113a79cSeschrock 	EIPMI_COMMAND_TIMEOUT,		/* command timeout */
759113a79cSeschrock 	EIPMI_DATA_LENGTH_EXCEEDED,	/* maximum data length exceeded */
769113a79cSeschrock 	EIPMI_SEND_FAILED,		/* failed to send BMC request */
779113a79cSeschrock 	EIPMI_UNSPECIFIED,		/* unspecified error */
789113a79cSeschrock 	EIPMI_UNKNOWN,			/* unknown error */
799113a79cSeschrock 	EIPMI_BAD_RESPONSE,		/* received unexpected response */
809113a79cSeschrock 	EIPMI_BAD_RESPONSE_LENGTH,	/* unexpected response length */
819113a79cSeschrock 	EIPMI_INVALID_RESERVATION,	/* invalid reservation */
829113a79cSeschrock 	EIPMI_NOT_PRESENT,		/* requested entity not present */
839113a79cSeschrock 	EIPMI_INVALID_REQUEST,		/* malformed request */
849113a79cSeschrock 	EIPMI_BUSY,			/* SP is busy */
859113a79cSeschrock 	EIPMI_NOSPACE,			/* SP is out of space */
869113a79cSeschrock 	EIPMI_UNAVAILABLE,		/* SP is present but unavailable */
879113a79cSeschrock 	EIPMI_ACCESS			/* insufficient privileges */
889113a79cSeschrock };
899113a79cSeschrock 
909113a79cSeschrock /*
919113a79cSeschrock  * Basic library functions.
929113a79cSeschrock  *
939113a79cSeschrock  * The ipmi_handle is the primary interface to the library.  The library itself
949113a79cSeschrock  * is not MT-safe, but it is safe within a single handle.  Multithreaded clients
959113a79cSeschrock  * should either open multiple handles, or otherwise synchronize access to the
969113a79cSeschrock  * same handle.
979113a79cSeschrock  *
989113a79cSeschrock  * There is a single command response buffer that is stored with the handle, to
999113a79cSeschrock  * simplify memory management in the caller.  The memory referenced by a command
1009113a79cSeschrock  * response is only valid until the next command is issued.  The caller is
1019113a79cSeschrock  * responsible for making a copy of the response if it is needed.
1029113a79cSeschrock  */
1039113a79cSeschrock extern ipmi_handle_t *ipmi_open(int *, char **);
1049113a79cSeschrock extern void ipmi_close(ipmi_handle_t *);
1059113a79cSeschrock 
1069113a79cSeschrock extern int ipmi_errno(ipmi_handle_t *);
1079113a79cSeschrock extern const char *ipmi_errmsg(ipmi_handle_t *);
1089113a79cSeschrock 
1099113a79cSeschrock /*
1109113a79cSeschrock  * Raw requests.  See section 5.
1119113a79cSeschrock  */
1129113a79cSeschrock typedef struct ipmi_cmd {
1139113a79cSeschrock 	uint8_t		ic_netfn:6;
1149113a79cSeschrock 	uint8_t		ic_lun:2;
1159113a79cSeschrock 	uint8_t		ic_cmd;
1169113a79cSeschrock 	uint16_t	ic_dlen;
1179113a79cSeschrock 	void		*ic_data;
1189113a79cSeschrock } ipmi_cmd_t;
1199113a79cSeschrock 
1209113a79cSeschrock extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
1219113a79cSeschrock 
1229113a79cSeschrock /*
1239113a79cSeschrock  * Retrieve basic information about the IPMI device.  See section 20.1 "Get
1249113a79cSeschrock  * Device ID Command".
1259113a79cSeschrock  */
1269113a79cSeschrock #define	IPMI_CMD_GET_DEVICEID		0x01
1279113a79cSeschrock 
1289113a79cSeschrock typedef struct ipmi_deviceid {
1299113a79cSeschrock 	uint8_t		id_devid;
130*2c32020fSeschrock 	DECL_BITFIELD3(
131*2c32020fSeschrock 	    id_dev_rev		:4,
132*2c32020fSeschrock 	    __reserved		:3,
133*2c32020fSeschrock 	    id_dev_sdrs		:1);
134*2c32020fSeschrock 	DECL_BITFIELD2(
135*2c32020fSeschrock 	    id_firm_major	:7,
136*2c32020fSeschrock 	    id_dev_available	:1);
1379113a79cSeschrock 	uint8_t		id_firm_minor;
1389113a79cSeschrock 	uint8_t		id_ipmi_rev;
1399113a79cSeschrock 	uint8_t		id_dev_support;
1409113a79cSeschrock 	uint8_t		id_manufacturer[3];
1419113a79cSeschrock 	uint16_t	id_product;
1429113a79cSeschrock } ipmi_deviceid_t;
1439113a79cSeschrock 
1449113a79cSeschrock #define	IPMI_OEM_SUN	0x2a
1459113a79cSeschrock 
1469113a79cSeschrock ipmi_deviceid_t *ipmi_get_deviceid(ipmi_handle_t *);
1479113a79cSeschrock 
1489113a79cSeschrock #define	ipmi_devid_manufacturer(dp)		\
1499113a79cSeschrock 	((dp)->id_manufacturer[0] |		\
1509113a79cSeschrock 	((dp)->id_manufacturer[1] << 8) |	\
1519113a79cSeschrock 	((dp)->id_manufacturer[2] << 16))
1529113a79cSeschrock 
1539113a79cSeschrock /*
1549113a79cSeschrock  * SDR (Sensor Device Record) requests.  A cache of the current SDR repository
1559113a79cSeschrock  * is kept as part of the IPMI handle and updated when necessary.  Routines to
1569113a79cSeschrock  * access the raw SDR repository are also provided.
1579113a79cSeschrock  */
1589113a79cSeschrock 
1599113a79cSeschrock /*
1609113a79cSeschrock  * Reserve repository command.  See section 33.11.
1619113a79cSeschrock  */
1629113a79cSeschrock #define	IPMI_CMD_RESERVE_SDR_REPOSITORY	0x22
1639113a79cSeschrock 
1649113a79cSeschrock /*
1659113a79cSeschrock  * Get SDR command.  See section 33.12.  This command accesses the raw SDR
1669113a79cSeschrock  * repository.  Clients can also use the lookup functions to retrieve a
1679113a79cSeschrock  * particular SDR record by name.
1689113a79cSeschrock  *
1699113a79cSeschrock  * The list of possible types is indicated in the sub-chapters of section 43.
1709113a79cSeschrock  */
1719113a79cSeschrock typedef struct ipmi_sdr {
1729113a79cSeschrock 	uint16_t	is_id;
1739113a79cSeschrock 	uint8_t		is_version;
1749113a79cSeschrock 	uint8_t		is_type;
1759113a79cSeschrock 	uint8_t		is_length;
1769113a79cSeschrock 	uint8_t		is_record[1];
1779113a79cSeschrock } ipmi_sdr_t;
1789113a79cSeschrock #define	IPMI_CMD_GET_SDR		0x23
1799113a79cSeschrock 
1809113a79cSeschrock #define	IPMI_SDR_FIRST			0x0000
1819113a79cSeschrock #define	IPMI_SDR_LAST			0xFFFF
1829113a79cSeschrock 
1839113a79cSeschrock extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
1849113a79cSeschrock 
1859113a79cSeschrock /*
1869113a79cSeschrock  * Generic Device Locator Record.  See section 43.7.
1879113a79cSeschrock  */
1889113a79cSeschrock 
1899113a79cSeschrock #define	IPMI_SDR_TYPE_GENERIC_LOCATOR		0x10
1909113a79cSeschrock 
1919113a79cSeschrock typedef struct ipmi_sdr_generic_locator {
1929113a79cSeschrock 	/* RECORD KEY BYTES */
193*2c32020fSeschrock 	DECL_BITFIELD2(
194*2c32020fSeschrock 	    __reserved1		:1,
195*2c32020fSeschrock 	    is_gl_accessaddr	:7);
196*2c32020fSeschrock 	DECL_BITFIELD2(
197*2c32020fSeschrock 	    is_gl_channel_msb	:1,
198*2c32020fSeschrock 	    is_gl_slaveaddr	:7);
199*2c32020fSeschrock 	DECL_BITFIELD3(
200*2c32020fSeschrock 	    is_gl_bus		:3,
201*2c32020fSeschrock 	    is_gl_lun		:2,
202*2c32020fSeschrock 	    is_gl_channel	:3);
2039113a79cSeschrock 	/* RECORD BODY BYTES */
204*2c32020fSeschrock 	DECL_BITFIELD2(
205*2c32020fSeschrock 	    is_gl_span		:3,
206*2c32020fSeschrock 	    __reserved2		:5);
2079113a79cSeschrock 	uint8_t		__reserved3;
2089113a79cSeschrock 	uint8_t		is_gl_type;
2099113a79cSeschrock 	uint8_t		is_gl_modifier;
2109113a79cSeschrock 	uint8_t		is_gl_entity;
2119113a79cSeschrock 	uint8_t		is_gl_instance;
2129113a79cSeschrock 	uint8_t		is_gl_oem;
213*2c32020fSeschrock 	DECL_BITFIELD2(
214*2c32020fSeschrock 	    is_gl_idlen		:6,
215*2c32020fSeschrock 	    is_gl_idtype	:2);
2169113a79cSeschrock 	char		is_gl_idstring[1];
2179113a79cSeschrock } ipmi_sdr_generic_locator_t;
2189113a79cSeschrock 
2199113a79cSeschrock /*
2209113a79cSeschrock  * FRU Device Locator Record.  See section 43.8.
2219113a79cSeschrock  */
2229113a79cSeschrock 
2239113a79cSeschrock #define	IPMI_SDR_TYPE_FRU_LOCATOR		0x11
2249113a79cSeschrock 
2259113a79cSeschrock typedef struct ipmi_sdr_fru_locator {
2269113a79cSeschrock 	/* RECORD KEY BYTES */
227*2c32020fSeschrock 	DECL_BITFIELD2(
228*2c32020fSeschrock 	    __reserved1		:1,
229*2c32020fSeschrock 	    is_fl_accessaddr	:7);
2309113a79cSeschrock 	union {
2319113a79cSeschrock 		struct {
2329113a79cSeschrock 			uint8_t	_is_fl_devid;
2339113a79cSeschrock 		} _logical;
2349113a79cSeschrock 		struct {
235*2c32020fSeschrock 			DECL_BITFIELD2(
236*2c32020fSeschrock 			    __reserved		:1,
237*2c32020fSeschrock 			    _is_fl_slaveaddr	:7);
2389113a79cSeschrock 		} _nonintelligent;
2399113a79cSeschrock 	} _devid_or_slaveaddr;
240*2c32020fSeschrock 	DECL_BITFIELD4(
241*2c32020fSeschrock 	    is_fl_bus		:3,
242*2c32020fSeschrock 	    is_fl_lun		:2,
243*2c32020fSeschrock 	    __reserved2		:2,
244*2c32020fSeschrock 	    is_fl_logical	:1);
245*2c32020fSeschrock 	DECL_BITFIELD2(
246*2c32020fSeschrock 	    __reserved3		:4,
247*2c32020fSeschrock 	    is_fl_channel	:4);
2489113a79cSeschrock 	/* RECORD BODY BYTES */
2499113a79cSeschrock 	uint8_t		__reserved4;
2509113a79cSeschrock 	uint8_t		is_fl_type;
2519113a79cSeschrock 	uint8_t		is_fl_modifier;
2529113a79cSeschrock 	uint8_t		is_fl_entity;
2539113a79cSeschrock 	uint8_t		is_fl_instance;
2549113a79cSeschrock 	uint8_t		is_fl_oem;
255*2c32020fSeschrock 	DECL_BITFIELD2(
256*2c32020fSeschrock 	    is_fl_idlen		:6,
257*2c32020fSeschrock 	    is_fl_idtype	:2);
2589113a79cSeschrock 	char		is_fl_idstring[1];
2599113a79cSeschrock } ipmi_sdr_fru_locator_t;
2609113a79cSeschrock 
2619113a79cSeschrock #define	is_fl_devid	_devid_or_slaveaddr._logical._is_fl_devid
2629113a79cSeschrock #define	is_fl_slaveaddr	_devid_or_slaveaddr._nonintelligent._is_fl_slaveaddr
2639113a79cSeschrock 
2649113a79cSeschrock /*
2659113a79cSeschrock  * The remaining SDR types do not have an associated structure, yet.
2669113a79cSeschrock  */
2679113a79cSeschrock #define	IPMI_SDR_TYPE_FULL_SENSOR		0x01
2689113a79cSeschrock #define	IPMI_SDR_TYPE_COMPACT_SENSOR		0x02
2699113a79cSeschrock #define	IPMI_SDR_TYPE_EVENT_ONLY		0x03
2709113a79cSeschrock #define	IPMI_SDR_TYPE_ENTITY_ASSOCIATION	0x08
2719113a79cSeschrock #define	IPMI_SDR_TYPE_DEVICE_RELATIVE		0x09
2729113a79cSeschrock #define	IPMI_SDR_TYPE_MANAGEMENT_DEVICE		0x12
2739113a79cSeschrock #define	IPMI_SDR_TYPE_MANAGEMENT_CONFIRMATION	0x13
2749113a79cSeschrock #define	IPMI_SDR_TYPE_BMC_MESSAGE_CHANNEL	0x14
2759113a79cSeschrock #define	IPMI_SDR_TYPE_OEM			0xC0
2769113a79cSeschrock 
2779113a79cSeschrock /*
2789113a79cSeschrock  * Lookup the given sensor type by name.  These functions automatically read in
2799113a79cSeschrock  * and cache the complete SDR repository.
2809113a79cSeschrock  */
2819113a79cSeschrock extern ipmi_sdr_fru_locator_t *ipmi_sdr_lookup_fru(ipmi_handle_t *,
2829113a79cSeschrock     const char *);
2839113a79cSeschrock extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
2849113a79cSeschrock     const char *);
2859113a79cSeschrock 
2869113a79cSeschrock /*
2879113a79cSeschrock  * Get Sensor Reading.  See section 35.14.
2889113a79cSeschrock  */
2899113a79cSeschrock 
2909113a79cSeschrock #define	IPMI_CMD_GET_SENSOR_READING	0x2d
2919113a79cSeschrock 
2929113a79cSeschrock typedef struct ipmi_sensor_reading {
2939113a79cSeschrock 	uint8_t		isr_reading;
294*2c32020fSeschrock 	DECL_BITFIELD4(
295*2c32020fSeschrock 	    __reserved1			:5,
296*2c32020fSeschrock 	    isr_state_unavailable	:1,
297*2c32020fSeschrock 	    isr_scanning_disabled	:1,
298*2c32020fSeschrock 	    isr_event_disabled		:1);
2999113a79cSeschrock 	uint16_t	isr_state;
3009113a79cSeschrock } ipmi_sensor_reading_t;
3019113a79cSeschrock 
3029113a79cSeschrock extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
3039113a79cSeschrock 
3049113a79cSeschrock /*
3059113a79cSeschrock  * Set Sensor Reading.  See section 35.14.
3069113a79cSeschrock  */
3079113a79cSeschrock #define	IPMI_CMD_SET_SENSOR_READING	0x30
3089113a79cSeschrock 
3099113a79cSeschrock #define	IPMI_SENSOR_OP_CLEAR	0x3	/* clear '0' bits */
3109113a79cSeschrock #define	IPMI_SENSOR_OP_SET	0x2	/* set '1' bits */
3119113a79cSeschrock #define	IPMI_SENSOR_OP_EXACT	0x1	/* set bits exactly */
3129113a79cSeschrock 
3139113a79cSeschrock typedef struct ipmi_set_sensor_reading {
3149113a79cSeschrock 	uint8_t		iss_id;
315*2c32020fSeschrock 	DECL_BITFIELD5(
316*2c32020fSeschrock 	    iss_set_reading		:1,
317*2c32020fSeschrock 	    __reserved			:1,
318*2c32020fSeschrock 	    iss_deassrt_op		:2,
319*2c32020fSeschrock 	    iss_assert_op		:2,
320*2c32020fSeschrock 	    iss_data_bytes		:2);
3219113a79cSeschrock 	uint8_t		iss_sensor_reading;
3229113a79cSeschrock 	uint16_t	iss_assert_state;	/* optional */
3239113a79cSeschrock 	uint16_t	iss_deassert_state;	/* optional */
3249113a79cSeschrock 	uint8_t		iss_event_data1;	/* optional */
3259113a79cSeschrock 	uint8_t		iss_event_data2;	/* optional */
3269113a79cSeschrock 	uint8_t		iss_event_data3;	/* optional */
3279113a79cSeschrock } ipmi_set_sensor_reading_t;
3289113a79cSeschrock 
3299113a79cSeschrock extern int ipmi_set_sensor_reading(ipmi_handle_t *,
3309113a79cSeschrock     ipmi_set_sensor_reading_t *);
3319113a79cSeschrock 
3329113a79cSeschrock /*
3334557a2a1Srobj  * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec.
3344557a2a1Srobj  *
3354557a2a1Srobj  * Payloads for these two commands are described in Sections 34.1 and 34.2 of
3364557a2a1Srobj  * the spec, respectively.
3374557a2a1Srobj  */
3384557a2a1Srobj #define	IPMI_CMD_GET_FRU_INV_AREA	0x10
3394557a2a1Srobj #define	IPMI_CMD_READ_FRU_DATA		0x11
3404557a2a1Srobj 
3414557a2a1Srobj /*
3424557a2a1Srobj  * Structs to hold the FRU Common Header and the FRU Product Info Area, as
3434557a2a1Srobj  * described in the IPMI Platform Management FRU Information Storage
3444557a2a1Srobj  * Definition (v1.1).
3454557a2a1Srobj  */
3464557a2a1Srobj typedef struct ipmi_fru_hdr
3474557a2a1Srobj {
3484557a2a1Srobj 	uint8_t		ifh_format;
3494557a2a1Srobj 	uint8_t		ifh_int_use_off;
3504557a2a1Srobj 	uint8_t		ifh_chassis_info_off;
3514557a2a1Srobj 	uint8_t		ifh_board_info_off;
3524557a2a1Srobj 	uint8_t		ifh_product_info_off;
3534557a2a1Srobj 	uint8_t		ifh_multi_rec_off;
3544557a2a1Srobj 	uint8_t		ifh_pad;
3554557a2a1Srobj 	uint8_t		ifh_chksum;
3564557a2a1Srobj } ipmi_fru_hdr_t;
3574557a2a1Srobj 
3584557a2a1Srobj /*
3594557a2a1Srobj  * Because only 6 bits are used to specify the length of each field in the FRU
3604557a2a1Srobj  * product and board info areas, the biggest string we would ever need to hold
3614557a2a1Srobj  * would be 63 chars plus a NULL.
3624557a2a1Srobj  */
3634557a2a1Srobj #define	FRU_INFO_MAXLEN	64
3644557a2a1Srobj 
3654557a2a1Srobj typedef struct ipmi_fru_brd_info
3664557a2a1Srobj {
3674557a2a1Srobj 	char	ifbi_manuf_date[3];
3684557a2a1Srobj 	char	ifbi_manuf_name[FRU_INFO_MAXLEN];
3694557a2a1Srobj 	char	ifbi_board_name[FRU_INFO_MAXLEN];
3704557a2a1Srobj 	char	ifbi_product_serial[FRU_INFO_MAXLEN];
3714557a2a1Srobj 	char	ifbi_part_number[FRU_INFO_MAXLEN];
3724557a2a1Srobj } ipmi_fru_brd_info_t;
3734557a2a1Srobj 
3744557a2a1Srobj typedef struct ipmi_fru_prod_info
3754557a2a1Srobj {
3764557a2a1Srobj 	char	ifpi_manuf_name[FRU_INFO_MAXLEN];
3774557a2a1Srobj 	char	ifpi_product_name[FRU_INFO_MAXLEN];
3784557a2a1Srobj 	char	ifpi_part_number[FRU_INFO_MAXLEN];
3794557a2a1Srobj 	char	ifpi_product_version[FRU_INFO_MAXLEN];
3804557a2a1Srobj 	char	ifpi_product_serial[FRU_INFO_MAXLEN];
3814557a2a1Srobj 	char	ifpi_asset_tag[FRU_INFO_MAXLEN];
3824557a2a1Srobj } ipmi_fru_prod_info_t;
3834557a2a1Srobj 
3844557a2a1Srobj int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **);
3854557a2a1Srobj int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *);
3864557a2a1Srobj int ipmi_fru_parse_product(ipmi_handle_t *, char *, ipmi_fru_prod_info_t *);
3874557a2a1Srobj 
3884557a2a1Srobj /*
3891af98250Seschrock  * User management.  The raw functions are private to libipmi, and only the
3901af98250Seschrock  * higher level abstraction (ipmi_user_t) is exported to consumers of the
3911af98250Seschrock  * library.
3921af98250Seschrock  */
3931af98250Seschrock 
3941af98250Seschrock #define	IPMI_USER_PRIV_CALLBACK		0x1
3951af98250Seschrock #define	IPMI_USER_PRIV_USER		0x2
3961af98250Seschrock #define	IPMI_USER_PRIV_OPERATOR		0x3
3971af98250Seschrock #define	IPMI_USER_PRIV_ADMIN		0x4
3981af98250Seschrock #define	IPMI_USER_PRIV_OEM		0x5
3991af98250Seschrock #define	IPMI_USER_PRIV_NONE		0xf
4001af98250Seschrock 
4011af98250Seschrock typedef struct ipmi_user {
4021af98250Seschrock 	uint8_t		iu_uid;
4031af98250Seschrock 	char		*iu_name;
4041af98250Seschrock 	boolean_t	iu_enabled;
4051af98250Seschrock 	boolean_t	iu_ipmi_msg_enable;
4061af98250Seschrock 	boolean_t	iu_link_auth_enable;
4071af98250Seschrock 	uint8_t		iu_priv;
4081af98250Seschrock 	struct ipmi_user *iu_next;
4091af98250Seschrock } ipmi_user_t;
4101af98250Seschrock 
4111af98250Seschrock extern int ipmi_user_iter(ipmi_handle_t *,
4121af98250Seschrock     int (*)(ipmi_user_t *, void *), void *);
4131af98250Seschrock extern ipmi_user_t *ipmi_user_lookup_name(ipmi_handle_t *, const char *);
4141af98250Seschrock extern ipmi_user_t *ipmi_user_lookup_id(ipmi_handle_t *, uint8_t);
4151af98250Seschrock extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *);
4161af98250Seschrock 
4171af98250Seschrock /*
4189113a79cSeschrock  * The remaining functions are private to the implementation of the Sun ILOM
4199113a79cSeschrock  * service processor.  These function first check the manufacturer from the IPMI
4209113a79cSeschrock  * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun
4219113a79cSeschrock  * devices.
4229113a79cSeschrock  */
4239113a79cSeschrock 
4249113a79cSeschrock /*
4259113a79cSeschrock  * Sun OEM LED requests.
4269113a79cSeschrock  */
4279113a79cSeschrock 
4289113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_OFF	0
4299113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_ON		1
4309113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_STANDBY	2
4319113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_SLOW	3
4329113a79cSeschrock #define	IPMI_SUNOEM_LED_MODE_FAST	4
4339113a79cSeschrock 
4349113a79cSeschrock /*
4359113a79cSeschrock  * These functions take a SDR record and construct the appropriate form of the
4369113a79cSeschrock  * above commands.
4379113a79cSeschrock  */
4389113a79cSeschrock extern int ipmi_sunoem_led_set(ipmi_handle_t *,
4399113a79cSeschrock     ipmi_sdr_generic_locator_t *, uint8_t);
4409113a79cSeschrock extern int ipmi_sunoem_led_get(ipmi_handle_t *,
4419113a79cSeschrock     ipmi_sdr_generic_locator_t *, uint8_t *);
4429113a79cSeschrock 
4439113a79cSeschrock /*
4449113a79cSeschrock  * Sun OEM uptime.  Note that the underlying command returns the uptime in big
4459113a79cSeschrock  * endian form.  This wrapper automatically converts to the appropriate native
4469113a79cSeschrock  * form.
4479113a79cSeschrock  */
4489113a79cSeschrock 
4499113a79cSeschrock #define	IPMI_CMD_SUNOEM_UPTIME		0x08
4509113a79cSeschrock 
4519113a79cSeschrock extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *);
4529113a79cSeschrock 
4539113a79cSeschrock /*
4549113a79cSeschrock  * Sun OEM FRU update.  The FRU information is managed through a generic
4559113a79cSeschrock  * identifier, and then a type-specific data portion.  The wrapper function will
4569113a79cSeschrock  * automatically fill in the data length field according to which type is
4579113a79cSeschrock  * specified.
4589113a79cSeschrock  */
4599113a79cSeschrock 
4609113a79cSeschrock #define	IPMI_CMD_SUNOEM_FRU_UPDATE	0x16
4619113a79cSeschrock 
4629113a79cSeschrock #define	IPMI_SUNOEM_FRU_DIMM	0x00
4639113a79cSeschrock #define	IPMI_SUNOEM_FRU_CPU	0x01
4649113a79cSeschrock #define	IPMI_SUNOEM_FRU_BIOS	0x02
4659113a79cSeschrock #define	IPMI_SUNOEM_FRU_DISK	0x03
4669113a79cSeschrock 
4679113a79cSeschrock typedef struct ipmi_sunoem_fru {
4689113a79cSeschrock 	uint8_t				isf_type;
4699113a79cSeschrock 	uint8_t				isf_id;
4709113a79cSeschrock 	uint8_t				isf_datalen;
4719113a79cSeschrock 	union {
4729113a79cSeschrock 		struct {
4739113a79cSeschrock 			uint8_t		isf_data[128];
4749113a79cSeschrock 		} dimm;
4759113a79cSeschrock 		struct {
4769113a79cSeschrock 			uint32_t	isf_thermtrip;
4779113a79cSeschrock 			uint32_t	isf_eax;
4789113a79cSeschrock 			char		isf_product[48];
4799113a79cSeschrock 		} cpu;
4809113a79cSeschrock 		struct {
4819113a79cSeschrock 			char		isf_part[16];
4829113a79cSeschrock 			char		isf_version[16];
4839113a79cSeschrock 		} bios;
4849113a79cSeschrock 		struct {
4859113a79cSeschrock 			char		isf_manufacturer[16];
4869113a79cSeschrock 			char		isf_model[28];
4879113a79cSeschrock 			char		isf_serial[20];
4889113a79cSeschrock 			char		isf_version[8];
4899113a79cSeschrock 			char		isf_capacity[16];
4909113a79cSeschrock 		} disk;
4919113a79cSeschrock 	} isf_data;
4929113a79cSeschrock } ipmi_sunoem_fru_t;
4939113a79cSeschrock 
4949113a79cSeschrock int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *);
4959113a79cSeschrock 
4969113a79cSeschrock #pragma pack()
4979113a79cSeschrock 
4989113a79cSeschrock #ifdef	__cplusplus
4999113a79cSeschrock }
5009113a79cSeschrock #endif
5019113a79cSeschrock 
5029113a79cSeschrock #endif	/* _LIBIPMI_H */
503