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/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index f23407b..f4c86e6 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -27,6 +27,25 @@
const Json emptyJson{};
const std::vector<Json> emptyJsonList{};
+template <typename T>
+uint16_t extractTerminusHandle(std::vector<uint8_t>& pdr)
+{
+ T* var = nullptr;
+ if (std::is_same<T, pldm_pdr_fru_record_set>::value)
+ {
+ var = (T*)(pdr.data() + sizeof(pldm_pdr_hdr));
+ }
+ else
+ {
+ var = (T*)(pdr.data());
+ }
+ if (var != nullptr)
+ {
+ return var->terminus_handle;
+ }
+ return TERMINUS_HANDLE;
+}
+
HostPDRHandler::HostPDRHandler(
int mctp_fd, uint8_t mctp_eid, sdeventplus::Event& event, pldm_pdr* repo,
const std::string& eventsJsonsDir, pldm_entity_association_tree* entityTree,
@@ -226,8 +245,8 @@
}
else
{
- pldm_entity_association_pdr_add_from_node(node, repo, &entities,
- numEntities, true);
+ pldm_entity_association_pdr_add_from_node(
+ node, repo, &entities, numEntities, true, TERMINUS_HANDLE);
}
}
free(entities);
@@ -370,6 +389,7 @@
bool tlValid = true;
uint32_t rh = 0;
uint16_t terminusHandle = 0;
+ uint16_t pdrTerminusHandle = 0;
uint8_t tid = 0;
uint8_t completionCode{};
@@ -439,6 +459,8 @@
{
if (pdrHdr->type == PLDM_TERMINUS_LOCATOR_PDR)
{
+ pdrTerminusHandle =
+ extractTerminusHandle<pldm_terminus_locator_pdr>(pdr);
auto tlpdr =
reinterpret_cast<const pldm_terminus_locator_pdr*>(
pdr.data());
@@ -464,9 +486,26 @@
}
else if (pdrHdr->type == PLDM_STATE_SENSOR_PDR)
{
+ pdrTerminusHandle =
+ extractTerminusHandle<pldm_state_sensor_pdr>(pdr);
stateSensorPDRs.emplace_back(pdr);
}
-
+ else if (pdrHdr->type == PLDM_PDR_FRU_RECORD_SET)
+ {
+ pdrTerminusHandle =
+ extractTerminusHandle<pldm_pdr_fru_record_set>(pdr);
+ }
+ else if (pdrHdr->type == PLDM_STATE_EFFECTER_PDR)
+ {
+ pdrTerminusHandle =
+ extractTerminusHandle<pldm_state_effecter_pdr>(pdr);
+ }
+ else if (pdrHdr->type == PLDM_NUMERIC_EFFECTER_PDR)
+ {
+ pdrTerminusHandle =
+ extractTerminusHandle<pldm_numeric_effecter_value_pdr>(
+ pdr);
+ }
// if the TLPDR is invalid update the repo accordingly
if (!tlValid)
{
@@ -475,7 +514,8 @@
}
else
{
- pldm_pdr_add(repo, pdr.data(), respCount, rh, true);
+ pldm_pdr_add(repo, pdr.data(), respCount, rh, true,
+ pdrTerminusHandle);
}
}
}