dimm-spd-reader: fix PMIC type detection from SPD
Add support for identifying PMIC unknown state as 0xFF. Update PMIC SPD detection flow to read SPD registers 0x200, 0x204, and 0x208. Check bit7 to determine whether the PMIC is installed, and use SPD bit[3:0] as the PMIC type. Also update the IPMI error handling path to return completion code 0x07 for command 0x6c when PMIC detection fails or the PMIC type is unknown.
This commit is contained in:
@@ -1374,7 +1374,7 @@ ipmi::RspType<uint8_t> ipmiBiosSetDimmPara(ipmi::Context::ptr ctx, std::vector<u
|
||||
railData[3] = static_cast<double>(dimmInfo.dimmCur.SWD) / 1000.0;
|
||||
railData[4] = static_cast<double>(dimmInfo.dimmCur.SWE) / 1000.0;
|
||||
railData[5] = static_cast<double>(dimmInfo.dimmCur.SWF) / 1000.0;
|
||||
for(int i=0; i<4; i++) {
|
||||
for(int i=0; i<6; i++) { //Jim debug check i<6 or i<4
|
||||
ret = setDimmParaToDbus(ctx, dimmName, "Current", railName[i], railData[i]);
|
||||
if(ret < 0)
|
||||
return ipmi::responseUnspecifiedError();
|
||||
@@ -1387,7 +1387,7 @@ ipmi::RspType<uint8_t> ipmiBiosSetDimmPara(ipmi::Context::ptr ctx, std::vector<u
|
||||
railData[3] = static_cast<double>(dimmInfo.dimmPow.SWD) / 1000.0;
|
||||
railData[4] = static_cast<double>(dimmInfo.dimmPow.SWE) / 1000.0;
|
||||
railData[5] = static_cast<double>(dimmInfo.dimmPow.SWF) / 1000.0;
|
||||
for(int i=0; i<4; i++) {
|
||||
for(int i=0; i<6; i++) { //Jim debug check i<6 or i<4
|
||||
ret = setDimmParaToDbus(ctx, dimmName, "Power", railName[i], railData[i]);
|
||||
if(ret < 0)
|
||||
return ipmi::responseUnspecifiedError();
|
||||
@@ -1740,6 +1740,21 @@ static std::optional<T> getDIMMData(const nlohmann::json& js, const std::string&
|
||||
auto value = dimmData["Status_Reg"][regStr];
|
||||
return static_cast<T>(value.get<int>());
|
||||
}
|
||||
else if (dataType == DataType::ERROR) {
|
||||
auto err = static_cast<ErrCode>(indexId);
|
||||
std::string errStr;
|
||||
|
||||
char hexStr[5];
|
||||
snprintf(hexStr, sizeof(hexStr), "0x%02x", static_cast<int>(err));
|
||||
errStr = hexStr;
|
||||
|
||||
if (!dimmData["Error_Code"].contains(errStr)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto value = dimmData["Error_Code"][errStr];
|
||||
return static_cast<T>(value.get<int>());
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -1748,7 +1763,7 @@ static std::optional<T> getDIMMData(const nlohmann::json& js, const std::string&
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
reqId: 0:TS0 1:TS1 2:SPD_TEMP 3: Max Temp 4:Voltage 5:Current 6: Status Reg
|
||||
reqId: 0:TS0 1:TS1 2:SPD_TEMP 3: Max Temp 4:Voltage 5:Current 6: Status Reg 7: Error Code
|
||||
*****************************************************************************/
|
||||
ipmi::RspType<std::vector<uint8_t>> ipmiGetDimmTemp(uint8_t reqId)
|
||||
{
|
||||
@@ -1757,7 +1772,7 @@ ipmi::RspType<std::vector<uint8_t>> ipmiGetDimmTemp(uint8_t reqId)
|
||||
const nlohmann::json empty{};
|
||||
nlohmann::json js;
|
||||
|
||||
if(reqId > 6) {
|
||||
if(reqId > 7) {
|
||||
std::cout << "invalid reqId :" << (int)reqId << std::endl;
|
||||
return ipmi::responseParmOutOfRange();
|
||||
}
|
||||
@@ -1806,7 +1821,8 @@ ipmi::RspType<std::vector<uint8_t>> ipmiGetDimmTemp(uint8_t reqId)
|
||||
+ "_" + std::string(1, 'A' + i);
|
||||
std::optional<double> temp, swa, swb, swc, swd, swe, swf;
|
||||
std::optional<uint8_t> r4, r5, r6, r7, r8, r9, ra, rb;
|
||||
|
||||
std::optional<uint8_t> err_r32;
|
||||
|
||||
switch(static_cast<ReqId>(reqId))
|
||||
{
|
||||
case ReqId::TS0:
|
||||
@@ -1847,6 +1863,11 @@ ipmi::RspType<std::vector<uint8_t>> ipmiGetDimmTemp(uint8_t reqId)
|
||||
ra = getDIMMData<uint8_t>(js, dimmName, DataType::STATUS, StatusReg::REG_0A);
|
||||
rb = getDIMMData<uint8_t>(js, dimmName, DataType::STATUS, StatusReg::REG_0B);
|
||||
break;
|
||||
|
||||
case ReqId::ERROR_CODE:
|
||||
err_r32 = getDIMMData<uint8_t>(js, dimmName, DataType::ERROR, ErrCode::errCode_REG_32);
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout << "invalid reqId :" << (int)reqId << std::endl;
|
||||
return ipmi::responseParmOutOfRange();
|
||||
@@ -1865,6 +1886,11 @@ ipmi::RspType<std::vector<uint8_t>> ipmiGetDimmTemp(uint8_t reqId)
|
||||
byte_vector.push_back(opt.value_or(0xFF));
|
||||
}
|
||||
}
|
||||
else if(reqId == 7) {
|
||||
for (const auto& opt : {err_r32}) {
|
||||
byte_vector.push_back(opt.value_or(0xFF));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const auto& rail : {swa, swb, swc, swd, swe, swf}) {
|
||||
auto bytes = convertDoubleToTwoBytes(rail);
|
||||
|
||||
Reference in New Issue
Block a user