2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * CDDL HEADER START
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * The contents of this file are subject to the terms of the
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Common Development and Distribution License (the "License").
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * You may not use this file except in compliance with the License.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * See the License for the specific language governing permissions
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * and limitations under the License.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * When distributing Covered Code, include this CDDL HEADER in each
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * If applicable, add the following below this CDDL HEADER, with the
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * fields enclosed by brackets "[]" replaced with your own identifying
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * information: Portions Copyright [yyyy] [name of copyright owner]
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * CDDL HEADER END
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjstatic int ipmi_present(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjstatic int ipmi_enum(topo_mod_t *, tnode_t *, const char *,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjextern int ipmi_fru_label(topo_mod_t *mod, tnode_t *node,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjextern int ipmi_fru_fmri(topo_mod_t *mod, tnode_t *node,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj TOPO_METH_PRESENT_VERSION0, TOPO_STABILITY_INTERNAL, ipmi_present },
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston { TOPO_METH_SENSOR_FAILURE, TOPO_METH_SENSOR_FAILURE_DESC,
e5dcf7beb7c949f9234713d5818b581ec3825443Robert Johnston TOPO_METH_SENSOR_FAILURE_VERSION, TOPO_STABILITY_INTERNAL,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj { "ipmi", FM_FMRI_SCHEME_HC, TOPO_VERSION, &ipmi_ops };
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Determine if the entity is present.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj/*ARGSUSED*/
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_present(topo_mod_t *mod, tnode_t *tn, topo_version_t version,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Some broken IPMI implementations don't export correct
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * entities, so referring to an entity isn't sufficient.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * For these platforms, we allow the XML to specify a
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * single SDR record that represents the current present
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj "Failed to get present state of %s (%s)\n",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (-1);
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston if (topo_prop_get_string_array(tn, TOPO_PGROUP_IPMI,
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston TOPO_PROP_IPMI_ENTITY_REF, &names, &nelems, &err)
7793aa8b1cb26c7fc1397aa9db2364098fc25543Eric Schrock * Not all nodes have an entity_ref attribute.
7793aa8b1cb26c7fc1397aa9db2364098fc25543Eric Schrock * For these cases, return ENOTSUP so that we
7793aa8b1cb26c7fc1397aa9db2364098fc25543Eric Schrock * fall back to the default hc presence
7793aa8b1cb26c7fc1397aa9db2364098fc25543Eric Schrock * detection.
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston for (i = 0; i < nelems; i++)
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston if ((ep = ipmi_entity_lookup_sdr(ihp, names[i]))
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston for (i = 0; i < nelems; i++)
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston topo_mod_free(mod, names, (nelems * sizeof (char *)));
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston "Failed to get present state of %s=%d\n",
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston topo_node_name(tn), topo_node_instance(tn));
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (-1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj "ipmi_entity_present() failed: %s",
9af3851a3a831b4de34b42482c22351e14f33f16eschrock return (-1);
72c9c96770c90a8042add81e56bb8a2f9e4a29dcRobert Johnston "ipmi_entity_present(%d, %d) = %d\n", ep->ie_type,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (nvlist_add_uint32(nvl, TOPO_METH_PRESENT_RET, present) != 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * This determines if the entity has a FRU locator record set, in which case we
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * treat this as a FRU, even if it's part of an association.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj/*ARGSUSED*/
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_check_sdr(ipmi_handle_t *ihp, ipmi_entity_t *ep, const char *name,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Main entity enumerator. If we find a matching entity type, then instantiate
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * a topo node.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_check_entity(ipmi_handle_t *ihp, ipmi_entity_t *ep, void *data)
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * The purpose of power and cooling domains is to group psus and fans
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * together. Unfortunately, some broken IPMI implementations declare
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * domains that don't contain other elements. Since the end goal is to
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * only enumerate psus and fans, we'll just ignore such elements.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if ((fmri = topo_mod_hcfmri(mod, pnode, FM_HC_SCHEME_VERSION,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj edp->ed_name, edp->ed_instance, NULL, auth, NULL, NULL,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * We inherit our label from our parent, appending our label in the
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * process. This results in defaults labels of the form "FM 1 FAN 0"
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * by default when given a hierarchy.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj (void) snprintf(label, sizeof (label), "%s ", edp->ed_label);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj (void) snprintf(label + len, sizeof (label) - len, "%s %d",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Store IPMI entity details as properties on the node
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (topo_method_register(mod, tn, ipmi_methods) != 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_mod_dprintf(mod, "topo_method_register() failed: %s",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * If we are a child of a non-chassis node, and there isn't an explicit
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * FRU locator record, then propagate the parent's FRU. Otherwise, set
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * the FRU to be the same as the resource.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj (void) ipmi_entity_iter_sdr(ihp, ep, ipmi_check_sdr, edp);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_mod_dprintf(mod, "topo_node_resource() failed: %s",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_mod_dprintf(mod, "topo_node_fru_set() failed: %s",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * Iterate over children, once for recursive domains and once for
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * libtopo enumeration point. This simply iterates over entities looking for
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * the appropriate type.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj/*ARGSUSED*/
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robjipmi_enum(topo_mod_t *mod, tnode_t *rnode, const char *name,
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_instance_t min, topo_instance_t max, void *arg, void *unused)
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * If the node being passed in ISN'T the chassis node, then we're being
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * asked to post-process a statically defined node.
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (-1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (-1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if ((ret = ipmi_entity_iter(ihp, ipmi_check_entity, &data)) != 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * We don't return failure if IPMI enumeration fails. This may
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj * be due to the SP being unavailable or an otherwise transient
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj "failed to enumerate entities: %s",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (-1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (topo_method_register(mod, tn, ipmi_methods) != 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_mod_dprintf(mod, "ipmi_post_process() failed: %s",
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (1);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj/*ARGSUSED*/
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj if (topo_mod_register(mod, &ipmi_info, TOPO_VERSION) != 0) {
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj topo_mod_dprintf(mod, "IPMI enumerator initialized\n");
2eeaed14a5e2ed9bd811643ad5bffc3510ca0310robj return (0);