7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/types.h>
28 #include <sys/time.h>
29 #include <sys/nvpair.h>
30 #include <sys/cmn_err.h>
31 #include <sys/cred.h>
32 #include <sys/open.h>
33 #include <sys/ddi.h>
34 #include <sys/sunddi.h>
35 #include <sys/conf.h>
36 #include <sys/modctl.h>
37 #include <sys/cyclic.h>
38 #include <sys/errorq.h>
39 #include <sys/stat.h>
40 #include <sys/cpuvar.h>
41 #include <sys/mc_intel.h>
42 #include <sys/mc.h>
43 #include <sys/fm/protocol.h>
44 #include "nhm_log.h"
45 #include "intel_nhm.h"
46
139 (void) nvlist_alloc(&newdimm, NV_UNIQUE_NAME, KM_SLEEP);
140 (void) nvlist_add_uint32(newdimm, "dimm-number", dimm);
141
142 if (nhm_dimm->dimm_size >= 1024*1024*1024) {
143 (void) snprintf(sbuf, sizeof (sbuf), "%dG",
144 (int)(nhm_dimm->dimm_size / (1024*1024*1024)));
145 } else {
146 (void) snprintf(sbuf, sizeof (sbuf), "%dM",
147 (int)(nhm_dimm->dimm_size / (1024*1024)));
148 }
149 (void) nvlist_add_string(newdimm, "dimm-size", sbuf);
150 (void) nvlist_add_uint64(newdimm, "size", nhm_dimm->dimm_size);
151 (void) nvlist_add_uint32(newdimm, "nbanks", (uint32_t)nhm_dimm->nbanks);
152 (void) nvlist_add_uint32(newdimm, "ncolumn",
153 (uint32_t)nhm_dimm->ncolumn);
154 (void) nvlist_add_uint32(newdimm, "nrow", (uint32_t)nhm_dimm->nrow);
155 (void) nvlist_add_uint32(newdimm, "width", (uint32_t)nhm_dimm->width);
156 (void) nvlist_add_uint32(newdimm, "ranks", (uint32_t)nhm_dimm->nranks);
157 inhm_rank(newdimm, nhm_dimm, node, channel, dimm,
158 nhm_dimm->dimm_size / nhm_dimm->nranks);
159 if (nhm_dimm->manufacturer && nhm_dimm->manufacturer[0]) {
160 t = sizeof (nhm_dimm->manufacturer);
161 (void) strncpy(sbuf, nhm_dimm->manufacturer, t);
162 sbuf[t] = 0;
163 (void) nvlist_add_string(newdimm, "manufacturer", sbuf);
164 }
165 if (nhm_dimm->serial_number && nhm_dimm->serial_number[0]) {
166 t = sizeof (nhm_dimm->serial_number);
167 (void) strncpy(sbuf, nhm_dimm->serial_number, t);
168 sbuf[t] = 0;
169 (void) nvlist_add_string(newdimm, FM_FMRI_HC_SERIAL_ID, sbuf);
170 }
171 if (nhm_dimm->part_number && nhm_dimm->part_number[0]) {
172 t = sizeof (nhm_dimm->part_number);
173 (void) strncpy(sbuf, nhm_dimm->part_number, t);
174 sbuf[t] = 0;
175 (void) nvlist_add_string(newdimm, FM_FMRI_HC_PART, sbuf);
176 }
177 if (nhm_dimm->revision && nhm_dimm->revision[0]) {
178 t = sizeof (nhm_dimm->revision);
179 (void) strncpy(sbuf, nhm_dimm->revision, t);
180 sbuf[t] = 0;
181 (void) nvlist_add_string(newdimm, FM_FMRI_HC_REVISION, sbuf);
182 }
183 t = sizeof (nhm_dimm->label);
184 (void) strncpy(sbuf, nhm_dimm->label, t);
185 sbuf[t] = 0;
186 (void) nvlist_add_string(newdimm, FM_FAULT_FRU_LABEL, sbuf);
187 return (newdimm);
188 }
189
190 static void
191 inhm_dimmlist(uint32_t node, nvlist_t *nvl)
192 {
193 nvlist_t **dimmlist;
194 nvlist_t **newchannel;
195 int nchannels = CHANNELS_PER_MEMORY_CONTROLLER;
196 int nd;
197 uint8_t i, j;
|
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright (c) 2018, Joyent, Inc.
29 */
30
31 #include <sys/types.h>
32 #include <sys/time.h>
33 #include <sys/nvpair.h>
34 #include <sys/cmn_err.h>
35 #include <sys/cred.h>
36 #include <sys/open.h>
37 #include <sys/ddi.h>
38 #include <sys/sunddi.h>
39 #include <sys/conf.h>
40 #include <sys/modctl.h>
41 #include <sys/cyclic.h>
42 #include <sys/errorq.h>
43 #include <sys/stat.h>
44 #include <sys/cpuvar.h>
45 #include <sys/mc_intel.h>
46 #include <sys/mc.h>
47 #include <sys/fm/protocol.h>
48 #include "nhm_log.h"
49 #include "intel_nhm.h"
50
143 (void) nvlist_alloc(&newdimm, NV_UNIQUE_NAME, KM_SLEEP);
144 (void) nvlist_add_uint32(newdimm, "dimm-number", dimm);
145
146 if (nhm_dimm->dimm_size >= 1024*1024*1024) {
147 (void) snprintf(sbuf, sizeof (sbuf), "%dG",
148 (int)(nhm_dimm->dimm_size / (1024*1024*1024)));
149 } else {
150 (void) snprintf(sbuf, sizeof (sbuf), "%dM",
151 (int)(nhm_dimm->dimm_size / (1024*1024)));
152 }
153 (void) nvlist_add_string(newdimm, "dimm-size", sbuf);
154 (void) nvlist_add_uint64(newdimm, "size", nhm_dimm->dimm_size);
155 (void) nvlist_add_uint32(newdimm, "nbanks", (uint32_t)nhm_dimm->nbanks);
156 (void) nvlist_add_uint32(newdimm, "ncolumn",
157 (uint32_t)nhm_dimm->ncolumn);
158 (void) nvlist_add_uint32(newdimm, "nrow", (uint32_t)nhm_dimm->nrow);
159 (void) nvlist_add_uint32(newdimm, "width", (uint32_t)nhm_dimm->width);
160 (void) nvlist_add_uint32(newdimm, "ranks", (uint32_t)nhm_dimm->nranks);
161 inhm_rank(newdimm, nhm_dimm, node, channel, dimm,
162 nhm_dimm->dimm_size / nhm_dimm->nranks);
163 if (nhm_dimm->manufacturer[0]) {
164 t = sizeof (nhm_dimm->manufacturer);
165 (void) strncpy(sbuf, nhm_dimm->manufacturer, t);
166 sbuf[t] = 0;
167 (void) nvlist_add_string(newdimm, "manufacturer", sbuf);
168 }
169 if (nhm_dimm->serial_number[0]) {
170 t = sizeof (nhm_dimm->serial_number);
171 (void) strncpy(sbuf, nhm_dimm->serial_number, t);
172 sbuf[t] = 0;
173 (void) nvlist_add_string(newdimm, FM_FMRI_HC_SERIAL_ID, sbuf);
174 }
175 if (nhm_dimm->part_number[0]) {
176 t = sizeof (nhm_dimm->part_number);
177 (void) strncpy(sbuf, nhm_dimm->part_number, t);
178 sbuf[t] = 0;
179 (void) nvlist_add_string(newdimm, FM_FMRI_HC_PART, sbuf);
180 }
181 if (nhm_dimm->revision[0]) {
182 t = sizeof (nhm_dimm->revision);
183 (void) strncpy(sbuf, nhm_dimm->revision, t);
184 sbuf[t] = 0;
185 (void) nvlist_add_string(newdimm, FM_FMRI_HC_REVISION, sbuf);
186 }
187 t = sizeof (nhm_dimm->label);
188 (void) strncpy(sbuf, nhm_dimm->label, t);
189 sbuf[t] = 0;
190 (void) nvlist_add_string(newdimm, FM_FAULT_FRU_LABEL, sbuf);
191 return (newdimm);
192 }
193
194 static void
195 inhm_dimmlist(uint32_t node, nvlist_t *nvl)
196 {
197 nvlist_t **dimmlist;
198 nvlist_t **newchannel;
199 int nchannels = CHANNELS_PER_MEMORY_CONTROLLER;
200 int nd;
201 uint8_t i, j;
|