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_FAILED; } /* 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_cpr_4011_info_get(info); 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; break; } return ret; }
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; }