1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <libipmi.h>
#include <stddef.h>
#include "ipmi_impl.h"
#define IPMI_CMD_SUNOEM_LED_GET 0x21
#define IPMI_CMD_SUNOEM_LED_SET 0x22
typedef struct ipmi_cmd_sunoem_led_set {
DECL_BITFIELD2(
ic_sls_channel_msb :1, /* device slave address */
ic_sls_slaveaddr :7); /* (from SDR record) */
uint8_t ic_sls_type; /* led type */
DECL_BITFIELD2(
__reserved :1, /* device access address */
ic_sls_accessaddr :7); /* (from SDR record */
uint8_t ic_sls_hwinfo; /* OEM hardware info */
uint8_t ic_sls_mode; /* LED mode */
uint8_t ic_sls_eid; /* entity ID */
uint8_t ic_sls_einst; /* entity instance */
uint8_t ic_sls_force; /* force direct access */
uint8_t ic_sls_role; /* BMC authorization */
} ipmi_cmd_sunoem_led_set_t;
typedef struct ipmi_cmd_sunoem_led_get {
DECL_BITFIELD2(
ic_slg_channel_msb :1, /* device slave address */
ic_slg_slaveaddr :7); /* (from SDR record) */
uint8_t ic_slg_type; /* led type */
DECL_BITFIELD2(
__reserved :1, /* device access address */
ic_slg_accessaddr :7); /* (from SDR record */
uint8_t ic_slg_hwinfo; /* OEM hardware info */
uint8_t ic_slg_eid; /* entity ID */
uint8_t ic_slg_einst; /* entity instance */
uint8_t ic_slg_force; /* force direct access */
} ipmi_cmd_sunoem_led_get_t;
#define IPMI_SUNOEM_LED_TYPE_OK2RM 0
#define IPMI_SUNOEM_LED_TYPE_SERVICE 1
#define IPMI_SUNOEM_LED_TYPE_ACT 2
#define IPMI_SUNOEM_LED_TYPE_LOCATE 3
#define IPMI_SUNOEM_LED_TYPE_ANY 0xFF
boolean_t
ipmi_is_sun_ilom(ipmi_deviceid_t *dp)
{
return (ipmi_devid_manufacturer(dp) == IPMI_OEM_SUN &&
ipmi_devid_product(dp) == IPMI_PROD_SUN_ILOM);
}
static int
check_sunoem(ipmi_handle_t *ihp)
{
ipmi_deviceid_t *devid;
if ((devid = ipmi_get_deviceid(ihp)) == NULL)
return (-1);
if (!ipmi_is_sun_ilom(devid))
return (ipmi_set_error(ihp, EIPMI_INVALID_COMMAND, NULL));
return (0);
}
static int
ipmi_send_sunoem_led_set(ipmi_handle_t *ihp, ipmi_cmd_sunoem_led_set_t *req)
{
ipmi_cmd_t cmd, *resp;
cmd.ic_netfn = IPMI_NETFN_OEM;
cmd.ic_cmd = IPMI_CMD_SUNOEM_LED_SET;
cmd.ic_lun = 0;
cmd.ic_data = req;
cmd.ic_dlen = sizeof (*req);
if ((resp = ipmi_send(ihp, &cmd)) == NULL)
return (-1);
if (resp->ic_dlen != 0)
return (ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL));
return (0);
}
static int
ipmi_send_sunoem_led_get(ipmi_handle_t *ihp, ipmi_cmd_sunoem_led_get_t *req,
uint8_t *result)
{
ipmi_cmd_t cmd, *resp;
cmd.ic_netfn = IPMI_NETFN_OEM;
cmd.ic_cmd = IPMI_CMD_SUNOEM_LED_GET;
cmd.ic_lun = 0;
cmd.ic_data = req;
cmd.ic_dlen = sizeof (*req);
if ((resp = ipmi_send(ihp, &cmd)) == NULL)
return (-1);
if (resp->ic_dlen != 1)
return (ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL));
*result = *((uint8_t *)resp->ic_data);
return (0);
}
int
ipmi_sunoem_led_set(ipmi_handle_t *ihp, ipmi_sdr_generic_locator_t *dev,
uint8_t mode)
{
ipmi_cmd_sunoem_led_set_t cmd = { 0 };
if (check_sunoem(ihp) != 0)
return (-1);
cmd.ic_sls_slaveaddr = dev->is_gl_slaveaddr;
cmd.ic_sls_channel_msb = dev->is_gl_channel_msb;
cmd.ic_sls_type = dev->is_gl_oem;
cmd.ic_sls_accessaddr = dev->is_gl_accessaddr;
cmd.ic_sls_hwinfo = dev->is_gl_oem;
cmd.ic_sls_mode = mode;
cmd.ic_sls_eid = dev->is_gl_entity;
cmd.ic_sls_einst = dev->is_gl_instance;
return (ipmi_send_sunoem_led_set(ihp, &cmd));
}
int
ipmi_sunoem_led_get(ipmi_handle_t *ihp, ipmi_sdr_generic_locator_t *dev,
uint8_t *mode)
{
ipmi_cmd_sunoem_led_get_t cmd = { 0 };
if (check_sunoem(ihp) != 0)
return (-1);
cmd.ic_slg_slaveaddr = dev->is_gl_slaveaddr;
cmd.ic_slg_channel_msb = dev->is_gl_channel_msb;
cmd.ic_slg_type = dev->is_gl_oem;
cmd.ic_slg_accessaddr = dev->is_gl_accessaddr;
cmd.ic_slg_hwinfo = dev->is_gl_oem;
cmd.ic_slg_eid = dev->is_gl_entity;
cmd.ic_slg_einst = dev->is_gl_instance;
return (ipmi_send_sunoem_led_get(ihp, &cmd, mode));
}
int
ipmi_sunoem_uptime(ipmi_handle_t *ihp, uint32_t *uptime, uint32_t *gen)
{
ipmi_cmd_t cmd, *resp;
uint8_t unused;
if (check_sunoem(ihp) != 0)
return (-1);
cmd.ic_netfn = IPMI_NETFN_OEM;
cmd.ic_lun = 0;
cmd.ic_cmd = IPMI_CMD_SUNOEM_UPTIME;
cmd.ic_dlen = sizeof (unused);
cmd.ic_data = &unused;
if ((resp = ipmi_send(ihp, &cmd)) == NULL)
return (-1);
if (resp->ic_dlen != 2 * sizeof (uint32_t))
return (ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL));
if (uptime)
*uptime = BE_IN32(&((uint32_t *)resp->ic_data)[0]);
if (gen)
*gen = BE_IN32(&((uint32_t *)resp->ic_data)[1]);
return (0);
}
int
ipmi_sunoem_update_fru(ipmi_handle_t *ihp, ipmi_sunoem_fru_t *req)
{
ipmi_cmd_t cmd, *resp;
if (check_sunoem(ihp) != 0)
return (-1);
switch (req->isf_type) {
case IPMI_SUNOEM_FRU_DIMM:
req->isf_datalen = sizeof (req->isf_data.dimm);
break;
case IPMI_SUNOEM_FRU_CPU:
req->isf_datalen = sizeof (req->isf_data.cpu);
break;
case IPMI_SUNOEM_FRU_BIOS:
req->isf_datalen = sizeof (req->isf_data.bios);
break;
case IPMI_SUNOEM_FRU_DISK:
req->isf_datalen = sizeof (req->isf_data.disk);
break;
}
cmd.ic_netfn = IPMI_NETFN_OEM;
cmd.ic_cmd = IPMI_CMD_SUNOEM_FRU_UPDATE;
cmd.ic_lun = 0;
cmd.ic_dlen = offsetof(ipmi_sunoem_fru_t, isf_data) +
req->isf_datalen;
cmd.ic_data = req;
if ((resp = ipmi_send(ihp, &cmd)) == NULL)
return (-1);
if (resp->ic_dlen != 0)
return (ipmi_set_error(ihp, EIPMI_BAD_RESPONSE_LENGTH, NULL));
return (0);
}
|