Latest import from original repository.

This commit is contained in:
Jeffrey Townsend
2016-09-17 12:08:48 -07:00
parent f837d15f52
commit 698200f840
18 changed files with 173 additions and 138 deletions

View File

@@ -32,7 +32,8 @@
#define PSU2_ID 2
#define CHASSIS_FAN_COUNT 5
#define CHASSIS_THERMAL_COUNT 3
#define CHASSIS_THERMAL_COUNT 4
#define CHASSIS_LED_COUNT 10
#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/57-003c/"
#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/58-003f/"

View File

@@ -120,28 +120,25 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max)
onlp_oid_t* e = table;
memset(table, 0, max*sizeof(onlp_oid_t));
int i;
int n_led=10, n_thermal=4, n_fan=5;
//assert(max > (n_led+n_thermal+n_fan));
/* 2 PSUs */
*e++ = ONLP_PSU_ID_CREATE(1);
*e++ = ONLP_PSU_ID_CREATE(2);
/* LEDs Item */
for (i=1; i<=n_led; i++)
for (i=1; i<=CHASSIS_LED_COUNT; i++)
{
*e++ = ONLP_LED_ID_CREATE(i);
}
/* THERMALs Item */
for (i=1; i<=n_thermal; i++)
for (i=1; i<=CHASSIS_THERMAL_COUNT; i++)
{
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
/* Fans Item */
for (i=1; i<=n_fan; i++)
for (i=1; i<=CHASSIS_FAN_COUNT; i++)
{
*e++ = ONLP_FAN_ID_CREATE(i);
}

View File

@@ -143,6 +143,18 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
}
return PSU_TYPE_AC_B2F;
}
else if (strncmp(model_name, "CPR-6011-2M11", strlen("CPR-6011-2M11")) == 0) {
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}
return PSU_TYPE_AC_F2B;
}
else if (strncmp(model_name, "CPR-6011-2M21", strlen("CPR-6011-2M21")) == 0) {
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}
return PSU_TYPE_AC_B2F;
}
}
/* Check DC model name */

View File

@@ -215,6 +215,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
if (val != PSU_STATUS_POWER_GOOD) {
info->status |= ONLP_PSU_STATUS_FAILED;
return 0;
}

View File

@@ -77,8 +77,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */
"12-003f/psu_",
};
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
static char* cpu_coretemp_files[] =
{
"/sys/devices/platform/coretemp.0/temp2_input",
@@ -87,8 +85,8 @@ static char* cpu_coretemp_files[] =
"/sys/devices/platform/coretemp.0/temp5_input",
NULL,
};
#endif
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
@@ -158,13 +156,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
*info = linfo[local_id];
if(local_id == THERMAL_CPU_CORE) {
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
return rv;
#else
return ONLP_STATUS_OK;
#endif
}
/* get fullpath */

View File

@@ -77,8 +77,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */
"58-003f/psu_",
};
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
static char* cpu_coretemp_files[] =
{
"/sys/devices/platform/coretemp.0/temp2_input",
@@ -87,8 +85,7 @@ static char* cpu_coretemp_files[] =
"/sys/devices/platform/coretemp.0/temp5_input",
NULL,
};
#endif
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
@@ -158,13 +155,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
*info = linfo[local_id];
if(local_id == THERMAL_CPU_CORE) {
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
return rv;
#else
return ONLP_STATUS_OK;
#endif
}
/* get fullpath */
@@ -179,5 +171,3 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
return ONLP_STATUS_OK;
}

View File

