예제 #1
0
int
onlp_sysi_platform_manage_fans(void)
{
    int rc, oldP, newP = 0;
    onlp_thermal_info_t ti;
    int  fd, len;
    char  buf[10] = {0};
    char path[70] = "/sys/devices/platform/as4610_fan/fan_duty_cycle_percentage";

    if (chassis_fan_count() == 0) {
        return ONLP_STATUS_E_UNSUPPORTED;
    }

    /* Get fan duty cycle */
    fd = open(path, O_RDWR, 0644);
    if (fd == -1){
        return ONLP_STATUS_E_INTERNAL;
    }

    len = read(fd, buf, sizeof(buf));
    if (len <= 0){
        close(fd);
        return ONLP_STATUS_E_INTERNAL;
    }

    if (close(fd) == -1) {
        return ONLP_STATUS_E_INTERNAL;
    }

    DEBUG_PRINT("[Debug][%s][%d][read data: %s]\n", __FUNCTION__, __LINE__, buf);
    oldP = atoi(buf);

    /* Get temperature */
    rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti);
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }

    /* Bring fan speed to high if current speed is unexpected
     */
    if (oldP != FAN_PERCENTAGE_LOW && oldP != FAN_PERCENTAGE_HIGH) {
        onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_HIGH);
        return ONLP_STATUS_OK;
    }

    if (oldP == FAN_PERCENTAGE_LOW && ti.mcelsius >= 61000) {
        newP = FAN_PERCENTAGE_HIGH;

    }
    else if (oldP == FAN_PERCENTAGE_HIGH && ti.mcelsius <= 49000) {
        newP = FAN_PERCENTAGE_LOW;
    }

    if (newP) {
        onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), newP);
    }

    return ONLP_STATUS_OK;
}
예제 #2
0
int
onlp_sysi_platform_manage_fans(void)
{ 

    int rc;
    onlp_thermal_info_t ti1;
    onlp_thermal_info_t ti2;
    int mtemp=0;
    int new_rpm=0;

    if (chassis_fan_count() == 0) {
        return ONLP_STATUS_E_UNSUPPORTED;
    }
  
    /* Get temperature */
    rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }
        
    rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }
             
    mtemp=(ti1.mcelsius+ti2.mcelsius)/2;
    /* Bring fan speed according the temp
     */
    if(mtemp<50000)
        new_rpm=FAN_IDLE_RPM;
    else if((mtemp>=55000)&&(mtemp<60000))
        new_rpm=FAN_LEVEL1_RPM;
    else if((mtemp>=65000)&&(mtemp<70000))
        new_rpm=FAN_LEVEL2_RPM;
    else if(mtemp>=75000)
        new_rpm=FAN_LEVEL3_RPM;
    else{
        return ONLP_STATUS_OK;
   }
       
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm);
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); 
    
        
    return ONLP_STATUS_OK;
}
예제 #3
0
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
    int i;
    onlp_oid_t* e = table;
    memset(table, 0, max*sizeof(onlp_oid_t));
    
    /* 6 Thermal sensors on the chassis */
    for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
        *e++ = ONLP_THERMAL_ID_CREATE(i);
    }

    /* 5 LEDs on the chassis */
    for (i = 1; i <= CHASSIS_LED_COUNT; i++) {
        *e++ = ONLP_LED_ID_CREATE(i);
    }

    /* 2 PSUs on the chassis */
    for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
        *e++ = ONLP_PSU_ID_CREATE(i);
    }

    /* 6 Fans on the chassis */
    for (i = 1; i <= CHASSIS_FAN_COUNT; i++) {
        *e++ = ONLP_FAN_ID_CREATE(i);
    }

    return 0;
}
예제 #4
0
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
    int i;
    onlp_oid_t* e = table;
    memset(table, 0, max*sizeof(onlp_oid_t));

    /* 4 Thermal sensors on the chassis */
    for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++)
    {
        *e++ = ONLP_THERMAL_ID_CREATE(i);
    }

    /* 5 LEDs on the chassis */
    for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++)
    {
        *e++ = ONLP_LED_ID_CREATE(i);
    }

    /* 2 PSUs on the chassis */
    for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++)
    {
        *e++ = ONLP_PSU_ID_CREATE(i);
    }

    /* 4 Fans on the chassis */
    for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++)
    {
        *e++ = ONLP_FAN_ID_CREATE(i);
    }

    return 0;
}
예제 #5
0
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
    onlp_oid_t* e = table;
    memset(table, 0, max*sizeof(onlp_oid_t));
    int i;
    
    /* 2 PSUs */
    *e++ = ONLP_PSU_ID_CREATE(1);
    *e++ = ONLP_PSU_ID_CREATE(2);

    /* LEDs Item */
    for (i=1; i<=CHASSIS_LED_COUNT; i++)
    {
        *e++ = ONLP_LED_ID_CREATE(i);
    }

    /* THERMALs Item */
    for (i=1; i<=CHASSIS_THERMAL_COUNT; i++)
    {
        *e++ = ONLP_THERMAL_ID_CREATE(i);
    }

    /* Fans Item */
    for (i=1; i<=CHASSIS_FAN_COUNT; i++)
    {
        *e++ = ONLP_FAN_ID_CREATE(i);
    }

    return 0;
}
예제 #6
0
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
    onlp_oid_t* e = table;
    memset(table, 0, max*sizeof(onlp_oid_t));

    /* 2 PSUs */
    *e++ = ONLP_PSU_ID_CREATE(1);
    *e++ = ONLP_PSU_ID_CREATE(2);

    /* 1 Fan */
    *e++ = ONLP_FAN_ID_CREATE(1);

    /* 9 Thermal sensors */
    *e++ = ONLP_THERMAL_ID_CREATE(1);
    *e++ = ONLP_THERMAL_ID_CREATE(2);
    *e++ = ONLP_THERMAL_ID_CREATE(3);
    *e++ = ONLP_THERMAL_ID_CREATE(4);
    *e++ = ONLP_THERMAL_ID_CREATE(5);
    *e++ = ONLP_THERMAL_ID_CREATE(6);
    *e++ = ONLP_THERMAL_ID_CREATE(7);
    *e++ = ONLP_THERMAL_ID_CREATE(8);
    *e++ = ONLP_THERMAL_ID_CREATE(11);

    /* 5 LEDs */
    *e++ = ONLP_LED_ID_CREATE(1);
    *e++ = ONLP_LED_ID_CREATE(2);
    *e++ = ONLP_LED_ID_CREATE(3);
    *e++ = ONLP_LED_ID_CREATE(4);
    *e++ = ONLP_LED_ID_CREATE(5);

    return 0;
}
예제 #7
0
static int
_psu_info_get(onlp_psu_info_t* info)
{
    int val   = 0;
    int index = ONLP_OID_ID_GET(info->hdr.id);

    /* Set capability
     */
    info->caps = ONLP_PSU_CAPS_AC;

    if (info->status & ONLP_PSU_STATUS_FAILED) {
        return ONLP_STATUS_OK;
    }

    /* Set the associated oid_table */
    info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
    info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);

    /* Read voltage, current and power */
    if (psu_power_info_get(index, "volt_in", &val) == 0 &&
        0 != val) {
        info->mvin = val;
        info->caps |= ONLP_PSU_CAPS_VIN;

        if (psu_power_info_get(index, "volt", &val) == 0) {
            info->mvout = val;
            info->caps |= ONLP_PSU_CAPS_VOUT;
        }

        if (psu_power_info_get(index, "curr_in", &val) == 0) {
            info->miin = val;
            info->caps |= ONLP_PSU_CAPS_IIN;
        }

        if (psu_power_info_get(index, "curr", &val) == 0) {
            info->miout = val;
            info->caps |= ONLP_PSU_CAPS_IOUT;
        }

        if (psu_power_info_get(index, "power_in", &val) == 0) {
            info->mpin = val;
            info->caps |= ONLP_PSU_CAPS_PIN;
        }

        if (psu_power_info_get(index, "power", &val) == 0) {
            info->mpout = val;
            info->caps |= ONLP_PSU_CAPS_POUT;
        }
    } else {
        info->status |= ONLP_PSU_STATUS_FAILED;
        return ONLP_STATUS_OK;
    }

    return psu_read_eeprom(index, info, NULL);
}
예제 #8
0
static int
psu_cpr_4011_info_get(onlp_psu_info_t* info)
{
    int val   = 0;
    int index = ONLP_OID_ID_GET(info->hdr.id);
    
    /* Set capability
     */
    info->caps = ONLP_PSU_CAPS_AC;
    
	if (info->status & ONLP_PSU_STATUS_FAILED) {
	    return ONLP_STATUS_OK;
	}

    /* Set the associated oid_table */
    info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
    info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);

    /* Read voltage, current and power */
    if (psu_cpr_4011_pmbus_info_get(index, "psu_v_out", &val) == 0) {
        info->mvout = val;
        info->caps |= ONLP_PSU_CAPS_VOUT;
    }

    if (psu_cpr_4011_pmbus_info_get(index, "psu_v_in", &val) == 0) {
        info->mvin = val;
        info->caps |= ONLP_PSU_CAPS_VIN;
    }

    if (psu_cpr_4011_pmbus_info_get(index, "psu_i_out", &val) == 0) {
        info->miout = val;
        info->caps |= ONLP_PSU_CAPS_IOUT;
    }
    
    if (psu_cpr_4011_pmbus_info_get(index, "psu_i_in", &val) == 0) {
        info->miin = val;
        info->caps |= ONLP_PSU_CAPS_IIN;
    }

    if (psu_cpr_4011_pmbus_info_get(index, "psu_p_out", &val) == 0) {
        info->mpout = val;
        info->caps |= ONLP_PSU_CAPS_POUT;
    }   

    if (psu_cpr_4011_pmbus_info_get(index, "psu_p_in", &val) == 0) {
        info->mpin = val;
        info->caps |= ONLP_PSU_CAPS_PIN;
    }   

    return ONLP_STATUS_OK;
}
예제 #9
0
int
onlp_sysi_platform_manage_leds(void)
{
    int rv;
    onlp_fan_info_t fi;
    onlp_led_mode_t mode = ONLP_LED_MODE_GREEN;

    rv = onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &fi);
    if(rv < 0) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    else if((fi.status & 1) == 0) {
        mode = ONLP_LED_MODE_OFF;
    }
    else if(fi.status & ONLP_FAN_STATUS_FAILED) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    onlp_ledi_mode_set(ONLP_LED_ID_CREATE(2), mode);

    onlp_psu_info_t pi;

    mode = ONLP_LED_MODE_GREEN;
    rv = onlp_psu_info_get(ONLP_PSU_ID_CREATE(1), &pi);
    if(rv < 0) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    else if((pi.status & 1) == 0) {
        mode = ONLP_LED_MODE_OFF;
    }
    else if(pi.status & ONLP_PSU_STATUS_FAILED) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    onlp_ledi_mode_set(ONLP_LED_ID_CREATE(4), mode);


    mode = ONLP_LED_MODE_GREEN;
    rv = onlp_psu_info_get(ONLP_PSU_ID_CREATE(2), &pi);
    if(rv < 0) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    else if((pi.status & 1) == 0) {
        mode = ONLP_LED_MODE_OFF;
    }
    else if(pi.status & ONLP_PSU_STATUS_FAILED) {
        mode = ONLP_LED_MODE_ORANGE;
    }
    onlp_ledi_mode_set(ONLP_LED_ID_CREATE(5), mode);

    return 0;
}
예제 #10
0
int
psu_um400d_info_get(onlp_psu_info_t* info)
{
    int index = ONLP_OID_ID_GET(info->hdr.id);

    /* Set capability
     */
    info->caps = ONLP_PSU_CAPS_DC48;

    if (info->status & ONLP_PSU_STATUS_FAILED) {
        return ONLP_STATUS_OK;
    }

    /* Set the associated oid_table */
    info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);

    return ONLP_STATUS_OK;
}
예제 #11
0
/*
 * For AC power Front to Back :
 *	* If any fan fail, please fan speed register to 15
 *	* The max value of Fan speed register is 9
 *		[LM75(48) + LM75(49) + LM75(4A)] > 174  => set Fan speed value from 4 to 5
 *		[LM75(48) + LM75(49) + LM75(4A)] > 182  => set Fan speed value from 5 to 7
 *		[LM75(48) + LM75(49) + LM75(4A)] > 190  => set Fan speed value from 7 to 9
 *
 *		[LM75(48) + LM75(49) + LM75(4A)] < 170  => set Fan speed value from 5 to 4
 *		[LM75(48) + LM75(49) + LM75(4A)] < 178  => set Fan speed value from 7 to 5
 *		[LM75(48) + LM75(49) + LM75(4A)] < 186  => set Fan speed value from 9 to 7
 *
 *
 * For  AC power Back to Front :
 *	* If any fan fail, please fan speed register to 15
 *	* The max value of Fan speed register is 10
 *		[LM75(48) + LM75(49) + LM75(4A)] > 140  => set Fan speed value from 4 to 5
 *		[LM75(48) + LM75(49) + LM75(4A)] > 150  => set Fan speed value from 5 to 7
 *		[LM75(48) + LM75(49) + LM75(4A)] > 160  => set Fan speed value from 7 to 10
 *
 *		[LM75(48) + LM75(49) + LM75(4A)] < 135  => set Fan speed value from 5 to 4
 *		[LM75(48) + LM75(49) + LM75(4A)] < 145  => set Fan speed value from 7 to 5
 *		[LM75(48) + LM75(49) + LM75(4A)] < 155  => set Fan speed value from 10 to 7
 */
