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 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <scsi/libses.h>
33 #include <scsi/libses_plugin.h>
37 typedef struct ses_riverwalk_stringin
{
38 uint8_t rws_download_status
;
39 uint8_t rws_descriptor_start
;
40 uint16_t rws_descriptor_length
;
57 uint8_t rws_diag_start
;
59 uint16_t rws_diag_length
;
63 uint8_t rws_sasaddr
[8];
64 uint8_t rws_sys_sn
[8];
68 } ses_riverwalk_stringin_t
;
74 sun_riverwalk_parse_node(ses_plugin_t
*sp
, ses_node_t
*np
)
76 nvlist_t
*props
= ses_node_props(np
);
78 ses_riverwalk_stringin_t
*strp
;
87 if (ses_node_type(np
) != SES_NODE_ENCLOSURE
&&
88 ses_node_type(np
) != SES_NODE_ELEMENT
)
92 * Find the containing enclosure node and extract the STRING IN
95 for (encp
= np
; ses_node_type(encp
) != SES_NODE_ENCLOSURE
;
96 encp
= ses_node_parent(encp
))
99 encprops
= ses_node_props(encp
);
100 if (nvlist_lookup_byte_array(encprops
, SES_EN_PROP_STRING
,
101 &stringin
, &len
) != 0)
104 if (len
< sizeof (ses_riverwalk_stringin_t
))
107 strp
= (ses_riverwalk_stringin_t
*)stringin
;
109 switch (ses_node_type(np
)) {
110 case SES_NODE_ELEMENT
:
112 * We can get part and serial information for power supplies and
113 * the SIM cards (ESC_ELECTRONICS elements).
115 VERIFY(nvlist_lookup_uint64(props
, SES_PROP_ELEMENT_TYPE
,
117 VERIFY(nvlist_lookup_uint64(props
, SES_PROP_ELEMENT_CLASS_INDEX
,
122 case SES_ET_POWER_SUPPLY
:
125 if (strncmp(strp
->rws_ps0_id
, "SPS0", 4) != 0)
128 pn
= strp
->rws_ps0_pn
;
129 sn
= strp
->rws_ps0_sn
;
133 if (strncmp(strp
->rws_ps1_id
, "SPS1", 4) != 0)
136 pn
= strp
->rws_ps1_pn
;
137 sn
= strp
->rws_ps1_sn
;
142 case SES_ET_ESC_ELECTRONICS
:
145 if (strncmp(strp
->rws_sim0_id
, "SIM0", 4) != 0)
148 pn
= strp
->rws_sim0_pn
;
149 sn
= strp
->rws_sim0_sn
;
153 if (strncmp(strp
->rws_sim1_id
, "SIM1", 4) != 0)
156 pn
= strp
->rws_sim1_pn
;
157 sn
= strp
->rws_sim1_sn
;
164 * The J4200 uses identical STRING IN data except that
165 * the PSU part numbers are replaced with fan part
166 * numbers. The power supply part and serial number
167 * information are not available.
171 if (strncmp(strp
->rws_ps0_id
, "FAN0", 4) != 0)
174 pn
= strp
->rws_ps0_pn
;
175 sn
= strp
->rws_ps0_sn
;
179 if (strncmp(strp
->rws_ps1_id
, "FAN1", 4) != 0)
182 pn
= strp
->rws_ps1_pn
;
183 sn
= strp
->rws_ps1_sn
;
194 (void) bcopy(pn
, buf
, sizeof (strp
->rws_ps0_pn
));
195 buf
[sizeof (strp
->rws_ps0_pn
)] = '\0';
196 SES_NV_ADD(string
, nverr
, props
, LIBSES_PROP_PART
,
201 (void) bcopy(sn
, buf
, sizeof (strp
->rws_ps0_sn
));
202 buf
[sizeof (strp
->rws_ps0_sn
)] = '\0';
203 SES_NV_ADD(string
, nverr
, props
, LIBSES_PROP_SERIAL
,
209 case SES_NODE_ENCLOSURE
:
211 * The chassis serial number is derived from the MID FRU
214 if (strncmp(strp
->rws_mid_id
, "MID ", 4) == 0 &&
215 strp
->rws_mid_sn
[0] != '\0') {
216 (void) bcopy(strp
->rws_mid_sn
, buf
,
217 sizeof (strp
->rws_mid_sn
));
218 buf
[sizeof (strp
->rws_mid_sn
)] = '\0';
219 SES_NV_ADD(string
, nverr
, props
, LIBSES_EN_PROP_CSN
,
230 _ses_init(ses_plugin_t
*sp
)
232 ses_plugin_config_t config
= {
233 .spc_node_parse
= sun_riverwalk_parse_node
236 return (ses_plugin_register(sp
, LIBSES_PLUGIN_VERSION
,