fix psu bug in I2C mode

Signed-off-by: johnson <JOHNSON.LU@deltaww.com>
This commit is contained in:
johnson
2019-03-26 14:10:05 +08:00
parent 47e58496ad
commit ef36713233
9 changed files with 259 additions and 234 deletions

View File

@@ -59,8 +59,8 @@ struct dps_800ab_16_d_data {
u8 fan_fault; u8 fan_fault;
u16 fan_duty_cycle[2]; u16 fan_duty_cycle[2];
u16 fan_speed[2]; u16 fan_speed[2];
u8 mfr_model[14]; u8 mfr_model[16];
u8 mfr_serial[14]; u8 mfr_serial[16];
}; };
static int two_complement_to_int(u16 data, u8 valid_bit, int mask); static int two_complement_to_int(u16 data, u8 valid_bit, int mask);

View File

@@ -96,11 +96,6 @@ onlp_fan_info_t linfo[] = {
static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_name) static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_name)
{ {
int rv = ONLP_STATUS_OK; int rv = ONLP_STATUS_OK;
#ifdef I2C
int rpm = 0;
int fantray_present = -1;
char fullpath[100] = {0};
#endif
#ifdef BMC #ifdef BMC
uint8_t bit_data = 0x00; uint8_t bit_data = 0x00;
UINT4 u4Data = 0; UINT4 u4Data = 0;
@@ -149,8 +144,11 @@ static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_
info->status |= ONLP_FAN_STATUS_FAILED; info->status |= ONLP_FAN_STATUS_FAILED;
break; break;
} }
#endif #elif defined I2C
#ifdef I2C int rpm = 0;
int fantray_present = -1;
char fullpath[100] = {0};
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed);
rpm = dni_i2c_lock_read_attribute(NULL, fullpath); rpm = dni_i2c_lock_read_attribute(NULL, fullpath);
info->rpm = rpm; info->rpm = rpm;
@@ -203,11 +201,6 @@ static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_
static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, char *dev_name) static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, char *dev_name)
{ {
int rv = ONLP_STATUS_OK; int rv = ONLP_STATUS_OK;
#ifdef I2C
int psu_present = 0;
int r_data = 0;
char fullpath[100] = {0};
#endif
#ifdef BMC #ifdef BMC
UINT4 multiplier = 1; UINT4 multiplier = 1;
UINT4 u4Data = 0; UINT4 u4Data = 0;
@@ -249,8 +242,11 @@ static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, cha
} }
break; break;
} }
#endif #elif defined I2C
#ifdef I2C int psu_present = 0;
int r_data = 0;
char fullpath[100] = {0};
switch(local_id) { switch(local_id) {
case FAN_1_ON_PSU1: case FAN_1_ON_PSU1:
psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);

View File

@@ -208,8 +208,7 @@ int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
info->mode = ONLP_LED_MODE_OFF; info->mode = ONLP_LED_MODE_OFF;
break; break;
} }
#endif #elif defined I2C
#ifdef I2C
switch(local_id) switch(local_id)
{ {
case LED_FRONT_FAN: case LED_FRONT_FAN:

View File

@@ -42,12 +42,12 @@
static onlp_shlock_t* dni_lock = NULL; static onlp_shlock_t* dni_lock = NULL;
#define DNI_BUS_LOCK() \ #define DNI_LOCK() \
do{ \ do{ \
onlp_shlock_take(dni_lock); \ onlp_shlock_take(dni_lock); \
}while(0) }while(0)
#define DNI_BUS_UNLOCK() \ #define DNI_UNLOCK() \
do{ \ do{ \
onlp_shlock_give(dni_lock); \ onlp_shlock_give(dni_lock); \
}while(0) }while(0)
@@ -64,6 +64,7 @@ void lockinit()
} }
} }
#ifdef BMC
int dni_ipmi_data_time_check(long last_time, long new_time, int time_threshold) int dni_ipmi_data_time_check(long last_time, long new_time, int time_threshold)
{ {
int ipmi_data_update = 0; int ipmi_data_update = 0;
@@ -210,7 +211,7 @@ int dni_bmc_sensor_read(char *device_name, UINT4 *num, UINT4 multiplier, int sen
if(ipmi_data_update == 1) if(ipmi_data_update == 1)
{ {
DNI_BUS_LOCK(); DNI_LOCK();
if(dni_ipmi_data_time_check(file_last_time, bmc_check.time, time_threshold)) if(dni_ipmi_data_time_check(file_last_time, bmc_check.time, time_threshold))
{ {
sprintf(ipmi_cmd, "ipmitool sdr > /tmp/bmc_info"); sprintf(ipmi_cmd, "ipmitool sdr > /tmp/bmc_info");
@@ -234,7 +235,7 @@ int dni_bmc_sensor_read(char *device_name, UINT4 *num, UINT4 multiplier, int sen
} }
gettimeofday(&new_tv,NULL); gettimeofday(&new_tv,NULL);
bmc_check.time = new_tv.tv_sec; bmc_check.time = new_tv.tv_sec;
DNI_BUS_UNLOCK(); DNI_UNLOCK();
} }
for(dev_num = 0; dev_num < DEV_NUM; dev_num++) for(dev_num = 0; dev_num < DEV_NUM; dev_num++)
@@ -305,11 +306,11 @@ int dni_bmc_data_get(int bus, int addr, int reg, int *r_data)
if(ipmi_data_update == 1) if(ipmi_data_update == 1)
{ {
DNI_BUS_LOCK(); DNI_LOCK();
swpld_table[swpld_num].time = new_tv.tv_sec; swpld_table[swpld_num].time = new_tv.tv_sec;
sprintf(cmd, "ipmitool raw 0x38 0x2 %d 0x%x 0x00 255 > /tmp/%s_data", bus, addr, swpld_table[swpld_num].name); sprintf(cmd, "ipmitool raw 0x38 0x2 %d 0x%x 0x00 255 > /tmp/%s_data", bus, addr, swpld_table[swpld_num].name);
system(cmd); system(cmd);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
} }
sprintf(data_path, "/tmp/%s_data",swpld_table[swpld_num].name); sprintf(data_path, "/tmp/%s_data",swpld_table[swpld_num].name);
@@ -332,7 +333,7 @@ int dni_bmc_data_set(int bus, int addr, int reg, uint8_t w_data)
char cmd[50] = {0}; char cmd[50] = {0};
FILE *fptr = NULL; FILE *fptr = NULL;
DNI_BUS_LOCK(); DNI_LOCK();
sprintf(cmd, "ipmitool raw 0x38 0x3 %d 0x%x 0x%x %d > /dev/null", bus, addr, reg, w_data); sprintf(cmd, "ipmitool raw 0x38 0x3 %d 0x%x 0x%x %d > /dev/null", bus, addr, reg, w_data);
fptr = popen(cmd, "w"); fptr = popen(cmd, "w");
if(fptr != NULL) if(fptr != NULL)
@@ -340,7 +341,7 @@ int dni_bmc_data_set(int bus, int addr, int reg, uint8_t w_data)
else else
rv = ONLP_STATUS_E_INVALID; rv = ONLP_STATUS_E_INVALID;
pclose(fptr); pclose(fptr);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }
@@ -362,7 +363,7 @@ int dni_bmc_fanpresent_info_get(uint8_t *fan_present_bit)
if(ipmi_data_update == 1) if(ipmi_data_update == 1)
{ {
DNI_BUS_LOCK(); DNI_LOCK();
fan.time = new_tv.tv_sec; fan.time = new_tv.tv_sec;
sprintf(fanpresent_cmd, "ipmitool raw 0x38 0x0e"); sprintf(fanpresent_cmd, "ipmitool raw 0x38 0x0e");
fptr = popen(fanpresent_cmd, "r"); fptr = popen(fanpresent_cmd, "r");
@@ -379,7 +380,7 @@ int dni_bmc_fanpresent_info_get(uint8_t *fan_present_bit)
else else
rv = ONLP_STATUS_E_INVALID; rv = ONLP_STATUS_E_INVALID;
pclose(fptr); pclose(fptr);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
} }
*fan_present_bit = fan.data; *fan_present_bit = fan.data;
@@ -448,7 +449,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number)
if(ipmi_data_update == 1) if(ipmi_data_update == 1)
{ {
DNI_BUS_LOCK(); DNI_LOCK();
if(dni_ipmi_data_time_check(file_last_time, psu_eeprom_check.time, PSU_EEPROM_TIME_THRESHOLD)) if(dni_ipmi_data_time_check(file_last_time, psu_eeprom_check.time, PSU_EEPROM_TIME_THRESHOLD))
{ {
for(psu_num = 1; psu_num < 3; psu_num++) for(psu_num = 1; psu_num < 3; psu_num++)
@@ -478,7 +479,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number)
} }
} }
psu_eeprom_check.time = new_tv.tv_sec; psu_eeprom_check.time = new_tv.tv_sec;
DNI_BUS_UNLOCK(); DNI_UNLOCK();
} }
for(table_num = 0; table_num < 2 ; table_num++) for(table_num = 0; table_num < 2 ; table_num++)
{ {
@@ -497,7 +498,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number)
END: END:
return rv; return rv;
} }
#endif
int hex_to_int(char hex_input) int hex_to_int(char hex_input)
{ {
int first = hex_input / 16 - 3; int first = hex_input / 16 - 3;
@@ -543,26 +544,26 @@ int dni_i2c_lock_read(mux_info_t * mux_info, dev_info_t * dev_info)
{ {
int r_data = 0; int r_data = 0;
DNI_BUS_LOCK(); DNI_LOCK();
if(dev_info->size == 1) if(dev_info->size == 1)
r_data = onlp_i2c_readb(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags); r_data = onlp_i2c_readb(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags);
else else
r_data = onlp_i2c_readw(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags); r_data = onlp_i2c_readw(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return r_data; return r_data;
} }
int dni_i2c_lock_write(mux_info_t * mux_info, dev_info_t * dev_info) int dni_i2c_lock_write(mux_info_t * mux_info, dev_info_t * dev_info)
{ {
DNI_BUS_LOCK(); DNI_LOCK();
/* Write size */ /* Write size */
if(dev_info->size == 1) if(dev_info->size == 1)
onlp_i2c_write(dev_info->bus, dev_info->addr, dev_info->offset, 1, &dev_info->data_8, dev_info->flags); onlp_i2c_write(dev_info->bus, dev_info->addr, dev_info->offset, 1, &dev_info->data_8, dev_info->flags);
else else
onlp_i2c_writew(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->data_16, dev_info->flags); onlp_i2c_writew(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->data_16, dev_info->flags);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return 0; return 0;
} }
@@ -571,14 +572,14 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath)
int fd, nbytes = 10, rv = -1; int fd, nbytes = 10, rv = -1;
char r_data[10] = {0}; char r_data[10] = {0};
DNI_BUS_LOCK(); DNI_LOCK();
if ((fd = open(fullpath, O_RDONLY)) >= 0) if ((fd = open(fullpath, O_RDONLY)) >= 0)
{ {
if ((read(fd, r_data, nbytes)) > 0) if ((read(fd, r_data, nbytes)) > 0)
rv = atoi(r_data); rv = atoi(r_data);
} }
close(fd); close(fd);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }
@@ -586,7 +587,7 @@ int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullp
{ {
int fd, rv = -1; int fd, rv = -1;
DNI_BUS_LOCK(); DNI_LOCK();
/* Create output file descriptor */ /* Create output file descriptor */
if ((fd = open(fullpath, O_WRONLY, 0644)) >= 0) if ((fd = open(fullpath, O_WRONLY, 0644)) >= 0)
{ {
@@ -597,7 +598,7 @@ int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullp
} }
} }
close(fd); close(fd);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }
@@ -613,7 +614,7 @@ int dni_lock_cpld_read_attribute(char *cpld_path, int addr)
sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path); sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path);
sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path); sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path);
sprintf(address, "0x%02x", addr); sprintf(address, "0x%02x", addr);
DNI_BUS_LOCK(); DNI_LOCK();
/* Create output file descriptor */ /* Create output file descriptor */
if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0)
{ {
@@ -632,7 +633,7 @@ int dni_lock_cpld_read_attribute(char *cpld_path, int addr)
} }
} }
close(fd); close(fd);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }
@@ -648,7 +649,7 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data)
sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path); sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path);
sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path); sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path);
sprintf(address, "0x%02x", addr); sprintf(address, "0x%02x", addr);
DNI_BUS_LOCK(); DNI_LOCK();
/* Create output file descriptor */ /* Create output file descriptor */
if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0)
{ {
@@ -668,7 +669,7 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data)
} }
} }
close(fd); close(fd);
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }
@@ -692,8 +693,7 @@ int dni_fan_present(int id)
} }
else else
rv = ONLP_STATUS_E_INVALID; rv = ONLP_STATUS_E_INVALID;
#endif #elif defined I2C
#ifdef I2C
int fantray_present = -1; int fantray_present = -1;
switch(id) { switch(id) {
case LED_REAR_FAN_TRAY_1: case LED_REAR_FAN_TRAY_1:
@@ -748,7 +748,7 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in
{ {
int fd, rv = 0; int fd, rv = 0;
int len; int len;
DNI_BUS_LOCK(); DNI_LOCK();
if ((buffer == NULL) || (buf_size < 0)) { if ((buffer == NULL) || (buf_size < 0)) {
rv = -1; rv = -1;
@@ -777,7 +777,7 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in
} }
ERROR: ERROR:
DNI_BUS_UNLOCK(); DNI_UNLOCK();
return rv; return rv;
} }

View File

@@ -31,6 +31,7 @@
#include <onlplib/shlocks.h> #include <onlplib/shlocks.h>
#define BMC #define BMC
//#define I2C
typedef unsigned int UINT4; typedef unsigned int UINT4;

View File

@@ -57,7 +57,8 @@ static int dni_psu_pmbus_info_get(int id, char *node, int *value)
*value = 0; *value = 0;
switch (id) { switch(id)
{
case PSU1_ID: case PSU1_ID:
sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node);
break; break;
@@ -84,6 +85,13 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{ {
int ret = ONLP_STATUS_OK; int ret = ONLP_STATUS_OK;
int local_id; int local_id;
local_id = ONLP_OID_ID_GET(info->hdr.id);
/* Set the associated oid_table
* Set PSU's fan and thermal to child OID */
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(local_id + CHASSIS_FAN_COUNT);
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(local_id + CHASSIS_THERMAL_COUNT);
#ifdef BMC #ifdef BMC
int i = 0; int i = 0;
char device_name[10] = {0}; char device_name[10] = {0};
@@ -93,20 +101,8 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info)
char name1[20] = {0}; char name1[20] = {0};
char *module_name = name; char *module_name = name;
char *module_name1 = name1; char *module_name1 = name1;
#endif
#ifdef I2C
int val = 0;
char val_char[16] = {'\0'};
char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'};
#endif
local_id = ONLP_OID_ID_GET(info->hdr.id);
/* Set the associated oid_table
* Set PSU's fan and thermal to child OID */
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(local_id + CHASSIS_FAN_COUNT);
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(local_id + CHASSIS_THERMAL_COUNT);
#ifdef BMC
/* get psu model name */ /* get psu model name */
if(dni_bmc_psueeprom_info_get(name, "Product Name", local_id) == ONLP_STATUS_OK) if(dni_bmc_psueeprom_info_get(name, "Product Name", local_id) == ONLP_STATUS_OK)
{ {
@@ -189,17 +185,34 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info)
} }
else else
info->caps |= ONLP_PSU_STATUS_UNPLUGGED; info->caps |= ONLP_PSU_STATUS_UNPLUGGED;
#endif
#ifdef I2C #elif defined I2C
int val = 0;
char val_char[15] = {'\0'};
char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'};
char psu_path[PSU_NODE_MAX_PATH_LEN] = {'\0'};
int index = ONLP_OID_ID_GET(info->hdr.id); int index = ONLP_OID_ID_GET(info->hdr.id);
switch(index)
{
case PSU1_ID:
sprintf(psu_path, "%s", PSU1_AC_PMBUS_PREFIX);
break;
case PSU2_ID:
sprintf(psu_path, "%s", PSU2_AC_PMBUS_PREFIX);
break;
default:
break;
}
/* Read PSU product name from attribute */ /* Read PSU product name from attribute */
sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, "psu_mfr_model"); sprintf(node_path, "%s%s", psu_path, "psu_mfr_model");
dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0); dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0);
strcpy(info->model, val_char); strcpy(info->model, val_char);
/* Read PSU serial number from attribute */ /* Read PSU serial number from attribute */
sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, "psu_mfr_serial"); sprintf(node_path, "%s%s", psu_path, "psu_mfr_serial");
dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0); dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0);
strcpy(info->serial, val_char); strcpy(info->serial, val_char);
@@ -239,6 +252,7 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info)
info->mpout = val; info->mpout = val;
info->caps |= ONLP_PSU_CAPS_POUT; info->caps |= ONLP_PSU_CAPS_POUT;
} }
#endif #endif
return ret; return ret;
} }
@@ -247,15 +261,6 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{ {
int ret = ONLP_STATUS_OK; int ret = ONLP_STATUS_OK;
int index = ONLP_OID_ID_GET(id); int index = ONLP_OID_ID_GET(id);
#ifdef BMC
char device_name[10] = {0};
UINT4 u4Data = 0;
UINT4 multiplier = 1000;
#endif
#ifdef I2C
int psu_present = -1;
int val = 0;
#endif
VALIDATE(id); VALIDATE(id);
@@ -263,6 +268,10 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
memset(info, 0, sizeof(onlp_psu_info_t)); memset(info, 0, sizeof(onlp_psu_info_t));
*info = pinfo[index]; *info = pinfo[index];
#ifdef BMC #ifdef BMC
char device_name[10] = {0};
UINT4 u4Data = 0;
UINT4 multiplier = 1000;
/* Check PSU have voltage input or not */ /* Check PSU have voltage input or not */
sprintf(device_name, "PSU%d_Vin", index); sprintf(device_name, "PSU%d_Vin", index);
if(dni_bmc_sensor_read(device_name, &u4Data, multiplier, PSU_SENSOR) == ONLP_STATUS_OK) if(dni_bmc_sensor_read(device_name, &u4Data, multiplier, PSU_SENSOR) == ONLP_STATUS_OK)
@@ -276,9 +285,12 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
info->status = ONLP_PSU_STATUS_PRESENT; info->status = ONLP_PSU_STATUS_PRESENT;
info->caps |= ONLP_PSU_CAPS_VIN; info->caps |= ONLP_PSU_CAPS_VIN;
} }
#endif #elif defined I2C
#ifdef I2C int psu_present = -1;
switch (index) { int val = 0;
switch(index)
{
case PSU1_ID: case PSU1_ID:
psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);
break; break;
@@ -293,22 +305,23 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
dni_psu_pmbus_info_get(index, "psu_v_in", &val); dni_psu_pmbus_info_get(index, "psu_v_in", &val);
/* Check PSU is PRESENT or not */ /* Check PSU is PRESENT or not */
if(psu_present == 0) if(val == 0 && psu_present == 1)
info->status |= ONLP_PSU_STATUS_PRESENT;
else if(val == 0 && psu_present == 1)
{ {
/* PSU is not PRESENT */ /* PSU is not PRESENT */
/* Able to read PSU VIN(psu_power_not_good) */ /* Able to read PSU VIN(psu_power_not_good) */
info->status |= ONLP_PSU_STATUS_FAILED; info->status |= ONLP_PSU_STATUS_FAILED;
return ret; return ret;
} }
else else if(val == 0 && psu_present == 0)
{ {
/* Unable to read PSU VIN(psu_power_good) */ /* Unable to read PSU VIN(psu_power_good) */
info->status |= ONLP_PSU_STATUS_UNPLUGGED; info->status |= ONLP_PSU_STATUS_UNPLUGGED;
} }
else
{
info->status |= ONLP_PSU_STATUS_PRESENT;
}
#endif #endif
ret = dni_psu_info_get(id, info); ret = dni_psu_info_get(id, info);
return ret; return ret;
} }

