Exemple #1
0
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
    int rv = ONLP_STATUS_OK;
    int supported = 0;

    if (value == NULL)
        return ONLP_STATUS_E_PARAM;

    if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0))
        return ONLP_STATUS_E_UNSUPPORTED;

    *value = 0;
    switch (control)
    {
        case ONLP_SFP_CONTROL_RX_LOS:
            rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_rxlos", (port+1));
            break;

        case ONLP_SFP_CONTROL_TX_DISABLE:
            rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1));
            break;

        case ONLP_SFP_CONTROL_TX_FAULT:
            rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_fault", (port+1));
            break;

        default:
            rv = ONLP_STATUS_E_UNSUPPORTED;
            break;
    }
    return rv;
}
Exemple #2
0
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    int val   = 0;
    int ret   = ONLP_STATUS_OK;
    int index = ONLP_OID_ID_GET(id);
    psu_type_t psu_type; 

    VALIDATE(id);

    memset(info, 0, sizeof(onlp_psu_info_t));
    *info = pinfo[index]; /* Set the onlp_oid_hdr_t */

    if (onlp_file_read_int(&val, PSU_PRESENT_FORMAT, index) < 0) {
        AIM_LOG_ERROR("Unable to read present status from PSU(%d)\r\n", index);
        return ONLP_STATUS_E_INTERNAL;
    }

    if (val != PSU_STATUS_PRESENT) {
        info->status &= ~ONLP_PSU_STATUS_PRESENT;
        return ONLP_STATUS_OK;
    }
    info->status |= ONLP_PSU_STATUS_PRESENT;


    /* Get power good status */
    if (onlp_file_read_int(&val, PSU_POWERGOOD_FORMAT, index) < 0) {
        AIM_LOG_ERROR("Unable to read power status from PSU(%d)\r\n", index);
        return ONLP_STATUS_E_INTERNAL;
    }

    if (val != PSU_STATUS_POWER_GOOD) {
        info->status |=  ONLP_PSU_STATUS_FAILED;
    }


    /* Get PSU type
     */
    psu_type = psu_type_get(index, info->model, sizeof(info->model));
    switch (psu_type) {
        case PSU_TYPE_AC_DPS850_F2B:
        case PSU_TYPE_AC_DPS850_B2F:
            ret = psu_dps850_info_get(info);      
            break;
        case PSU_TYPE_AC_YM2851_F2B:
        case PSU_TYPE_AC_YM2851_B2F:
            ret = psu_ym2651y_info_get(info);
            break;
        case PSU_TYPE_UNKNOWN:  /* User insert a unknown PSU or unplugged.*/
            info->status |= ONLP_PSU_STATUS_UNPLUGGED;
            info->status &= ~ONLP_PSU_STATUS_FAILED;
            ret = ONLP_STATUS_OK;
            break;
        default:
            ret = ONLP_STATUS_E_UNSUPPORTED;
            break;
    }

    return ret;
}
Exemple #3
0
int 
sys_fan_info_get(onlp_fan_info_t* info, int id)
{
    int rv, fan_status, fan_rpm, perc_val, percentage;
    int max_fan_speed = 22000;
    fan_status = 0;
    fan_rpm = 0;       

    rv = sys_fan_present_get(info, id);
    if (rv < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }
 
    rv = onlp_file_read_int(&fan_status, SYS_FAN_PREFIX "fan%d_alarm", id);
    if (rv < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }

    /* fan status > 1, means failure */
    if (fan_status > 0) {
        info->status |= ONLP_FAN_STATUS_FAILED;
        return ONLP_STATUS_OK;
    }
        
    rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", id);
    if (rv < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }    
    info->rpm = fan_rpm;
    
    /* get speed percentage*/
    switch (id)
	{
        case FAN_ID_FAN1:    
        case FAN_ID_FAN2:
        case FAN_ID_FAN3:
        case FAN_ID_FAN4:
            rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d",
                                    FAN_CTRL_SET1);
            break;
        case FAN_ID_FAN5:
        case FAN_ID_FAN6:
        case FAN_ID_FAN7:
        case FAN_ID_FAN8:
			rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d",
                                    FAN_CTRL_SET2);
            break;
        default:
            return ONLP_STATUS_E_INVALID;
    }   
    if (rv < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }
   
    percentage = (info->rpm*100)/max_fan_speed; 
    info->percentage = percentage;
    
    return ONLP_STATUS_OK;
}
Exemple #4
0
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
    int rv;

    if (port < 0 || port >= 48) {
        return ONLP_STATUS_E_UNSUPPORTED;
    }

    int addr = (port < 29) ? 61 : 62;
    int bus  = (addr == 61) ? 10 : 11;

    switch(control)
        {
        case ONLP_SFP_CONTROL_RX_LOS:
            {
            	if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) {
                    AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        case ONLP_SFP_CONTROL_TX_FAULT:
            {
            	if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) {
                    AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        case ONLP_SFP_CONTROL_TX_DISABLE:
            {
            	if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) {
                    AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        default:
            rv = ONLP_STATUS_E_UNSUPPORTED;
        }

    return rv;
}
int
onlp_sfpi_is_present(int port)
{
    /*
     * Return 1 if present.
     * Return 0 if not present.
     * Return < 0 if error.
     */
    int present;
    int bus, addr;

    if(port <0 || port > 54)
        return ONLP_STATUS_E_INTERNAL;
    
    if(port < 48)
        return ONLP_STATUS_E_UNSUPPORTED;
        
    addr = 60;
    bus  = 3;

	if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) {
        AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
        return ONLP_STATUS_E_INTERNAL;
    }

    return present;
}
Exemple #6
0
int
onlp_file_read_int_max(int* value, char** files)
{
    char** s = NULL;
    int max = 0;

    if(value == NULL || files == NULL || *files == NULL) {
        return ONLP_STATUS_E_PARAM;
    }

    *value = 0;

    for(s = files; *s; s++) {
        int value = 0;
        int rv = onlp_file_read_int(&value, *s);
        if(rv < 0) {
            return rv;
        }
        if(max < value) {
            max = value;
        }
    }

    *value = max;
    return 0;
}
Exemple #7
0
static int
sys_fan_info_get__(onlp_fan_info_t* info, int id)
{
    int rv;

    rv = onlp_file_read_int(&info->rpm,
                            SYS_HWMON_PREFIX "/fan%d_input", id);

    if(rv == ONLP_STATUS_E_INTERNAL) {
        return rv;
    }

    if(rv == ONLP_STATUS_E_MISSING) {
        info->status &= ~1;
        return 0;
    }

    if(info->rpm <= X86_64_WNC_SST1_N1_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) {
        info->status |= ONLP_FAN_STATUS_FAILED;
    }

    /*
     * Calculate percentage based on current speed and the maximum.
     */
    info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE;
    if(info->status & ONLP_FAN_STATUS_F2B) {
        info->percentage = info->rpm * 100 / X86_64_WNC_SST1_N1_R0_CONFIG_SYSFAN_F2B_RPM_MAX;
    }
    if(info->status & ONLP_FAN_STATUS_B2F) {
        info->percentage = info->rpm * 100 / X86_64_WNC_SST1_N1_R0_CONFIG_SYSFAN_B2F_RPM_MAX;
    }
    return 0;
}
Exemple #8
0
int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
    int  lid, value;
		
    VALIDATE(id);
	
    lid = ONLP_OID_ID_GET(id);

    /* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[ONLP_OID_ID_GET(id)];

    /* Get LED mode */
    if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) {
        DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]);
        return ONLP_STATUS_E_INTERNAL;
    }

    info->mode = driver_to_onlp_led_mode(lid, value);

    /* Set the on/off status */
    if (info->mode != ONLP_LED_MODE_OFF) {
        info->status |= ONLP_LED_STATUS_ON;
    }

    return ONLP_STATUS_OK;
}
Exemple #9
0
/*
 * This function should return whether an SFP is inserted on the given
 * port.
 *
 * Returns 1 if the SFP is present.
 * Returns 0 if the SFP is not present.
 * Returns ONLP_E_* if there was an error determining the status.
 */
