Skip to content

Commit 08cea7e

Browse files
committed
vpd-manager: Add module VPD sanity check
Added new dbus API to perform the santity check for all the vpds. It takes one eeprom path at a time and checks for it's header, TOC and all it's records. Test: busctl introspect com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager NAME TYPE SIGNATURE RESULT/VALUE FLAGS .CollectFRUVPD method o - - .GetExpandedLocationCode method sq s - .GetFRUsByExpandedLocationCode method s ao - .GetFRUsByUnexpandedLocationCode method sq ao - .GetHardwarePath method o s - .PerformVPDRecollection method - - - .ReadKeyword method sv v - .UpdateKeyword method sv i - .WriteKeyword method ossay i - .WriteKeywordOnHardware method sv i - .deleteFRUVPD method o - - .performVpdSanityCheck method s - - .CollectionStatus property s "Completed" emits-change writable busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager performVpdSanityCheck s "/sys/bus/spi/drivers/at25/spi12.0/eeprom" Journal- vpd-manager[1078]: FileName: /usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/ipz_parser.cpp, Line: 1011 Performing sanity check for file path: /sys/bus/spi/drivers/at25/spi12.0/eeprom vpd-manager[1078]: FileName: /usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/ipz_parser.cpp, Line: 206 DBG: test purpose:checkHeader done vpd-manager[1078]: FileName: /usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/ipz_parser.cpp, Line: 246 DBG: test purpose:readTOC done vpd-manager[1078]: FileName: /usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/ipz_parser.cpp, Line: 297 DBG: test purpose:readPT done vpd-manager[1078]: FileName: /usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/ipz_parser.cpp, Line: 1023 SUCCESS busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager performVpdSanityCheck s "" "0x50003D0E": { "SRC": "BD554000", "Message": "An EEPROM path access error occurred.", "PLID": "0x50003D0E", "CreatorID": "BMC", "Subsystem": "CEC Hardware - VPD Interface", "Commit Time": "09/05/2025 09:10:03", "Sev": "Informational Event", "CompID": "bmc vpd" Signed-off-by: Alpana Kumari <[email protected]>
1 parent 4abf6c6 commit 08cea7e

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

vpd-manager/include/ipz_parser.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ class IpzVpdParser : public ParserInterface
106106
*/
107107
int writeKeywordOnHardware(const types::WriteVpdParams i_paramsToWriteData);
108108

109+
/**
110+
* @brief API to perform sanity check on EEPROM.
111+
*
112+
* @return SUCCESS or FAILURE.
113+
*/
114+
int vpdSanityCheck();
115+
109116
private:
110117
/**
111118
* @brief Check ECC of VPD header.

vpd-manager/include/manager.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ class Manager
203203
*/
204204
void performVpdRecollection();
205205

206+
/**
207+
* @brief API to perform sanity check on EEPROM.
208+
*
209+
* @param[in] i_vpdPath - EEPROM path
210+
*
211+
* @return SUCCESS or FAILURE.
212+
*/
213+
int performVpdSanityCheck(const types::Path i_vpdPath);
214+
206215
/**
207216
* @brief Get unexpanded location code.
208217
*

vpd-manager/include/parser_interface.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ class ParserInterface
6161
return -1;
6262
}
6363

64+
/**
65+
* @brief API to perform sanity check on EEPROM.
66+
*
67+
* @return SUCCESS or FAILURE.
68+
*/
69+
virtual int vpdSanityCheck()
70+
{
71+
return -1;
72+
}
6473
/**
6574
* @brief Virtual destructor.
6675
*/

vpd-manager/src/ipz_parser.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ std::pair<types::RecordOffsetList, types::InvalidRecordList>
272272
// Verify the ECC for this Record
273273
if (!recordEccCheck(itrToPT))
274274
{
275+
logging::logMessage(
276+
"ERROR: ECC check failed for [" + recordName + "]");
275277
throw(EccException("ERROR: ECC check failed"));
276278
}
277279
}
@@ -996,4 +998,34 @@ bool IpzVpdParser::processInvalidRecords(
996998
}
997999
return l_rc;
9981000
}
1001+
1002+
int IpzVpdParser::vpdSanityCheck()
1003+
{
1004+
try
1005+
{
1006+
logging::logMessage(
1007+
"Performing sanity check for file path: " + m_vpdFilePath);
1008+
auto itrToVPD = m_vpdVector.cbegin();
1009+
1010+
// Check vaidity of VHDR record
1011+
checkHeader(itrToVPD);
1012+
1013+
// Read the table of contents
1014+
auto ptLen = readTOC(itrToVPD);
1015+
1016+
// Read the table of contents record, to get offsets to other records.
1017+
auto l_result = readPT(itrToVPD, ptLen);
1018+
1019+
logging::logMessage("SUCCESS");
1020+
return constants::SUCCESS;
1021+
}
1022+
catch (const std::exception& e)
1023+
{
1024+
logging::logMessage(
1025+
"FAILED: Exception caught [" + std::string(e.what()) + "]");
1026+
1027+
return constants::FAILURE;
1028+
}
1029+
}
1030+
9991031
} // namespace vpd

vpd-manager/src/manager.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ Manager::Manager(
121121
this->performVpdRecollection();
122122
});
123123

124+
iFace->register_method("performVpdSanityCheck",
125+
[this](const types::Path i_vpdPath) {
126+
this->performVpdSanityCheck(i_vpdPath);
127+
});
128+
124129
// Indicates FRU VPD collection for the system has not started.
125130
iFace->register_property_rw<std::string>(
126131
"CollectionStatus", sdbusplus::vtable::property_::emits_change,
@@ -640,4 +645,42 @@ void Manager::performVpdRecollection()
640645
m_worker->performVpdRecollection();
641646
}
642647
}
648+
649+
int Manager::performVpdSanityCheck(const types::Path i_vpdPath)
650+
{
651+
try
652+
{
653+
if (i_vpdPath.empty())
654+
{
655+
throw std::runtime_error("Given FRU path is empty");
656+
}
657+
658+
nlohmann::json l_sysCfgJsonObj{};
659+
660+
if (m_worker.get() != nullptr)
661+
{
662+
l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
663+
}
664+
665+
std::shared_ptr<Parser> l_parserObj =
666+
std::make_shared<Parser>(i_vpdPath, l_sysCfgJsonObj);
667+
668+
std::shared_ptr<vpd::ParserInterface> l_vpdParserInstance =
669+
l_parserObj->getVpdParserInstance();
670+
671+
return l_vpdParserInstance->vpdSanityCheck();
672+
}
673+
catch (const std::exception& l_exception)
674+
{
675+
EventLogger::createAsyncPel(
676+
types::ErrorType::InvalidEeprom, types::SeverityType::Informational,
677+
__FILE__, __FUNCTION__, 0,
678+
"Sanity check failed for file[" + i_vpdPath +
679+
"], reason: " + std::string(l_exception.what()),
680+
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
681+
682+
return constants::FAILURE;
683+
}
684+
}
685+
643686
} // namespace vpd

0 commit comments

Comments
 (0)