envd.h revision 47b4653e9ff2a8aebb64f9e357713fd04108674b
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ENVD_H
#define _ENVD_H
#include <libintl.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Chicago Platform Details
*/
#define MAX_SENSORS 9
#define MAX_FANS 6
/*
* Fan names and ids
*/
#define ENV_SYSTEM_FAN0 "system-fan0"
#define ENV_SYSTEM_FAN1 "system-fan1"
#define ENV_SYSTEM_FAN2 "system-fan2"
#define ENV_SYSTEM_FAN3 "system-fan3"
#define ENV_SYSTEM_FAN4 "system-fan4"
#define SYSTEM_FAN0_ID 0
#define SYSTEM_FAN1_ID 1
#define SYSTEM_FAN2_ID 2
#define SYSTEM_FAN3_ID 3
#define SYSTEM_FAN4_ID 4
#define CPU0_FAN_ID SYSTEM_FAN0_ID
#define CPU1_FAN_ID SYSTEM_FAN1_ID
/*
* Sensor names and ids
*/
#define SENSOR_CPU0 "cpu0"
#define SENSOR_CPU1 "cpu1"
#define SENSOR_MB "MotherBoard"
#define SENSOR_ADT7462 "ADT7462"
#define SENSOR_LM95221 "LM95221"
#define SENSOR_FIRE "FireASIC"
#define SENSOR_LSI1064 "LSI1064"
#define SENSOR_FRONT_PANEL "Front_panel"
#define SENSOR_PSU "PSU"
#define CPU0_SENSOR_ID 0
#define CPU1_SENSOR_ID 1
#define ADT7462_SENSOR_ID 2
#define MB_SENSOR_ID 3
#define LM95221_SENSOR_ID 4
#define FIRE_SENSOR_ID 5
#define LSI1064_SENSOR_ID 6
#define FRONT_PANEL_SENSOR_ID 7
#define PSU_SENSOR_ID 8
/*
* Hard disk sensor names and ids
*/
#define ENV_DISK0 "hard-disk0"
#define ENV_DISK1 "hard-disk1"
#define ENV_DISK2 "hard-disk2"
#define ENV_DISK3 "hard-disk3"
#define DISK0_ID 0
#define DISK1_ID 1
#define DISK2_ID 2
#define DISK3_ID 3
/*
* Thresholds and other constants
*/
#define DISK_SCAN_INTERVAL 10
#define DISK_HIGH_WARN_TEMPERATURE 55
#define DISK_LOW_WARN_TEMPERATURE 5
#define DISK_HIGH_SHUTDOWN_TEMPERATURE 60
#define DISK_LOW_SHUTDOWN_TEMPERATURE 0
#define DISK_INVALID_TEMP 0xFFFF
#define LSI1064_VENDOR_ID 0x1000
#define LSI1064_DEVICE_ID 0x50
#define FAN_SCAN_INTERVAL 10
#define SENSOR_SCAN_INTERVAL 2
#define SENSOR_WARNING_DURATION 4
#define SENSOR_WARNING_INTERVAL 30
#define DISK_WARNING_INTERVAL 30
#define DISK_WARNING_DURATION 20
#define SENSOR_SHUTDOWN_INTERVAL 60
#define DISK_SHUTDOWN_INTERVAL 30
#define ENV_CONF_FILE "envmodel.conf"
#define TUNABLE_CONF_FILE "piclenvd.conf"
#define SHUTDOWN_CMD "/usr/sbin/shutdown -y -g 60 -i 5"
#define PICL_PLUGINS_NODE "plugins"
#define PICL_ENVIRONMENTAL_NODE "environmental"
#define MAX_RETRIES_FOR_FAN_FAULT 10
#define MAX_FAN_RETRIES 14
#define MAX_SENSOR_RETRIES 14
/*
* constants used for retrieving SMART data
*/
#define DEFAULT_SCSI_TIMEOUT 60
#define IEC_PAGE 0x1C
#define HDA_TEMP 0xc2
#define DRIVE_TEMP 0xe7
#define GET_SMART_INFO 0x31
#define SMART_FIELDS 30
#define REPORT_ON_REQUEST 0x6
#define PAGE_FMT 4
#define IEC_PAGE_SIZE 12
#define SMART_FLAG_SIZE 2
#define ATTRIBUTE_DATA_SIZE 8
#define VENDOR_ATTR_SIZE 131
#define SMART_RESERVED_SIZE 10
#define COLLECTION_DATA_SIZE 6
#define DISK0_PHYSPATH \
"/pci@1e,600000/pci@0/pci@9/pci@0/scsi@1/sd@0,0"
#define DISK1_PHYSPATH \
"/pci@1e,600000/pci@0/pci@9/pci@0/scsi@1/sd@1,0"
#define DISK2_PHYSPATH \
"/pci@1e,600000/pci@0/pci@9/pci@0/scsi@1/sd@2,0"
#define DISK3_PHYSPATH \
"/pci@1e,600000/pci@0/pci@9/pci@0/scsi@1/sd@3,0"
#define ENV_DISK0_DEVFS \
#define ENV_DISK1_DEVFS \
#define ENV_DISK2_DEVFS \
#define ENV_DISK3_DEVFS \
#define DISK0_NODE_PATH \
#define DISK1_NODE_PATH \
#define DISK2_NODE_PATH \
#define DISK3_NODE_PATH \
#define SCSI_CONTROLLER_NODE_PATH \
/* CPU Path Names */
#define ENV_MONITOR_DEVFS "/devices/ebus@1f,464000/env-monitor@3,0"
/*
*/
#define ENV_SYSTEM_FAN0_DEVFS \
#define ENV_SYSTEM_FAN1_DEVFS \
#define ENV_SYSTEM_FAN2_DEVFS \
#define ENV_SYSTEM_FAN3_DEVFS \
#define ENV_SYSTEM_FAN4_DEVFS \
/* MIN and MAX SPEED are in RPM units */
#define CPU_FAN_SPEED_MIN 250
#define CPU_FAN_SPEED_MAX 5000
#define SYSTEM_FAN_SPEED_MIN 250
#define SYSTEM_FAN_SPEED_MAX 5000
/*
* devfs-path for various temperature sensors and CPU platform path
*/
#define SENSOR_CPU0_DEVFS \
#define SENSOR_CPU1_DEVFS \
#define SENSOR_MB_DEVFS \
#define SENSOR_ADT7462_DEVFS \
#define SENSOR_LM95221_DEVFS \
#define SENSOR_FIRE_DEVFS \
#define SENSOR_LSI1064_DEVFS \
#define SENSOR_FRONT_PANEL_DEVFS \
#define SENSOR_PSU_DEVFS \
/*
* Temperature type
*/
/*
* SEEPROM LAYOUT
*
* The layout of environmental segment in the SEEPROM in Chicago is as
* shown below. Note that this is a stripped-down version of the Envseg
* Definition v2.0 (but compatible). In particular, piclenvd in Chicago
* pairs, and it doesn't use the SensorPolicy and the list of
*
*
* 0 1 2 3 4 5
* +---------+------------------+----------+---------+---------+
* 0x1800: | HDR_TAG | HDR_VER | HDR_LEN | HDR_CRC | N_SEGS |
* +---------+---------+--------+----------+---------+---------+
* 0x1806: | SEG1_NAME | SEG1_DESC |
* +-------------------+-------------------+-------------------+
* 0x180C: | SEG1_OFF | SEG1_LEN | SEG2_NAME |
* +-------------------+-------------------+-------------------+
* ~ ~
* . .
* ~ ~
* +-------------------+-------------------+-------------------+
* 0xXXXX: | SEGn_OFF | SEGn_LEN |
* +-------------------+-------------------+
*
*
* +---------+---------+---------------------------------------+
* ENVSEG_OFF: | ESEG_VER| N_SNSRS | SENSOR1_ID |
* +---------+---------+---------------------------------------+
* | SNSR1_DOFF | SENSOR2_ID |
* +-------------------+---------------------------------------+
* ~ ~
* ~ ~
* +-------------------+---------------------------------------+
* | SNSRm_DOFF |
* +-------------------+
*
*
* +---------+---------+--------+----------+---------+---------+
* SNSRk_DOFF: | HI_POFF | HI_SHUT | HI_WARN| LO_WARN | LO_SHUT | LO_POFF |
* +-------------------+--------+----------+---------+---------+
*/
#define IOFRU_DEV "front-io-fru-prom@0,a4:front-io-fru-prom"
#define FRU_SEEPROM_NAME "front-io-fru-prom"
/*
* SEEPROM section header
*/
#define SSCN_TAG 0x08
#define SSCN_VER 0x0001
#define SSCN_OFFSET 0x1800
typedef struct {
/*
* SEEPROM segment header
*/
typedef struct {
/*
* Envseg layout V2 (stripped-down version)
*/
typedef struct {
typedef struct {
} es_sensor_t;
#define ENVSEG_VERSION 2
typedef struct {
} es_data_t;
/*
* Macros to fetch 16 and 32 bit msb-to-lsb data from unaligned addresses
*/
#define GET_UNALIGN16(addr) \
#define GET_UNALIGN32(addr) \
/*
*/
#define SENSOR_WARN 1
#define SENSOR_OK 0
#define FAN_FAILED 1
#define FAN_OK 0
/*
* Default limits for sensors in case environmental segment is absent
*/
#define CPU0_HIGH_POWER_OFF 105
#define CPU0_HIGH_SHUTDOWN 100
#define CPU0_HIGH_WARNING 95
#define CPU0_LOW_WARNING 5
#define CPU0_LOW_SHUTDOWN 0
#define CPU0_LOW_POWER_OFF 0
#define CPU1_HIGH_POWER_OFF 105
#define CPU1_HIGH_SHUTDOWN 100
#define CPU1_HIGH_WARNING 95
#define CPU1_LOW_WARNING 5
#define CPU1_LOW_SHUTDOWN 0
#define CPU1_LOW_POWER_OFF 0
#define ADT7462_HIGH_POWER_OFF 80
#define ADT7462_HIGH_SHUTDOWN 75
#define ADT7462_HIGH_WARNING 70
#define ADT7462_LOW_WARNING 5
#define ADT7462_LOW_SHUTDOWN 0
#define ADT7462_LOW_POWER_OFF 0
#define MB_HIGH_POWER_OFF 80
#define MB_HIGH_SHUTDOWN 75
#define MB_HIGH_WARNING 70
#define MB_LOW_WARNING 5
#define MB_LOW_SHUTDOWN 0
#define MB_LOW_POWER_OFF 0
#define LM95221_HIGH_POWER_OFF 80
#define LM95221_HIGH_SHUTDOWN 75
#define LM95221_HIGH_WARNING 70
#define LM95221_LOW_WARNING 5
#define LM95221_LOW_SHUTDOWN 0
#define LM95221_LOW_POWER_OFF 0
#define FIRE_HIGH_POWER_OFF 105
#define FIRE_HIGH_SHUTDOWN 100
#define FIRE_HIGH_WARNING 95
#define FIRE_LOW_WARNING 5
#define FIRE_LOW_SHUTDOWN 0
#define FIRE_LOW_POWER_OFF 0
#define LSI1064_HIGH_POWER_OFF 105
#define LSI1064_HIGH_SHUTDOWN 100
#define LSI1064_HIGH_WARNING 95
#define LSI1064_LOW_WARNING 5
#define LSI1064_LOW_SHUTDOWN 0
#define LSI1064_LOW_POWER_OFF 0
#define FRONT_PANEL_HIGH_POWER_OFF 75
#define FRONT_PANEL_HIGH_SHUTDOWN 70
#define FRONT_PANEL_HIGH_WARNING 60
#define FRONT_PANEL_LOW_WARNING 5
#define FRONT_PANEL_LOW_SHUTDOWN 0
#define FRONT_PANEL_LOW_POWER_OFF 0
#define PSU_HIGH_POWER_OFF 95
#define PSU_HIGH_SHUTDOWN 85
#define PSU_HIGH_WARNING 75
#define PSU_LOW_WARNING 5
#define PSU_LOW_SHUTDOWN 0
#define PSU_LOW_POWER_OFF 0
/*
* Temperature sensor related data structure
*/
typedef struct env_sensor {
char *name; /* sensor name */
char *devfs_path; /* sensor device devfs path */
int id;
int fd; /* device file descriptor */
int error; /* error flag */
} env_sensor_t;
typedef struct env_disk {
char *name; /* disk name */
char *devfs_path; /* disk device devfs path */
char *physpath; /* used to be probe for IDLW TIME */
char *nodepath; /* used to detect presence of disk */
int fd; /* device file descriptor */
int current_temp;
int ref_temp;
int reliability_temp;
} env_disk_t;
/*
* Fan information data structure
*/
typedef int fanspeed_t;
typedef struct env_fan {
char *name; /* fan name */
char *devfs_path; /* fan device devfs path */
int forced_speed; /* forced (fixed) speed */
int fd; /* device file descriptor */
int last_status; /* Fan status */
} env_fan_t;
/*
* Tuneables
*/
typedef struct env_tuneable {
char *name;
char type;
void *value;
int (*rfunc)(ptree_rarg_t *, void *);
int (*wfunc)(ptree_warg_t *, const void *);
int nbytes;
/*
* Smart structures
*/
typedef struct smart_field {
typedef struct smart_struct {
/* offline collection information */
extern int env_debug;
/*
* Various messages
*/
#define ENVD_PLUGIN_INIT_FAILED \
gettext("SUNW_piclenvd: initialization failed!\n")
#define ENVD_PICL_SETUP_FAILED \
gettext("SUNW_piclenvd: PICL setup failed!\n")
#define PM_THREAD_CREATE_FAILED \
gettext("SUNW_piclenvd: pmthr thread creation failed!\n")
#define PM_THREAD_EXITING \
gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n")
#define DISK_TEMP_THREAD_EXITING \
gettext("SUNW_piclenvd: Disk temp thread exiting." \
" Disk temperature will not be monitored. errno:%d %s\n")
#define ENVTHR_THREAD_CREATE_FAILED \
gettext("SUNW_piclenvd: envthr thread creation failed!\n")
#define ENV_SHUTDOWN_MSG \
gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
"limits (%d...%d). Shutting down the system.\n")
#define ENV_WARNING_MSG \
gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
"operating limits (%d...%d).\n")
#define ENV_FAN_OPEN_FAIL \
gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n")
#define ENV_SENSOR_OPEN_FAIL \
gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n")
#define ENV_SENSOR_ACCESS_FAIL \
gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n")
#define ENV_SENSOR_ACCESS_OK \
gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n")
#define ENV_FAN_FAILURE_WARNING_MSG \
gettext("SUNW_piclenvd: %s has Failed.\n" \
"(rpm = %s status = %s)\n")
#define ENV_FAN_OK_MSG \
gettext("SUNW_piclenvd: %s is OKAY.\n")
#define ENV_FRU_OPEN_FAIL \
gettext("SUNW_piclenvd: can't open FRU SEEPROM path:%s errno:%d\n")
#define ENV_FRU_BAD_ENVSEG \
gettext("SUNW_piclenvd: version mismatch or environmental segment " \
"header too short in FRU SEEPROM %s\n")
#define ENV_FRU_BAD_SCNHDR \
gettext("SUNW_piclenvd: invalid section header tag:%x version:%x\n")
#define ENV_FRU_NOMEM_FOR_SEG \
gettext("SUNW_piclenvd: cannot allocate %d bytes for env seg memory\n")
#define ENV_DEFAULT_LIMITS \
gettext("SUNW_piclenvd: error reading ES segment, using defaults\n")
#ifdef __cplusplus
}
#endif
#endif /* _ENVD_H */