int
onlp_sysi_platform_manage_fans(void)
{
    int i = 0, arr_size, temp;
    fan_ctrl_policy_t *policy;
    int cur_duty_cycle, new_duty_cycle;
    onlp_thermal_info_t thermal_1, thermal_2, thermal_3;

    int  fd, len;
    char  buf[10] = {0};

    /* Get each fan status
     */
    for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++)
    {
        onlp_fan_info_t fan_info;

        if (onlp_fan_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) {
            AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i);
            return ONLP_STATUS_E_INTERNAL;
        }

        /* Decision 1: Set fan as full speed if any fan is failed.
         */
        if (fan_info.status & ONLP_FAN_STATUS_FAILED) {
            AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i);
            return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX);
        }

        /* Decision 1.1: Set fan as full speed if any fan is not present.
         */
        if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) {
            AIM_LOG_ERROR("Fan(%d) is not present, set the other fans as full speed\r\n", i);
            return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX);
        }

        /* Get fan direction (Only get the first one since all fan direction are the same)
         */
        if (i == 1) {
            if (fan_info.status & ONLP_FAN_STATUS_F2B) {
                policy   = fan_ctrl_policy_f2b;
                arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_f2b);
            }
            else {
                policy   = fan_ctrl_policy_b2f;
                arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_b2f);
            }
        }
    }

    /* Get current fan speed
     */
    fd = open(FAN_SPEED_CTRL_PATH, O_RDONLY);
    if (fd == -1){
        AIM_LOG_ERROR("Unable to open fan speed control node (%s)", FAN_SPEED_CTRL_PATH);
        return ONLP_STATUS_E_INTERNAL;
    }

    len = read(fd, buf, sizeof(buf));
    close(fd);
    if (len <= 0) {
        AIM_LOG_ERROR("Unable to read fan speed from (%s)", FAN_SPEED_CTRL_PATH);
        return ONLP_STATUS_E_INTERNAL;
    }
    cur_duty_cycle = atoi(buf);


    /* Decision 2: If no matched fan speed is found from the policy,
     *             use FAN_DUTY_CYCLE_MIN as default speed
     */
	for (i = 0; i < arr_size; i++) {
	    if (policy[i].duty_cycle != cur_duty_cycle)
		    continue;

		break;
	}

	if (i == arr_size) {
        return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle);
	}

    /* Get current temperature
     */
    if (onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK ||
        onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK ||
        onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) {
        AIM_LOG_ERROR("Unable to read thermal status");
        return ONLP_STATUS_E_INTERNAL;
    }
    temp = thermal_1.mcelsius + thermal_2.mcelsius + thermal_3.mcelsius;


    /* Decision 3: Decide new fan speed depend on fan direction/current fan speed/temperature
     */
    new_duty_cycle = cur_duty_cycle;

    if ((temp >= policy[i].temp_up_adjust) && (i != (arr_size-1))) {
	    new_duty_cycle = policy[i+1].duty_cycle;
	}
	else if ((temp <= policy[i].temp_down_adjust) && (i != 0)) {
	    new_duty_cycle = policy[i-1].duty_cycle;
	}

	if (new_duty_cycle == cur_duty_cycle) {
        /* Duty cycle does not change, just return */
	    return ONLP_STATUS_OK;
	}

    return onlp_fan_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle);
}
예제 #12
0
int
onlp_sysi_platform_manage_leds(void)
{ 
		int rc,rc1;
		
		onlp_fan_info_t info1,info2;
		onlp_led_mode_t fan_new_mode;
		onlp_thermal_info_t ti;
		onlp_led_mode_t temp_new_mode;
		onlp_psu_info_t psu1;
		onlp_led_mode_t psu1_new_mode;
		onlp_psu_info_t psu2;
		onlp_led_mode_t psu2_new_mode;
		onlp_led_mode_t sys_new_mode;
		/*fan led */
		rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &info1);
        
        rc1=onlp_fani_info_get(ONLP_FAN_ID_CREATE(2), &info2);
        
		if ((rc != ONLP_STATUS_OK)||(rc1 != ONLP_STATUS_OK)){
			fan_new_mode=ONLP_LED_MODE_RED;
			goto temp_led;
		}
		if(((info1.status&0x3)==1)&&((info2.status&0x3)==1))
			fan_new_mode=ONLP_LED_MODE_GREEN;
		else 
			fan_new_mode=ONLP_LED_MODE_RED;
       
