Add error judgment on set/get function.

Signed-off-by: johnson.lu <johnson.lu@deltaww.com>
This commit is contained in:
johnson.lu
2018-04-20 10:36:51 +08:00
parent f634c7d91a
commit b92a1c57e1
6 changed files with 324 additions and 137 deletions

View File

@@ -109,13 +109,18 @@ dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed);
rpm = dni_i2c_lock_read_attribute(&mux_info, fullpath);
if(rpm == -1){
AIM_LOG_ERROR("Unable to read rpm from fan(%d)\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
info->rpm = rpm;
if(info->rpm == FAN_ZERO_RPM)
info->rpm = 0;
/* get speed percentage from rpm */
info->percentage = (info->rpm * 100)/MAX_FRONT_FAN_SPEED;
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
mux_info.channel = FAN_I2C_SEL_FAN_IO_CTRL;
present_bit = dni_i2c_lock_read(&mux_info, &dev_info);
@@ -181,13 +186,19 @@ dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].status);
r_data = dni_i2c_lock_read_attribute(&mux_info, fullpath);
if (r_data == 1) {
if ((r_data == -1)) {
info->status |= ONLP_FAN_STATUS_FAILED;
AIM_LOG_ERROR("Unable to read status from fan(%d)\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
/* Read PSU FAN speed from psu_fan1_speed_rpm */
sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed);
r_data = dni_i2c_lock_read_attribute(&mux_info, fullpath);
if(r_data == -1){
AIM_LOG_ERROR("Unable to read rpm from fan(%d)\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
info->rpm = r_data;
/* get speed percentage from rpm */
@@ -224,9 +235,16 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
case FAN_5_ON_FAN_BOARD:
case FAN_6_ON_FAN_BOARD:
rc = dni_fani_info_get_fan(local_id, info);
if(rc != ONLP_STATUS_OK){
rc = ONLP_STATUS_E_INVALID;
}
break;
case FAN_1_ON_PSU1:
rc = dni_fani_info_get_fan_on_psu(local_id, info);
if(rc != ONLP_STATUS_OK){
rc = ONLP_STATUS_E_INVALID;
}
break;
default:
rc = ONLP_STATUS_E_INVALID;
@@ -252,6 +270,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm)
char data[10] = {0};
char fullpath[70] = {0};
mux_info_t mux_info;
int ret = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
@@ -278,7 +297,11 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm)
mux_info.channel = FAN_I2C_SEL_FAN_CTRL;
mux_info.flags = DEFAULT_FLAG;
dni_i2c_lock_write_attribute(&mux_info, data, fullpath);
ret = dni_i2c_lock_write_attribute(&mux_info, data, fullpath);
if(ret == -1){
AIM_LOG_ERROR("Unable to set fan(%d) rpm\r\n",local_id);
return ONLP_STATUS_E_INVALID;
}
return ONLP_STATUS_OK;
}
@@ -327,7 +350,11 @@ onlp_fani_percentage_set(onlp_oid_t id, int percentage)
/* Write percentage to psu_fan1_duty_cycle_percentage */
sprintf(data, "%d", percentage);
dni_i2c_lock_write_attribute(&mux_info, data, fullpath);
if(dni_i2c_lock_write_attribute(&mux_info, data, fullpath) == -1){
AIM_LOG_ERROR("Unable to set fan(%d) percentage\r\n",local_id);
return ONLP_STATUS_E_INVALID;
}
return ONLP_STATUS_OK;
}

View File