@@ -31,7 +31,7 @@
#define PREFIX_PATH_ON_MAIN_BOARD "/sys/devices/platform/as6712_32x_fan/"
#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/"
#define MAX_FAN_SPEED 25500
#define MAX_FAN_SPEED 18000 /* use the smaller max_speed of the 2 fans in a fantray */
#define MAX_PSU_FAN_SPEED 19328
#define PROJECT_NAME
@@ -92,7 +92,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */
{ \
{ ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \
0x0, \
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
0, \
0, \
0, \
ONLP_FAN_MODE_INVALID, \
@@ -181,7 +181,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
static int
_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
{
int psu_id;
int psu_id, is_ac = 0;
int fd, len, nbytes = 10;
char r_data[10] = {0};
char fullpath[80] = {0};
@@ -198,31 +198,45 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
switch (psu_type) {
case PSU_TYPE_AC_F2B:
is_ac = 1;
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B);
info->caps |= ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE;
break;
case PSU_TYPE_AC_B2F:
is_ac = 1;
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F);
info->caps |= ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE;
break;
case PSU_TYPE_DC_48V_F2B:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B);
break;
case PSU_TYPE_DC_48V_B2F:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F);
break;
default:
DEBUG_PRINT("[Debug][%s][%d][psu_type=%d]\n", __FUNCTION__, __LINE__, psu_type);
break;
}
/* get fan fault status
*/
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
if (atoi(r_data) > 0)
info->status |= ONLP_FAN_STATUS_FAILED;
if (is_ac)
{
/* get fan fault status
*/
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
if (atoi(r_data) > 0)
info->status |= ONLP_FAN_STATUS_FAILED;
/* get fan speed
*/
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
info->rpm = atoi(r_data);
/* get fan speed
*/
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
info->rpm = atoi(r_data);
/* get speed percentage from rpm */
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
info->status |= ONLP_FAN_STATUS_PRESENT;
/* get speed percentage from rpm */
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
info->status |= ONLP_FAN_STATUS_PRESENT;
}
return ONLP_STATUS_OK;
}

View File

@@ -235,6 +235,12 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led
int
onlp_ledi_init(void)
{
int ret;
if ((ret = onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF)) != ONLP_STATUS_OK)
{
return ret;
}
return ONLP_STATUS_OK;
}
@@ -252,7 +258,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
/* get fullpath */
sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename);
/* Set the onlp_oid_hdr_t and capabilities */
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[ONLP_OID_ID_GET(id)];
/* Set LED mode */
@@ -308,7 +314,7 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
local_id = ONLP_OID_ID_GET(id);
sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename);
if (deviceNodeWriteInt(fullpath, onlp_to_driver_led_mode(local_id, mode), 0) != 0)
{
return ONLP_STATUS_E_INTERNAL;

View File

@@ -64,9 +64,9 @@ int deviceNodeWrite(char *filename, char *buffer, int buf_size, int data_len)
int deviceNodeWriteInt(char *filename, int value, int data_len)
{
char buf[8] = {0};
sprintf(buf, "%d", value);
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
sprintf(buf, "%d", value);
return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len);
}
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)
@@ -140,5 +140,24 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
}
}
/* Check DC model name */
memset(model_name, 0, sizeof(model_name));
node = (id == PSU1_ID) ? PSU1_DC_HWMON_NODE(psu_model_name) : PSU2_DC_HWMON_NODE(psu_model_name);
if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) == 0) {
if (strncmp(model_name, "um400d01G", strlen("um400d01G")) == 0) {
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}
return PSU_TYPE_DC_48V_B2F;
}
else if (strncmp(model_name, "um400d01-01G", strlen("um400d01-01G")) == 0) {
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}
return PSU_TYPE_DC_48V_F2B;
}
}
return PSU_TYPE_UNKNOWN;
}

View File

@@ -29,7 +29,9 @@
#include "x86_64_accton_as6712_32x_log.h"
#define CHASSIS_FAN_COUNT 5
#define CHASSIS_THERMAL_COUNT 4
#define CHASSIS_THERMAL_COUNT 5
#define CHASSIS_LED_COUNT 10
#define CHASSIS_PSU_COUNT 2
#define PSU1_ID 1
#define PSU2_ID 2
@@ -46,6 +48,11 @@
#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node
#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node
#define PSU1_DC_HWMON_PREFIX "/sys/bus/i2c/devices/35-0050/"
#define PSU2_DC_HWMON_PREFIX "/sys/bus/i2c/devices/36-0053/"
#define PSU1_DC_HWMON_NODE(node) PSU1_DC_HWMON_PREFIX#node
#define PSU2_DC_HWMON_NODE(node) PSU2_DC_HWMON_PREFIX#node
#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom"
int deviceNodeWriteInt(char *filename, int value, int data_len);
@@ -55,7 +62,9 @@ int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_le
typedef enum psu_type {
PSU_TYPE_UNKNOWN,
PSU_TYPE_AC_F2B,
PSU_TYPE_AC_B2F
PSU_TYPE_AC_B2F,
PSU_TYPE_DC_48V_F2B,
PSU_TYPE_DC_48V_B2F
} psu_type_t;
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);

View File

