host-bmc PDR flow: support refreshEntireRepository
Support the refreshEntireRepository format of the
pldmPDRRepositoryChgEvent event, to fetch all PDRs of the host.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: Ic91806e35c34b6fb9421df6be7e801d0c8c7c866
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 3c8d54e..f8594d6 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -85,7 +85,7 @@
});
}
-void HostPDRHandler::fetchPDR(std::vector<uint32_t>&& recordHandles)
+void HostPDRHandler::fetchPDR(PDRRecordHandles&& recordHandles)
{
pdrRecordHandles.clear();
pdrRecordHandles = std::move(recordHandles);
@@ -107,7 +107,17 @@
auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
bool merged = false;
- for (auto recordHandle : pdrRecordHandles)
+ uint32_t nextRecordHandle{};
+ uint32_t recordHandle{};
+ bool isFormatRecHandles = false;
+ if (!pdrRecordHandles.empty())
+ {
+ recordHandle = pdrRecordHandles.front();
+ pdrRecordHandles.pop_front();
+ isFormatRecHandles = true;
+ }
+
+ do
{
auto instanceId = requester.getInstanceId(mctp_eid);
@@ -138,7 +148,6 @@
}
uint8_t completionCode{};
- uint32_t nextRecordHandle{};
uint32_t nextDataTransferHandle{};
uint8_t transferFlag{};
uint16_t respCount{};
@@ -194,8 +203,19 @@
pldm_pdr_add(repo, pdr.data(), respCount, 0, true);
}
}
+
+ recordHandle = nextRecordHandle;
+ if (!pdrRecordHandles.empty())
+ {
+ recordHandle = pdrRecordHandles.front();
+ pdrRecordHandles.pop_front();
+ }
+ else if (isFormatRecHandles)
+ {
+ break;
+ }
}
- }
+ } while (recordHandle);
if (merged)
{
diff --git a/host-bmc/host_pdr_handler.hpp b/host-bmc/host_pdr_handler.hpp
index a54c008..fbb206c 100644
--- a/host-bmc/host_pdr_handler.hpp
+++ b/host-bmc/host_pdr_handler.hpp
@@ -11,6 +11,7 @@
#include <sdeventplus/event.hpp>
#include <sdeventplus/source/event.hpp>
+#include <deque>
#include <map>
#include <memory>
#include <vector>
@@ -24,7 +25,7 @@
// vector which would hold the PDR record handle data returned by
// pldmPDRRepositoryChgEvent event data
using ChangeEntry = uint32_t;
-using PDRRecordHandles = std::vector<ChangeEntry>;
+using PDRRecordHandles = std::deque<ChangeEntry>;
/** @struct SensorEntry
*
@@ -88,7 +89,7 @@
* PDRs that need to be fetched.
*/
- void fetchPDR(std::vector<uint32_t>&& recordHandles);
+ void fetchPDR(PDRRecordHandles&& recordHandles);
/** @brief Send a PLDM event to host firmware containing a list of record
* handles of PDRs that the host firmware has to fetch.
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index b94fdab..6801566 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -448,6 +448,12 @@
}
PDRRecordHandles pdrRecordHandles;
+
+ if (eventDataFormat == FORMAT_IS_PDR_TYPES)
+ {
+ return PLDM_ERROR_INVALID_DATA;
+ }
+
if (eventDataFormat == FORMAT_IS_PDR_HANDLES)
{
uint8_t eventDataOperation{};
@@ -487,15 +493,10 @@
changeRecordDataSize -=
dataOffset + (numberOfChangeEntries * sizeof(ChangeEntry));
}
-
- if (hostPDRHandler && !pdrRecordHandles.empty())
- {
- hostPDRHandler->fetchPDR(std::move(pdrRecordHandles));
- }
}
- else
+ if (hostPDRHandler)
{
- return PLDM_ERROR_INVALID_DATA;
+ hostPDRHandler->fetchPDR(std::move(pdrRecordHandles));
}
return PLDM_SUCCESS;