psvcpolicy.c revision 8a88157cd7245729dea5d91a5181bb05a80164a8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Daktari platform platform specific environment monitoring policies
*/
#include <poll.h>
#include <syslog.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <strings.h>
#include <libintl.h>
#include <config_admin.h>
#include <libdevice.h>
#include <picl.h>
#include <picltree.h>
#include <psvc_objects.h>
#include <sys/hpc3130_events.h>
#include <assert.h>
#include <limits.h>
#include <sys/systeminfo.h>
/*LINTLIBRARY*/
/* resides in libcfgadm */
const char *, struct cfga_confirm *, struct cfga_msg *, char **,
/* Local Routine */
static void shutdown_routine(void);
#ifdef DEBUG
static int dak_policy_debug = 0;
#else
#endif
#define GEN_FAULT_LED "FSP_GEN_FAULT_LED"
#define EMPTY_STRING "EMPTY"
#define SET_LED_FAILED_MSG \
gettext("Failed to set LED state, id = %s, errno = %d\n")
#define GET_PRESENCE_FAILED_MSG \
gettext("Failed to get presence attribute, id = %s, errno = %d\n")
#define GET_SENSOR_FAILED_MSG \
gettext("Failed to get sensor value, id = %s, errno = %d\n")
#define ADD_PS_MSG \
gettext("WARNING: Only 1 Power Supply in system. ADD a 2nd Power Supply.\n")
#define REMOVE_LOAD_MSG \
gettext("WARNING: Power Supply at 95%% current. Remove some load.\n")
#define PS_OVER_CURRENT_MSG \
gettext("WARNING: Power Supply overcurrent detected\n")
#define PS_UNDER_CURRENT_MSG \
gettext("WARNING: PS%d Undercurrent on one or more DC lines\n")
#define DEVICE_HANDLE_FAIL_MSG \
gettext("Failed to get device handle for %s, errno = %d\n")
#define DEVTREE_NODE_CREATE_FAILED \
gettext("psvc PICL plugin: Failed to create node for %s, errno = %d")
#define DEVTREE_NODE_DELETE_FAILED \
gettext("psvc PICL plugin: Failed to delete node for %s, errno = %d")
#define SET_FANSPEED_FAILED_MSG \
gettext("Failed to set fan speed, id = %s, errno = %d\n")
#define NO_FRU_INFO_MSG \
gettext("No FRU Information for %s using default module card\n")
#define DAKTARI_MAX_PS 3
#define DAK_MAX_PS_I_SENSORS 4
#define DAK_MAX_DISKS 12
#define DAK_MAX_CPU_MOD 4
#define DAK_MAX_FAULT_SENSORS 3
#define DAK_MAX_FANS 10
static int co_ps = 0;
static char *shutdown_string = "shutdown -y -g 60 -i 5 \"OVERTEMP condition\"";
typedef struct i2c_hp {
char name[256];
char compatible[256];
} i2c_hp_t;
typedef struct seg_desc {
} seg_desc_t;
static int32_t threshold_names[] = {
PSVC_NOT_USED, /* LOW MODE which is not used */
};
/*
* The I2C bus is noisy, and the state may be incorrectly reported as
* having changed. When the state changes, we attempt to confirm by
* retrying. If any retries indicate that the state has not changed, we
* assume the state change(s) were incorrect and the state has not changed.
* The following variables are used to store the tuneable values read in
* from the optional i2cparam.conf file for this shared object library.
*/
static int n_retry_pshp_status = PSVC_NUM_OF_RETRIES;
static int retry_sleep_pshp_status = 1;
static int n_read_overcurrent = PSVC_THRESHOLD_COUNTER;
static int n_read_undercurrent = PSVC_THRESHOLD_COUNTER;
static int n_retry_devicefail = PSVC_NUM_OF_RETRIES;
static int retry_sleep_devicefail = 1;
static int n_read_fanfault = PSVC_THRESHOLD_COUNTER;
static int n_retry_pshp = PSVC_NUM_OF_RETRIES;
static int retry_sleep_pshp = 1;
static int n_retry_diskfault = PSVC_NUM_OF_RETRIES;
static int retry_sleep_diskfault = 1;
static int n_retry_temp_shutdown = PSVC_NUM_OF_RETRIES;
static int retry_sleep_temp_shutdown = 1;
typedef struct {
int *pvar;
char *texttag;
static i2c_noise_param_t i2cparams[] = {
&n_retry_pshp_status, "n_retry_pshp_status",
&retry_sleep_pshp_status, "retry_sleep_pshp_status",
&n_read_overcurrent, "n_read_overcurrent",
&n_read_undercurrent, "n_read_undercurrent",
&n_retry_devicefail, "n_retry_devicefail",
&retry_sleep_devicefail, "retry_sleep_devicefail",
&n_read_fanfault, "n_read_fanfault",
&n_retry_pshp, "n_retry_pshp",
&retry_sleep_pshp, "retry_sleep_pshp",
&n_retry_diskfault, "n_retry_diskfault",
&retry_sleep_diskfault, "retry_sleep_diskfault",
&n_retry_temp_shutdown, "n_retry_temp_shutdown",
&retry_sleep_temp_shutdown, "retry_sleep_temp_shutdown",
};
#pragma init(i2cparams_load)
static void
int usingDefaults)
{
char s[128];
if (!usingDefaults) {
(void) snprintf(s, sizeof (s),
"# Values from /usr/platform/%s/lib/i2cparam.conf\n",
platform);
} else {
/* no file - we're using the defaults */
(void) snprintf(s, sizeof (s),
"# No /usr/platform/%s/lib/i2cparam.conf file, using defaults\n",
platform);
}
p = pi2cparams;
*(p->pvar));
if (!usingDefaults)
p++;
}
}
static void
i2cparams_load(void)
{
char platform[64];
char s[128];
char var[128];
int val;
return;
}
/* read thru the i2cparam.conf file and set variables */
if (s[0] == '#') /* skip comment lines */
continue;
/* try to find a string match and get the value */
continue;
if (val < 1)
p = &(i2cparams[0]);
0) {
break;
}
p++;
}
}
}
/* output the values of the parameters */
}
{
int IO_offset = 0xd;
return (err);
}
{
int IO_offset = 0x8;
return (err);
}
{
int IO_offset = 0x7;
return (err);
}
/*
* used to determine if a change of state occured. valid when states
* are strings.
*/
static int8_t
{
int change = 0;
change = 1;
change = 1;
return (change);
}
/*
* Update thresholds tries to read the temperature thresholds from the FRU
* SEEproms and then updates the thresholds in the object by overriding the
* hardcoded thresholds. For Daktari it is an Error if the FRU does not
* contain the segment that had the temperature thresholds.
*/
static int32_t
{
return (status);
PSVC_FRU);
if (status == PSVC_FAILURE)
return (status);
for (i = 0; i < match_count; i++) {
seg_found = 0;
if (status != PSVC_SUCCESS)
return (status);
&fru_data);
if (status != PSVC_SUCCESS) {
return (status);
}
&fru_data);
&fru_data);
if (status != PSVC_SUCCESS) {
"Failed psvc_get_attr for FRU info\n");
return (status);
}
seg_found = 1;
}
if (seg_found) {
&fru_data);
if (status != PSVC_SUCCESS) {
"Failed psvc_get_attr for FRU info\n");
return (status);
} else {
for (j = 0; j < sizeof (temp_array); j++) {
if (threshold_names[j] ==
continue;
temp = temp_array[j];
threshold_names[j], &temp);
if (status != PSVC_SUCCESS) {
return (status);
}
}
}
} else {
" using default temperatures\n", id);
}
}
return (status);
}
{
char *control_id;
int32_t init_speed = 0;
return (status);
if (status != PSVC_SUCCESS)
return (status);
&init_speed);
if (status == PSVC_FAILURE) {
return (status);
}
return (status);
}
{
char *temp_sensor;
return (status);
if (status == PSVC_FAILURE)
return (status);
for (i = 0; i < match_count; i++) {
&temp_sensor, PSVC_DEV_TEMP_SENSOR, i);
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS) {
return (status);
}
if (temp < lowest_temp)
lowest_temp = temp;
}
if (status == PSVC_FAILURE) {
return (status);
}
return (status);
}
{
char state[32];
char *physical_dev;
int32_t i, device_count;
char parent_path[256];
if (status == PSVC_FAILURE)
return (status);
for (i = 0; i < device_count; i++) {
&physical_dev, PSVC_PHYSICAL_DEVICE, i);
if (status != PSVC_SUCCESS)
return (status);
continue;
if (status != PSVC_SUCCESS)
continue;
&present);
if (status == PSVC_FAILURE) {
errno);
return (status);
}
(present == PSVC_PRESENT)) {
/* convert name to node, and parent path */
&child_node);
/* Device removed */
}
}
return (status);
}
{
char valid_switch_state[32];
char *led_id;
char led_state[32];
static int8_t hotplug_failed_count = 0;
static int unplugged_ps = 0;
int retry;
char *unplugged_id;
if (status == PSVC_FAILURE) {
return (status);
}
if (present == PSVC_ABSENT) {
return (PSVC_FAILURE);
}
id, "_SENSOR_VALID_SWITCH");
retry = 0;
do {
if (retry)
(void) sleep(retry_sleep_pshp_status);
if (status == PSVC_FAILURE) {
if (hotplug_failed_count == 0) {
/*
* First time the get_attr call failed
* set count so that if we fail again
* we will know
*/
hotplug_failed_count = 1;
/*
* We probably failed because the power
* supply was just insterted or removed
* before the get_attr call. We then
* return from this policy successfully
* knowing it will be run again shortly
* with the right PS state.
*/
return (PSVC_SUCCESS);
} else {
/*
* We have failed before and so this
* we will consider a hardware problem
* and it should be reported
*/
"Failed getting %s State: ",
"ps_hotplug_status_0\n",
return (status);
}
}
/*
* Because we have successfully gotten a value from
* the i2c device on the PS we will set the
* failed_count to 0
*/
hotplug_failed_count = 0;
if (status == PSVC_FAILURE)
return (status);
retry++;
/*
* check to see if we need to retry. the conditions are:
*
* valid_switch_state state retry
* --------------------------------------------------
* PSVC_OFF !PSVC_HOTPLUGGED yes
* PSVC_ON PSVC_HOTPLUGGED yes
* PSVC_OFF PSVC_HOTPLUGGED no
* PSVC_ON !PSVC_HOTPLUGGED no
*/
} while ((retry < n_retry_pshp_status) &&
state, PSVC_HOTPLUGGED));
state);
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
for (j = 0; j < led_count; j++) {
&led_id, PSVC_DEV_FAULT_LED, j);
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS) {
errno);
return (status);
}
}
if (status != PSVC_SUCCESS) {
return (status);
}
(char **)NULL, 10));
return (status);
}
if (status == PSVC_FAILURE)
return (status);
(char **)NULL, 10));
if (unplugged_ps == 0) {
if (status != PSVC_SUCCESS) {
errno);
return (status);
}
}
}
return (status);
}
{
int32_t i, j;
char state[32];
static int8_t overcurrent_failed_check = 0;
static int threshold_counter = 0;
if (power_supply_id[0] == NULL) {
for (i = 0; i < DAKTARI_MAX_PS; i++) {
PSVC_ASSOC_ID_ATTR, &(power_supply_id[i]),
PSVC_PS, i);
if (status != PSVC_SUCCESS)
return (status);
for (j = 0; j < DAK_MAX_PS_I_SENSORS; ++j) {
&(sensor_id[i][j]), PSVC_PS_I_SENSOR, j);
if (status != PSVC_SUCCESS)
return (status);
PSVC_HI_WARN_ATTR, &(hi_warn[i][j]));
if (status != PSVC_SUCCESS)
return (status);
}
}
}
for (i = 0; i < DAKTARI_MAX_PS; i++) {
if (status == PSVC_FAILURE) {
power_supply_id[i], errno);
return (status);
}
if (present == PSVC_ABSENT) {
continue;
}
power_supply_id[i]);
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
continue;
} else {
ps_present++;
}
for (j = 0; j < DAK_MAX_PS_I_SENSORS; ++j) {
if (status != PSVC_SUCCESS) {
if (overcurrent_failed_check == 0) {
/*
* First time the get_attr call
* failed set count so that if we
* fail again we will know
*/
/*
* We probably failed because the power
* supply was just insterted or removed
* before the get_attr call. We then
* return from this policy successfully
* knowing it will be run again shortly
* with the right PS state.
*/
return (PSVC_SUCCESS);
} else {
/*
* We have failed before and so this we
* will consider a hardware problem and
* it should be reported.
*/
"Failed getting %s sensor value",
sensor_id[i][j]);
return (status);
}
}
/*
* Because we have successfully gotten a value from the
* i2c device on the PS we will set the failed_count
* to 0.
*/
oc_flag = 1;
}
}
}
if (oc_flag) {
/*
* Because we observed an overcurrent
* condition, we increment threshold_counter.
* Once threshold_counter reaches the value
* of n_read_overcurrent we log the event.
*/
if (threshold_counter == n_read_overcurrent) {
threshold_counter = 0;
if (ps_present == 1) {
} else {
}
}
} else {
threshold_counter = 0;
}
return (PSVC_SUCCESS);
}
{
static char *sensor_id[DAK_MAX_PS_I_SENSORS];
int32_t j;
static int8_t undercurrent_failed_check = 0;
if (status == PSVC_FAILURE) {
return (status);
}
if (present == PSVC_ABSENT) {
return (PSVC_FAILURE);
}
for (j = 0; j < DAK_MAX_PS_I_SENSORS; ++j) {
&(sensor_id[j]), PSVC_PS_I_SENSOR, j);
if (status != PSVC_SUCCESS)
return (status);
PSVC_LO_WARN_ATTR, &(lo_warn[j]));
if (status != PSVC_SUCCESS)
return (status);
}
*uc_flag = 0;
for (j = 0; j < DAK_MAX_PS_I_SENSORS; ++j) {
if (status != PSVC_SUCCESS) {
if (undercurrent_failed_check == 0) {
/*
* First time the get_attr call
* failed set count so that if we
* fail again we will know.
*/
/*
* We probably failed because the power
* supply was just inserted or removed
* before the get_attr call. We then
* return from this policy successfully
* knowing it will be run again shortly
* with the right PS state.
*/
return (PSVC_SUCCESS);
} else {
/*
* Repeated failures are logged.
*/
"Failed getting %s sensor value",
sensor_id[j]);
return (status);
}
}
/*
* Because we have successfully gotten a value from the
* i2c device on the PS we will set the failed_count
* to 0.
*/
*uc_flag = 1;
return (PSVC_SUCCESS);
}
}
return (PSVC_SUCCESS);
}
{
char *led_id = "FSP_POWER_FAULT_LED";
int i, j, uc_flag;
char led_state[32];
static int threshold_counter[DAKTARI_MAX_PS];
int fail_state;
static int8_t device_fail_failed_check = 0;
int retry, should_retry;
for (i = 0; i < DAKTARI_MAX_PS; i++) {
if (status != PSVC_SUCCESS)
return (status);
for (j = 0; j < DAK_MAX_FAULT_SENSORS; j++) {
PSVC_ASSOC_ID_ATTR, &(sensor_id[i][j]),
if (status != PSVC_SUCCESS)
return (status);
}
}
}
for (i = 0; i < DAKTARI_MAX_PS; i++) {
fail_state = 0;
&present);
if (status == PSVC_FAILURE)
return (status);
if (present == PSVC_ABSENT) {
return (PSVC_FAILURE);
}
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
return (PICL_SUCCESS);
}
retry = 0;
do {
if (retry)
(void) sleep(retry_sleep_devicefail);
fail_state = 0;
should_retry = 0;
for (j = 0; j < DAK_MAX_FAULT_SENSORS; ++j) {
if (status != PSVC_SUCCESS) {
if (device_fail_failed_check == 0) {
/*
* First time the get_attr call
* failed set count so that
* if we fail again we will know
*/
/*
* We probably failed because
* the power supply was just
* insterted or removed before
* the get_attr call. We then
* return from this policy
* successfully knowing it will
* be run again shortly
* with the right PS state.
*/
return (PSVC_SUCCESS);
} else {
/*
* We have failed before and
* so this we will consider a
* hardware problem and
* it should be reported.
*/
"getting sensor state for "
"%s\n", sensor_id[i][j]);
return (status);
}
}
/*
* Because we have successfully gotten
* a value from the i2c device on the
* PS we will set the failed_count to 0.
*/
/*
* If we find that the sensor is on we
* fill in the name of the sensor in
* the bad_sensor array. If the sensor
* is off we use EMPTY_STRING as a check
* later on as to when NOT to print out
* what is in bad_sensor[].
*/
fail_state++;
sizeof (bad_sensors[j]));
} else {
}
}
retry++;
/*
* check to see if we need to retry. the conditions are:
*
* fail_state past_state retry
* --------------------------------------------------
* + PSVC_OK yes
* 0 PSVC_ERROR yes
* + PSVC_ERROR no
* 0 PSVC_OK no
*/
if ((fail_state > 0) &&
should_retry = 1;
} else if ((fail_state == 0) &&
should_retry = 1;
}
/* Under current check */
if (status != PSVC_FAILURE) {
if (uc_flag) {
/*
* Because we observed an undercurrent
* condition, we increment threshold counter.
* Once threshold counter reaches the value
* of n_read_undercurrent we log the event.
*/
threshold_counter[i]++;
if (threshold_counter[i] >=
fail_state++;
i);
}
} else {
threshold_counter[i] = 0;
}
}
if (fail_state != 0) {
} else {
}
if (status != PSVC_SUCCESS)
return (status);
fault);
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
char dev_label[32];
for (j = 0; j < DAK_MAX_FAULT_SENSORS; ++j) {
if (strcmp(bad_sensors[j],
EMPTY_STRING) != 0)
bad_sensors[j]);
}
} else {
}
if (status != PSVC_SUCCESS) {
errno);
return (status);
}
}
}
return (PSVC_SUCCESS);
}
{
char state[32];
int ps_cnt = 0;
int i, j;
int dr_conf;
unsigned char controller_names[HPC3130_CONTROLLERS] =
{ 0xe2, 0xe6, 0xe8, 0xec };
for (i = 0; i < DAKTARI_MAX_PS; i++) {
if (rv != PSVC_SUCCESS)
return (rv);
}
}
/*
* Go through the power supplies to make sure they're present
* and OK.
*/
for (i = 0; i < DAKTARI_MAX_PS; i++) {
&present);
if (rv != PSVC_SUCCESS)
return (rv);
if (present != PSVC_PRESENT) {
ps_cnt--;
continue;
} else {
state);
if (rv != PSVC_SUCCESS)
return (rv);
ps_cnt--;
}
}
/*
* No change in DR configuration is needed if the new power supply
* count equals the current count.
*/
return (PSVC_SUCCESS);
/*
* Disable DR when hotplugged down to 1 power supply; enable DR when
* hotplugged up from 1 supply.
*/
return (PSVC_SUCCESS);
}
for (i = 0; i < HPC3130_CONTROLLERS; i++) {
for (j = 0; j < HPC3130_SLOTS; j++) {
HPC3130_DEV, controller_names[i], j);
if (fd == -1)
return (PSVC_FAILURE);
if (rv == -1)
return (PSVC_FAILURE);
}
}
return (PSVC_SUCCESS);
}
{
char switch_status[32];
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
return (status);
}
{
int r;
static int threshold_counter = 0;
for (r = 0; r < DAK_MAX_FANS; r++) {
if (status != PSVC_SUCCESS)
return (status);
}
}
for (r = 0; r < DAK_MAX_FANS; r++) {
&enabled);
if (status != PSVC_SUCCESS)
return (status);
if (enabled == PSVC_ENABLED) {
char *switch_id;
char *other_fan_id;
/*
* If any other fan on the fan tray has an ERROR state,
* mark this fan bad and return
*/
if (status == PSVC_FAILURE)
return (status);
if (status != PSVC_SUCCESS)
return (status);
sizeof (ffault));
if (status != PSVC_SUCCESS)
return (status);
sizeof (fstate));
return (status);
}
}
/*
* fans.
*/
if (status != PSVC_FAILURE) {
if (status == PSVC_FAILURE) {
return (status);
}
if (features & PSVC_DEV_PRIMARY)
sizeof (switch_state));
else
sizeof (switch_state));
if (status == PSVC_FAILURE) {
return (status);
}
/* allow time for speed to be determined */
}
if (status != PSVC_SUCCESS) {
return (status);
}
if (speed == 0) {
if (threshold_counter ==
int32_t i;
char led_state[32];
char *led_id;
char *slot_id;
char label[32];
threshold_counter = 0;
sizeof (fault));
if (status != PSVC_SUCCESS)
return (status);
sizeof (state));
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
label);
/* turn on fault LEDs */
sizeof (led_state));
for (i = 0; i < led_count; ++i) {
fan_id[r],
PSVC_DEV_FAULT_LED, i);
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
}
/* turn on OK to remove LEDs */
PSVC_PARENT, 0);
if (status != PSVC_SUCCESS)
return (status);
sizeof (led_state));
for (i = 0; i < led_count; ++i) {
PSVC_SLOT_REMOVE_LED, i);
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
}
}
}
}
}
return (PSVC_SUCCESS);
}
/*
* This routine takes in the PSVC handle pointer, the PS name, and the
* instance number (0, 1, or 2). It simply make a psvc_get call to get the
* presence of each of the children under the PS. This call will set the
* presence state of the child device if it was not there when the system
* was booted.
*/
static int
{
char *sensor_id;
int j;
/* Get the Sensor Valid Switch presence */
id, "_SENSOR_VALID_SWITCH");
&presence);
if (status != PSVC_SUCCESS)
return (status);
/* Go through each PS's fault sensors */
for (j = 0; j < DAK_MAX_FAULT_SENSORS; j++) {
&(sensor_id), PSVC_DEV_FAULT_SENSOR, j);
if (status != PSVC_SUCCESS)
return (status);
&presence);
if (status != PSVC_SUCCESS)
return (status);
}
/* Go through each PS's current sensors */
for (j = 0; j < DAK_MAX_PS_I_SENSORS; ++j) {
&(sensor_id), PSVC_PS_I_SENSOR, j);
if (status != PSVC_SUCCESS)
return (status);
&presence);
if (status != PSVC_SUCCESS)
return (status);
}
/* Go through each PS's onboard i2c hardware */
for (j = 0; j < 3; j++) {
&(sensor_id), PSVC_PHYSICAL_DEVICE, j);
if (status != PSVC_SUCCESS)
return (status);
&presence);
if (status != PSVC_SUCCESS)
return (status);
}
return (status);
}
{{{0, 0x90}, "adio", "i2c-pcf8591"}, {{0, 0x70}, "ioexp", "i2c-pcf8574"},
{{0, 0xa0}, "fru", "i2c-at24c64"}},
{{{0, 0x92}, "adio", "i2c-pcf8591"}, {{0, 0x72}, "ioexp", "i2c-pcf8574"},
{{0, 0xa2}, "fru", "i2c-at24c64"}},
{{{0, 0x94}, "adio", "i2c-pcf8591"}, {{0, 0x74}, "ioexp", "i2c-pcf8574"},
{{0, 0xa4}, "fru", "i2c-at24c64"}},
};
{
int i;
int retry;
if (status != PSVC_SUCCESS)
return (status);
retry = 0;
do {
if (retry)
(void) sleep(retry_sleep_pshp);
if (status != PSVC_SUCCESS)
return (status);
retry++;
} while ((retry < n_retry_pshp) &&
(presence != previous_presence));
if (presence == previous_presence) {
/* No change */
return (status);
}
if (status != PSVC_SUCCESS)
return (status);
/* convert name to node, and parent path */
if (presence == PSVC_PRESENT) {
/*
* Run this code if Power Supply was just added into the
* System. This code toggles hotplug switch and adds the
* PS and it's children to the picl tree. We then goto adding
* device drivers at bottom of the routine.
*/
char switch_state[32];
/* may detect presence before all connections are made */
/* Device added */
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
/* Enable i2c bus */
for (i = 0; i < switch_count; ++i) {
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
if (status == PSVC_FAILURE)
return (status);
}
} else {
/*
* Run this code if PS was just removed from the system. We
* delete the device from the picl tree and then shut off
* all fault lights associated with the PS. We also set the
* device state to PSVC_REMOVED so that if we hit overcurrent
* or fault checking code we can do a psvc call to see that
* the device has not offically been added into the system.
* We then will drop to code lower in the routine to remove
* the device drivers for this PS.
*/
/* Device removed */
for (i = 0; i < led_count; i++) {
&led_id, PSVC_DEV_FAULT_LED, i);
if (status != PSVC_SUCCESS) {
return (status);
}
if (status != PSVC_SUCCESS) {
errno);
return (status);
}
}
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
}
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
if (presence != PSVC_PRESENT) {
/*
* This is the additional code needed to remove the PS from
* the system. It removes the device drivers from the
* device tree.
*/
if (dev_handle == NULL) {
return (PSVC_FAILURE);
} else if ((devctl_device_remove(dev_handle)) &&
return (PSVC_FAILURE);
} else {
}
if (dev_handle == NULL) {
return (PSVC_FAILURE);
} else if ((devctl_device_remove(dev_handle)) &&
return (PSVC_FAILURE);
} else {
}
if (dev_handle == NULL) {
fru_devpath, errno);
return (PSVC_FAILURE);
} else if ((devctl_device_remove(dev_handle)) &&
fru_devpath, errno);
return (PSVC_FAILURE);
} else {
}
return (status);
}
/*
* This code is to update the presences of power supply child
* devices in the event that picld was started without a power
* supply present. This call makes the devices available
* after that initial insertion.
*/
if (status == PSVC_FAILURE) {
return (status);
}
/*
* We fall through to here if the device has been inserted.
* Add the devinfo tree node entry for the seeprom and attach
* the i2c seeprom driver
*/
if (bus_handle == NULL) {
return (PSVC_FAILURE);
}
/* Create the deivce nodes for all 3 i2c parts on the PS */
for (i = 0; i < 3; i++) {
return (PSVC_FAILURE);
}
if (status == -1) {
return (PSVC_FAILURE);
}
if (status == -1) {
return (PSVC_FAILURE);
}
&dev_handle)) {
return (PSVC_FAILURE);
} else
}
return (status);
}
static void
{
static boolean_t shutdown_flag = 0;
if (!(shutdown_flag)) {
shutdown_flag = 1;
}
}
/*
* This policy checks temperature sensors to see if the fault attribute
* is set to either High or Low Shutdown. If so then it shuts the system
* down with a 1 minute warning period
*/
{
char fault[32] = {0};
int retry;
return (status);
}
retry = 0;
do {
if (retry)
(void) sleep(retry_sleep_temp_shutdown);
if (status != PSVC_SUCCESS)
return (status);
retry++;
(retry < n_retry_temp_shutdown));
}
return (PSVC_SUCCESS);
}
{
int32_t i;
int retry;
/*
* Check which disk faulted, now get the disks.
* We are now going to get disk, disk parent,
* parent's leds, and check to see if parent's leds are on
*/
for (i = 0; i < DAK_MAX_DISKS; i++) {
if (status != PSVC_SUCCESS)
return (status);
PSVC_ASSOC_ID_ATTR, &(parent_id[i]),
PSVC_PARENT, 0);
if (status != PSVC_SUCCESS)
return (status);
PSVC_ASSOC_ID_ATTR, &(led_id[i]),
PSVC_SLOT_FAULT_LED, 0);
if (status != PSVC_SUCCESS)
return (status);
}
}
for (i = 0; i < DAK_MAX_DISKS; i++) {
curr_state[0] = 0;
prev_state[0] = 0;
&present);
if (status != PSVC_SUCCESS)
return (status);
if (present == PSVC_ABSENT)
continue;
/*
* Check if whether or not the led is on.
* If so, then this disk has a problem and
* set its fault and error states to bad.
* If not, then set fault and error states to good.
* If the disk underwent a change in state, then
* print out what state it's now in.
*/
if (status != PSVC_SUCCESS)
return (status);
retry = 0;
do {
if (retry)
(void) sleep(retry_sleep_diskfault);
if (status != PSVC_SUCCESS)
return (status);
retry++;
/*
* check to see if we need to retry. the conditions are:
*
* prev_state led_state retry
* --------------------------------------------------
* PSVC_ERROR PSVC_LED_ON yes
* PSVC_OK PSVC_LED_OFF yes
* PSVC_ERROR PSVC_LED_OFF no
* PSVC_OK PSVC_LED_ON no
*/
} while ((retry < n_retry_diskfault) &&
led_state, PSVC_LED_ON));
/*
* Set the disk's state and fault id according to
* what we found the disk fault sensor (disk_slot_fault_led)
* to be.
*/
} else {
}
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
/*
* Check disk states. If they differ, then print out
* the current state of the disk
*/
if (status != PSVC_SUCCESS)
return (status);
} else {
}
}
}
return (PSVC_SUCCESS);
}
{
int32_t i;
char *dev_id;
if (status != PSVC_SUCCESS)
return (status);
fault_state = 0;
for (i = 0; i < dev_count; i++) {
&dev_id, PSVC_DEV_FAULT_SENSOR, i);
if (status != PSVC_SUCCESS)
return (status);
&present);
if (status != PSVC_SUCCESS)
return (status);
if (present == PSVC_ABSENT)
continue;
if (status != PSVC_SUCCESS)
return (status);
fault_state = 1;
}
}
if (fault_state == 1) {
if (status != PSVC_SUCCESS)
return (status);
PSVC_ON);
if (status != PSVC_SUCCESS)
return (status);
}
} else {
if (status != PSVC_SUCCESS)
return (status);
PSVC_OFF);
if (status != PSVC_SUCCESS)
return (status);
}
}
return (status);
}
{
int32_t i;
char *led_id;
char led_state[32];
if (status != PSVC_SUCCESS)
return (status);
fault_state = 0;
for (i = 0; i < led_count; i++) {
&led_id, PSVC_DEV_FAULT_SENSOR, i);
if (status != PSVC_SUCCESS)
return (status);
if (status != PSVC_SUCCESS)
return (status);
fault_state = 1;
}
}
if (fault_state == 1) {
if (status != PSVC_SUCCESS)
return (status);
PSVC_ON);
if (status != PSVC_SUCCESS)
return (status);
}
} else {
if (status != PSVC_SUCCESS)
return (status);
PSVC_OFF);
if (status != PSVC_SUCCESS)
return (status);
}
}
return (status);
}
/*
* This function detects whether the module present in the dakatari's
* CPU slot is a CPU module or a Zulu (XVR-4000).
* Based on this detection it also sets the appropriate temperature sensors
* to HOTPLUGGED, so that it works properly with check_temp() function
*/
#define MAX_MODULE_SIZE 20
#define MAX_TEMP_SENSOR_SIZE 30
{
char other_module_id[MAX_MODULE_SIZE];
int offset = 0x7;
return (status);
}
PSVC_FRU);
if (status == PSVC_FAILURE) {
return (status);
}
for (i = 0; i < match_count; i++) {
seg_found = 0;
PSVC_FRU, i);
if (status != PSVC_SUCCESS)
return (status);
&fru_data);
if (status != PSVC_SUCCESS) {
return (status);
}
&fru_data);
if (status != PSVC_SUCCESS) {
return (status);
}
&fru_data);
if (status != PSVC_SUCCESS) {
return (status);
}
seg_found = 1;
}
if (seg_found) {
&fru_data);
if (status != PSVC_SUCCESS) {
return (status);
}
} else {
}
}
}
}
/*
* If the module in the CPU slot is a Zulu (XVR-4000), then
* location 0x1EB0 in its FRUid prom has a value 0xFB.
* If Zulu (XVR-4000) is detected, delete the CPU node, otherwise
* delete the Zulu node. Also set the temperature sensor value to
* HOTPLUGGED for absent temperature sensors.
*/
if (status == PSVC_FAILURE) {
return (status);
}
if (status == PSVC_FAILURE) {
return (status);
}
/*
* Remove CPU node
*/
if (status == PSVC_FAILURE) {
return (status);
}
} else {
if (status == PSVC_FAILURE) {
return (status);
}
if (status == PSVC_FAILURE) {
return (status);
}
/*
* Remove Zulu (XVR-4000) node
*/
if (status == PSVC_FAILURE) {
return (status);
}
}
return (PSVC_SUCCESS);
}
/*
* Remove the CPU slot's module node
*/
{
char parent_path[256];
/* convert name to node, and parent path */
/* Device removed */
return (PSVC_SUCCESS);
}
/*
* Set absent temperature sensor values to HOTPLUGGED
*/
{
char state[32];
if (status == PSVC_FAILURE) {
return (status);
}
if (status == PSVC_FAILURE) {
return (status);
}
}
return (PSVC_SUCCESS);
}