@@ -92,6 +92,25 @@ psu_cpr_4011_pmbus_info_get(int id, char *node, int *value)
return ret;
}
int
psu_um400d_info_get(onlp_psu_info_t* info)
{
int index = ONLP_OID_ID_GET(info->hdr.id);
/* Set capability
*/
info->caps = ONLP_PSU_CAPS_DC48;
if (info->status & ONLP_PSU_STATUS_FAILED) {
return ONLP_STATUS_OK;
}
/* Set the associated oid_table */
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
return ONLP_STATUS_OK;
}
int
onlp_psui_init(void)
{
@@ -208,6 +227,10 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
case PSU_TYPE_AC_B2F:
ret = psu_cpr_4011_info_get(info);
break;
case PSU_TYPE_DC_48V_F2B:
case PSU_TYPE_DC_48V_B2F:
ret = psu_um400d_info_get(info);
break;
default:
ret = ONLP_STATUS_E_UNSUPPORTED;
break;

View File

@@ -38,11 +38,6 @@
#include "platform_lib.h"
#define NUM_OF_THERMAL_ON_MAIN_BROAD 5
#define NUM_OF_FAN_ON_MAIN_BROAD 5
#define NUM_OF_PSU_ON_MAIN_BROAD 2
#define NUM_OF_LED_ON_MAIN_BROAD 10
#define OPEN_READ_FILE(fd,fullpath,data,nbytes,len) \
DEBUG_PRINT("[Debug][%s][%d][openfile: %s]\n", __FUNCTION__, __LINE__, fullpath); \
if ((fd = open(fullpath, O_RDONLY)) == -1) \
@@ -124,26 +119,26 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max)
onlp_oid_t* e = table;
memset(table, 0, max*sizeof(onlp_oid_t));
/* 4 Thermal sensors on the chassis */
for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++)
/* 5 Thermal sensors on the chassis */
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++)
{
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
/* 9 LEDs on the chassis */
for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++)
/* 10 LEDs on the chassis */
for (i = 1; i <= CHASSIS_LED_COUNT; i++)
{
*e++ = ONLP_LED_ID_CREATE(i);
}
/* 4 Fans on the chassis */
for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++)
/* 5 Fans on the chassis */
for (i = 1; i <= CHASSIS_FAN_COUNT; i++)
{
*e++ = ONLP_FAN_ID_CREATE(i);
}
/* 2 PSUs on the chassis */
for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++)
for (i = 1; i <= CHASSIS_PSU_COUNT; i++)
{
*e++ = ONLP_PSU_ID_CREATE(i);
}
@@ -218,7 +213,7 @@ onlp_sysi_platform_manage_fans(void)
/* Get each fan status
*/
for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++)
for (i = 1; i <= CHASSIS_FAN_COUNT; i++)
{
onlp_fan_info_t fan_info;

View File

@@ -235,6 +235,8 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led
int
onlp_ledi_init(void)
{
/* Turn off Diag LED */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF);
return ONLP_STATUS_OK;
}

View File

@@ -66,7 +66,7 @@ int deviceNodeWriteInt(char *filename, int value, int data_len)
char buf[8] = {0};
sprintf(buf, "%d", value);
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
return deviceNodeWrite(filename, buf, strlen(buf), data_len);
}
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)

View File

@@ -76,8 +76,6 @@ static char* last_path[] = /* must map with onlp_thermal_id */
"36-003f/psu_temp1_input",
};
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
static char* cpu_coretemp_files[] =
{
"/sys/devices/platform/coretemp.0/temp2_input",
@@ -86,8 +84,7 @@ static char* cpu_coretemp_files[] =
"/sys/devices/platform/coretemp.0/temp5_input",
NULL,
};
#endif
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
@@ -155,13 +152,8 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
*info = linfo[local_id];
if(local_id == THERMAL_CPU_CORE) {
#if 0 /* Temprarily comment below function to avoid compiler error
"implicit declaration of function 'onlp_file_read_int_max'" */
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
return rv;
#else
return ONLP_STATUS_OK;
#endif
}
/* get fullpath */
@@ -173,4 +165,3 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
return ONLP_STATUS_OK;
}

View File

