Improve the pldmtool to display logical entities
- The logic in pldmtool was written in such a way that
it would display anything as OEM if it is not in the
supported map.
- For example a "core" (entity type - Processor | Logical Bit)
which is a logical Processor entity is wrongly displayed as
OEM by the pldmtool.With this commit that behavior of pldmtool
is fixed.
Tested By:
root@rainier:/tmp# ./pldmtool platform getpdr -d 64
{
"nextRecordHandle": 65,
"responseCount": 20,
"recordHandle": 64,
"PDRHeaderVersion": 1,
"PDRType": "FRU Record Set PDR",
"recordChangeNumber": 0,
"dataLength": 10,
"PLDMTerminusHandle": 2,
"FRURecordSetIdentifier": 42496,
"entityType": "[Logical] Processor",
"entityInstanceNumber": 1,
"containerID": 2
}
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I52e314cbc80629d05f2b4dbf4fcd7ad40989fb91
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index 1203e91..82b2f95 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -360,15 +360,43 @@
{PLDM_OEM_PDR, "OEM PDR"},
};
+ bool isLogicalBitSet(const uint16_t entity_type)
+ {
+ return entity_type & 0x8000;
+ }
+
+ uint16_t getEntityTypeForLogicalEntity(const uint16_t logical_entity_type)
+ {
+ return logical_entity_type & 0x7FFF;
+ }
+
std::string getEntityName(pldm::pdr::EntityType type)
{
+ uint16_t entityNumber = type;
+ std::string entityName = "[Physical] ";
+
+ if (isLogicalBitSet(type))
+ {
+ entityName = "[Logical] ";
+ entityNumber = getEntityTypeForLogicalEntity(type);
+ }
+
try
{
- return entityType.at(type);
+ return entityName + entityType.at(entityNumber);
}
catch (const std::out_of_range& e)
{
- return std::to_string(static_cast<unsigned>(type)) + "(OEM)";
+ if (type >= PLDM_OEM_ENTITY_TYPE_START &&
+ type <= PLDM_OEM_ENTITY_TYPE_END)
+ {
+
+ return entityName +
+ std::to_string(static_cast<unsigned>(entityNumber)) +
+ "(OEM)";
+ }
+
+ return std::to_string(static_cast<unsigned>(entityNumber));
}
}