7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
a62bb709433c06fe335121c07822de4984bdcb84cindi * Common Development and Distribution License (the "License").
a62bb709433c06fe335121c07822de4984bdcb84cindi * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (mp = topo_list_next(&node->tn_methods); mp != NULL;
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * Simple API to determine if the specified node supports a given topo method
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * (specified by the method name and version). Returns true if supported, false
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj * otherwise.
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robjtopo_method_supported(tnode_t *node, const char *name, topo_version_t vers)
825ba0f20a74fd9c5d0d1ce2c195da2cc88a7f77robj for (mp = topo_list_next(&node->tn_methods); mp != NULL;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiset_methregister_error(topo_mod_t *mod, tnode_t *node, topo_imethod_t *mp,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "method registration failed for %s: %s\n",
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_method_register(topo_mod_t *mod, tnode_t *node, const topo_method_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Initialize module methods
c40d7343efa60b18ad1ceb316eb337caeea79046cindi if (topo_method_lookup(node, meth->tm_name) != NULL) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((imp->tim_name = topo_mod_strdup(mod, meth->tm_name))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((imp->tim_desc = topo_mod_strdup(mod, meth->tm_desc))
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "registered module %s method "
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_method_unregister(topo_mod_t *mod, tnode_t *node, const char *name)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (mp = topo_list_next(&node->tn_methods); mp != NULL;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditopo_method_unregister_all(topo_mod_t *mod, tnode_t *node)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi while ((mp = topo_list_next(&node->tn_methods)) != NULL) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_version_t version, nvlist_t *in, nvlist_t **out, int *err)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi for (mp = topo_list_next(&node->tn_methods); mp != NULL;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((rc = mp->tim_func(mp->tim_mod, node, version, in, out))
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
c40d7343efa60b18ad1ceb316eb337caeea79046cindi topo_version_t version, nvlist_t *in, nvlist_t **out, int *err)
c40d7343efa60b18ad1ceb316eb337caeea79046cindi rc = topo_method_call(node, method, version, in, out, err);
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnstontopo_sensor_failed(int32_t type, uint32_t state, struct sensor_errinfo *seinfo)
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Unless the sensor explicitely says otherwise, all failures are
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * non-recoverable, hard failures, coming from an unknown source.
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston seinfo->se_src = TOPO_SENSOR_ERRSRC_UNKNOWN;
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (state & (TOPO_SENSOR_STATE_THRESH_LOWER_NONREC |
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (state & (TOPO_SENSOR_STATE_THRESH_LOWER_CRIT |
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (state & TOPO_SENSOR_STATE_POWER_SUPPLY_PREDFAIL) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston seinfo->se_src = TOPO_SENSOR_ERRSRC_INTERNAL;
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (state & TOPO_SENSOR_STATE_POWER_SUPPLY_FAILURE) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston seinfo->se_src = TOPO_SENSOR_ERRSRC_INTERNAL;
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston (TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_LOST |
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE |
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston TOPO_SENSOR_STATE_POWER_SUPPLY_INPUT_RANGE_PRES)) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston seinfo->se_src = TOPO_SENSOR_ERRSRC_EXTERNAL;
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (state & TOPO_SENSOR_STATE_GENERIC_FAIL_NONRECOV) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (state & TOPO_SENSOR_STATE_GENERIC_FAIL_CRITICAL) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (state & TOPO_SENSOR_STATE_GENERIC_OK_DEASSERTED)
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (state & TOPO_SENSOR_STATE_GENERIC_PREDFAIL_ASSERTED) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Determine whether there are any sensors indicating failure. This function
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * is used internally to determine whether a given component is usable, as well
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * by external monitoring software that wants additional information such as
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * which sensors indicated failure. The return value is an nvlist of nvlists
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * indexed by sensor name, each entry with the following contents:
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * type, state, units, reading
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Identical to sensor node.
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * Boolean value that is set to indicate that the error is
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * non-recoverable (the unit is out of service). The default is
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston * critical failure, which indicates a fault but the unit is still
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnstontopo_method_sensor_failure(topo_mod_t *mod, tnode_t *node,
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston topo_version_t version, nvlist_t *in, nvlist_t **out)
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (strcmp(name, PSU) != 0 && strcmp(name, FAN) != 0)
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston return (topo_mod_seterrno(mod, ETOPO_METHOD_NOTSUP));
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (topo_node_facility(mod->tm_hdl, node, TOPO_FAC_TYPE_SENSOR,
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston return (topo_mod_seterrno(mod, ETOPO_METHOD_NOTSUP));
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (topo_mod_nvalloc(mod, &nvl, NV_UNIQUE_NAME) != 0)
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston for (fp = topo_list_next(&faclist.tf_list); fp != NULL;
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (topo_prop_getpgrp(fp->tf_node, TOPO_PGROUP_FACILITY,
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (strcmp(nvpair_name(elem), TOPO_PROP_VAL) != 0 ||
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (strcmp(propname, TOPO_FACILITY_TYPE) == 0) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (strcmp(propname, TOPO_SENSOR_STATE) == 0) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (strcmp(propname, TOPO_SENSOR_UNITS) == 0) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston } else if (strcmp(propname, TOPO_SENSOR_READING) == 0) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (topo_sensor_failed(type, state, &seinfo)) {
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston if (topo_mod_nvalloc(mod, &tmp, NV_UNIQUE_NAME) != 0 ||
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston nvlist_add_nvlist(nvl, topo_node_name(fp->tf_node),
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston while ((fp = topo_list_next(&faclist.tf_list)) != NULL) {