temp_led:		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode);
		
		/*temperature led */
	
		rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti);
		if (rc != ONLP_STATUS_OK) {
			temp_new_mode=ONLP_LED_MODE_OFF;
			goto psu1_led;
		}
		if(ti.mcelsius >= 75000)
			temp_new_mode=ONLP_LED_MODE_RED;
		else
			temp_new_mode=ONLP_LED_MODE_GREEN;
         
psu1_led:		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_TEMP),temp_new_mode);
		
		/*psu1 and psu2 led */
		rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(1),&psu1);
		
		if (rc != ONLP_STATUS_OK) {
			psu1_new_mode=ONLP_LED_MODE_OFF;
			goto psu2_led;
		}
		
		if((psu1.status&0x1)&&!(psu1.status&0x2))
			psu1_new_mode=ONLP_LED_MODE_GREEN;
		else
			psu1_new_mode=ONLP_LED_MODE_OFF;
psu2_led:		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1),psu1_new_mode);
		//psu2 led 	----------------
			rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(2),&psu2);
			
		 if (rc != ONLP_STATUS_OK) {
			psu2_new_mode=ONLP_LED_MODE_OFF;
			goto sys_led;
		}
		
		if((psu2.status&0x1)&&!(psu2.status&0x2))
			psu2_new_mode=ONLP_LED_MODE_GREEN;
		else
			psu2_new_mode=ONLP_LED_MODE_OFF;
