cmd_dimm_t * cmd_dimm_lookup(fmd_hdl_t *hdl, nvlist_t *asru) { cmd_dimm_t *dimm; const char *unum; if ((unum = cmd_fmri_get_unum(asru)) == NULL) { CMD_STAT_BUMP(bad_mem_asru); return (NULL); } dimm = dimm_lookup_by_unum(unum); if (dimm != NULL && !fmd_nvl_fmri_present(hdl, dimm->dimm_asru_nvl)) { /* * The DIMM doesn't exist anymore, so we need to delete the * state structure, which is now out of date. The containing * bank (if any) is also out of date, so blow it away too. */ fmd_hdl_debug(hdl, "dimm_lookup: discarding old dimm\n"); if (dimm->dimm_bank != NULL) cmd_bank_destroy(hdl, dimm->dimm_bank); cmd_dimm_destroy(hdl, dimm); return (NULL); } return (dimm); }
cmd_branch_t * cmd_branch_create(fmd_hdl_t *hdl, nvlist_t *asru) { cmd_branch_t *branch; const char *b_unum; if ((b_unum = cmd_fmri_get_unum(asru)) == NULL) { CMD_STAT_BUMP(bad_mem_asru); return (NULL); } fmd_hdl_debug(hdl, "branch_create: creating new branch %s\n", b_unum); CMD_STAT_BUMP(branch_creat); branch = fmd_hdl_zalloc(hdl, sizeof (cmd_branch_t), FMD_SLEEP); branch->branch_nodetype = CMD_NT_BRANCH; branch->branch_version = CMD_BRANCH_VERSION; cmd_bufname(branch->branch_bufname, sizeof (branch->branch_bufname), "branch_%s", b_unum); cmd_fmri_init(hdl, &branch->branch_asru, asru, "branch_asru_%s", b_unum); (void) nvlist_lookup_string(branch->branch_asru_nvl, FM_FMRI_MEM_UNUM, (char **)&branch->branch_unum); cmd_list_append(&cmd.cmd_branches, branch); cmd_branch_dirty(hdl, branch); return (branch); }
cmd_branch_t * cmd_branch_lookup(fmd_hdl_t *hdl, nvlist_t *asru) { cmd_branch_t *branch; const char *unum; if ((unum = cmd_fmri_get_unum(asru)) == NULL) { CMD_STAT_BUMP(bad_mem_asru); return (NULL); } for (branch = cmd_list_next(&cmd.cmd_branches); branch != NULL; branch = cmd_list_next(branch)) { if (strcmp(branch->branch_unum, unum) == 0) return (branch); } fmd_hdl_debug(hdl, "cmd_branch_lookup: discarding old \n"); return (NULL); }
cmd_dimm_t * cmd_dimm_create(fmd_hdl_t *hdl, nvlist_t *asru) { cmd_dimm_t *dimm; const char *unum; nvlist_t *fmri; size_t nserids = 0; char **serids = NULL; if (!fmd_nvl_fmri_present(hdl, asru)) { fmd_hdl_debug(hdl, "dimm_lookup: discarding old ereport\n"); return (NULL); } if ((unum = cmd_fmri_get_unum(asru)) == NULL) { CMD_STAT_BUMP(bad_mem_asru); return (NULL); } #ifdef sun4v if (nvlist_lookup_string_array(asru, FM_FMRI_HC_SERIAL_ID, &serids, &nserids) != 0) { fmd_hdl_debug(hdl, "sun4v mem: FMRI does not" " have serial_ids\n"); CMD_STAT_BUMP(bad_mem_asru); return (NULL); } #endif fmri = cmd_mem_fmri_create(unum, serids, nserids); if (fmd_nvl_fmri_expand(hdl, fmri) < 0) { CMD_STAT_BUMP(bad_mem_asru); nvlist_free(fmri); return (NULL); } fmd_hdl_debug(hdl, "dimm_create: creating new DIMM %s\n", unum); CMD_STAT_BUMP(dimm_creat); dimm = fmd_hdl_zalloc(hdl, sizeof (cmd_dimm_t), FMD_SLEEP); dimm->dimm_nodetype = CMD_NT_DIMM; dimm->dimm_version = CMD_DIMM_VERSION; cmd_bufname(dimm->dimm_bufname, sizeof (dimm->dimm_bufname), "dimm_%s", unum); cmd_fmri_init(hdl, &dimm->dimm_asru, fmri, "dimm_asru_%s", unum); nvlist_free(fmri); (void) nvlist_lookup_string(dimm->dimm_asru_nvl, FM_FMRI_MEM_UNUM, (char **)&dimm->dimm_unum); dimm_attach_to_bank(hdl, dimm); cmd_mem_retirestat_create(hdl, &dimm->dimm_retstat, dimm->dimm_unum, 0, CMD_DIMM_STAT_PREFIX); cmd_list_append(&cmd.cmd_dimms, dimm); cmd_dimm_dirty(hdl, dimm); return (dimm); }