Remove PDR's based on Terminus Handle
The current pldm infrastructure is written in way that
it deletes all the PDR's which are marked as "remote",when
we get a PDR refresh entire repository signal comes from remote
PLDM terminus,this does not work in muti-host scenario where BMC
talks to more than one HOST that talks pldm.
When a repository refresh signal comes form a remote PLDM terminus,
BMC is supposed to only delete the PDR's corresponding to the same
PLDM terminus.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I51f77c3f9537da722a00d97070674958c5baf1b4
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 418c831..afb5637 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -109,7 +109,8 @@
}
}
- pldm_entity_association_pdr_add(entityTree, pdrRepo, false);
+ pldm_entity_association_pdr_add(entityTree, pdrRepo, false,
+ TERMINUS_HANDLE);
// save a copy of bmc's entity association tree
pldm_entity_association_tree_copy_root(entityTree, bmcEntityTree);
diff --git a/libpldmresponder/pdr_utils.cpp b/libpldmresponder/pdr_utils.cpp
index d097b26..cc999a8 100644
--- a/libpldmresponder/pdr_utils.cpp
+++ b/libpldmresponder/pdr_utils.cpp
@@ -2,6 +2,8 @@
#include "pdr.hpp"
+#include <config.h>
+
#include <climits>
using namespace pldm::pdr;
@@ -23,7 +25,7 @@
RecordHandle Repo::addRecord(const PdrEntry& pdrEntry)
{
return pldm_pdr_add(repo, pdrEntry.data, pdrEntry.size,
- pdrEntry.handle.recordHandle, false);
+ pdrEntry.handle.recordHandle, false, TERMINUS_HANDLE);
}
const pldm_pdr_record* Repo::getFirstRecord(PdrEntry& pdrEntry)
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 707c9ff..fe825d7 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -471,8 +471,8 @@
int Handler::pldmPDRRepositoryChgEvent(const pldm_msg* request,
size_t payloadLength,
- uint8_t /*formatVersion*/,
- uint8_t /*tid*/, size_t eventDataOffset)
+ uint8_t /*formatVersion*/, uint8_t tid,
+ size_t eventDataOffset)
{
uint8_t eventDataFormat{};
uint8_t numberOfChangeRecords{};
@@ -544,6 +544,24 @@
}
if (hostPDRHandler)
{
+ // if we get a Repository change event with the eventDataFormat
+ // as REFRESH_ENTIRE_REPOSITORY, then delete all the PDR's that
+ // have the matched Terminus handle
+ if (eventDataFormat == REFRESH_ENTIRE_REPOSITORY)
+ {
+ // We cannot get the Repo change event from the Terminus
+ // that is not already added to the BMC repository
+
+ for (const auto& [terminusHandle, terminusInfo] :
+ hostPDRHandler->tlPDRInfo)
+ {
+ if (std::get<0>(terminusInfo) == tid)
+ {
+ pldm_pdr_remove_pdrs_by_terminus_handle(pdrRepo.getPdr(),
+ terminusHandle);
+ }
+ }
+ }
hostPDRHandler->fetchPDR(std::move(pdrRecordHandles));
}