@@ -129,37 +129,6 @@ onlp_fan_info_t linfo[] = {
if (close(fd) == -1) \
return ONLP_STATUS_E_INTERNAL
/* There is no CPLD register for reading fan direction on this platform,
* to read fan direction, we need to read from PSU-fan,
* the direction of PSU-fan and chassis-fan are the same.
*/
static uint32_t
_onlp_fani_info_get_fan_direction(void)
{
/* Try to read direction from PSU1.
* If PSU1 is not valid, read from PSU2
*/
int i = 0;
for (i = PSU1_ID; i <= PSU2_ID; i++) {
psu_type_t psu_type;
psu_type = get_psu_type(i, NULL, 0);
if (psu_type == PSU_TYPE_UNKNOWN) {
continue;
}
if (PSU_TYPE_AC_F2B == psu_type) {
return ONLP_FAN_STATUS_F2B;
}
else {
return ONLP_FAN_STATUS_B2F;
}
}
return 0;
}
static int
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
{
@@ -175,10 +144,6 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
info->status |= ONLP_FAN_STATUS_FAILED;
}
/* get fan direction (both : the same)
*/
info->status |= _onlp_fani_info_get_fan_direction();
/* get fan speed (take the min from two speeds)
*/
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
@@ -203,7 +168,7 @@ _onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
}
static int
_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info)
{
int fd, len, nbytes = 10;
char r_data[10] = {0};
@@ -211,7 +176,17 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
/* get fan direction
*/
info->status |= _onlp_fani_info_get_fan_direction();
switch(get_psu_type(psu_id, NULL, 0))
{
case PSU_TYPE_AC_F2B:
info->status |= ONLP_FAN_STATUS_F2B;
break;
case PSU_TYPE_AC_B2F:
info->status |= ONLP_FAN_STATUS_B2F;
break;
default:
break;
}
/* get fan fault status
*/
@@ -252,10 +227,12 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
*info = linfo[local_id];
switch (local_id)
{
case FAN_1_ON_PSU1:
{
case FAN_1_ON_PSU1:
rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU1_ID, info);
break;
case FAN_1_ON_PSU2:
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
rc = _onlp_fani_info_get_fan_on_psu(local_id, PSU2_ID, info);
break;
case FAN_1_ON_MAIN_BOARD:
case FAN_2_ON_MAIN_BOARD:
@@ -268,7 +245,7 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
default:
rc = ONLP_STATUS_E_INVALID;
break;
}
}
return rc;
}

View File

@@ -117,13 +117,13 @@ int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_le
#define I2C_PSU_MODEL_NAME_LEN 9
#define I2C_PSU_FAN_DIR_LEN 3
#include <ctype.h>
psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
{
char *node = NULL;
char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0};
char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0};
/* Check AC model name */
node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name);
@@ -131,11 +131,16 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) != 0) {
return PSU_TYPE_UNKNOWN;
}
if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) {
return PSU_TYPE_UNKNOWN;
}
if(isspace(model_name[strlen(model_name)-1])) {
model_name[strlen(model_name)-1] = 0;
}
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}

View File

@@ -56,7 +56,7 @@ enum onlp_thermal_id
THERMAL_CPU_CORE,
THERMAL_1_ON_MAIN_BROAD,
THERMAL_2_ON_MAIN_BROAD,
THERMAL_3_ON_MAIN_BROAD,
THERMAL_3_ON_MAIN_BROAD,
THERMAL_1_ON_PSU1,
THERMAL_1_ON_PSU2,
};
@@ -70,7 +70,7 @@ static char* last_path[] = /* must map with onlp_thermal_id */
"3-004a/temp1_input",
"3-004b/temp1_input",
"11-005b/psu_temp1_input",
"10-0058/psu_temp1_input",
"10-0058/psu_temp1_input",
};
static char* cpu_coretemp_files[] =
@@ -85,31 +85,31 @@ static char* cpu_coretemp_files[] =
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "tmp75-MAC_up-1-48", 0},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "tmp75-MAC_down-2-49", 0},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "tmp75-MAC_left-3-4A", 0},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "tmp75-CPU-4-4B", 0},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
}
@@ -141,24 +141,24 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
char r_data[10] = {0};
char fullpath[50] = {0};
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
/* Set the onlp_oid_hdr_t and capabilities */
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[local_id];
if(local_id == THERMAL_CPU_CORE) {
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
return rv;
}
}
/* get fullpath */
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len);
info->mcelsius = atoi(r_data) / temp_base;
info->mcelsius = atoi(r_data) / temp_base;
DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);
return ONLP_STATUS_OK;
return ONLP_STATUS_OK;
}