sys_led	:		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2),psu2_new_mode);
		//sys led 	----------------

		if((fan_new_mode!=ONLP_LED_MODE_GREEN)||((psu2_new_mode!=ONLP_LED_MODE_GREEN)&& \
			(psu1_new_mode!=ONLP_LED_MODE_GREEN)))
			sys_new_mode=ONLP_LED_MODE_RED_BLINKING;
		else
			sys_new_mode=ONLP_LED_MODE_GREEN;
		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode);
        
              
		return ONLP_STATUS_OK;
}
예제 #13
0
int
onlp_sysi_platform_manage_leds(void)
{ 
		int i,tray_i,rc;
		onlp_fan_info_t info;
		onlp_led_mode_t fan_new_mode;
        onlp_led_mode_t fan_tray_new_mode[3];
		onlp_psu_info_t psu;
		onlp_led_mode_t psu_new_mode;
		onlp_led_mode_t sys_new_mode;
        onlp_led_mode_t locator_new_mode;
		/*fan led */
		/*fan led */
        for(tray_i=0;tray_i<3;tray_i++){
            for(i=CHASSIS_FAN_COUNT-2*tray_i;i>=CHASSIS_FAN_COUNT-2*tray_i-1;i--){
                rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &info);
                if ((rc != ONLP_STATUS_OK) ||((info.status&0x1)!=1)){
                    fan_tray_new_mode[tray_i]=ONLP_LED_MODE_OFF;
                    goto tray_next;
                }
                else{
                    if((info.status&0x2)==1){
                        fan_tray_new_mode[tray_i]=ONLP_LED_MODE_YELLOW;
                        goto tray_next;
                    }
                }
            }
            fan_tray_new_mode[tray_i]=ONLP_LED_MODE_GREEN;
tray_next:  continue;
        }
        onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY0),fan_tray_new_mode[0]);
        onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY1),fan_tray_new_mode[1]);
        onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY2),fan_tray_new_mode[2]);
        
        if((fan_tray_new_mode[0]==ONLP_LED_MODE_GREEN)&&(fan_tray_new_mode[1]==ONLP_LED_MODE_GREEN)&& 
            (fan_tray_new_mode[2]==ONLP_LED_MODE_GREEN))
            fan_new_mode=ONLP_LED_MODE_GREEN;
        else if((fan_tray_new_mode[0]==ONLP_LED_MODE_OFF)||(fan_tray_new_mode[1]==ONLP_LED_MODE_OFF)|| 
            (fan_tray_new_mode[2]==ONLP_LED_MODE_OFF))
             fan_new_mode=ONLP_LED_MODE_YELLOW;
        else
            fan_new_mode=ONLP_LED_MODE_YELLOW_BLINKING;
    
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode);
		/*psu1 and psu2 led */
        for(i=1;i<=CHASSIS_PSU_COUNT;i++){
            rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(i),&psu);
            
            if (rc != ONLP_STATUS_OK) {
               continue;
            }
            if((psu.status&0x1)&&!(psu.status&0x2)){
                psu_new_mode=ONLP_LED_MODE_GREEN;
                goto sys_led;
            }
        }
		psu_new_mode=ONLP_LED_MODE_YELLOW_BLINKING;
     