@@ -107,7 +107,11 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
mux_info.flags = DEFAULT_FLAG;
/* Set front panel's mode of leds */
r_data = dni_lock_cpld_read_attribute(CPLD_B_PATH,LED_REG);
r_data = dni_lock_cpld_read_attribute(CPLD_B_PATH,LED_REG);
if(r_data == -1){
AIM_LOG_ERROR("Unable to read front panel led status from reg\r\n");
return ONLP_STATUS_E_INTERNAL;
}
int local_id = ONLP_OID_ID_GET(id);
switch(local_id)
{
@@ -146,6 +150,10 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
dev_info.addr = FAN_TRAY;
mux_info.channel = 0x02;
r_data = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(r_data == -1){
AIM_LOG_ERROR("Unable to read fan tray 1 led status from reg\r\n");
return ONLP_STATUS_E_INTERNAL;
}
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
if(fantray_present >= 0)
{
@@ -164,6 +172,11 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
dev_info.addr = FAN_TRAY;
mux_info.channel = 0x01;
r_data = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(r_data == -1){
AIM_LOG_ERROR("Unable to read fan tray 2 led status from reg\r\n");
return ONLP_STATUS_E_INTERNAL;
}
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
if(fantray_present >= 0)
{
@@ -182,6 +195,11 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
dev_info.addr = FAN_TRAY;
mux_info.channel = 0x00;
r_data = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(r_data == -1){
AIM_LOG_ERROR("Unable to read fan tray 3 led status from reg\r\n");
return ONLP_STATUS_E_INTERNAL;
}
fantray_present = dni_i2c_lock_read(&mux_info, &dev_info);
if(fantray_present >= 0)
{
@@ -244,118 +262,163 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
case LED_FRONT_FAN:
front_panel_led_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,LED_REG);
if(front_panel_led_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
front_panel_led_value &= ~0x30;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
front_panel_led_value |= 0x10;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
else if(mode == ONLP_LED_MODE_ORANGE){
front_panel_led_value |= 0x20;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
else{
front_panel_led_value = front_panel_led_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
case LED_FRONT_SYS:
front_panel_led_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,LED_REG);
if(front_panel_led_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
front_panel_led_value &= ~0x03;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
front_panel_led_value |= 0x03;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
else if(mode == ONLP_LED_MODE_ORANGE){
front_panel_led_value |= 0x01;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_GREEN_BLINKING)
{
else if(mode == ONLP_LED_MODE_GREEN_BLINKING){
front_panel_led_value |= 0x02;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
else{
front_panel_led_value = front_panel_led_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
case LED_FRONT_PWR:
front_panel_led_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,LED_REG);
if(front_panel_led_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
front_panel_led_value &= ~0x0c;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
front_panel_led_value |= 0x0c;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE)
{
else if(mode == ONLP_LED_MODE_ORANGE){
front_panel_led_value |= 0x08;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING)
{
else if(mode == ONLP_LED_MODE_ORANGE_BLINKING){
front_panel_led_value |= 0x04;
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value);
else{
front_panel_led_value = front_panel_led_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,LED_REG,front_panel_led_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
case LED_REAR_FAN_TRAY_1:
fan_tray_led_reg_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(fan_tray_led_reg_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
fan_tray_led_reg_value &= ~0x30;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
fan_tray_led_reg_value |= 0x20;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
else if(mode == ONLP_LED_MODE_RED){
fan_tray_led_reg_value |= 0x10;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
else{
fan_tray_led_reg_value = fan_tray_led_reg_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
case LED_REAR_FAN_TRAY_2:
fan_tray_led_reg_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(fan_tray_led_reg_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
fan_tray_led_reg_value &= ~0x0c;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
fan_tray_led_reg_value |= 0x08;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
else if(mode == ONLP_LED_MODE_RED){
fan_tray_led_reg_value |= 0x04;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
else{
fan_tray_led_reg_value = fan_tray_led_reg_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
case LED_REAR_FAN_TRAY_3:
fan_tray_led_reg_value = dni_lock_cpld_read_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG);
if(fan_tray_led_reg_value == -1 ){
AIM_LOG_ERROR("Unable to read led(%d) status from reg\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
fan_tray_led_reg_value &= ~0x03;
if(mode == ONLP_LED_MODE_GREEN)
{
if(mode == ONLP_LED_MODE_GREEN){
fan_tray_led_reg_value |= 0x02;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else if(mode == ONLP_LED_MODE_RED)
{
else if(mode == ONLP_LED_MODE_RED){
fan_tray_led_reg_value |= 0x01;
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
}
else
dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value);
else{
fan_tray_led_reg_value = fan_tray_led_reg_value;
}
if(dni_lock_cpld_write_attribute(CPLD_B_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value) != 0){
AIM_LOG_ERROR("Unable to set led(%d) status\r\n",local_id);
return ONLP_STATUS_E_INTERNAL;
}
break;
}
return ONLP_STATUS_OK;
}
/*

View File

@@ -37,8 +37,7 @@
#define CHASSIS_FAN_COUNT 6
#define CHASSIS_THERMAL_COUNT 6
#define MAX_REAR_FAN_SPEED 19000
#define MAX_FRONT_FAN_SPEED 19000
#define MAX_FAN_SPEED 19000
#define MAX_PSU_FAN_SPEED 18240
#define NUM_OF_SFP 48

View File

@@ -35,26 +35,21 @@
/******************* Utility Function *****************************************/
int
ak7448_get_respond_val(int port)
{
ak7448_get_respond_val(int port){
int respond_default = 0xff;
int value = 0x00;
if(port > NUM_OF_SFP && port <= (NUM_OF_SFP + NUM_OF_QSFP))
{
if(port > NUM_OF_SFP && port <= (NUM_OF_SFP + NUM_OF_QSFP)){
value = respond_default & (~(1 << ((port % 8)-1)));
return value;
}
else
{
return respond_default;
else{
return respond_default;
}
}
int
ak7448_get_respond_reg(int port)
{
ak7448_get_respond_reg(int port){
return QSFP_RESPOND_REG;
}
@@ -65,15 +60,13 @@ ak7448_get_respond_reg(int port)
***********************************************************/
int
onlp_sfpi_init(void)
{
onlp_sfpi_init(void){
/* Called at initialization time */
return ONLP_STATUS_OK;
}
int
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
{
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap){
/*Ports {1, 52}*/
int p;
AIM_BITMAP_CLR_ALL(bmap);
@@ -85,8 +78,7 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
}
int
onlp_sfpi_is_present(int port)
{
onlp_sfpi_is_present(int port){
char port_data[2];
int present, present_bit;
@@ -94,19 +86,30 @@ onlp_sfpi_is_present(int port)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH) < 0){
AIM_LOG_ERROR("Unable to select port(%d)\r\n", port);
}
/* Read SFP MODULE is present or not */
present_bit = dni_i2c_lock_read_attribute(NULL, SFP_IS_PRESENT_PATH);
if(present_bit < 0){
AIM_LOG_ERROR("Unable to read present or not from port(%d)\r\n", port);
}
}
else if(port > 48 && port < 53)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_ERROR("Unable to select port(%d)\r\n", port);
}
/* Read SFP MODULE is present or not */
present_bit = dni_i2c_lock_read_attribute(NULL, QSFP_IS_PRESENT_PATH);
if(present_bit < 0){
AIM_LOG_ERROR("Unable to read present or not from port(%d)\r\n", port);
}
}
/* From sfp_is_present value,
@@ -193,14 +196,20 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0 ){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
memset(data, 0 ,256);
@@ -243,13 +252,21 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
switch (control) {
@@ -302,20 +319,31 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_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);
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_RESET_PATH);
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:
@@ -326,7 +354,10 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
break;
case ONLP_SFP_CONTROL_LP_MODE:
sprintf(port_data, "%d", value);
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_LP_MODE_PATH);
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:
@@ -356,7 +387,11 @@ onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
@@ -364,7 +399,11 @@ onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
dev_info.addr = PORT_ADDR;
@@ -395,7 +434,10 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
@@ -403,7 +445,10 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
dev_info.addr = PORT_ADDR;
@@ -435,7 +480,11 @@ onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
@@ -443,7 +492,10 @@ onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
dev_info.addr = PORT_ADDR;
@@ -474,7 +526,10 @@ onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
@@ -482,7 +537,10 @@ onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
dev_info.addr = PORT_ADDR;
@@ -503,13 +561,19 @@ onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH);
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;
}
}
else if(port > 48 && port < 53)
{
/* Select QSFP port */
sprintf(port_data, "%d", port );
dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH);
if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_SELECT_PORT_PATH) < 0){
AIM_LOG_INFO("Unable to select port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
}
switch (control) {

View File

@@ -168,6 +168,28 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max)
return 0;
}
int
dni_sysi_set_fan(int new_percentage)
{
int ret = 0;
int i = 0;
for(i = 1; i <= 6 ; i++)
{
ret = onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(i), MAX_FAN_SPEED * new_percentage / 100);
if(ret != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("Unable to set fan(%d) rpm\r\n",ONLP_FAN_ID_CREATE(i));
return ret;
}
}
if(onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) , new_percentage) != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("Unable to set fan(%d) percentage\r\n",ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1));
return ret;
}
return ONLP_STATUS_OK;
}
int
onlp_sysi_platform_manage_fans(void)
{
@@ -176,28 +198,24 @@ onlp_sysi_platform_manage_fans(void)
int highest_temp = 0;
onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS];
/* Get current temperature */
if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), &thermal[0]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), &thermal[1]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BOARD), &thermal[2]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), &thermal[3]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), &thermal[4]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_FAN_BOARD), &thermal[5]) != ONLP_STATUS_OK ||
onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), &thermal[6]) != ONLP_STATUS_OK)
for(i = 1; i <= NUM_OF_THERMAL_ON_BOARDS; i++)
{
//ret = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i),&thermal[i-1]);
if(onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i),&thermal[i-1]) != ONLP_STATUS_OK)
{
/* Setting all fans speed to maximum */
new_percentage = SPEED_100_PERCENTAGE;
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_3_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_4_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_5_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_6_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) , new_percentage);
AIM_LOG_ERROR("Unable to read thermal status");
if(dni_sysi_set_fan(new_percentage) != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("Unable to set fan\r\n");
return ONLP_STATUS_E_INTERNAL;
}
AIM_LOG_ERROR("Unable to read status from thermal(%d)\r\n",i);
return ONLP_STATUS_E_INTERNAL;
}
}
for (i = 0; i < NUM_OF_THERMAL_ON_BOARDS; i++)
{
@@ -210,13 +228,10 @@ onlp_sysi_platform_manage_fans(void)
highest_temp = highest_temp/1000;
decide_percentage(&new_percentage, highest_temp);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_3_ON_FAN_BOARD), MAX_FRONT_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_4_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_5_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_6_ON_FAN_BOARD), MAX_REAR_FAN_SPEED * new_percentage / 100);
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) , new_percentage);
if(dni_sysi_set_fan(new_percentage) != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("Unable to set fan\r\n");
}
return ONLP_STATUS_OK;
}
@@ -250,12 +265,14 @@ onlp_sysi_platform_manage_leds(void)
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
else
{
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
/* Fan tray 2 */
@@ -269,12 +286,14 @@ onlp_sysi_platform_manage_leds(void)
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
else
{
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
/* Fan tray 3 */
@@ -288,12 +307,14 @@ onlp_sysi_platform_manage_leds(void)
if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 )
{
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
else
{
/* Red */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
/* FRONT FAN & SYS LED */
@@ -309,14 +330,16 @@ onlp_sysi_platform_manage_leds(void)
if(count == ALL_FAN_TRAY_EXIST && dni_fan_speed_good() == FAN_SPEED_NORMALLY)
{
/* Green FAN operates normally */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_GREEN);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_GREEN);
if((onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK) ||
(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK))
return ONLP_STATUS_E_INTERNAL;
}
else
{
/* Solid Amber FAN or more failed*/
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE);
if((onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE) != ONLP_STATUS_OK) ||
(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE) != ONLP_STATUS_OK))
return ONLP_STATUS_E_INTERNAL;
}
/* Set front light of PWR */
@@ -336,11 +359,13 @@ onlp_sysi_platform_manage_leds(void)
if(psu_state == 1)
{
/* Green */
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
else
else
{
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF);
if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF) != ONLP_STATUS_OK)
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;

