Пример #1
0
static uint32_t
_onlp_fani_info_get_psu_fan_direction(void)
{
    /* Try to read direction from PSU1.
     * If PSU1 is not valid, read from PSU2
     */
    int i = 0;

    for (i = PSU1_ID; i <= PSU2_ID; i++) {
        psu_type_t psu_type;
        psu_type = get_psu_type(i, NULL, 0);

        if (psu_type == PSU_TYPE_UNKNOWN) {
            continue;
        }

		switch (psu_type) {
			case PSU_TYPE_AC_F2B:
			case PSU_TYPE_DC_48V_F2B:
			case PSU_TYPE_DC_12V_F2B:
				return ONLP_FAN_STATUS_F2B;
			case PSU_TYPE_AC_B2F:
			case PSU_TYPE_DC_48V_B2F:
			case PSU_TYPE_DC_12V_B2F:
				return ONLP_FAN_STATUS_B2F;
			default:
				return 0;
		};
    }

    return 0;
}
Пример #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 */

    /* Get the present state */
    if (psu_status_info_get(index, "psu_present", &val) != 0) {
        printf("Unable to read PSU(%d) node(psu_present)\r\n", index);
    }

    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 (psu_status_info_get(index, "psu_power_good", &val) != 0) {
        printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index);
    }

    if (val != PSU_STATUS_POWER_GOOD) {
		info->status |= ONLP_PSU_STATUS_UNPLUGGED;
		return ONLP_STATUS_OK;
    }


    /* Get PSU type
     */
    psu_type = get_psu_type(index, info->model, sizeof(info->model));

    switch (psu_type) {
        case PSU_TYPE_AC_F2B:
        case PSU_TYPE_AC_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;
}
Пример #3
0
static int
_onlp_fani_info_get_fan_on_psu(int local_id, int psu_id, onlp_fan_info_t* info)
{
    int   fd, len, nbytes = 10;
    char  r_data[10]   = {0};
    char  fullpath[80] = {0};

    /* get fan direction
     */
    switch(get_psu_type(psu_id, NULL, 0))
        {
        case PSU_TYPE_AC_F2B:
            info->status |= ONLP_FAN_STATUS_F2B;
            break;
        case PSU_TYPE_AC_B2F:
            info->status |= ONLP_FAN_STATUS_B2F;
            break;
        default:
            break;
        }

    /* get fan fault status
     */
    sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
    OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
    info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0;

    /* get fan speed
     */
    sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
    OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
    info->rpm = atoi(r_data);

    /* get speed percentage from rpm */
    info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
    info->status |= ONLP_FAN_STATUS_PRESENT;

    return ONLP_STATUS_OK;
}
Пример #4
0
static int
_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
{
    int   psu_id, is_ac=0;
    int   fd, len, nbytes = 10;
    char  r_data[10]   = {0};
    char  fullpath[50] = {0};
    psu_type_t psu_type;
    
    /* get fan other cap status according to psu type 
     */
    psu_id    = (local_id-FAN_1_ON_PSU1) + 1;
    
    if (LOCAL_DEBUG)
        printf("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id); 
    
    psu_type  = get_psu_type(psu_id, NULL, 0); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */

    if (LOCAL_DEBUG)
        printf("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type); 


    switch (psu_type) {
        case PSU_TYPE_AC_F2B:
            SET_PSU_TYPE_CPR_4011_F2B_FAN(info);
            is_ac = 1;
            break;
        case PSU_TYPE_AC_B2F:
            SET_PSU_TYPE_CPR_4011_B2F_FAN(info);
            is_ac = 1;
            break;
        case PSU_TYPE_DC_48V_F2B:
            SET_PSU_TYPE_UM400D_F2B_FAN(info);
            break;
        case PSU_TYPE_DC_48V_B2F:
            SET_PSU_TYPE_UM400D_B2F_FAN(info);
            break;
        default:
            if (LOCAL_DEBUG)
                printf("[Debug][%s][%d][psu_type=%d]\n", __FUNCTION__, __LINE__, psu_type); 

            break;
    }
    
    if (1 == is_ac)
    {
        /* get fan fault status 
         */
        sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, last_path[local_id].status);	
        OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
        if (atoi(r_data) > 0)
            info->status |= ONLP_FAN_STATUS_FAILED;
     
        /* get fan speed
         */
        sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, last_path[local_id].speed);	
        OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);    
        info->rpm = atoi(r_data); 

        /* get speed percentage from rpm */
        info->percentage = (info->rpm * 100)/19328;        

    }
     		
    return ONLP_STATUS_OK;
}
Пример #5
0
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
    char                  name[ONLP_CONFIG_INFO_STR_MAX];
    char                  status;
    int                   ret = ONLP_STATUS_OK;
    int                   index = ONLP_OID_ID_GET(id);
    psu_type_t            psu_type; 
    
    UI8_T product_ser[PSUI_PRODUCT_SER_NO_LEN];
    
    UI8_T rps_status = 0, power_ok = 0, power_on = 0, power_present = 0;

    VALIDATE(id);

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

    /* Get PSU type and product name, bus ID=index+10*/
	if( index == 1)
    	psu_type = get_psu_type(PSU1_BUS_ID, info->model, sizeof(info->model));
	else if( index == 2)
		psu_type = get_psu_type(PSU2_BUS_ID, info->model, sizeof(info->model));
	 
    //debug
    DIAG_PRINT("%s, id:%d, index:%d, psu_type:%d\n",__FUNCTION__,id,index,psu_type);
    switch (psu_type)
    {
        case PSU_TYPE_AC_F2B:
        case PSU_TYPE_AC_B2F:
			if( index == 1)
            ret = psu_ne2572_info_get(PSU1_BUS_ID, info);/* Get PSU electric info from PMBus */
			else if (index == 2)
				ret = psu_ne2572_info_get(PSU2_BUS_ID, info);/* Get PSU electric info from PMBus */
            break;
        case PSU_TYPE_DC_48V_F2B:
        case PSU_TYPE_DC_48V_B2F:
            ret = psu_um400d_info_get(info);
            break;
        default:
            ret = ONLP_STATUS_E_UNSUPPORTED;
            return ret;
    }

    /* Get the product serial number, bus ID=index+10 */
	if(index == 1) 
	{
	    if (psu_info_get_product_ser(psu_type, PSU1_BUS_ID, product_ser) < 0) 
	    {
	        printf("Unable to read PSU(%d) item(serial number)\r\n", index);
	    }
	    else
	    {
	        memcpy(info->serial, product_ser, sizeof(product_ser));
	    }
	} 
	else if( index == 2) 
	{
	   if (psu_info_get_product_ser(psu_type, PSU2_BUS_ID, product_ser) < 0) 
	    {
	        printf("Unable to read PSU(%d) item(serial number)\r\n", index);
	    }
	    else
	    {
	        memcpy(info->serial, product_ser, sizeof(product_ser));
	    }
	}
    /* Get psu status from CPLD */
    if (psu_info_get_status(index, &status) < 0) 
    {
        printf("Unable to read PSU(%d) item(psu status)\r\n", index);
    }
    else
    {
        rps_status = (UI8_T)atoi(&status);
        power_present = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_PRESENT);
        power_ok = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_OK);
        power_on = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_ON);

        /* Empty */
        if (!power_present)
        {
            info->status |= ONLP_PSU_STATUS_UNPLUGGED;
        }

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

        if (power_on)
        {
            info->status |= ONLP_PSU_STATUS_PRESENT;
        }

        DIAG_PRINT("rps_status:0x%x ,info->status:0x%x\n", rps_status, info->status);
        DIAG_PRINT("present:%d, ok:%d, on:%d\n", power_present, power_ok, power_on);

    }



    return ret;
}