sys_led	:		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_POWER),psu_new_mode);
		//sys led 	----------------
		if((fan_new_mode!=ONLP_LED_MODE_GREEN)||(psu_new_mode!=ONLP_LED_MODE_GREEN))
			sys_new_mode=ONLP_LED_MODE_YELLOW_BLINKING;
		else
			sys_new_mode=ONLP_LED_MODE_GREEN;
		
		onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode);
        
        locator_new_mode=ONLP_LED_MODE_BLUE;
        onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOCATOR),locator_new_mode);
		return ONLP_STATUS_OK;
}
예제 #14
0
    return ONLP_STATUS_OK;
}

/*
 * Get all information about the given PSU oid.
 */
static onlp_psu_info_t pinfo[] =
{
    { }, /* Not used */
    {
	{
	    ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0,
	    {
		ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1),
		ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU1),
		ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1)
	    }
	},
    },
    {
	{
	    ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0,
	    {
		ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2),
		ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2),
		ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2)
	    }
	},
    }
};
예제 #15
0
/*
 * 1. If any FAN failed, set all the other fans as full speed (100%)
 * 2. When (LM75-1 + LM75-2)/2 >= 49.5 C, set fan speed from 40% to 65%.
 * 3. When (LM75-1 + LM75-2)/2 >= 53C, set fan speed from 65% to 80%
 * 4. When (LM75-1 + LM75-2)/2 >= 57.7C, set fan speed from 80% to 100%

 * 5. When (LM75-1 + LM75-2)/2 <= 52.7C, set fan speed from 100% to 80%
 * 6. When (LM75-1 + LM75-2)/2 <= 47.7C, set fan speed from 80% to 65%
 * 7. When (LM75-1 + LM75-2)/2 <= 42.7C, set fan speed from 65% to 40%
 * 8. The default FAN speed is 40%
 */
