2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Facility node support for SES enclosures. We support the following facility 2N/A * nodes, based on the node type: 2N/A * sensor=<name> (temperature) 2N/A * sensor=<name> (voltage) 2N/A * sensor=<name> (current) 2N/A * Most of these are handled by a single method that supports getting and 2N/A * setting boolean properties on the node. The fan speed sensor requires a 2N/A * special handler, while the analog enclosure sensors all have similar 2N/A * behavior and can be grouped together using a common method. 2N/A * Get or set an indicator. This method is invoked with arguments indicating 2N/A * the property to query to retrieve the value. Some elements (enclosures and 2N/A * devices) support a request property that is distinct from an array-detected 2N/A * property. Either of these conditions will result in the indicator being 2N/A * lit, so we have to check both properties. 2N/A * Read the given sensor value. This just looks up the value in the node 2N/A * properties, and multiplies by a fixed value (determined when the method is 2N/A "invalid arguments to 'reading' method\n");
2N/A * Returns the current sensor state. This can be invoked for one of two 2N/A * different types of sensors: threshold or discrete sensors. For discrete 2N/A * sensors, we expect a name of a boolean property and indicate 2N/A "invalid arguments to 'state' method\n");
2N/A /* discrete (fault) sensor */ 2N/A /* threshold sensor */ 2N/A * Read the status of a PSU. This is such a specialized operation that it has 2N/A * its own method instead of trying to piggyback on ses_sensor_state(). We 2N/A * use the following mapping to get to the standard topo power supply states: 2N/A * acfail -> INPUT_LOST 2N/A * dcfail -> INPUT_LOST 2N/A * undervoltage -> INPUT_RANGE 2N/A * overvoltage -> INPUT_RANGE_PRES 2N/A * overcurrent -> INPUT_RANGE_PRES 2N/A * overtemp -> (none) 2N/A * If we ever have a need for reading overtemp, we can expand the topo 2N/A * representation for power supplies, but at the moment this seems unnecessary. 2N/A * Create a facility node, either a sensor or an indicator. 2N/A * We need the node-id property for each facility node. 2N/A "failed to create property %s: %s\n",
2N/A * Add an indicator. This can be represented by a single property, or by the 2N/A * union of two elements when SES is capable of distinguishing between 2N/A * requested failure and detected failure. 2N/A /* create facility node and add methods */ 2N/A /* set standard properties */ 2N/A "failed to set facility node properties: %s\n",
2N/A /* 'mode' property */ 2N/A /* create facility node and add methods */ 2N/A /* set standard properties */ 2N/A "failed to set facility node properties: %s\n",
2N/A * Add an analog (threshold) sensor to the enclosure. This is used for fan 2N/A * speed, voltage, current, and temperature sensors. 2N/A "failed to set facility node properties: %s\n",
2N/A /* 'reading' property */ 2N/A /* 'state' property */ 2N/A * Add a discrete sensor for simple boolean values. This is used to indicate 2N/A * externally-detected failures for fans, bays, and enclosures. 2N/A /* 'state' property */ 2N/A /* create facility node and add methods */ 2N/A /* 'state' property */ 2N/A * Every element supports an 'ident' indicator. All elements also 2N/A * support a 'fail' indicator, but the properties used to represent 2N/A * this condition differs between elements. 2N/A * Disks support an additional 'ok2rm' indicator, as well as 2N/A * externally detected 'fail' sensor. 2N/A * Add the fan speed sensor, and a discrete sensor for 2N/A * detecting failure. 2N/A * For power supplies, we have a number of different sensors: 2N/A * acfail, dcfail, overtemp, undervoltate, overvoltage, 2N/A * and overcurrent. Rather than expose these all as individual 2N/A * sensors, we lump them together into a 'status' sensor of 2N/A * type TOPO_SENSOR_TYPE_POWER_SUPPLY and export the 2N/A * appropriate status flags as defined by the libtopo standard. 2N/A * Add enclosure-wide sensors (temperature, voltage, and current) beneath the 2N/A * The only tricky part here is getting the name for the 2N/A * sensor, where we follow the algorithm of the standard 2N/A * 'ident' and 'fail' LEDs, and 'fault' sensor. 2N/A * Environmental sensors (temperature, voltage, current). We have no 2N/A * way of knowing if any of these sensors correspond to a particular 2N/A * element, so we just attach them to the enclosure as a whole. In the 2N/A * future, some vendor-specific libses plugin knowledge could let us 2N/A * make this correlation clearer.