pdr: Implement terminus locator PDR for BMC
This commit creates the TL PDR for the BMC. The TID and MCTP EID for
BMC is static, 1 and 8 respectively. BMC PDRs are assigned the value
of 1 for PLDMTerminusHandle. Added the parser for terminus locator
PDR in pldmtool.
Tested:
/tmp/pldmtool platform GetPdr -d 0
nextRecordHandle: 2
responseCount: 19
recordHandle: 1
PDRHeaderVersion: 1
PDRType: 1
recordChangeNumber: 0
dataLength: 9
PLDMTerminusHandle: 1
validity: valid
TID: 1
containerID: 0
terminusLocatorType: MCTP_EID
terminusLocatorValueSize: 1
EID: 8
Change-Id: I596301d6c676b450ae1f2cef872966b4c40d8bae
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index c6f05a2..0745384 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -16,6 +16,10 @@
namespace pdr
{
+constexpr uint8_t BmcMctpEid = 8;
+constexpr uint8_t BmcPldmTerminusHandle = 1;
+constexpr uint8_t BmcTerminusId = 1;
+
/** @brief Build (if not built already) and retrieve PDR by the PDR types
*
* @param[in] dir - directory housing platform specific PDR JSON files
diff --git a/libpldmresponder/pdr_state_effecter.hpp b/libpldmresponder/pdr_state_effecter.hpp
index 1391def..173d328 100644
--- a/libpldmresponder/pdr_state_effecter.hpp
+++ b/libpldmresponder/pdr_state_effecter.hpp
@@ -2,7 +2,8 @@
#include "libpldm/platform.h"
-#include "libpldmresponder/pdr_utils.hpp"
+#include "pdr.hpp"
+#include "pdr_utils.hpp"
namespace pldm
{
@@ -62,7 +63,7 @@
pdr->hdr.record_change_num = 0;
pdr->hdr.length = pdrSize - sizeof(pldm_pdr_hdr);
- pdr->terminus_handle = 0;
+ pdr->terminus_handle = pdr::BmcPldmTerminusHandle;
pdr->effecter_id = handler.getNextEffecterId();
pdr->entity_type = e.value("type", 0);
pdr->entity_instance = e.value("instance", 0);
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 211ff65..3a9266e 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -3,6 +3,7 @@
#include "common/utils.hpp"
#include "event_parser.hpp"
+#include "pdr.hpp"
#include "pdr_numeric_effecter.hpp"
#include "pdr_state_effecter.hpp"
#include "platform_numeric_effecter.hpp"
@@ -137,6 +138,7 @@
{
if (!pdrCreated)
{
+ generateTerminusLocatorPDR(pdrRepo);
generate(*dBusIntf, pdrJsonsDir, pdrRepo);
pdrCreated = true;
}
@@ -556,6 +558,33 @@
return ccOnlyResponse(request, rc);
}
+void Handler::generateTerminusLocatorPDR(Repo& repo)
+{
+ std::vector<uint8_t> pdrBuffer(sizeof(pldm_terminus_locator_pdr));
+
+ auto pdr = reinterpret_cast<pldm_terminus_locator_pdr*>(pdrBuffer.data());
+
+ pdr->hdr.record_handle = 0;
+ pdr->hdr.version = 1;
+ pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR;
+ pdr->hdr.record_change_num = 0;
+ pdr->hdr.length = sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr);
+ pdr->terminus_handle = BmcPldmTerminusHandle;
+ pdr->validity = PLDM_TL_PDR_VALID;
+ pdr->tid = BmcTerminusId;
+ pdr->container_id = 0x0;
+ pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID;
+ pdr->terminus_locator_value_size =
+ sizeof(pldm_terminus_locator_type_mctp_eid);
+ auto locatorValue = reinterpret_cast<pldm_terminus_locator_type_mctp_eid*>(
+ pdr->terminus_locator_value);
+ locatorValue->eid = BmcMctpEid;
+
+ PdrEntry pdrEntry{};
+ pdrEntry.data = pdrBuffer.data();
+ pdrEntry.size = pdrBuffer.size();
+ repo.addRecord(pdrEntry);
+}
} // namespace platform
} // namespace responder
} // namespace pldm
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 1ff6bc4..5cf2534 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -68,6 +68,7 @@
{
if (!buildPDRLazily)
{
+ generateTerminusLocatorPDR(pdrRepo);
generate(*dBusIntf, pdrJsonsDir, pdrRepo);
pdrCreated = true;
}
@@ -402,6 +403,12 @@
return rc;
}
+ /** @brief Build BMC Terminus Locator PDR
+ *
+ * @param[in] repo - instance of concrete implementation of Repo
+ */
+ void generateTerminusLocatorPDR(Repo& repo);
+
private:
pdr_utils::Repo pdrRepo;
uint16_t nextEffecterId{};