int
onlp_sysi_platform_manage_fans(void)
{
#define LEV1_UP_TEMP    57500  /*temperature*/
#define LEV1_DOWN_TEMP  NULL  /* unused */
#define LEV1_SPEED_PERC 100   /*percentage*/

#define LEV2_UP_TEMP    53000
#define LEV2_DOWN_TEMP  52700
#define LEV2_SPEED_PERC 80

#define LEV3_UP_TEMP    49500
#define LEV3_DOWN_TEMP  47700
#define LEV3_SPEED_PERC 65

#define LEV4_UP_TEMP    NULL  /* unused */
#define LEV4_DOWN_TEMP  42700
#define LEV4_SPEED_PERC 40

#define FAN_NUM_ON_MAIN_BROAD  5


	int rc, i;
    int is_up;
    int new_temp, temp1, temp2, diff;
    static int new_perc = 0, ori_perc = 0;
    static int ori_temp = 0;
    onlp_thermal_info_t thermal_info;
    onlp_fan_info_t fan_info;

    /* get new temperature */
    if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &thermal_info)) != ONLP_STATUS_OK)
        goto _EXIT;

    temp1 = thermal_info.mcelsius;

    if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_info)) != ONLP_STATUS_OK)
        goto _EXIT;

    temp2 = thermal_info.mcelsius;

    new_temp = (temp1+temp2)/2;

    /* check fan status */
    for (i=1; i<=FAN_NUM_ON_MAIN_BROAD; i++)
    {
        if ((rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info)) != ONLP_STATUS_OK)
            goto _EXIT;

        if (fan_info.status & ONLP_FAN_STATUS_FAILED)
        {
            new_perc = LEV1_SPEED_PERC;
            goto _CTRL;
        }
    }

    diff = new_temp - ori_temp;

    if (diff == 0)
        goto _EXIT;
    else
        is_up = (diff > 0 ? 1 : 0);

    if (is_up)
    {
        if (new_temp >= LEV1_UP_TEMP)
            new_perc = LEV1_SPEED_PERC;
        else if (new_temp >= LEV2_UP_TEMP)
            new_perc = LEV2_SPEED_PERC;
        else if (new_temp >= LEV3_UP_TEMP)
            new_perc = LEV3_SPEED_PERC;
        else
            new_perc = LEV4_SPEED_PERC;
    }
    else
    {
        if (new_temp <= LEV4_DOWN_TEMP)
            new_perc = LEV4_SPEED_PERC;
        else if (new_temp <= LEV3_DOWN_TEMP)
            new_perc = LEV3_SPEED_PERC;
        else if (new_temp <= LEV2_DOWN_TEMP)
            new_perc = LEV2_SPEED_PERC;
        else
            new_perc = LEV1_SPEED_PERC;
    }

