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 /* 392*4557a2a1Srobj * These IPMI message id/opcodes are documented in Appendix G in the IPMI spec. 393*4557a2a1Srobj * 394*4557a2a1Srobj * Payloads for these two commands are described in Sections 34.1 and 34.2 of 395*4557a2a1Srobj * the spec, respectively. 396*4557a2a1Srobj */ 397*4557a2a1Srobj #define IPMI_CMD_GET_FRU_INV_AREA 0x10 398*4557a2a1Srobj #define IPMI_CMD_READ_FRU_DATA 0x11 399*4557a2a1Srobj 400*4557a2a1Srobj /* 401*4557a2a1Srobj * Structs to hold the FRU Common Header and the FRU Product Info Area, as 402*4557a2a1Srobj * described in the IPMI Platform Management FRU Information Storage 403*4557a2a1Srobj * Definition (v1.1). 404*4557a2a1Srobj */ 405*4557a2a1Srobj typedef struct ipmi_fru_hdr 406*4557a2a1Srobj { 407*4557a2a1Srobj uint8_t ifh_format; 408*4557a2a1Srobj uint8_t ifh_int_use_off; 409*4557a2a1Srobj uint8_t ifh_chassis_info_off; 410*4557a2a1Srobj uint8_t ifh_board_info_off; 411*4557a2a1Srobj uint8_t ifh_product_info_off; 412*4557a2a1Srobj uint8_t ifh_multi_rec_off; 413*4557a2a1Srobj uint8_t ifh_pad; 414*4557a2a1Srobj uint8_t ifh_chksum; 415*4557a2a1Srobj } ipmi_fru_hdr_t; 416*4557a2a1Srobj 417*4557a2a1Srobj /* 418*4557a2a1Srobj * Because only 6 bits are used to specify the length of each field in the FRU 419*4557a2a1Srobj * product and board info areas, the biggest string we would ever need to hold 420*4557a2a1Srobj * would be 63 chars plus a NULL. 421*4557a2a1Srobj */ 422*4557a2a1Srobj #define FRU_INFO_MAXLEN 64 423*4557a2a1Srobj 424*4557a2a1Srobj typedef struct ipmi_fru_brd_info 425*4557a2a1Srobj { 426*4557a2a1Srobj char ifbi_manuf_date[3]; 427*4557a2a1Srobj char ifbi_manuf_name[FRU_INFO_MAXLEN]; 428*4557a2a1Srobj char ifbi_board_name[FRU_INFO_MAXLEN]; 429*4557a2a1Srobj char ifbi_product_serial[FRU_INFO_MAXLEN]; 430*4557a2a1Srobj char ifbi_part_number[FRU_INFO_MAXLEN]; 431*4557a2a1Srobj } ipmi_fru_brd_info_t; 432*4557a2a1Srobj 433*4557a2a1Srobj typedef struct ipmi_fru_prod_info 434*4557a2a1Srobj { 435*4557a2a1Srobj char ifpi_manuf_name[FRU_INFO_MAXLEN]; 436*4557a2a1Srobj char ifpi_product_name[FRU_INFO_MAXLEN]; 437*4557a2a1Srobj char ifpi_part_number[FRU_INFO_MAXLEN]; 438*4557a2a1Srobj char ifpi_product_version[FRU_INFO_MAXLEN]; 439*4557a2a1Srobj char ifpi_product_serial[FRU_INFO_MAXLEN]; 440*4557a2a1Srobj char ifpi_asset_tag[FRU_INFO_MAXLEN]; 441*4557a2a1Srobj } ipmi_fru_prod_info_t; 442*4557a2a1Srobj 443*4557a2a1Srobj int ipmi_fru_read(ipmi_handle_t *, ipmi_sdr_fru_locator_t *, char **); 444*4557a2a1Srobj int ipmi_fru_parse_board(ipmi_handle_t *, char *, ipmi_fru_brd_info_t *); 445*4557a2a1Srobj int ipmi_fru_parse_product(ipmi_handle_t *, char *, ipmi_fru_prod_info_t *); 446*4557a2a1Srobj 447*4557a2a1Srobj /* 4489113a79cSeschrock * The remaining functions are private to the implementation of the Sun ILOM 4499113a79cSeschrock * service processor. These function first check the manufacturer from the IPMI 4509113a79cSeschrock * device ID, and will return EIPMI_NOT_SUPPORTED if attempted for non-Sun 4519113a79cSeschrock * devices. 4529113a79cSeschrock */ 4539113a79cSeschrock 4549113a79cSeschrock /* 4559113a79cSeschrock * Sun OEM LED requests. 4569113a79cSeschrock */ 4579113a79cSeschrock 4589113a79cSeschrock #define IPMI_CMD_SUNOEM_LED_GET 0x21 4599113a79cSeschrock #define IPMI_CMD_SUNOEM_LED_SET 0x22 4609113a79cSeschrock 4619113a79cSeschrock typedef struct ipmi_cmd_sunoem_led_set { 462a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH) 463a10acbd6Seschrock uint8_t ic_sls_channel_msb:1; /* device slave address */ 464a10acbd6Seschrock uint8_t ic_sls_slaveaddr:7; /* (from SDR record) */ 465a10acbd6Seschrock #else 466a10acbd6Seschrock uint8_t ic_sls_slaveaddr:7; 467a10acbd6Seschrock uint8_t ic_sls_channel_msb:1; 468a10acbd6Seschrock #endif 4699113a79cSeschrock uint8_t ic_sls_type; /* led type */ 470a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH) 471a10acbd6Seschrock uint8_t __reserved:1; /* device access address */ 472a10acbd6Seschrock uint8_t ic_sls_accessaddr:7; /* (from SDR record) */ 473a10acbd6Seschrock #else 474a10acbd6Seschrock uint8_t ic_sls_accessaddr:7; 475a10acbd6Seschrock uint8_t __reserved:1; 476a10acbd6Seschrock #endif 4779113a79cSeschrock uint8_t ic_sls_hwinfo; /* OEM hardware info */ 4789113a79cSeschrock uint8_t ic_sls_mode; /* LED mode */ 4799113a79cSeschrock uint8_t ic_sls_force; /* force direct access */ 4809113a79cSeschrock uint8_t ic_sls_role; /* BMC authorization */ 4819113a79cSeschrock } ipmi_cmd_sunoem_led_set_t; 4829113a79cSeschrock 4839113a79cSeschrock typedef struct ipmi_cmd_sunoem_led_get { 484a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH) 485a10acbd6Seschrock uint8_t ic_slg_channel_msb:1; /* device slave address */ 486a10acbd6Seschrock uint8_t ic_slg_slaveaddr:7; /* (from SDR record) */ 487a10acbd6Seschrock #else 488a10acbd6Seschrock uint8_t ic_slg_slaveaddr:7; 489a10acbd6Seschrock uint8_t ic_slg_channel_msb:1; 490a10acbd6Seschrock #endif 4919113a79cSeschrock uint8_t ic_slg_type; /* led type */ 492a10acbd6Seschrock #if defined(_BIT_FIELDS_LTOH) 493a10acbd6Seschrock uint8_t __reserved:1; /* device access address */ 494a10acbd6Seschrock uint8_t ic_slg_accessaddr:7; /* (from SDR record) */ 495a10acbd6Seschrock #else 496a10acbd6Seschrock uint8_t ic_slg_accessaddr:7; 497a10acbd6Seschrock uint8_t __reserved:1; 498a10acbd6Seschrock #endif 4999113a79cSeschrock uint8_t ic_slg_hwinfo; /* OEM hardware info */ 5009113a79cSeschrock uint8_t ic_slg_force; /* force direct access */ 5019113a79cSeschrock } ipmi_cmd_sunoem_led_get_t; 5029113a79cSeschrock 5039113a79cSeschrock #define IPMI_SUNOEM_LED_TYPE_OK2RM 0 5049113a79cSeschrock #define IPMI_SUNOEM_LED_TYPE_SERVICE 1 5059113a79cSeschrock #define IPMI_SUNOEM_LED_TYPE_ACT 2 5069113a79cSeschrock #define IPMI_SUNOEM_LED_TYPE_LOCATE 3 5079113a79cSeschrock #define IPMI_SUNOEM_LED_TYPE_ANY 0xFF 5089113a79cSeschrock 5099113a79cSeschrock #define IPMI_SUNOEM_LED_MODE_OFF 0 5109113a79cSeschrock #define IPMI_SUNOEM_LED_MODE_ON 1 5119113a79cSeschrock #define IPMI_SUNOEM_LED_MODE_STANDBY 2 5129113a79cSeschrock #define IPMI_SUNOEM_LED_MODE_SLOW 3 5139113a79cSeschrock #define IPMI_SUNOEM_LED_MODE_FAST 4 5149113a79cSeschrock 5159113a79cSeschrock /* 5169113a79cSeschrock * These functions take a SDR record and construct the appropriate form of the 5179113a79cSeschrock * above commands. 5189113a79cSeschrock */ 5199113a79cSeschrock extern int ipmi_sunoem_led_set(ipmi_handle_t *, 5209113a79cSeschrock ipmi_sdr_generic_locator_t *, uint8_t); 5219113a79cSeschrock extern int ipmi_sunoem_led_get(ipmi_handle_t *, 5229113a79cSeschrock ipmi_sdr_generic_locator_t *, uint8_t *); 5239113a79cSeschrock 5249113a79cSeschrock /* 5259113a79cSeschrock * Sun OEM uptime. Note that the underlying command returns the uptime in big 5269113a79cSeschrock * endian form. This wrapper automatically converts to the appropriate native 5279113a79cSeschrock * form. 5289113a79cSeschrock */ 5299113a79cSeschrock 5309113a79cSeschrock #define IPMI_CMD_SUNOEM_UPTIME 0x08 5319113a79cSeschrock 5329113a79cSeschrock extern int ipmi_sunoem_uptime(ipmi_handle_t *, uint32_t *, uint32_t *); 5339113a79cSeschrock 5349113a79cSeschrock /* 5359113a79cSeschrock * Sun OEM FRU update. The FRU information is managed through a generic 5369113a79cSeschrock * identifier, and then a type-specific data portion. The wrapper function will 5379113a79cSeschrock * automatically fill in the data length field according to which type is 5389113a79cSeschrock * specified. 5399113a79cSeschrock */ 5409113a79cSeschrock 5419113a79cSeschrock #define IPMI_CMD_SUNOEM_FRU_UPDATE 0x16 5429113a79cSeschrock 5439113a79cSeschrock #define IPMI_SUNOEM_FRU_DIMM 0x00 5449113a79cSeschrock #define IPMI_SUNOEM_FRU_CPU 0x01 5459113a79cSeschrock #define IPMI_SUNOEM_FRU_BIOS 0x02 5469113a79cSeschrock #define IPMI_SUNOEM_FRU_DISK 0x03 5479113a79cSeschrock 5489113a79cSeschrock typedef struct ipmi_sunoem_fru { 5499113a79cSeschrock uint8_t isf_type; 5509113a79cSeschrock uint8_t isf_id; 5519113a79cSeschrock uint8_t isf_datalen; 5529113a79cSeschrock union { 5539113a79cSeschrock struct { 5549113a79cSeschrock uint8_t isf_data[128]; 5559113a79cSeschrock } dimm; 5569113a79cSeschrock struct { 5579113a79cSeschrock uint32_t isf_thermtrip; 5589113a79cSeschrock uint32_t isf_eax; 5599113a79cSeschrock char isf_product[48]; 5609113a79cSeschrock } cpu; 5619113a79cSeschrock struct { 5629113a79cSeschrock char isf_part[16]; 5639113a79cSeschrock char isf_version[16]; 5649113a79cSeschrock } bios; 5659113a79cSeschrock struct { 5669113a79cSeschrock char isf_manufacturer[16]; 5679113a79cSeschrock char isf_model[28]; 5689113a79cSeschrock char isf_serial[20]; 5699113a79cSeschrock char isf_version[8]; 5709113a79cSeschrock char isf_capacity[16]; 5719113a79cSeschrock } disk; 5729113a79cSeschrock } isf_data; 5739113a79cSeschrock } ipmi_sunoem_fru_t; 5749113a79cSeschrock 5759113a79cSeschrock int ipmi_sunoem_update_fru(ipmi_handle_t *, ipmi_sunoem_fru_t *); 5769113a79cSeschrock 5779113a79cSeschrock #pragma pack() 5789113a79cSeschrock 5799113a79cSeschrock #ifdef __cplusplus 5809113a79cSeschrock } 5819113a79cSeschrock #endif 5829113a79cSeschrock 5839113a79cSeschrock #endif /* _LIBIPMI_H */ 584