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.
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.
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]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #include "ipmi_impl.h"
32 #define IPMI_CMD_SUNOEM_LED_GET 0x21
33 #define IPMI_CMD_SUNOEM_LED_SET 0x22
35 typedef struct ipmi_cmd_sunoem_led_set
{
37 ic_sls_channel_msb
:1, /* device slave address */
38 ic_sls_slaveaddr
:7); /* (from SDR record) */
39 uint8_t ic_sls_type
; /* led type */
41 __reserved
:1, /* device access address */
42 ic_sls_accessaddr
:7); /* (from SDR record */
43 uint8_t ic_sls_hwinfo
; /* OEM hardware info */
44 uint8_t ic_sls_mode
; /* LED mode */
45 uint8_t ic_sls_eid
; /* entity ID */
46 uint8_t ic_sls_einst
; /* entity instance */
47 uint8_t ic_sls_force
; /* force direct access */
48 uint8_t ic_sls_role
; /* BMC authorization */
49 } ipmi_cmd_sunoem_led_set_t
;
51 typedef struct ipmi_cmd_sunoem_led_get
{
53 ic_slg_channel_msb
:1, /* device slave address */
54 ic_slg_slaveaddr
:7); /* (from SDR record) */
55 uint8_t ic_slg_type
; /* led type */
57 __reserved
:1, /* device access address */
58 ic_slg_accessaddr
:7); /* (from SDR record */
59 uint8_t ic_slg_hwinfo
; /* OEM hardware info */
60 uint8_t ic_slg_eid
; /* entity ID */
61 uint8_t ic_slg_einst
; /* entity instance */
62 uint8_t ic_slg_force
; /* force direct access */
63 } ipmi_cmd_sunoem_led_get_t
;
65 #define IPMI_SUNOEM_LED_TYPE_OK2RM 0
66 #define IPMI_SUNOEM_LED_TYPE_SERVICE 1
67 #define IPMI_SUNOEM_LED_TYPE_ACT 2
68 #define IPMI_SUNOEM_LED_TYPE_LOCATE 3
69 #define IPMI_SUNOEM_LED_TYPE_ANY 0xFF
72 ipmi_is_sun_ilom(ipmi_deviceid_t
*dp
)
74 return (ipmi_devid_manufacturer(dp
) == IPMI_OEM_SUN
&&
75 ipmi_devid_product(dp
) == IPMI_PROD_SUN_ILOM
);
79 check_sunoem(ipmi_handle_t
*ihp
)
81 ipmi_deviceid_t
*devid
;
83 if ((devid
= ipmi_get_deviceid(ihp
)) == NULL
)
86 if (!ipmi_is_sun_ilom(devid
))
87 return (ipmi_set_error(ihp
, EIPMI_INVALID_COMMAND
, NULL
));
93 ipmi_send_sunoem_led_set(ipmi_handle_t
*ihp
, ipmi_cmd_sunoem_led_set_t
*req
)
95 ipmi_cmd_t cmd
, *resp
;
97 cmd
.ic_netfn
= IPMI_NETFN_OEM
;
98 cmd
.ic_cmd
= IPMI_CMD_SUNOEM_LED_SET
;
101 cmd
.ic_dlen
= sizeof (*req
);
103 if ((resp
= ipmi_send(ihp
, &cmd
)) == NULL
)
106 if (resp
->ic_dlen
!= 0)
107 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));
113 ipmi_send_sunoem_led_get(ipmi_handle_t
*ihp
, ipmi_cmd_sunoem_led_get_t
*req
,
116 ipmi_cmd_t cmd
, *resp
;
118 cmd
.ic_netfn
= IPMI_NETFN_OEM
;
119 cmd
.ic_cmd
= IPMI_CMD_SUNOEM_LED_GET
;
122 cmd
.ic_dlen
= sizeof (*req
);
124 if ((resp
= ipmi_send(ihp
, &cmd
)) == NULL
)
127 if (resp
->ic_dlen
!= 1)
128 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));
130 *result
= *((uint8_t *)resp
->ic_data
);
135 ipmi_sunoem_led_set(ipmi_handle_t
*ihp
, ipmi_sdr_generic_locator_t
*dev
,
138 ipmi_cmd_sunoem_led_set_t cmd
= { 0 };
140 if (check_sunoem(ihp
) != 0)
143 cmd
.ic_sls_slaveaddr
= dev
->is_gl_slaveaddr
;
144 cmd
.ic_sls_channel_msb
= dev
->is_gl_channel_msb
;
145 cmd
.ic_sls_type
= dev
->is_gl_oem
;
146 cmd
.ic_sls_accessaddr
= dev
->is_gl_accessaddr
;
147 cmd
.ic_sls_hwinfo
= dev
->is_gl_oem
;
148 cmd
.ic_sls_mode
= mode
;
149 cmd
.ic_sls_eid
= dev
->is_gl_entity
;
150 cmd
.ic_sls_einst
= dev
->is_gl_instance
;
152 return (ipmi_send_sunoem_led_set(ihp
, &cmd
));
156 ipmi_sunoem_led_get(ipmi_handle_t
*ihp
, ipmi_sdr_generic_locator_t
*dev
,
159 ipmi_cmd_sunoem_led_get_t cmd
= { 0 };
161 if (check_sunoem(ihp
) != 0)
164 cmd
.ic_slg_slaveaddr
= dev
->is_gl_slaveaddr
;
165 cmd
.ic_slg_channel_msb
= dev
->is_gl_channel_msb
;
166 cmd
.ic_slg_type
= dev
->is_gl_oem
;
167 cmd
.ic_slg_accessaddr
= dev
->is_gl_accessaddr
;
168 cmd
.ic_slg_hwinfo
= dev
->is_gl_oem
;
169 cmd
.ic_slg_eid
= dev
->is_gl_entity
;
170 cmd
.ic_slg_einst
= dev
->is_gl_instance
;
172 return (ipmi_send_sunoem_led_get(ihp
, &cmd
, mode
));
176 ipmi_sunoem_uptime(ipmi_handle_t
*ihp
, uint32_t *uptime
, uint32_t *gen
)
178 ipmi_cmd_t cmd
, *resp
;
181 if (check_sunoem(ihp
) != 0)
184 cmd
.ic_netfn
= IPMI_NETFN_OEM
;
186 cmd
.ic_cmd
= IPMI_CMD_SUNOEM_UPTIME
;
187 cmd
.ic_dlen
= sizeof (unused
);
188 cmd
.ic_data
= &unused
;
190 if ((resp
= ipmi_send(ihp
, &cmd
)) == NULL
)
193 if (resp
->ic_dlen
!= 2 * sizeof (uint32_t))
194 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));
197 *uptime
= BE_IN32(&((uint32_t *)resp
->ic_data
)[0]);
199 *gen
= BE_IN32(&((uint32_t *)resp
->ic_data
)[1]);
205 ipmi_sunoem_update_fru(ipmi_handle_t
*ihp
, ipmi_sunoem_fru_t
*req
)
207 ipmi_cmd_t cmd
, *resp
;
209 if (check_sunoem(ihp
) != 0)
212 switch (req
->isf_type
) {
213 case IPMI_SUNOEM_FRU_DIMM
:
214 req
->isf_datalen
= sizeof (req
->isf_data
.dimm
);
217 case IPMI_SUNOEM_FRU_CPU
:
218 req
->isf_datalen
= sizeof (req
->isf_data
.cpu
);
221 case IPMI_SUNOEM_FRU_BIOS
:
222 req
->isf_datalen
= sizeof (req
->isf_data
.bios
);
225 case IPMI_SUNOEM_FRU_DISK
:
226 req
->isf_datalen
= sizeof (req
->isf_data
.disk
);
230 cmd
.ic_netfn
= IPMI_NETFN_OEM
;
231 cmd
.ic_cmd
= IPMI_CMD_SUNOEM_FRU_UPDATE
;
233 cmd
.ic_dlen
= offsetof(ipmi_sunoem_fru_t
, isf_data
) +
237 if ((resp
= ipmi_send(ihp
, &cmd
)) == NULL
)
240 if (resp
->ic_dlen
!= 0)
241 return (ipmi_set_error(ihp
, EIPMI_BAD_RESPONSE_LENGTH
, NULL
));