_CTRL :

    if (LOCAL_DEBUG)
        printf("\n[DEBUG][%s][%d]{ori:temp=%d, perc=%d} {new:temp=%d, perc=%d}\n", __FUNCTION__, __LINE__,
                ori_temp, ori_perc, new_temp, new_perc);

    if (ori_perc == new_perc)
        goto _EXIT;

    /* ctrl fans */
    AIM_LOG_INFO("Fan Speeds are now at %d%%", new_perc);

    if ((rc = onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_perc)) != ONLP_STATUS_OK)
        goto _EXIT;

    /* update om */
    ori_perc = new_perc;
    ori_temp = new_temp;

_EXIT :

    return rc;
}
예제 #16
0
int
onlp_sysi_platform_manage_fans(void)
{ 

    int rc;
    onlp_thermal_info_t ti2, ti3, ti4;
    int mtemp=0;
    int new_rpm=0;
    
    if (chassis_fan_count() == 0) {
        return ONLP_STATUS_E_UNSUPPORTED;
    }
  
    /* Get temperature */
    /*rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }*/
        
    rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }
    rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(3), &ti3);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }
        
    rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(4), &ti4);
	
    if (rc != ONLP_STATUS_OK) {
        return rc;
    }
             
    mtemp=(ti2.mcelsius+ti3.mcelsius + ti4.mcelsius) / 3;

    DEBUG_PRINT("mtemp %d\n", mtemp);

    /* Bring fan speed according the temp
     */
  
    if(mtemp<25000)
        new_rpm=FAN_IDLE_RPM;
    else if((mtemp>=30000)&&(mtemp<40000))
        new_rpm=FAN_LEVEL1_RPM;
    else if((mtemp>=45000)&&(mtemp<55000))
        new_rpm=FAN_LEVEL2_RPM;
    else if((mtemp>=60000)&&(mtemp<75000))
        new_rpm=FAN_LEVEL3_RPM;
    else if(mtemp>=80000)
        new_rpm=FAN_LEVEL4_RPM;
    else{
        return ONLP_STATUS_OK;
   }
  
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm);
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); 
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(3),new_rpm); 
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(4),new_rpm); 
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(5),new_rpm); 
    onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(6),new_rpm);
     
    return ONLP_STATUS_OK;
}
예제 #17
0
 */