int
onlp_sfpi_is_present(int port)
{
    int value = 0;

    onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/port_%d_abs", (port+1));
    return value;
}
static int
psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id)
{
    /* THERMAL6 -> PSU1 */
    /* THERMAL7 -> PSU2 */
    char* dir = powerpc_quanta_lb8_r9_system_psu_dir(pid);
    info->status |= 1;
    return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id);
}
Exemple #11
0
int pca953x_gpio_value_get(int gpio, int *value) {
    int ret;

    try_export_gpio(gpio);
    ret = onlp_file_read_int(value, "%s%d/value", GPIO_PREF, gpio);
    try_unexport_gpio(gpio);

    return ret;
}
Exemple #12
0
static int
psu_fan_info_get__(onlp_fan_info_t* info, int id)
{
    extern char* psu_paths[];

    /* FAN5 -> PSU1 */
    /* FAN6 -> PSU2 */
    char* dir = psu_paths[id-4];
    return onlp_file_read_int(&info->rpm, "%s/fan1_input", dir);
}
static int
psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id)
{
    /* THERMAL6 -> PSU1 */
    /* THERMAL7 -> PSU2 */
    extern struct psu_info_s psu_info[];
    char* dir = psu_info[pid].path;
    info->status |= 1;
    return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id);
}
Exemple #14
0
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
    int ver=0;
	
    if(onlp_file_read_int(&ver, "%s/version", PREFIX_PATH_ON_CPLD_DEV) < 0)
        return ONLP_STATUS_E_INTERNAL;
		
    pi->cpld_versions = aim_fstrdup("%d", ver);
	
    return 0;
}
int psu_ym2651y_pmbus_info_get(int id, char *node, int *value)
{
    int  ret = 0;
    char path[PSU_NODE_MAX_PATH_LEN] = {0};
    
    *value = 0;

    if (PSU1_ID == id) {
        ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node);
    }
    else {
		ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node);
    }

    if (ret < 0) {
        AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path);
        return ONLP_STATUS_E_INTERNAL;
    }

    return ret;
}
Exemple #16
0
static int
onlp_board_model_id_get(void)
{
    static int board_model_id = MODEL_ID_LAST;

    if (board_model_id == MODEL_ID_LAST)
    {
        if (onlp_file_read_int(&board_model_id, SYS_HWMON1_PREFIX "/board_model_id") != ONLP_STATUS_OK)
            return 0;
    }

    return board_model_id;
}
Exemple #17
0
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
    int   i, v[NUM_OF_CPLD]={0};
    for (i=0; i < NUM_OF_CPLD; i++) {
        v[i] = 0;
        if(onlp_file_read_int(v+i, arr_cplddev_version[i]) < 0) {
            return ONLP_STATUS_E_INTERNAL;
        }
    }
    pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]);
    return 0;
}
Exemple #18
0
int
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
{
    int p, port_name;

    for(p = 1; p < 33; p++) {
        if (onlp_file_read_int(&port_name, sfp_get_port_info_path(p, "port_name")) == 0) {
            AIM_BITMAP_SET(bmap, port_name);
        }
    }

    return ONLP_STATUS_OK;
}
Exemple #19
0
static int
psu_fan_info_get__(onlp_fan_info_t* info, int id)
{
    /* FAN5 -> PSU1 */
    /* FAN6 -> PSU2 */
    const char* dir =  powerpc_quanta_lb8_r9_system_psu_dir(id-4);

    if(dir == NULL) {
        /* Error already reported */
        return ONLP_STATUS_E_INTERNAL;
    }

    return onlp_file_read_int(&info->rpm, "%s/fan1_input", dir);
}
Exemple #20
0
static int
sfp_node_read_int(char *node_path, int *value, int data_len)
{
    int ret = 0;
    *value = 0;

    ret = onlp_file_read_int(value, node_path);

    if (ret < 0) {
        AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path);
        return ONLP_STATUS_E_INTERNAL;
    }

    return ret;
}
Exemple #21
0
/*
 * Retrieve the information structure for the given thermal OID.
 *
 * If the OID is invalid, return ONLP_E_STATUS_INVALID.
 * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
 * Otherwise, return ONLP_STATUS_OK with the OID's information.
 *
 * Note -- it is expected that you fill out the information
 * structure even if the sensor described by the OID is not present.
 */
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
    int local_id;
    VALIDATE(id);

    local_id = ONLP_OID_ID_GET(id);

    /* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[local_id];

    if(local_id >= THERMAL_CPU_CORE_FIRST && local_id <= THERMAL_CPU_CORE_LAST) {
	char desc[32], *dp = &desc[0];
        int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label");
        if (rv > 0) {
            memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE);
            strncpy(info->hdr.description, dp, rv);
        }

        /* Set the onlp_oid_hdr_t and capabilities */
        return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input");
    }
    return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]);
}
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
    int   i, v[NUM_OF_CPLD]={0};

    for (i=0; i < NUM_OF_CPLD; i++) {
        v[i] = 0;
        if(onlp_file_read_int(v+i, "%s/%s", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
            return ONLP_STATUS_E_INTERNAL;
        }
    }
    pi->cpld_versions = aim_fstrdup("brd=%d, mgmt=%d, port=%d", v[0], v[1], v[2]);

    return ONLP_STATUS_OK;
}
Exemple #23
0
/*
 * Retrieve the information structure for the given thermal OID.
 *
 * If the OID is invalid, return ONLP_E_STATUS_INVALID.
 * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
 * Otherwise, return ONLP_STATUS_OK with the OID's information.
 *
 * Note -- it is expected that you fill out the information
 * structure even if the sensor described by the OID is not present.
 */
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
    int   tid;
    VALIDATE(id);
	
    tid = ONLP_OID_ID_GET(id);
	
    /* Set the onlp_oid_hdr_t and capabilities */		
    *info = linfo[tid];

    if(tid == THERMAL_CPU_CORE) {
        int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
        return rv;
    }

    return onlp_file_read_int(&info->mcelsius, devfiles__[tid]);
}
static int
sys_thermal_info_get__(onlp_thermal_info_t* info, int id)
{
    int rv;

    rv = onlp_file_read_int(&info->mcelsius,
                            SYS_HWMON_PREFIX "/temp%d_input", id);

    if(rv == ONLP_STATUS_E_INTERNAL) {
        return rv;
    }

    if(rv == ONLP_STATUS_E_MISSING) {
        info->status &= ~1;
        return 0;
    }

    return ONLP_STATUS_OK;
}
Exemple #25
0
int
onlp_sfpi_is_present(int port)
{
    /*
     * Return 1 if present.
     * Return 0 if not present.
     * Return < 0 if error.
     */
    int present;
    int bus, addr;

    addr = (port < 29) ? 61 : 62;
    bus  = (addr == 61) ? 10 : 11;
    
	if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) {
        AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
        return ONLP_STATUS_E_INTERNAL;
    }

    return present;
}
Exemple #26
0
static int
sys_fan_info_get__(onlp_fan_info_t* info, int id)
{
    int rv;
    const char* controller = powerpc_quanta_lb9_system_fan_dir();

    if(controller == NULL) {
        /* Error already reported. */
        return ONLP_STATUS_E_INTERNAL;
    }

    rv = onlp_file_read_int(&info->rpm,
                            "%s/fan%d_input", controller, id);

    if(rv == ONLP_STATUS_E_INTERNAL) {
        return rv;
    }

    if(rv == ONLP_STATUS_E_MISSING) {
        info->status &= ~1;
        return 0;
    }

    if(info->rpm <= POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) {
        info->status |= ONLP_FAN_STATUS_FAILED;
    }

    /*
     * Calculate percentage based on current speed and the maximum.
     */
    info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE;
    if(info->status & ONLP_FAN_STATUS_F2B) {
        info->percentage = info->rpm * 100 / POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX;
    }
    if(info->status & ONLP_FAN_STATUS_B2F) {
        info->percentage = info->rpm * 100 / POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX;
    }

    return 0;
}
static int
sys_thermal_info_get__(onlp_thermal_info_t* info, int id)
{
    int rv;

    /* Fixed for both F2B and B2F configurations */
    const char* controller = SYS_CONTROLLER_PREFIX_TEMPERATURE;

    rv = onlp_file_read_int(&info->mcelsius,
                            "%s//temp%d_input", controller, id);

    if(rv == ONLP_STATUS_E_INTERNAL) {
        return rv;
    }

    if(rv == ONLP_STATUS_E_MISSING) {
        info->status &= ~1;
        return 0;
    }

    return ONLP_STATUS_OK;
}
Exemple #28
0
static int 
psu_status_info_get(int id, char *node, int *value)
{
    int ret = 0;
    char node_path[ONLP_NODE_MAX_PATH_LEN] = {0};
    
    *value = 0;
    if (PSU1_ID == id) {
	sprintf(node_path, status_devfiles__[id]);
    }
    else if (PSU2_ID == id) {
	sprintf(node_path, status_devfiles__[id]);
    }
    
    ret = onlp_file_read_int(value, node_path);

    if (ret < 0) {
	AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path);
	return ONLP_STATUS_E_INTERNAL;
    }

    return ONLP_STATUS_OK;
}
Exemple #29
0
static int
sys_thermal_info_get__(onlp_thermal_info_t* info, int id)
{
    int rv;

    if (id == THERMAL_ID_THERMAL3)
    {
        rv = onlp_file_read_int(&info->mcelsius, SYS_HWMON1_PREFIX "/mac_temp");
        info->mcelsius *= 1000;
    }
    else
    {
        uint8_t buffer[64];
        double dvalue;
        int len;

        memset(buffer, 0, sizeof(buffer));
        rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON1_PREFIX "/remote_temp%d", id);
        if (rv == ONLP_STATUS_OK)
        {
            dvalue = atof((const char *)buffer);
            info->mcelsius = (int)(dvalue * 1000);
        }
    }

    if(rv == ONLP_STATUS_E_INTERNAL)
        return rv;

    if(rv == ONLP_STATUS_E_MISSING)
    {
        info->status &= ~(ONLP_THERMAL_STATUS_PRESENT);
        return ONLP_STATUS_OK;
    }

    return ONLP_STATUS_OK;
}
Exemple #30
0
int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
    int  local_id, gret = 0, rret = 0;
    char fullpath_grn[50] = {0};
    char fullpath_red[50] = {0};
    int  gvalue = 0, rvalue = 0;
    char gbuf[32] = {0};
    char rbuf[32] = {0};

    VALIDATE(id);

    local_id = ONLP_OID_ID_GET(id);

    /* Set the onlp_oid_hdr_t and capabilities */
    *info = linfo[ONLP_OID_ID_GET(id)];

    /* get fullpath */
    switch (local_id) {
	case LED_SYS:
            sprintf(fullpath_grn, devfiles__[local_id], "grn");
            sprintf(fullpath_red, devfiles__[local_id], "red");

	    /* Set LED mode */
	    gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32);
	    rret = onlp_chassis_led_read(fullpath_red, rbuf, 32);
	    if (gret < 0 || rret < 0) {
                DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret);
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_FAILED;
		break;
	    }

	    info->status = ONLP_LED_STATUS_PRESENT;
	    if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') {
		info->mode = ONLP_LED_MODE_GREEN;
		info->status |= ONLP_LED_STATUS_ON;
	    }
	    else
	    if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') {
		info->mode = ONLP_LED_MODE_RED;
		info->status |= ONLP_LED_STATUS_ON;
	    }
	    else
	    if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') {
		info->mode = ONLP_LED_MODE_ORANGE;
		info->status |= ONLP_LED_STATUS_ON;
	    }
	    else
	    if (gbuf[0] == '0' && rbuf[0] == '0') {
		info->mode = ONLP_LED_MODE_OFF;
		info->status |= ONLP_LED_STATUS_ON;
	    }
	    else {
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_FAILED;
	    }
	    break;
	case LED_FAN1:
	case LED_FAN2:
	case LED_FAN3:
	case LED_FAN4:
            sprintf(fullpath_grn, devfiles__[local_id], "grn");

	    /* Set LED mode */
	    if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) {
		DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__);
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_FAILED;
	    }
	    else
	    if (gvalue == 1) {
		info->mode = ONLP_LED_MODE_GREEN;
		info->status = ONLP_LED_STATUS_ON;
	    }
	    else
	    if (gvalue == 0) {
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_ON;
	    }

            sprintf(fullpath_red, devfiles__[local_id], "red");

	    if (onlp_file_read_int(&rvalue, fullpath_red) != 0) {
		DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__);
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_FAILED;
	    }
	    else
	    if (rvalue == 1) {
		info->mode = ONLP_LED_MODE_RED;
		info->status = ONLP_LED_STATUS_ON;
	    }
	    else
	    if (rvalue == 0) {
		info->mode = ONLP_LED_MODE_OFF;
		info->status = ONLP_LED_STATUS_ON;
	    }
	    break;
	default:
	    DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id);
	    break;
    }
		
    return ONLP_STATUS_OK;
}