cmd_hc_sun4v.c revision 3f1e69bef33050bee99ea1e9992af13fc467281f
e97130129ddee9f8432c6fff2dac3c6765280066tsien * CDDL HEADER START
e97130129ddee9f8432c6fff2dac3c6765280066tsien * The contents of this file are subject to the terms of the
e97130129ddee9f8432c6fff2dac3c6765280066tsien * Common Development and Distribution License (the "License").
e97130129ddee9f8432c6fff2dac3c6765280066tsien * You may not use this file except in compliance with the License.
e97130129ddee9f8432c6fff2dac3c6765280066tsien * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e97130129ddee9f8432c6fff2dac3c6765280066tsien * See the License for the specific language governing permissions
e97130129ddee9f8432c6fff2dac3c6765280066tsien * and limitations under the License.
e97130129ddee9f8432c6fff2dac3c6765280066tsien * When distributing Covered Code, include this CDDL HEADER in each
e97130129ddee9f8432c6fff2dac3c6765280066tsien * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e97130129ddee9f8432c6fff2dac3c6765280066tsien * If applicable, add the following below this CDDL HEADER, with the
e97130129ddee9f8432c6fff2dac3c6765280066tsien * fields enclosed by brackets "[]" replaced with your own identifying
e97130129ddee9f8432c6fff2dac3c6765280066tsien * information: Portions Copyright [yyyy] [name of copyright owner]
e97130129ddee9f8432c6fff2dac3c6765280066tsien * CDDL HEADER END
9f69d791af115871f09fc0bc61acef99da23150btd * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
e97130129ddee9f8432c6fff2dac3c6765280066tsien * Use is subject to license terms.
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien/* Using a global variable is safe because the DE is single threaded */
e97130129ddee9f8432c6fff2dac3c6765280066tsiencmd_fault_add_location(fmd_hdl_t *hdl, nvlist_t *flt, const char *locstr) {
9f69d791af115871f09fc0bc61acef99da23150btd char *t, *s;
e97130129ddee9f8432c6fff2dac3c6765280066tsien if (nvlist_lookup_string(flt, FM_FAULT_LOCATION, &t) == 0)
9f69d791af115871f09fc0bc61acef99da23150btd /* Replace occurrence of ": " with "/" to avoid confusing ILOM. */
9f69d791af115871f09fc0bc61acef99da23150btd if (s != NULL) {
9f69d791af115871f09fc0bc61acef99da23150btd /* Also, remove any J number from end of this string. */
9f69d791af115871f09fc0bc61acef99da23150btd *s = '\0';
e97130129ddee9f8432c6fff2dac3c6765280066tsien fmd_hdl_error(hdl, "unable to alloc location for fault\n");
13faa91230bde46da937bf33010b9accc5bdeb59sdtypedef struct tr_ent {
13faa91230bde46da937bf33010b9accc5bdeb59sd const char *nac_component;
13faa91230bde46da937bf33010b9accc5bdeb59sd const char *hc_component;
13faa91230bde46da937bf33010b9accc5bdeb59sdmap_name(const char *p) {
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < tr_tbl_n; i++) {
13faa91230bde46da937bf33010b9accc5bdeb59sd return (i);
13faa91230bde46da937bf33010b9accc5bdeb59sd return (-1);
13faa91230bde46da937bf33010b9accc5bdeb59sd * This version of breakup_components assumes that all component names which
13faa91230bde46da937bf33010b9accc5bdeb59sd * it sees are of the form: <nonnumeric piece><numeric piece>
13faa91230bde46da937bf33010b9accc5bdeb59sd * i.e. no embedded numerals in component name which have to be spelled out.
13faa91230bde46da937bf33010b9accc5bdeb59sdcmd_breakup_components(char *str, char *sep, nvlist_t **hc_nvl)
13faa91230bde46da937bf33010b9accc5bdeb59sd continue; /* skip names that don't map */
13faa91230bde46da937bf33010b9accc5bdeb59sd if (instlen == 0) {
13faa91230bde46da937bf33010b9accc5bdeb59sd nvlist_add_string(hc_nvl[i], FM_FMRI_HC_ID, instbuf) != 0)
13faa91230bde46da937bf33010b9accc5bdeb59sd return (-1);
13faa91230bde46da937bf33010b9accc5bdeb59sd return (1);
13faa91230bde46da937bf33010b9accc5bdeb59sd if (nvlist_lookup_string(asru, FM_FMRI_CPU_CPUFRU, &cpufru) == 0) {
13faa91230bde46da937bf33010b9accc5bdeb59sd fmd_hdl_debug(hdl, "cmd_getfru_loc: Default fruloc=empty string\n");
13faa91230bde46da937bf33010b9accc5bdeb59sdcmd_mkboard_fru(fmd_hdl_t *hdl, char *frustr, char *serialstr, char *partstr) {
13faa91230bde46da937bf33010b9accc5bdeb59sd int n, i, len;
13faa91230bde46da937bf33010b9accc5bdeb59sd fmd_hdl_debug(hdl, "cmd_mkboard_fru: nac=%s components=%d\n", nac, n);
13faa91230bde46da937bf33010b9accc5bdeb59sd hc_list = fmd_hdl_zalloc(hdl, sizeof (nvlist_t *)*n, FMD_SLEEP);
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < n; i++) {
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < n; i++) {
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < n; i++) {
fbd1c0dae6f4a2ccc2ce0527c7f19d3dd5ea90b8sd if (nvlist_add_uint8(fru, FM_VERSION, FM_HC_SCHEME_VERSION) != 0 ||
fbd1c0dae6f4a2ccc2ce0527c7f19d3dd5ea90b8sd nvlist_add_string(fru, FM_FMRI_SCHEME, FM_FMRI_SCHEME_HC) != 0 ||
13faa91230bde46da937bf33010b9accc5bdeb59sd nvlist_add_nvlist_array(fru, FM_FMRI_HC_LIST, hc_list, n) != 0) {
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < n; i++) {
13faa91230bde46da937bf33010b9accc5bdeb59sd for (i = 0; i < n; i++) {
fbd1c0dae6f4a2ccc2ce0527c7f19d3dd5ea90b8sd nvlist_add_string(fru, FM_FMRI_HC_SERIAL_ID, serialstr) != 0) ||
fbd1c0dae6f4a2ccc2ce0527c7f19d3dd5ea90b8sd nvlist_add_string(fru, FM_FMRI_HC_PART, partstr) != 0)) {
13faa91230bde46da937bf33010b9accc5bdeb59sdcmd_boardfru_create_fault(fmd_hdl_t *hdl, nvlist_t *asru, const char *fltnm,
13faa91230bde46da937bf33010b9accc5bdeb59sd if (nvlist_lookup_string(asru, FM_FMRI_HC_SERIAL_ID, &serialstr) != 0)
13faa91230bde46da937bf33010b9accc5bdeb59sd if (nvlist_lookup_string(asru, FM_FMRI_HC_PART, &partstr) != 0)
13faa91230bde46da937bf33010b9accc5bdeb59sd flt = cmd_nvl_create_fault(hdl, fltnm, cert, nvlfru, nvlfru, NULL);
13faa91230bde46da937bf33010b9accc5bdeb59sd/* find_mb -- find hardware platform motherboard within libtopo */
13faa91230bde46da937bf33010b9accc5bdeb59sd/* ARGSUSED */
13faa91230bde46da937bf33010b9accc5bdeb59sd if (nvlist_lookup_nvlist_array(rsrc, FM_FMRI_HC_LIST, &hcl, &n) < 0) {
13faa91230bde46da937bf33010b9accc5bdeb59sd if (nvlist_lookup_string(hcl[0], FM_FMRI_HC_NAME, &name) != 0) {
13faa91230bde46da937bf33010b9accc5bdeb59sd/* init_mb -- read hardware platform motherboard from libtopo */
13faa91230bde46da937bf33010b9accc5bdeb59sd if ((thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION)) == NULL)
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien/*ARGSUSED*/
70818f5837509317d1f5dac4d82d7b5a2d547c29tsienfind_dimm_sn_mem(topo_hdl_t *thp, tnode_t *node, void *arg)
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (TOPO_WALK_TERMINATE); /* if no space, give up */
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien/*ARGSUSED*/
70818f5837509317d1f5dac4d82d7b5a2d547c29tsienfind_dimm_sn_hc(topo_hdl_t *thp, tnode_t *node, void *arg)
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien if (nvlist_lookup_string(fru, FM_FMRI_HC_SERIAL_ID, &sn) != 0) {
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (TOPO_WALK_TERMINATE); /* if no space, give up */
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien/* cmd_find_dimm_by_sn -- find fmri by sn from libtopo */
70818f5837509317d1f5dac4d82d7b5a2d547c29tsiencmd_find_dimm_by_sn(fmd_hdl_t *hdl, char *schemename, char *sn)
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien if ((thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION)) == NULL)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yetypedef struct cpuid {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yefind_cpu_rsc_by_sn(topo_hdl_t *thp, tnode_t *node, void *arg)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (topo_node_resource(node, &rsc, &err) < 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye return (TOPO_WALK_NEXT); /* no rsc, try next */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_string(rsc, FM_FMRI_HC_SERIAL_ID, &sn) != 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_nvlist_array(rsc, FM_FMRI_HC_LIST, &hcl, &n) != 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((nvlist_lookup_string(hcl[n - 1], FM_FMRI_HC_NAME, &name) != 0) ||
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (nvlist_lookup_string(hcl[n - 1], FM_FMRI_HC_ID, &id) != 0)) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((strcmp(name, "cpu") != 0) || (strcmp(rscid->id, id) != 0)) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (void) nvlist_dup(rsc, &rsc_nvl, NV_UNIQUE_NAME);
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye return (TOPO_WALK_TERMINATE); /* if no space, give up */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yecmd_find_cpu_rsc_by_sn(fmd_hdl_t *hdl, cpuid_t *cpuid)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION)) == NULL)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((twp = topo_walk_init(thp, FM_FMRI_SCHEME_HC,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yeget_cpu_fault_resource(fmd_hdl_t *hdl, nvlist_t *asru)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_uint64(asru, FM_FMRI_CPU_SERIAL_ID, &serint) != 0 ||
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye nvlist_lookup_uint32(asru, FM_FMRI_CPU_ID, &cpu) != 0)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (void) snprintf(serial, sizeof (serial), "%llx", serint);
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (void) snprintf(strid, sizeof (strid), "%d", cpu);
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yefind_mem_rsc_hc(topo_hdl_t *thp, tnode_t *node, void *arg)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (topo_node_resource(node, &rsc, &err) < 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye return (TOPO_WALK_NEXT); /* no rsc, try next */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_string(rsc, FM_FMRI_HC_SERIAL_ID, &sn) != 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (void) nvlist_dup(rsc, &rsc_nvl, NV_UNIQUE_NAME);
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye return (TOPO_WALK_TERMINATE); /* if no space, give up */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yecmd_find_mem_rsc_by_sn(fmd_hdl_t *hdl, char *sn)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((thp = fmd_hdl_topo_hold(hdl, TOPO_VERSION)) == NULL)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((twp = topo_walk_init(thp, FM_FMRI_SCHEME_HC,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yeget_mem_fault_resource(fmd_hdl_t *hdl, nvlist_t *fru)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_string(fru, FM_FMRI_HC_SERIAL_ID, &sn) == 0)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye * T1 platform fru is in mem scheme
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_string_array(fru, FM_FMRI_MEM_SERIAL_ID,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye return (cmd_find_mem_rsc_by_sn(hdl, snarray[0]));
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_lookup_string(asru, FM_FMRI_MEM_UNUM, &unum) == 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Yecmd_nvl_create_fault(fmd_hdl_t *hdl, const char *class, uint8_t cert,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye nvlist_t *asru, nvlist_t *fru, nvlist_t *rsrc)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye (void) nvlist_add_nvlist(fru, FM_FMRI_AUTHORITY,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye cmd.cmd_auth); /* not an error if this fails */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye * For T1 platform fault.memory.bank and fault.memory.dimm,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye * do not issue the hc schmem for resource and fru
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (is_T1_platform(asru) && (strstr(class, ".page") == NULL)) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye fllist = fmd_nvl_create_fault(hdl, class, cert, asru,
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye * Need to append the phyaddr & offset into the
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye * hc-specific of the fault.memory.page resource
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if ((rsrc != NULL) && strstr(class, ".page") != NULL) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (nvlist_alloc(&hsp, NV_UNIQUE_NAME, 0) == 0) {
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye fllist = fmd_nvl_create_fault(hdl, class, cert, asru,