View File

@@ -77,10 +77,10 @@ int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
int onlp_sfpi_is_present(int port) int onlp_sfpi_is_present(int port)
{ {
int present, present_bit = 0x00;
#ifdef BMC #ifdef BMC
uint8_t reg_t = 0x00; uint8_t reg_t = 0x00;
int bit_t = 0x00; int bit_t = 0x00;
int present, present_bit = 0x00;
if (port > 0 && port < 9) { /* SFP Port 1-8 */ if (port > 0 && port < 9) { /* SFP Port 1-8 */
reg_t = SFP_PRESENCE_1; reg_t = SFP_PRESENCE_1;
@@ -116,10 +116,8 @@ int onlp_sfpi_is_present(int port)
present_bit = present_bit & bit_t; present_bit = present_bit & bit_t;
present_bit = present_bit / bit_t; present_bit = present_bit / bit_t;
} }
#endif #elif defined I2C
#ifdef I2C
char port_data[3] = {'\0'}; char port_data[3] = {'\0'};
int present, present_bit;
if(port > 0 && port < 55) if(port > 0 && port < 55)
{ {
@@ -155,12 +153,12 @@ int onlp_sfpi_is_present(int port)
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{ {
int count = 0;
uint8_t bytes[7] = {0};
#ifdef BMC #ifdef BMC
uint8_t reg_t = 0x00; uint8_t reg_t = 0x00;
int present_data = 0x00; int present_data = 0x00;
uint8_t r_array[7] = {0}; uint8_t r_array[7] = {0};
uint8_t bytes[7] = {0};
int count = 0;
/* Read presence bitmap from SWPLD2 SFP+ and SWPLD1 QSFP28 Presence Register /* Read presence bitmap from SWPLD2 SFP+ and SWPLD1 QSFP28 Presence Register
* if only port 0 is present, return 3F FF FF FF FF FF FE * if only port 0 is present, return 3F FF FF FF FF FF FE
@@ -185,14 +183,14 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
for (count = 0; count < 7; count++) { for (count = 0; count < 7; count++) {
bytes[count] = ~r_array[6 - count]; bytes[count] = ~r_array[6 - count];
} }
#endif #elif defined I2C
#ifdef I2C
char present_all_data[21] = {'\0'}; char present_all_data[21] = {'\0'};
char *r_byte; char *r_byte;
char *r_array[7]; char *r_array[7];
uint8_t bytes[7] = {0};
int count = 0; /* Read presence bitmap from SWPLD2 SFP+ and SWPLD1 QSFP28 Presence Register
* if only port 0 is present, return 3F FF FF FF FF FF FE
* if only port 0 and 1 present, return 3F FF FF FF FF FF FC */
if(dni_i2c_read_attribute_string(SFP_IS_PRESENT_ALL_PATH, present_all_data, if(dni_i2c_read_attribute_string(SFP_IS_PRESENT_ALL_PATH, present_all_data,
sizeof(present_all_data), 0) < 0) { sizeof(present_all_data), 0) < 0) {
@@ -205,6 +203,7 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
r_array[count++] = r_byte; r_array[count++] = r_byte;
r_byte = strtok(NULL, " "); r_byte = strtok(NULL, " ");
} }
/* Convert a string to unsigned 8 bit integer /* Convert a string to unsigned 8 bit integer
* and saved into bytes[] */ * and saved into bytes[] */
for (count = 0; count < 7; count++) { for (count = 0; count < 7; count++) {
@@ -212,7 +211,6 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
} }
#endif #endif
/* Mask out non-existant SFP/QSFP ports */ /* Mask out non-existant SFP/QSFP ports */
bytes[0] &= 0x3F; bytes[0] &= 0x3F;
@@ -220,6 +218,7 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
int i = 0; int i = 0;
uint64_t presence_all = 0; uint64_t presence_all = 0;
for(i = 0; i < AIM_ARRAYSIZE(bytes); i++) { for(i = 0; i < AIM_ARRAYSIZE(bytes); i++) {
presence_all <<= 8; presence_all <<= 8;
presence_all |= bytes[i]; presence_all |= bytes[i];
@@ -265,28 +264,13 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
uint8_t reg_t = 0x00; uint8_t reg_t = 0x00;
int rdata_bit = 0x00; int rdata_bit = 0x00;
int bit_t = 0x00; int bit_t = 0x00;
#endif
#ifdef I2C
char port_data[3] = {'\0'};
if(port > 0 && port < 55)
{
/* Select SFP(1-48), QSFP(49-54) port */
sprintf(port_data, "%d", port );
if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
#endif
switch (control) { switch (control) {
case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_RESET_STATE:
/* From sfp_reset value, /* From sfp_reset value,
* return 0 = The module is in Reset * return 0 = The module is in Reset
* return 1 = The module is not in Reset */ * return 1 = The module is not in Reset */
#ifdef BMC
if (port > 48 && port < 55) { /* QSFP Port 49-54 */ if (port > 48 && port < 55) { /* QSFP Port 49-54 */
reg_t = QSFP_RESET; reg_t = QSFP_RESET;
if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &rdata_bit) != ONLP_STATUS_OK) if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &rdata_bit) != ONLP_STATUS_OK)
@@ -303,25 +287,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
*value = 1; *value = 1;
else if (rdata_bit == 1) else if (rdata_bit == 1)
*value = 0; *value = 0;
#endif
#ifdef I2C
*value = dni_i2c_lock_read_attribute(NULL, QSFP_RESET_PATH);
if (*value == 0)
{
*value = 1;
}
else if (*value == 1)
{
*value = 0;
}
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_RX_LOS: case ONLP_SFP_CONTROL_RX_LOS:
/* From sfp_rx_los value, /* From sfp_rx_los value,
* return 0 = The module is Normal Operation * return 0 = The module is Normal Operation
* return 1 = The module is Error */ * return 1 = The module is Error */
#ifdef BMC
if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 49) { /* SFP */
if (port > 0 && port < 9) { /* SFP Port 1-8 */ if (port > 0 && port < 9) { /* SFP Port 1-8 */
reg_t = SFP_RXLOS_1; reg_t = SFP_RXLOS_1;
@@ -347,19 +320,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rdata_bit = 1; /* return 1, module Error */ rdata_bit = 1; /* return 1, module Error */
} }
*value = rdata_bit; *value = rdata_bit;
#endif
#ifdef I2C
*value = dni_i2c_lock_read_attribute(NULL, SFP_RX_LOS_PATH);
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_TX_DISABLE: case ONLP_SFP_CONTROL_TX_DISABLE:
/* From sfp_tx_disable value, /* From sfp_tx_disable value,
* return 0 = The module is Enable Transmitter on * return 0 = The module is Enable Transmitter on
* return 1 = The module is Transmitter Disabled */ * return 1 = The module is Transmitter Disabled */
#ifdef BMC
if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 49) { /* SFP */
if (port > 0 && port < 9) { /* SFP Port 1-8 */ if (port > 0 && port < 9) { /* SFP Port 1-8 */
reg_t = SFP_TXDIS_1; reg_t = SFP_TXDIS_1;
@@ -385,18 +353,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rdata_bit = 1; /* return 1, module Transmitter Disabled */ rdata_bit = 1; /* return 1, module Transmitter Disabled */
} }
*value = rdata_bit; *value = rdata_bit;
#endif
#ifdef I2C
*value = dni_i2c_lock_read_attribute(NULL, SFP_TX_DISABLE_PATH);
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_TX_FAULT: case ONLP_SFP_CONTROL_TX_FAULT:
/* From sfp_tx_fault value, /* From sfp_tx_fault value,
* return 0 = The module is Normal * return 0 = The module is Normal
* return 1 = The module is Fault */ * return 1 = The module is Fault */
#ifdef BMC
if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 49) { /* SFP */
if (port > 0 && port < 9) { /* SFP Port 1-8 */ if (port > 0 && port < 9) { /* SFP Port 1-8 */
reg_t = SFP_TXFAULT_1; reg_t = SFP_TXFAULT_1;
@@ -422,14 +386,10 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rdata_bit = 1; /* return 1, module is Fault */ rdata_bit = 1; /* return 1, module is Fault */
} }
*value = rdata_bit; *value = rdata_bit;
#endif
#ifdef I2C
*value = dni_i2c_lock_read_attribute(NULL, SFP_TX_FAULT_PATH);
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_LP_MODE: case ONLP_SFP_CONTROL_LP_MODE:
#ifdef BMC
/* From sfp_lp_mode value, /* From sfp_lp_mode value,
* return 0 = The module is not in LP mode * return 0 = The module is not in LP mode
* return 1 = The module is in LP mode */ * return 1 = The module is in LP mode */
@@ -446,29 +406,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
rdata_bit = 0; /* return 0, module is not in LP mode */ rdata_bit = 0; /* return 0, module is not in LP mode */
} }
*value = rdata_bit; *value = rdata_bit;
#endif
#ifdef I2C
*value = dni_i2c_lock_read_attribute(NULL, QSFP_LP_MODE_PATH);
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
default: default:
value_t = ONLP_STATUS_E_UNSUPPORTED; value_t = ONLP_STATUS_E_UNSUPPORTED;
break; break;
} }
return value_t; #elif defined I2C
}
int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
int value_t;
#ifdef BMC
uint8_t reg_t = 0x00;
int data_bit = 0x00;
int bit_t = 0x00;
#endif
#ifdef I2C
char port_data[3] = {'\0'}; char port_data[3] = {'\0'};
if(port > 0 && port < 55) if(port > 0 && port < 55)
@@ -480,11 +425,69 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
return ONLP_STATUS_E_INTERNAL; return ONLP_STATUS_E_INTERNAL;
} }
} }
#endif
switch (control) { switch (control) {
case ONLP_SFP_CONTROL_RESET_STATE: case ONLP_SFP_CONTROL_RESET_STATE:
/* From sfp_reset value,
* return 0 = The module is in Reset
* return 1 = The module is NOT in Reset */
*value = dni_i2c_lock_read_attribute(NULL, QSFP_RESET_PATH);
if (*value == 0)
{
*value = 1;
}
else if (*value == 1)
{
*value = 0;
}
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_RX_LOS:
/* From sfp_rx_los value,
* return 0 = The module is Normal Operation
* return 1 = The module is Error */
*value = dni_i2c_lock_read_attribute(NULL, SFP_RX_LOS_PATH);
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_TX_DISABLE:
/* From sfp_tx_disable value,
* return 0 = The module is Enable Transmitter on
* return 1 = The module is Transmitter Disabled */
*value = dni_i2c_lock_read_attribute(NULL, SFP_TX_DISABLE_PATH);
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_TX_FAULT:
/* From sfp_tx_fault value,
* return 0 = The module is Normal
* return 1 = The module is Fault */
*value = dni_i2c_lock_read_attribute(NULL, SFP_TX_FAULT_PATH);
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_LP_MODE:
/* From sfp_lp_mode value,
* return 0 = The module is NOT in LP mode
* return 1 = The module is in LP mode */
*value = dni_i2c_lock_read_attribute(NULL, QSFP_LP_MODE_PATH);
value_t = ONLP_STATUS_OK;
break;
default:
value_t = ONLP_STATUS_E_UNSUPPORTED;
break;
}
#endif
return value_t;
}
int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
int value_t;
#ifdef BMC #ifdef BMC
uint8_t reg_t = 0x00;
int data_bit = 0x00;
int bit_t = 0x00;
switch (control) {
case ONLP_SFP_CONTROL_RESET_STATE:
if (port > 48 && port < 55) { /* QSFP Port 49-54 */ if (port > 48 && port < 55) { /* QSFP Port 49-54 */
reg_t = QSFP_RESET; reg_t = QSFP_RESET;
if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK) if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK)
@@ -506,21 +509,13 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
} else { } else {
return ONLP_STATUS_E_UNSUPPORTED; return ONLP_STATUS_E_UNSUPPORTED;
} }
#endif
#ifdef I2C
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_RESET_PATH) < 0){
AIM_LOG_INFO("Unable to control reset state from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_RX_LOS: case ONLP_SFP_CONTROL_RX_LOS:
value_t = ONLP_STATUS_E_UNSUPPORTED; value_t = ONLP_STATUS_E_UNSUPPORTED;
break; break;
case ONLP_SFP_CONTROL_TX_DISABLE: case ONLP_SFP_CONTROL_TX_DISABLE:
#ifdef BMC
if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 49) { /* SFP */
if (port > 0 && port < 9) { /* SFP Port 1-8 */ if (port > 0 && port < 9) { /* SFP Port 1-8 */
reg_t = SFP_TXDIS_1; reg_t = SFP_TXDIS_1;
@@ -555,21 +550,13 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
} else { } else {
return ONLP_STATUS_E_UNSUPPORTED; return ONLP_STATUS_E_UNSUPPORTED;
} }
#endif
#ifdef I2Ci
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_TX_DISABLE_PATH) < 0){
AIM_LOG_INFO("Unable to control tx disable from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
case ONLP_SFP_CONTROL_TX_FAULT: case ONLP_SFP_CONTROL_TX_FAULT:
value_t = ONLP_STATUS_E_UNSUPPORTED; value_t = ONLP_STATUS_E_UNSUPPORTED;
break; break;
case ONLP_SFP_CONTROL_LP_MODE: case ONLP_SFP_CONTROL_LP_MODE:
#ifdef BMC
if (port > 48 && port < 55) { /* QSFP Port 49-54 */ if (port > 48 && port < 55) { /* QSFP Port 49-54 */
reg_t = QSFP_LPMODE; reg_t = QSFP_LPMODE;
if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK) if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK)
@@ -591,20 +578,62 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
} else { } else {
return ONLP_STATUS_E_UNSUPPORTED; return ONLP_STATUS_E_UNSUPPORTED;
} }
#endif
#ifdef I2C
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_LP_MODE_PATH) < 0){
AIM_LOG_INFO("Unable to control LP mode from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
#endif
value_t = ONLP_STATUS_OK; value_t = ONLP_STATUS_OK;
break; break;
default: default:
value_t = ONLP_STATUS_E_UNSUPPORTED; value_t = ONLP_STATUS_E_UNSUPPORTED;
break; break;
} }
#elif defined I2C
char port_data[3] = {'\0'};
if(port > 0 && port < 55)
{
/* Select SFP(1-48), QSFP(49-54) port */
sprintf(port_data, "%d", port );
if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
switch (control) {
case ONLP_SFP_CONTROL_RESET_STATE:
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_RESET_PATH) < 0){
AIM_LOG_INFO("Unable to control reset state from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_RX_LOS:
value_t = ONLP_STATUS_E_UNSUPPORTED;
break;
case ONLP_SFP_CONTROL_TX_DISABLE:
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_TX_DISABLE_PATH) < 0){
AIM_LOG_INFO("Unable to control tx disable from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
value_t = ONLP_STATUS_OK;
break;
case ONLP_SFP_CONTROL_TX_FAULT:
value_t = ONLP_STATUS_E_UNSUPPORTED;
break;
case ONLP_SFP_CONTROL_LP_MODE:
sprintf(port_data, "%d", value);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_LP_MODE_PATH) < 0){
AIM_LOG_INFO("Unable to control LP mode from port(%d)\r\n", port);
value_t = ONLP_STATUS_E_INTERNAL;
}
value_t = ONLP_STATUS_OK;
break;
default:
value_t = ONLP_STATUS_E_UNSUPPORTED;
break;
}
#endif
return value_t; return value_t;
} }
@@ -700,23 +729,17 @@ int onlp_sfpi_denit(void)
int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
{ {
int count = 0;
uint8_t bytes[6] = {0};
#ifdef BMC #ifdef BMC
uint8_t reg_t = 0x00; uint8_t reg_t = 0x00;
int rxlos_data = 0x00; int rxlos_data = 0x00;
uint8_t r_array[6] = {0}; uint8_t r_array[6] = {0};
#endif
#ifdef I2C
char rxlos_all_data[18] = {'\0'};
char *r_byte;
char *r_array[6];
#endif
uint8_t bytes[6] = {0};
int count = 0;
/* Read rx_los bitmap from SWPLD2 SFP+ LOSS Register /* Read rx_los bitmap from SWPLD2 SFP+ LOSS Register
* if only port 0 is normal operation, return FF FF FF FF FF FE * if only port 0 is normal operation, return FF FF FF FF FF FE
* if only port 0 and 1 normal operation, return FF FF FF FF FF FC */ * if only port 0 and 1 normal operation, return FF FF FF FF FF FC */
#ifdef BMC
for (count = 0; count < 6; count++) { /* SFP Port 1-48 */ for (count = 0; count < 6; count++) { /* SFP Port 1-48 */
reg_t = SFP_RXLOS_1 + count; reg_t = SFP_RXLOS_1 + count;
if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &rxlos_data) != ONLP_STATUS_OK) if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &rxlos_data) != ONLP_STATUS_OK)
@@ -728,8 +751,15 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
for (count = 0; count < 6; count++) { for (count = 0; count < 6; count++) {
bytes[count] = r_array[5 - count]; bytes[count] = r_array[5 - count];
} }
#endif #elif defined I2C
#ifdef I2C char rxlos_all_data[18] = {'\0'};
char *r_byte;
char *r_array[6];
/* Read rx_los bitmap from SWPLD2 SFP+ LOSS Register
* if only port 0 is normal operation, return FF FF FF FF FF FE
* if only port 0 and 1 normal operation, return FF FF FF FF FF FC */
if(dni_i2c_read_attribute_string(SFP_RX_LOS_ALL_PATH, rxlos_all_data, if(dni_i2c_read_attribute_string(SFP_RX_LOS_ALL_PATH, rxlos_all_data,
sizeof(rxlos_all_data), 0) < 0) { sizeof(rxlos_all_data), 0) < 0) {
return -1; return -1;
@@ -741,6 +771,7 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
r_array[count++] = r_byte; r_array[count++] = r_byte;
r_byte = strtok(NULL, " "); r_byte = strtok(NULL, " ");
} }
/* Convert a string to unsigned 8 bit integer /* Convert a string to unsigned 8 bit integer
* and saved into bytes[] */ * and saved into bytes[] */
for (count = 0; count < 6; count++) { for (count = 0; count < 6; count++) {
@@ -768,6 +799,7 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
AIM_BITMAP_MOD(dst, i+1, 0); AIM_BITMAP_MOD(dst, i+1, 0);
return ONLP_STATUS_OK; return ONLP_STATUS_OK;
} }
int onlp_sfpi_dom_read(int port, uint8_t data[256]) int onlp_sfpi_dom_read(int port, uint8_t data[256])

