oem:ibm :Implement SetFruRecordTable
The commit implements the setFruRecordTable command
and also updates the DBus property for the IBM cable cards
for which the host sends a setFruRecordTable command.
Tested: using pldmtool
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
Change-Id: I70e4f85f627577d8ca1bc90447b10e9e2e8e7ccd
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index da19d00..20bc509 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "fru_parser.hpp"
+#include "libpldmresponder/pdr_utils.hpp"
+#include "oem_handler.hpp"
#include "pldmd/handler.hpp"
#include <libpldm/fru.h>
@@ -59,13 +61,16 @@
* @param[in] entityTree - opaque pointer to the entity association tree
* @param[in] bmcEntityTree - opaque pointer to bmc's entity association
* tree
+ * @param[in] oemFruHandler - OEM fru handler
*/
FruImpl(const std::string& configPath,
const std::filesystem::path& fruMasterJsonPath, pldm_pdr* pdrRepo,
pldm_entity_association_tree* entityTree,
- pldm_entity_association_tree* bmcEntityTree) :
+ pldm_entity_association_tree* bmcEntityTree,
+ pldm::responder::oem_fru::Handler* oemFruHandler) :
parser(configPath, fruMasterJsonPath),
- pdrRepo(pdrRepo), entityTree(entityTree), bmcEntityTree(bmcEntityTree)
+ pdrRepo(pdrRepo), entityTree(entityTree), bmcEntityTree(bmcEntityTree),
+ oemFruHandler(oemFruHandler)
{}
/** @brief Total length of the FRU table in bytes, this includes the pad
@@ -188,6 +193,14 @@
*/
std::vector<uint8_t> tableResize();
+ /* @brief set FRU Record Table
+ *
+ * @param[in] fruData - the data of the fru
+ *
+ * @return PLDM completion code
+ */
+ int setFRUTable(const std::vector<uint8_t>& fruData);
+
private:
uint16_t nextRSI()
{
@@ -211,6 +224,7 @@
pldm_pdr* pdrRepo;
pldm_entity_association_tree* entityTree;
pldm_entity_association_tree* bmcEntityTree;
+ pldm::responder::oem_fru::Handler* oemFruHandler;
std::map<dbus::ObjectPath, pldm_entity_node*> objToEntityNode{};
@@ -240,8 +254,10 @@
Handler(const std::string& configPath,
const std::filesystem::path& fruMasterJsonPath, pldm_pdr* pdrRepo,
pldm_entity_association_tree* entityTree,
- pldm_entity_association_tree* bmcEntityTree) :
- impl(configPath, fruMasterJsonPath, pdrRepo, entityTree, bmcEntityTree)
+ pldm_entity_association_tree* bmcEntityTree,
+ pldm::responder::oem_fru::Handler* oemFruHandler) :
+ impl(configPath, fruMasterJsonPath, pdrRepo, entityTree, bmcEntityTree,
+ oemFruHandler)
{
handlers.emplace(
PLDM_GET_FRU_RECORD_TABLE_METADATA,
@@ -258,6 +274,11 @@
[this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
return this->getFRURecordByOption(request, payloadLength);
});
+ handlers.emplace(
+ PLDM_SET_FRU_RECORD_TABLE,
+ [this](pldm_tid_t, const pldm_msg* request, size_t payloadLength) {
+ return this->setFRURecordTable(request, payloadLength);
+ });
}
/** @brief Handler for Get FRURecordTableMetadata
@@ -309,6 +330,17 @@
Response getFRURecordByOption(const pldm_msg* request,
size_t payloadLength);
+ /** @brief Handler for SetFRURecordTable
+ *
+ * @param[in] request - Request message
+ * @param[in] payloadLength - Request payload length
+ *
+ * @return PLDM response message
+ */
+ Response setFRURecordTable(const pldm_msg* request, size_t payloadLength);
+
+ using Table = std::vector<uint8_t>;
+
private:
FruImpl impl;
};