static int dl_fault_walk_inner(topo_hdl_t *thp, tnode_t *node, void *arg) { dl_fault_walk_inner_t *fwi = arg; char *facname = NULL, *factype = NULL; int err; /* * We're only interested in BAY children that are valid Facility Nodes. */ if (topo_node_flags(node) != TOPO_NODE_FACILITY || get_facility_props(thp, node, &facname, &factype) != 0) { goto out; } if (strcmp(fwi->fwi_name, facname) != 0) goto out; /* * Attempt to set the LED mode appropriately. If this fails, give up * and move on. */ (void) topo_prop_set_uint32(node, TOPO_PGROUP_FACILITY, TOPO_LED_MODE, TOPO_PROP_MUTABLE, fwi->fwi_mode, &err); out: topo_hdl_strfree(thp, facname); topo_hdl_strfree(thp, factype); return (TOPO_WALK_NEXT); }
/*ARGSUSED*/ static int fac_prov_mptsas_enum(topo_mod_t *mod, tnode_t *rnode, const char *name, topo_instance_t min, topo_instance_t max, void *arg, void *unused) { if (topo_node_flags(rnode) == TOPO_NODE_FACILITY) { if (topo_method_register(mod, rnode, mptsas_fac_methods) != 0) { topo_mod_dprintf(mod, "%s: topo_method_register() " "failed: %s", __func__, topo_mod_errmsg(mod)); return (-1); } return (0); } topo_mod_dprintf(mod, "%s: unexpected node flags %x", __func__, topo_node_flags(rnode)); return (-1); }
static void print_prop_nameval(topo_hdl_t *thp, tnode_t *node, nvlist_t *nvl) { int err; topo_type_t type; char *tstr, *propn, buf[48], *factype; nvpair_t *pv_nvp; int i; uint_t nelem; if ((pv_nvp = nvlist_next_nvpair(nvl, NULL)) == NULL) return; /* Print property name */ if ((pv_nvp = nvlist_next_nvpair(nvl, NULL)) == NULL || nvpair_name(pv_nvp) == NULL || strcmp(TOPO_PROP_VAL_NAME, nvpair_name(pv_nvp)) != 0) { (void) fprintf(stderr, "%s: malformed property name\n", g_pname); return; } else { (void) nvpair_value_string(pv_nvp, &propn); } if ((pv_nvp = nvlist_next_nvpair(nvl, pv_nvp)) == NULL || nvpair_name(pv_nvp) == NULL || strcmp(nvpair_name(pv_nvp), TOPO_PROP_VAL_TYPE) != 0 || nvpair_type(pv_nvp) != DATA_TYPE_UINT32) { (void) fprintf(stderr, "%s: malformed property type for %s\n", g_pname, propn); return; } else { (void) nvpair_value_uint32(pv_nvp, (uint32_t *)&type); } switch (type) { case TOPO_TYPE_BOOLEAN: tstr = "boolean"; break; case TOPO_TYPE_INT32: tstr = "int32"; break; case TOPO_TYPE_UINT32: tstr = "uint32"; break; case TOPO_TYPE_INT64: tstr = "int64"; break; case TOPO_TYPE_UINT64: tstr = "uint64"; break; case TOPO_TYPE_DOUBLE: tstr = "double"; break; case TOPO_TYPE_STRING: tstr = "string"; break; case TOPO_TYPE_FMRI: tstr = "fmri"; break; case TOPO_TYPE_INT32_ARRAY: tstr = "int32[]"; break; case TOPO_TYPE_UINT32_ARRAY: tstr = "uint32[]"; break; case TOPO_TYPE_INT64_ARRAY: tstr = "int64[]"; break; case TOPO_TYPE_UINT64_ARRAY: tstr = "uint64[]"; break; case TOPO_TYPE_STRING_ARRAY: tstr = "string[]"; break; case TOPO_TYPE_FMRI_ARRAY: tstr = "fmri[]"; break; default: tstr = "unknown type"; } (void) printf(" %-17s %-8s ", propn, tstr); /* * Get property value */ if (nvpair_name(pv_nvp) == NULL || (pv_nvp = nvlist_next_nvpair(nvl, pv_nvp)) == NULL) { (void) fprintf(stderr, "%s: malformed property value\n", g_pname); return; } switch (nvpair_type(pv_nvp)) { case DATA_TYPE_INT32: { int32_t val; (void) nvpair_value_int32(pv_nvp, &val); (void) printf(" %d", val); break; } case DATA_TYPE_UINT32: { uint32_t val, type; char val_str[49]; nvlist_t *fac, *rsrc = NULL; (void) nvpair_value_uint32(pv_nvp, &val); if (node == NULL || topo_node_flags(node) != TOPO_NODE_FACILITY) goto uint32_def; if (topo_node_resource(node, &rsrc, &err) != 0) goto uint32_def; if (nvlist_lookup_nvlist(rsrc, "facility", &fac) != 0) goto uint32_def; if (nvlist_lookup_string(fac, FM_FMRI_FACILITY_TYPE, &factype) != 0) goto uint32_def; nvlist_free(rsrc); rsrc = NULL; /* * Special case code to do friendlier printing of * facility node properties */ if ((strcmp(propn, TOPO_FACILITY_TYPE) == 0) && (strcmp(factype, TOPO_FAC_TYPE_SENSOR) == 0)) { topo_sensor_type_name(val, val_str, 48); (void) printf(" 0x%x (%s)", val, val_str); break; } else if ((strcmp(propn, TOPO_FACILITY_TYPE) == 0) && (strcmp(factype, TOPO_FAC_TYPE_INDICATOR) == 0)) { topo_led_type_name(val, val_str, 48); (void) printf(" 0x%x (%s)", val, val_str); break; } else if (strcmp(propn, TOPO_SENSOR_UNITS) == 0) { topo_sensor_units_name(val, val_str, 48); (void) printf(" 0x%x (%s)", val, val_str); break; } else if (strcmp(propn, TOPO_LED_MODE) == 0) { topo_led_state_name(val, val_str, 48); (void) printf(" 0x%x (%s)", val, val_str); break; } else if ((strcmp(propn, TOPO_SENSOR_STATE) == 0) && (strcmp(factype, TOPO_FAC_TYPE_SENSOR) == 0)) { if (topo_prop_get_uint32(node, TOPO_PGROUP_FACILITY, TOPO_FACILITY_TYPE, &type, &err) != 0) { goto uint32_def; } topo_sensor_state_name(type, val, val_str, 48); (void) printf(" 0x%x (%s)", val, val_str); break; } uint32_def: (void) printf(" 0x%x", val); if (rsrc != NULL) nvlist_free(rsrc); break; } case DATA_TYPE_INT64: { int64_t val; (void) nvpair_value_int64(pv_nvp, &val); (void) printf(" %lld", (longlong_t)val); break; } case DATA_TYPE_UINT64: { uint64_t val; (void) nvpair_value_uint64(pv_nvp, &val); (void) printf(" 0x%llx", (u_longlong_t)val); break; } case DATA_TYPE_DOUBLE: { double val; (void) nvpair_value_double(pv_nvp, &val); (void) printf(" %lf", (double)val); break; } case DATA_TYPE_STRING: { char *val; (void) nvpair_value_string(pv_nvp, &val); if (!opt_V && strlen(val) > 48) { (void) snprintf(buf, 48, "%s...", val); (void) printf(" %s", buf); } else { (void) printf(" %s", val); } break; } case DATA_TYPE_NVLIST: { nvlist_t *val; char *fmri; (void) nvpair_value_nvlist(pv_nvp, &val); if (topo_fmri_nvl2str(thp, val, &fmri, &err) != 0) { if (opt_V) nvlist_print(stdout, nvl); break; } if (!opt_V && strlen(fmri) > 48) { (void) snprintf(buf, 48, "%s", fmri); (void) snprintf(&buf[45], 4, "%s", DOTS); (void) printf(" %s", buf); } else { (void) printf(" %s", fmri); } topo_hdl_strfree(thp, fmri); break; } case DATA_TYPE_INT32_ARRAY: { int32_t *val; (void) nvpair_value_int32_array(pv_nvp, &val, &nelem); (void) printf(" [ "); for (i = 0; i < nelem; i++) (void) printf("%d ", val[i]); (void) printf("]"); break; } case DATA_TYPE_UINT32_ARRAY: { uint32_t *val; (void) nvpair_value_uint32_array(pv_nvp, &val, &nelem); (void) printf(" [ "); for (i = 0; i < nelem; i++) (void) printf("%u ", val[i]); (void) printf("]"); break; } case DATA_TYPE_INT64_ARRAY: { int64_t *val; (void) nvpair_value_int64_array(pv_nvp, &val, &nelem); (void) printf(" [ "); for (i = 0; i < nelem; i++) (void) printf("%lld ", val[i]); (void) printf("]"); break; } case DATA_TYPE_UINT64_ARRAY: { uint64_t *val; (void) nvpair_value_uint64_array(pv_nvp, &val, &nelem); (void) printf(" [ "); for (i = 0; i < nelem; i++) (void) printf("%llu ", val[i]); (void) printf("]"); break; } case DATA_TYPE_STRING_ARRAY: { char **val; (void) nvpair_value_string_array(pv_nvp, &val, &nelem); (void) printf(" [ "); for (i = 0; i < nelem; i++) (void) printf("\"%s\" ", val[i]); (void) printf("]"); break; } default: (void) fprintf(stderr, " unknown data type (%d)", nvpair_type(pv_nvp)); break; } (void) printf("\n"); }