View File

@@ -204,7 +204,7 @@ int onlp_sysi_platform_manage_leds(void)
int rpm = 0, rpm1 = 0, count = 0; int rpm = 0, rpm1 = 0, count = 0;
int fantray_count; int fantray_count;
char fantray_count_str[2] = {'\0'}; char fantray_count_str[2] = {'\0'};
uint8_t psu_state; uint8_t psu1_state, psu2_state;
int psu_pwr_status = 0; int psu_pwr_status = 0;
int psu_pwr_int = 0; int psu_pwr_int = 0;
int fantray_present = -1; int fantray_present = -1;
@@ -308,26 +308,13 @@ int onlp_sysi_platform_manage_leds(void)
} }
/* Set front light of PWR */ /* Set front light of PWR */
psu_state = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); psu1_state = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH);
psu2_state = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH);
psu_pwr_status = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_STATUS_REGISTER); psu_pwr_status = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_STATUS_REGISTER);
psu_pwr_int = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_INT_REGISTER); psu_pwr_int = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_INT_REGISTER);
if(psu_state == 0 && (psu_pwr_status & 0x80) == 0x80 && (psu_pwr_int & 0x10) == 0x10)
{
/* Green */
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
rv = ONLP_STATUS_E_INTERNAL;
}
else
{
/* Amber */
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_YELLOW) != ONLP_STATUS_OK)
rv = ONLP_STATUS_E_INTERNAL;
}
psu_state = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH); if(psu1_state == 0 && psu2_state == 0 && (psu_pwr_status & 0xc0) == 0xc0 && (psu_pwr_int & 0x30) == 0x30)
if(psu_state == 0 && (psu_pwr_status & 0x40) == 0x40 && (psu_pwr_int & 0x20) == 0x20)
{ {
/* Green */ /* Green */
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK) if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)