View File

@@ -136,6 +136,12 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
}
switch (local_id) {
case THERMAL_1_ON_CPU_BOARD:
case THERMAL_2_ON_MAIN_BOARD:
case THERMAL_3_ON_MAIN_BOARD:
case THERMAL_4_ON_MAIN_BOARD:
channel = 0x00; /* DEFAULT */
break;
case THERMAL_5_ON_FAN_BOARD:
offset = FAN_I2C_MUX_SEL_REG;
channel = FAN_I2C_SEL_THERMAL;
@@ -145,8 +151,7 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
channel = PSU_I2C_SEL_PSU_EEPROM;
break;
default:
channel = 0x00; /* DEFAULT */
break;
return ONLP_STATUS_E_INVALID;
}
mux_info.bus = I2C_BUS_5;
@@ -156,7 +161,11 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
mux_info.flags = DEFAULT_FLAG;
sprintf(fullpath, "%s%s", PREFIX_PATH, last_path[local_id]);
r_data = dni_i2c_lock_read_attribute(&mux_info, fullpath);
r_data = dni_i2c_lock_read_attribute(&mux_info, fullpath);
if(r_data == -1){
return ONLP_STATUS_E_INTERNAL;
}
/* Current temperature in milli-celsius */
info->mcelsius = r_data / temp_base;