Add LED manage function to sysi.c to 2410 and 2700 systems

Fix led_mode comparation in ledi.c
This commit is contained in:
Oleksandr Shamray oleksandrs@mellanox.com
2017-06-02 16:10:47 +00:00
parent 22e351983a
commit e892e00c8e
7 changed files with 169 additions and 23 deletions

View File

@@ -153,8 +153,11 @@ static onlp_led_info_t linfo[] =
static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode)
{
char *pos;
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
if ((pos=strchr(driver_led_mode, '\n')) != NULL)
*pos = '\0';
for (i = 0; i < nsize; i++)
{
if (id == led_map[i].id &&

View File

@@ -52,16 +52,6 @@
/* LED related data
*/
enum onlp_led_id
{
LED_RESERVED = 0,
LED_SYSTEM,
LED_FAN1,
LED_FAN2,
LED_FAN3,
LED_FAN4,
LED_PSU,
};
typedef struct led_light_mode_map {
enum onlp_led_id id;
@@ -170,8 +160,11 @@ static onlp_led_info_t linfo[] =
static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode)
{
char *pos;
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
if ((pos=strchr(driver_led_mode, '\n')) != NULL)
*pos = '\0';
for (i = 0; i < nsize; i++)
{
if (id == led_map[i].id &&

View File

@@ -42,6 +42,22 @@
#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s"
#define IDPROM_PATH "/bsp/eeprom/%s%d_info"
#define MIN_LIMIT_FRONT_FAN_RPM 21000
#define MIN_LIMIT_REAR_FAN_RPM 21000
/* LED related data
*/
enum onlp_led_id
{
LED_RESERVED = 0,
LED_SYSTEM,
LED_FAN1,
LED_FAN2,
LED_FAN3,
LED_FAN4,
LED_PSU,
};
typedef enum psu_type {
PSU_TYPE_UNKNOWN,
PSU_TYPE_AC_F2B,

View File

@@ -132,3 +132,67 @@ onlp_sysi_onie_info_get(onlp_onie_info_t* onie)
return rv;
}
int
onlp_sysi_platform_manage_leds(void)
{
int fan_number;
onlp_led_mode_t mode;
enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 };
/* after reboot, status LED should blink green, SW set to solid green */
onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), ONLP_LED_MODE_GREEN);
/*
* FAN Indicators
*
* Green - Fan is operating
* Red - No power or Fan failure
* Off - No power
*
*/
for( fan_number = 1; fan_number<= 8; fan_number+=2)
{
/* each 2 fans had same led_fan */
onlp_fan_info_t fi;
/* check fan i */
mode = ONLP_LED_MODE_GREEN;
if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) {
mode = ONLP_LED_MODE_RED;
}
else if( (fi.status & 0x1) == 0) {
/* Not present */
mode = ONLP_LED_MODE_RED;
}
else if(fi.status & ONLP_FAN_STATUS_FAILED) {
mode = ONLP_LED_MODE_RED;
}
else
{
if( fi.rpm < MIN_LIMIT_FRONT_FAN_RPM )
{
mode = ONLP_LED_MODE_RED;
}
}
/* check fan i+1 */
if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) {
mode = ONLP_LED_MODE_RED;
}
else if( (fi.status & 0x1) == 0) {
/* Not present */
mode = ONLP_LED_MODE_RED;
}
else if(fi.status & ONLP_FAN_STATUS_FAILED) {
mode = ONLP_LED_MODE_RED;
}
else
{
if( fi.rpm < MIN_LIMIT_REAR_FAN_RPM )
{
mode = ONLP_LED_MODE_RED;
}
}
onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode);
}
return ONLP_STATUS_OK;
}

View File

@@ -50,19 +50,6 @@
} \
} while(0)
/* LED related data
*/
enum onlp_led_id
{
LED_RESERVED = 0,
LED_SYSTEM,
LED_FAN1,
LED_FAN2,
LED_FAN3,
LED_FAN4,
LED_PSU,
};
typedef struct led_light_mode_map {
enum onlp_led_id id;
char* driver_led_mode;
@@ -170,8 +157,11 @@ static onlp_led_info_t linfo[] =
static int driver_to_onlp_led_mode(enum onlp_led_id id, char* driver_led_mode)
{
char *pos;
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
if ((pos=strchr(driver_led_mode, '\n')) != NULL)
*pos = '\0';
for (i = 0; i < nsize; i++)
{
if (id == led_map[i].id &&

View File

@@ -44,6 +44,22 @@
#define PSU_POWER_PREFIX "/bsp/power/psu%d_%s"
#define IDPROM_PATH "/bsp/eeprom/%s%d_info"
#define MIN_LIMIT_FRONT_FAN_RPM 21000
#define MIN_LIMIT_REAR_FAN_RPM 21000
/* LED related data
*/
enum onlp_led_id
{
LED_RESERVED = 0,
LED_SYSTEM,
LED_FAN1,
LED_FAN2,
LED_FAN3,
LED_FAN4,
LED_PSU,
};
typedef enum psu_type {
PSU_TYPE_UNKNOWN,
PSU_TYPE_AC_F2B,

View File

@@ -133,3 +133,67 @@ onlp_sysi_onie_info_get(onlp_onie_info_t* onie)
return rv;
}
int
onlp_sysi_platform_manage_leds(void)
{
int fan_number;
onlp_led_mode_t mode;
enum onlp_led_id fan_led_id[4] = { LED_FAN1, LED_FAN2, LED_FAN3, LED_FAN4 };
/* after reboot, status LED should blink green, SW set to solid green */
onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,LED_SYSTEM), ONLP_LED_MODE_GREEN);
/*
* FAN Indicators
*
* Green - Fan is operating
* Red - No power or Fan failure
* Off - No power
*
*/
for( fan_number = 1; fan_number<= 8; fan_number+=2)
{
/* each 2 fans had same led_fan */
onlp_fan_info_t fi;
/* check fan i */
mode = ONLP_LED_MODE_GREEN;
if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number), &fi) < 0) {
mode = ONLP_LED_MODE_RED;
}
else if( (fi.status & 0x1) == 0) {
/* Not present */
mode = ONLP_LED_MODE_RED;
}
else if(fi.status & ONLP_FAN_STATUS_FAILED) {
mode = ONLP_LED_MODE_RED;
}
else
{
if( fi.rpm < MIN_LIMIT_FRONT_FAN_RPM )
{
mode = ONLP_LED_MODE_RED;
}
}
/* check fan i+1 */
if(onlp_fani_info_get(ONLP_FAN_ID_CREATE(fan_number+1), &fi) < 0) {
mode = ONLP_LED_MODE_RED;
}
else if( (fi.status & 0x1) == 0) {
/* Not present */
mode = ONLP_LED_MODE_RED;
}
else if(fi.status & ONLP_FAN_STATUS_FAILED) {
mode = ONLP_LED_MODE_RED;
}
else
{
if( fi.rpm < MIN_LIMIT_REAR_FAN_RPM )
{
mode = ONLP_LED_MODE_RED;
}
}
onlp_ledi_mode_set(ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED,fan_led_id[fan_number/2]), mode);
}
return ONLP_STATUS_OK;
}