View File

@@ -134,22 +134,16 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{ {
uint8_t local_id = 0; uint8_t local_id = 0;
int rv = ONLP_STATUS_OK; int rv = ONLP_STATUS_OK;
#ifdef BMC
UINT4 multiplier = 1000;
UINT4 u4Data = 0;
char device_buf[20] = {0};
#endif
#ifdef I2C
int temp_base = 1;
char fullpath[50] = {0};
int r_data = 0;
#endif
VALIDATE(id); VALIDATE(id);
local_id = ONLP_OID_ID_GET(id); local_id = ONLP_OID_ID_GET(id);
*info = linfo[local_id]; *info = linfo[local_id];
#ifdef BMC #ifdef BMC
UINT4 multiplier = 1000;
UINT4 u4Data = 0;
char device_buf[20] = {0};
switch(local_id) { switch(local_id) {
case THERMAL_1_ON_FAN_BOARD: case THERMAL_1_ON_FAN_BOARD:
sprintf(device_buf, "Fan_Temp"); sprintf(device_buf, "Fan_Temp");
@@ -187,8 +181,11 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
info->mcelsius = u4Data; info->mcelsius = u4Data;
return 0; return 0;
} }
#endif #elif defined I2C
#ifdef I2C int temp_base = 1;
char fullpath[50] = {0};
int r_data = 0;
switch (local_id) { switch (local_id) {
case THERMAL_1_ON_FAN_BOARD: case THERMAL_1_ON_FAN_BOARD:
sprintf(fullpath,"%s%s", PREFIX_PATH, path[local_id]); sprintf(fullpath,"%s%s", PREFIX_PATH, path[local_id]);