Mercurial > illumos > onarm
annotate usr/src/cmd/fm/modules/sun4v/cpumem-diagnosis/cmd_branch.c @ 4:1a15d5aaf794
synchronized with onnv_86 (6202) in onnv-gate
author | Koji Uno <koji.uno@sun.com> |
---|---|
date | Mon, 31 Aug 2009 14:38:03 +0900 |
parents | c9caec207d52 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
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. | |
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 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
23 * Use is subject to license terms. | |
24 */ | |
25 | |
4
1a15d5aaf794
synchronized with onnv_86 (6202) in onnv-gate
Koji Uno <koji.uno@sun.com>
parents:
0
diff
changeset
|
26 #pragma ident "%Z%%M% %I% %E% SMI" |
0 | 27 |
28 #include <cmd_mem.h> | |
29 #include <cmd_branch.h> | |
30 #include <cmd_dimm.h> | |
31 #include <cmd.h> | |
32 #include <cmd_hc_sun4v.h> | |
33 | |
34 #include <errno.h> | |
35 #include <string.h> | |
36 #include <strings.h> | |
37 #include <fcntl.h> | |
38 #include <unistd.h> | |
39 #include <fm/fmd_api.h> | |
40 #include <sys/fm/protocol.h> | |
41 #include <sys/mem.h> | |
42 #include <sys/nvpair.h> | |
43 | |
44 #define BUF_SIZE 120 | |
45 #define LEN_CMP 6 | |
46 | |
47 | |
48 int | |
49 is_t5440_unum(const char *unum) | |
50 { | |
51 if ((strncmp(unum, "MB/CPU", LEN_CMP) == 0) || | |
52 (strncmp(unum, "MB/MEM", LEN_CMP) == 0)) | |
53 return (1); | |
54 return (0); | |
55 } | |
56 | |
57 int | |
58 is_dimm_on_memboard(cmd_branch_t *branch) | |
59 { | |
60 cmd_dimm_t *dimm; | |
61 cmd_branch_memb_t *bm; | |
62 | |
63 if (is_t5440_unum(branch->branch_unum)) { | |
64 for (bm = cmd_list_next(&branch->branch_dimms); bm != NULL; | |
65 bm = cmd_list_next(bm)) { | |
66 dimm = bm->dimm; | |
67 if (strstr(dimm->dimm_unum, "MEM") != NULL) { | |
68 return (1); | |
69 } | |
70 } | |
71 } | |
72 return (0); | |
73 } | |
74 | |
75 void | |
76 cmd_branch_add_dimm(fmd_hdl_t *hdl, cmd_branch_t *branch, cmd_dimm_t *dimm) | |
77 { | |
78 cmd_branch_memb_t *bm; | |
79 | |
80 if (dimm == NULL) | |
81 return; | |
82 | |
83 fmd_hdl_debug(hdl, "Attaching dimm %s to branch %s\n", | |
84 dimm->dimm_unum, branch->branch_unum); | |
85 bm = fmd_hdl_zalloc(hdl, sizeof (cmd_branch_memb_t), FMD_SLEEP); | |
86 bm->dimm = dimm; | |
87 cmd_list_append(&branch->branch_dimms, bm); | |
88 } | |
89 | |
90 void | |
91 cmd_branch_remove_dimm(fmd_hdl_t *hdl, cmd_branch_t *branch, cmd_dimm_t *dimm) | |
92 { | |
93 cmd_branch_memb_t *bm; | |
94 | |
95 fmd_hdl_debug(hdl, "Detaching dimm %s from branch %s\n", | |
96 dimm->dimm_unum, branch->branch_unum); | |
97 | |
98 for (bm = cmd_list_next(&branch->branch_dimms); bm != NULL; | |
99 bm = cmd_list_next(bm)) { | |
100 if (bm->dimm == dimm) { | |
101 cmd_list_delete(&branch->branch_dimms, bm); | |
102 fmd_hdl_free(hdl, bm, sizeof (cmd_branch_memb_t)); | |
103 return; | |
104 } | |
105 } | |
106 | |
107 fmd_hdl_abort(hdl, | |
108 "Attempt to disconnect dimm from non-parent branch\n"); | |
109 } | |
110 | |
111 static cmd_dimm_t * | |
112 branch_dimm_create(fmd_hdl_t *hdl, char *dimm_unum) | |
113 { | |
114 nvlist_t *fmri; | |
115 cmd_dimm_t *dimm; | |
116 | |
117 fmri = cmd_mem_fmri_create(dimm_unum); | |
118 | |
119 if (fmri != NULL && (fmd_nvl_fmri_expand(hdl, fmri) == 0)) { | |
120 dimm = cmd_dimm_create(hdl, fmri); | |
121 if (dimm != NULL) { | |
122 nvlist_free(fmri); | |
123 return (dimm); | |
124 } | |
125 } | |
126 | |
127 nvlist_free(fmri); | |
128 return (NULL); | |
129 } | |
130 | |
131 /* | |
132 * The cmd_dimm_t structure created for a DIMM in a branch never has a | |
133 * Jxxx in its unum; the cmd_dimm_t structure created for a DIMM containing | |
134 * a page, or in a bank (i.e. for ECC errors)-always-has a Jxxx in its | |
135 * unum. Therefore the set of cmd_dimm_t's created for a branch is always | |
136 * disjoint from the set of cmd_dimm_t's created for pages and/or banks, so | |
137 * the cmd_dimm_create will never link a 'branch' cmd_dimm_t into bank. | |
138 * Faulting a DIMM for ECC will not prevent subsequent faulting of "same" | |
139 * dimm for FBR/FBU and vice versa | |
140 */ | |
141 static int | |
142 branch_dimmlist_create(fmd_hdl_t *hdl, cmd_branch_t *branch) | |
143 { | |
144 int channel, d; | |
145 char dimm_unum[BUF_SIZE]; | |
146 cmd_dimm_t *dimm; | |
147 int dimm_count = 0; | |
148 int bn, cmp, br; | |
149 | |
150 if (is_t5440_unum(branch->branch_unum) == 0) { | |
151 for (channel = 0; channel < MAX_CHANNELS_ON_CHIP; channel++) { | |
152 for (d = 0; d < MAX_DIMMS_IN_CHANNEL; d++) { | |
153 (void) snprintf(dimm_unum, BUF_SIZE, | |
154 "%s/CH%1d/D%1d", branch->branch_unum, | |
155 channel, d); | |
156 dimm = branch_dimm_create(hdl, dimm_unum); | |
157 if (dimm != NULL) { | |
158 cmd_branch_add_dimm(hdl, branch, dimm); | |
159 dimm_count++; | |
160 } | |
161 } | |
162 } | |
163 } else { | |
164 (void) sscanf(branch->branch_unum, "%*6s%d%*4s%d%*3s%d", | |
165 &bn, &cmp, &br); | |
166 /* | |
167 * check dimm present for all possible branch dimms | |
168 * on cpuboard | |
169 */ | |
170 for (channel = 0; channel < BTK_MAX_CHANNEL; channel++) { | |
171 (void) snprintf(dimm_unum, BUF_SIZE, | |
172 "MB/CPU%1d/CMP%1d/BR%1d/CH%1d/D0", bn, cmp, | |
173 br, channel); | |
174 dimm = branch_dimm_create(hdl, dimm_unum); | |
175 if (dimm != NULL) { | |
176 cmd_branch_add_dimm(hdl, branch, dimm); | |
177 dimm_count++; | |
178 } | |
179 } | |
180 /* | |
181 * check dimm present for all possible branch dimms on | |
182 * memory-board. | |
183 */ | |
184 for (channel = 0; channel < BTK_MAX_CHANNEL; channel++) { | |
185 for (d = 1; d < MAX_DIMMS_IN_CHANNEL; d++) { | |
186 (void) snprintf(dimm_unum, BUF_SIZE, | |
187 "MB/MEM%1d/CMP%1d/BR%1d/CH%1d/D%1d", | |
188 bn, cmp, br, channel, d); | |
189 dimm = branch_dimm_create(hdl, dimm_unum); | |
190 if (dimm != NULL) { | |
191 cmd_branch_add_dimm(hdl, branch, dimm); | |
192 dimm_count++; | |
193 } | |
194 } | |
195 } | |
196 } | |
197 | |
198 return (dimm_count); | |
199 } | |
200 | |
201 | |
202 /* | |
203 * For t5440, the memory channel goes like this: | |
204 * VF -> cpuboard -> D0 -> motherboard -> memboard -> D[1..3] | |
205 * If there is a dimm on the memory board, the memory board, | |
206 * motherboard, cpuboard, and dimms are in the suspect list. | |
207 * If there is no dimm on the memory board, the cpu board and | |
208 * the dimms are in the suspect list | |
209 * memory board fault does not supported in this pharse of | |
210 * the project. | |
211 * The board certainty = total board certainty / number of | |
212 * the faulty boards in the suspect list. | |
213 */ | |
214 void | |
215 cmd_branch_create_fault(fmd_hdl_t *hdl, cmd_branch_t *branch, | |
216 const char *fltnm, nvlist_t *asru) | |
217 { | |
218 nvlist_t *flt, *mbnvl; | |
219 cmd_branch_memb_t *bm; | |
220 cmd_dimm_t *dimm; | |
221 int dimm_count = 0; | |
222 uint_t cert = 0; | |
223 uint_t board_cert = 0; | |
224 char *fruloc = NULL; | |
225 int count_board_fault = 1; | |
226 int memb_flag = 0; | |
227 | |
228 /* attach the dimms to the branch */ | |
229 dimm_count = branch_dimmlist_create(hdl, branch); | |
230 | |
231 if (is_dimm_on_memboard(branch)) { | |
232 mbnvl = init_mb(hdl); | |
233 if (mbnvl != NULL) | |
234 count_board_fault++; | |
235 memb_flag = 1; | |
236 } | |
237 | |
238 board_cert = CMD_BOARDS_CERT / count_board_fault; | |
239 | |
240 /* add the motherboard fault */ | |
241 if ((memb_flag) && (mbnvl != NULL)) { | |
242 fmd_hdl_debug(hdl, | |
243 "cmd_branch_create_fault: create motherboard fault"); | |
244 flt = cmd_boardfru_create_fault(hdl, mbnvl, fltnm, | |
245 board_cert, "MB"); | |
246 if (flt != NULL) | |
247 fmd_case_add_suspect(hdl, branch->branch_case.cc_cp, | |
248 flt); | |
249 nvlist_free(mbnvl); | |
250 } | |
251 | |
252 fruloc = cmd_getfru_loc(hdl, asru); | |
253 flt = cmd_boardfru_create_fault(hdl, asru, fltnm, board_cert, fruloc); | |
254 if (flt != NULL) | |
255 fmd_case_add_suspect(hdl, branch->branch_case.cc_cp, flt); | |
256 | |
257 if (dimm_count != 0) | |
258 cert = (100 - CMD_BOARDS_CERT) / dimm_count; | |
259 | |
260 /* create dimm faults */ | |
261 for (bm = cmd_list_next(&branch->branch_dimms); bm != NULL; | |
262 bm = cmd_list_next(bm)) { | |
263 dimm = bm->dimm; | |
264 if (dimm != NULL) { | |
265 dimm->dimm_flags |= CMD_MEM_F_FAULTING; | |
266 cmd_dimm_dirty(hdl, dimm); | |
267 flt = cmd_dimm_create_fault(hdl, dimm, fltnm, cert); | |
268 fmd_case_add_suspect(hdl, branch->branch_case.cc_cp, | |
269 flt); | |
270 } | |
271 } | |
272 if (fruloc != NULL) | |
273 fmd_hdl_strfree(hdl, fruloc); | |
274 } | |
275 | |
276 cmd_branch_t * | |
277 cmd_branch_create(fmd_hdl_t *hdl, nvlist_t *asru) | |
278 { | |
279 cmd_branch_t *branch; | |
280 const char *b_unum; | |
281 | |
282 if ((b_unum = cmd_fmri_get_unum(asru)) == NULL) { | |
283 CMD_STAT_BUMP(bad_mem_asru); | |
284 return (NULL); | |
285 } | |
286 | |
287 fmd_hdl_debug(hdl, "branch_create: creating new branch %s\n", b_unum); | |
288 CMD_STAT_BUMP(branch_creat); | |
289 | |
290 branch = fmd_hdl_zalloc(hdl, sizeof (cmd_branch_t), FMD_SLEEP); | |
291 branch->branch_nodetype = CMD_NT_BRANCH; | |
292 branch->branch_version = CMD_BRANCH_VERSION; | |
293 | |
294 cmd_bufname(branch->branch_bufname, sizeof (branch->branch_bufname), | |
295 "branch_%s", b_unum); | |
296 cmd_fmri_init(hdl, &branch->branch_asru, asru, "branch_asru_%s", | |
297 b_unum); | |
298 | |
299 (void) nvlist_lookup_string(branch->branch_asru_nvl, FM_FMRI_MEM_UNUM, | |
300 (char **)&branch->branch_unum); | |
301 | |
302 cmd_list_append(&cmd.cmd_branches, branch); | |
303 cmd_branch_dirty(hdl, branch); | |
304 | |
305 return (branch); | |
306 } | |
307 | |
308 cmd_branch_t * | |
309 cmd_branch_lookup_by_unum(fmd_hdl_t *hdl, const char *unum) | |
310 { | |
311 cmd_branch_t *branch; | |
312 | |
313 fmd_hdl_debug(hdl, "branch_lookup: dimm_unum %s", unum); | |
314 /* | |
315 * fbr/fbu unum dimm does not have a J number | |
316 */ | |
317 if (strstr(unum, "J") != NULL) | |
318 return (NULL); | |
319 | |
320 for (branch = cmd_list_next(&cmd.cmd_branches); branch != NULL; | |
321 branch = cmd_list_next(branch)) { | |
322 if (strcmp(branch->branch_unum, unum) == 0) | |
323 return (branch); | |
324 } | |
325 | |
326 fmd_hdl_debug(hdl, "branch_lookup_by_unum: no branch is found\n"); | |
327 return (NULL); | |
328 } | |
329 | |
330 cmd_branch_t * | |
331 cmd_branch_lookup(fmd_hdl_t *hdl, nvlist_t *asru) | |
332 { | |
333 cmd_branch_t *branch; | |
334 const char *unum; | |
335 | |
336 if ((unum = cmd_fmri_get_unum(asru)) == NULL) { | |
337 CMD_STAT_BUMP(bad_mem_asru); | |
338 return (NULL); | |
339 } | |
340 | |
341 for (branch = cmd_list_next(&cmd.cmd_branches); branch != NULL; | |
342 branch = cmd_list_next(branch)) { | |
343 if (strcmp(branch->branch_unum, unum) == 0) | |
344 return (branch); | |
345 } | |
346 | |
347 fmd_hdl_debug(hdl, "cmd_branch_lookup: discarding old \n"); | |
348 return (NULL); | |
349 } | |
350 | |
351 static cmd_branch_t * | |
352 branch_wrapv0(fmd_hdl_t *hdl, cmd_branch_pers_t *pers, size_t psz) | |
353 { | |
354 cmd_branch_t *branch; | |
355 | |
356 if (psz != sizeof (cmd_branch_pers_t)) { | |
357 fmd_hdl_abort(hdl, "size of state doesn't match size of " | |
358 "version 0 state (%u bytes).\n", | |
359 sizeof (cmd_branch_pers_t)); | |
360 } | |
361 | |
362 branch = fmd_hdl_zalloc(hdl, sizeof (cmd_branch_t), FMD_SLEEP); | |
363 bcopy(pers, branch, sizeof (cmd_branch_pers_t)); | |
364 fmd_hdl_free(hdl, pers, psz); | |
365 return (branch); | |
366 } | |
367 | |
368 void * | |
369 cmd_branch_restore(fmd_hdl_t *hdl, fmd_case_t *cp, cmd_case_ptr_t *ptr) | |
370 { | |
371 cmd_branch_t *branch; | |
372 size_t branchsz; | |
373 | |
374 | |
375 for (branch = cmd_list_next(&cmd.cmd_branches); branch != NULL; | |
376 branch = cmd_list_next(branch)) { | |
377 if (strcmp(branch->branch_bufname, ptr->ptr_name) == 0) | |
378 break; | |
379 } | |
380 | |
381 if (branch == NULL) { | |
382 fmd_hdl_debug(hdl, "restoring branch from %s\n", ptr->ptr_name); | |
383 | |
384 if ((branchsz = fmd_buf_size(hdl, NULL, ptr->ptr_name)) == 0) { | |
385 fmd_hdl_abort(hdl, "branch referenced by case %s does " | |
386 "not exist in saved state\n", | |
387 fmd_case_uuid(hdl, cp)); | |
388 } else if (branchsz > CMD_BRANCH_MAXSIZE || | |
389 branchsz < CMD_BRANCH_MINSIZE) { | |
390 fmd_hdl_abort(hdl, | |
391 "branch buffer referenced by case %s " | |
392 "is out of bounds (is %u bytes, max %u, min %u)\n", | |
393 fmd_case_uuid(hdl, cp), branchsz, | |
394 CMD_BRANCH_MAXSIZE, CMD_BRANCH_MINSIZE); | |
395 } | |
396 | |
397 if ((branch = cmd_buf_read(hdl, NULL, ptr->ptr_name, | |
398 branchsz)) == NULL) { | |
399 fmd_hdl_abort(hdl, "failed to read branch buf %s", | |
400 ptr->ptr_name); | |
401 } | |
402 | |
403 fmd_hdl_debug(hdl, "found %d in version field\n", | |
404 branch->branch_version); | |
405 | |
406 switch (branch->branch_version) { | |
407 case CMD_BRANCH_VERSION_0: | |
408 branch = branch_wrapv0(hdl, | |
409 (cmd_branch_pers_t *)branch, branchsz); | |
410 break; | |
411 default: | |
412 fmd_hdl_abort(hdl, "unknown version (found %d) " | |
413 "for branch state referenced by case %s.\n", | |
414 branch->branch_version, fmd_case_uuid(hdl, | |
415 cp)); | |
416 break; | |
417 } | |
418 | |
419 cmd_fmri_restore(hdl, &branch->branch_asru); | |
420 | |
421 if ((errno = nvlist_lookup_string(branch->branch_asru_nvl, | |
422 FM_FMRI_MEM_UNUM, (char **)&branch->branch_unum)) != 0) | |
423 fmd_hdl_abort(hdl, "failed to retrieve unum from asru"); | |
424 | |
425 | |
426 cmd_list_append(&cmd.cmd_branches, branch); | |
427 } | |
428 | |
429 switch (ptr->ptr_subtype) { | |
430 case CMD_PTR_BRANCH_CASE: | |
431 cmd_mem_case_restore(hdl, &branch->branch_case, cp, "branch", | |
432 branch->branch_unum); | |
433 break; | |
434 default: | |
435 fmd_hdl_abort(hdl, "invalid %s subtype %d\n", | |
436 ptr->ptr_name, ptr->ptr_subtype); | |
437 } | |
438 | |
439 return (branch); | |
440 } | |
441 | |
442 void | |
443 cmd_branch_dirty(fmd_hdl_t *hdl, cmd_branch_t *branch) | |
444 { | |
445 if (fmd_buf_size(hdl, NULL, branch->branch_bufname) != | |
446 sizeof (cmd_branch_pers_t)) | |
447 fmd_buf_destroy(hdl, NULL, branch->branch_bufname); | |
448 | |
449 /* No need to rewrite the FMRIs in the branch - they don't change */ | |
450 fmd_buf_write(hdl, NULL, branch->branch_bufname, &branch->branch_pers, | |
451 sizeof (cmd_branch_pers_t)); | |
452 } | |
453 | |
454 static void | |
455 branch_dimmlist_free(fmd_hdl_t *hdl, cmd_branch_t *branch) | |
456 { | |
457 cmd_branch_memb_t *bm; | |
458 | |
459 while ((bm = cmd_list_next(&branch->branch_dimms)) != NULL) { | |
460 cmd_list_delete(&branch->branch_dimms, bm); | |
461 fmd_hdl_free(hdl, bm, sizeof (cmd_branch_memb_t)); | |
462 } | |
463 } | |
464 | |
465 static void | |
466 branch_free(fmd_hdl_t *hdl, cmd_branch_t *branch, int destroy) | |
467 { | |
468 fmd_hdl_debug(hdl, "Free branch %s\n", branch->branch_unum); | |
469 if (branch->branch_case.cc_cp != NULL) { | |
470 if (destroy) { | |
471 if (branch->branch_case.cc_serdnm != NULL) { | |
472 fmd_serd_destroy(hdl, | |
473 branch->branch_case.cc_serdnm); | |
474 fmd_hdl_strfree(hdl, | |
475 branch->branch_case.cc_serdnm); | |
476 branch->branch_case.cc_serdnm = NULL; | |
477 } | |
478 } | |
479 cmd_case_fini(hdl, branch->branch_case.cc_cp, destroy); | |
480 } | |
481 | |
482 branch_dimmlist_free(hdl, branch); | |
483 cmd_fmri_fini(hdl, &branch->branch_asru, destroy); | |
484 | |
485 if (destroy) | |
486 fmd_buf_destroy(hdl, NULL, branch->branch_bufname); | |
487 cmd_list_delete(&cmd.cmd_branches, branch); | |
488 fmd_hdl_free(hdl, branch, sizeof (cmd_branch_t)); | |
489 } | |
490 | |
491 void | |
492 cmd_branch_destroy(fmd_hdl_t *hdl, cmd_branch_t *branch) | |
493 { | |
494 branch_free(hdl, branch, FMD_B_TRUE); | |
495 } | |
496 | |
497 int | |
498 branch_exist(fmd_hdl_t *hdl, cmd_branch_t *branch) | |
499 { | |
500 char dimm_unum[BUF_SIZE]; | |
501 int channel, d; | |
502 nvlist_t *fmri; | |
503 int bn, cmp, br; | |
504 | |
505 fmd_hdl_debug(hdl, "branch_exist"); | |
506 | |
507 if (is_t5440_unum(branch->branch_unum) == 0) { | |
508 for (channel = 0; channel < MAX_CHANNELS_ON_CHIP; channel++) { | |
509 for (d = 0; d < MAX_DIMMS_IN_CHANNEL; d++) { | |
510 (void) snprintf(dimm_unum, BUF_SIZE, | |
511 "%s/CH%1d/D%1d", branch->branch_unum, | |
512 channel, d); | |
513 fmri = cmd_mem_fmri_create(dimm_unum); | |
514 if (fmri != NULL && | |
515 (fmd_nvl_fmri_expand(hdl, fmri) == 0)) { | |
516 nvlist_free(fmri); | |
517 return (1); | |
518 } | |
519 nvlist_free(fmri); | |
520 } | |
521 } | |
522 } else { | |
523 (void) sscanf(branch->branch_unum, "%*6s%d%*4s%d%*3s%d", | |
524 &bn, &cmp, &br); | |
525 | |
526 for (channel = 0; channel < BTK_MAX_CHANNEL; channel++) { | |
527 (void) snprintf(dimm_unum, BUF_SIZE, | |
528 "MB/CPU%1d/CMP%1d/BR%1d/CH%1d/D0", bn, cmp, | |
529 br, channel); | |
530 fmri = cmd_mem_fmri_create(dimm_unum); | |
531 if (fmri != NULL && | |
532 (fmd_nvl_fmri_expand(hdl, fmri) == 0)) { | |
533 nvlist_free(fmri); | |
534 return (1); | |
535 } | |
536 nvlist_free(fmri); | |
537 } | |
538 | |
539 for (channel = 0; channel < BTK_MAX_CHANNEL; channel++) { | |
540 for (d = 1; d < MAX_DIMMS_IN_CHANNEL; d++) { | |
541 (void) snprintf(dimm_unum, BUF_SIZE, | |
542 "MB/MEM%1d/CMP%1d/BR%1d/CH%1d/D%1d", | |
543 bn, cmp, br, channel, d); | |
544 fmri = cmd_mem_fmri_create(dimm_unum); | |
545 if (fmri != NULL && | |
546 (fmd_nvl_fmri_expand(hdl, fmri) == 0)) { | |
547 nvlist_free(fmri); | |
548 return (1); | |
549 } | |
550 nvlist_free(fmri); | |
551 } | |
552 } | |
553 } | |
554 fmd_hdl_debug(hdl, "branch %s does not exist\n", branch->branch_unum); | |
555 return (0); | |
556 } | |
557 | |
558 /* | |
559 * If the case has been solved, don't need to check the dimmlist | |
560 * If the case has not been solved, the branch is valid if there is least one | |
561 * existing dimm in the branch | |
562 */ | |
563 void | |
564 cmd_branch_validate(fmd_hdl_t *hdl) | |
565 { | |
566 cmd_branch_t *branch, *next; | |
567 | |
568 fmd_hdl_debug(hdl, "cmd_branch_validate\n"); | |
569 | |
570 for (branch = cmd_list_next(&cmd.cmd_branches); branch != NULL; | |
571 branch = next) { | |
572 next = cmd_list_next(branch); | |
573 if (branch->branch_case.cc_cp != NULL && | |
574 fmd_case_solved(hdl, branch->branch_case.cc_cp)) | |
575 continue; | |
576 if (branch_exist(hdl, branch)) | |
577 continue; | |
578 cmd_branch_destroy(hdl, branch); | |
579 } | |
580 } | |
581 | |
582 void | |
583 cmd_branch_gc(fmd_hdl_t *hdl) | |
584 { | |
585 fmd_hdl_debug(hdl, "cmd_branch_gc\n"); | |
586 cmd_branch_validate(hdl); | |
587 } | |
588 | |
589 void | |
590 cmd_branch_fini(fmd_hdl_t *hdl) | |
591 { | |
592 cmd_branch_t *branch; | |
593 fmd_hdl_debug(hdl, "cmd_branch_fini\n"); | |
594 | |
595 while ((branch = cmd_list_next(&cmd.cmd_branches)) != NULL) | |
596 branch_free(hdl, branch, FMD_B_FALSE); | |
597 } |