fru: Add support to insert hot-plug PDRs into repository
This API helps to insert PDRs that are added or modified
during concurrent maintenance operations into the PDR repository.
The function assigns a new record handle (based on the last
BMC side PDR handle) and appends the provided PDR entry to the
repository.
Tested By: Tested and it successfully builds with -Doem-ibm=disabled
Change-Id: I4981caa7700b5022159056819b875e47240798a0
Signed-off-by: Pavithra Barithaya <pavithrabarithaya07@gmail.com>
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index ff6643a..7fe1b7c 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -504,6 +504,25 @@
return PLDM_ERROR_UNSUPPORTED_PLDM_CMD;
}
+uint32_t FruImpl::addHotPlugRecord(
+ pldm::responder::pdr_utils::PdrEntry pdrEntry)
+{
+ uint32_t lastHandle = 0;
+ uint32_t recordHandle = 0;
+
+ if (oemPlatformHandler)
+ {
+ auto lastLocalRecord = oemPlatformHandler->fetchLastBMCRecord(pdrRepo);
+ lastHandle = pldm_pdr_get_record_handle(pdrRepo, lastLocalRecord);
+ }
+
+ pdrEntry.handle.recordHandle = lastHandle + 1;
+ pldm_pdr_add(pdrRepo, pdrEntry.data, pdrEntry.size, false,
+ pdrEntry.handle.recordHandle, &recordHandle);
+
+ return recordHandle;
+}
+
namespace fru
{
Response Handler::getFRURecordTableMetadata(const pldm_msg* request,
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index 6586fad..2cc9f43 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -150,6 +150,16 @@
return associatedEntityMap;
}
+ /* @brief Method to set the oem platform handler in FRU handler class
+ *
+ * @param[in] handler - oem platform handler
+ */
+ inline void setOemPlatformHandler(
+ pldm::responder::oem_platform::Handler* handler)
+ {
+ oemPlatformHandler = handler;
+ }
+
/** @brief Get pldm entity by the object path
*
* @param[in] intfMaps - D-Bus interfaces and the associated property
@@ -235,6 +245,9 @@
pldm::responder::oem_fru::Handler* oemFruHandler = nullptr;
dbus::ObjectValueTree objects;
+ /** @OEM platform handler */
+ pldm::responder::oem_platform::Handler* oemPlatformHandler;
+
std::map<dbus::ObjectPath, pldm_entity_node*> objToEntityNode{};
/** @brief populateRecord builds the FRU records for an instance of FRU and
@@ -249,6 +262,16 @@
const fru_parser::FruRecordInfos& recordInfos,
const pldm_entity& entity);
+ /** @brief Add hotplug record that was modified or added to the PDR entry
+ * HotPlug is a feature where a FRU can be removed or added when
+ * the system is running, without needing it to power off.
+ *
+ * @param[in] pdrEntry - PDR record structure in PDR repository
+ *
+ * @return record handle of added or modified hotplug record
+ */
+ uint32_t addHotPlugRecord(pldm::responder::pdr_utils::PdrEntry pdrEntry);
+
/** @brief Deletes a FRU record from record set table.
* @param[in] rsi - the FRU Record Set Identifier
*
@@ -334,6 +357,15 @@
return impl.getAssociateEntityMap();
}
+ /* @brief Method to set the oem platform handler in host pdr handler class
+ *
+ * @param[in] handler - oem platform handler
+ */
+ void setOemPlatformHandler(pldm::responder::oem_platform::Handler* handler)
+ {
+ return impl.setOemPlatformHandler(handler);
+ }
+
/** @brief Handler for GetFRURecordByOption
*
* @param[in] request - Request message payload
diff --git a/pldmd/oem_ibm.hpp b/pldmd/oem_ibm.hpp
index e3fbddf..13dfa92 100644
--- a/pldmd/oem_ibm.hpp
+++ b/pldmd/oem_ibm.hpp
@@ -85,6 +85,7 @@
codeUpdate->setOemPlatformHandler(oemPlatformHandler.get());
hostPDRHandler->setOemPlatformHandler(oemPlatformHandler.get());
hostPDRHandler->setOemUtilsHandler(oemUtilsHandler.get());
+ fruHandler->setOemPlatformHandler(oemPlatformHandler.get());
platformHandler->setOemPlatformHandler(oemPlatformHandler.get());
baseHandler->setOemPlatformHandler(oemPlatformHandler.get());
slotHandler->setOemPlatformHandler(oemPlatformHandler.get());