int
onlp_fani_init(void)
{
    return ONLP_STATUS_OK;
}

/*
 * Get the fan information.
 */

/* Static fan information */
onlp_fan_info_t finfo[] = {
    { }, /* Not used */
    {
        { ONLP_FAN_ID_CREATE(1), "Chassis Fan 1", 0 },
        0x1,
        ONLP_FAN_CAPS_B2F,
        9000,
        100,
        ONLP_FAN_MODE_MAX,
        "FAN1Model",
        "FAN1SerialNumber",
    },
    {
        { ONLP_FAN_ID_CREATE(2), "Chassis Fan 2", 0 },
        0x0,
    },
    {
        { ONLP_FAN_ID_CREATE(3), "PSU-1 Fan 1", 0 },
        0x1,
예제 #18
0
static int
psu_ym2651y_info_get(onlp_psu_info_t* info)
{
    int val   = 0;
    int index = ONLP_OID_ID_GET(info->hdr.id);
    
    /* Set capability
     */
    info->caps = ONLP_PSU_CAPS_AC;
    
	if (info->status & ONLP_PSU_STATUS_FAILED) {
	    return ONLP_STATUS_OK;
	}

    /* Set the associated oid_table */
    info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
    info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);
    
    if (strncmp(info->model, "YM-2851J", strlen("YM-2851J")) == 0) {
        
            /* Read voltage, current and power */
        if (psu_dps850_pmbus_info_get(index, "psu_v_out", &val) == 0) {
            info->mvout = val;
            info->caps |= ONLP_PSU_CAPS_VOUT;
        }

        if (psu_dps850_pmbus_info_get(index, "psu_v_in", &val) == 0) {
            info->mvin  = val;
            info->caps |= ONLP_PSU_CAPS_VIN;
        }

        if (psu_dps850_pmbus_info_get(index, "psu_i_out", &val) == 0) {
            info->miout = val;
            info->caps |= ONLP_PSU_CAPS_IOUT;
        }

        if (psu_dps850_pmbus_info_get(index, "psu_i_in", &val) == 0) {
            info->caps |= ONLP_PSU_CAPS_IIN;
        }

        if (psu_dps850_pmbus_info_get(index, "psu_p_out", &val) == 0) {
            info->mpout = val;
            info->caps |= ONLP_PSU_CAPS_POUT;
        }

        if (psu_dps850_pmbus_info_get(index, "psu_p_in", &val) == 0) {
            info->mpin  = val;
            info->caps |= ONLP_PSU_CAPS_PIN;
        }
    } 
    else {

        /* Read voltage, current and power */
        if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) {
            info->mvout = val;
            info->caps |= ONLP_PSU_CAPS_VOUT;
        }

        if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) {
            info->miout = val;
            info->caps |= ONLP_PSU_CAPS_IOUT;
        }

        if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) {
            info->mpout = val;
            info->caps |= ONLP_PSU_CAPS_POUT;
        }
    }

	psu_serial_number_get(index, info->serial, sizeof(info->serial));

    return ONLP_STATUS_OK;
}
예제 #19
0
    if(cpld_base__ == NULL || cpld_base__ == MAP_FAILED) {
        return ONLP_STATUS_E_INTERNAL;
    }

    return ONLP_STATUS_OK;
}

/*
 * Get the fan information.
 */

/* Static fan information */
onlp_fan_info_t finfo[] = {
    { }, /* Not used */
    {
        { ONLP_FAN_ID_CREATE(FAN_ID_CHASSIS), "Chassis Fan 1", 0 },
    },
    {
        { ONLP_FAN_ID_CREATE(FAN_ID_PSU1), "PSU-1 Fan 1", ONLP_PSU_ID_CREATE(1) },
    },
    {
        { ONLP_FAN_ID_CREATE(FAN_ID_PSU2), "PSU-2 Fan 1", ONLP_PSU_ID_CREATE(2) },
    }
};

static int
chassis_fan_get_info(onlp_fan_info_t* info)
{
    unsigned char data;
    info->status = 0;