platform-mc: Terminus name handling
`PLDM-stack: Adding sensor monitoring section` design spec details that
the `Terminus name` is required to create the terminus's sensors,
states, effecters... D-Bus interfaces and `Terminus Name` can be
encoded in the Terminus's `Entity Auxiliary Names PDR` or in the MCTP
Entity-manager endpoint EID configuration file.
[1] https://gerrit.openbmc.org/c/openbmc/docs/+/47252/34/designs/pldm-stack.md#433
Section `28.18 Entity Auxiliary Names PDR` in DSP0248 V1.2.2 details
about the PDRs response for the name of one PLDM entity. When the
containerID is `0x0000` this entity is `Overall system` or `top most
containing entity`. The name of this entity will can be used as
`Terminus name`.
Support parsing `Entity Auxiliary Names PDR` and find the `Terminus
name` if it is reponsed in the terminus' PDRs. `Terminus Name` string
will be assigned to local variable and can be used as prefix for
sensors, state, effecters... names.
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I701537c48651b9de86de77941b752e30de112916
diff --git a/platform-mc/terminus.hpp b/platform-mc/terminus.hpp
index 3a1a302..aacf288 100644
--- a/platform-mc/terminus.hpp
+++ b/platform-mc/terminus.hpp
@@ -21,6 +21,10 @@
namespace platform_mc
{
+using ContainerID = uint16_t;
+using EntityInstanceNumber = uint16_t;
+using EntityName = std::string;
+using EntityType = uint16_t;
using SensorId = uint16_t;
using SensorCnt = uint8_t;
using NameLanguageTag = std::string;
@@ -29,6 +33,29 @@
SensorId, SensorCnt,
std::vector<std::vector<std::pair<NameLanguageTag, SensorName>>>>;
+/** @struct EntityKey
+ *
+ * EntityKey uniquely identifies the PLDM entity and a combination of Entity
+ * Type, Entity Instance Number, Entity Container ID
+ *
+ */
+struct EntityKey
+{
+ EntityType type; //!< Entity type
+ EntityInstanceNumber instanceIdx; //!< Entity instance number
+ ContainerID containerId; //!< Entity container ID
+
+ bool operator==(const EntityKey& e) const
+ {
+ return ((type == e.type) && (instanceIdx == e.instanceIdx) &&
+ (containerId == e.containerId));
+ }
+};
+
+using AuxiliaryNames = std::vector<std::pair<NameLanguageTag, std::string>>;
+using EntityKey = struct EntityKey;
+using EntityAuxiliaryNames = std::tuple<EntityKey, AuxiliaryNames>;
+
/**
* @brief Terminus
*
@@ -90,6 +117,12 @@
return tid;
}
+ /** @brief The getter to get terminus's mctp medium */
+ std::string_view getTerminusName()
+ {
+ return terminusName;
+ }
+
/** @brief A list of PDRs fetched from Terminus */
std::vector<std::vector<uint8_t>> pdrs{};
@@ -104,6 +137,12 @@
std::shared_ptr<SensorAuxiliaryNames> getSensorAuxiliaryNames(SensorId id);
private:
+ /** @brief Find the Terminus Name from the Entity Auxiliary name list
+ * The Entity Auxiliary name list is entityAuxiliaryNamesTbl.
+ * @return terminus name in string option
+ */
+ std::optional<std::string_view> findTerminusName();
+
/** @brief Parse the numeric sensor PDRs
*
* @param[in] pdrData - the response PDRs from GetPDR command
@@ -120,6 +159,14 @@
std::shared_ptr<SensorAuxiliaryNames>
parseSensorAuxiliaryNamesPDR(const std::vector<uint8_t>& pdrData);
+ /** @brief Parse the Entity Auxiliary name PDRs
+ *
+ * @param[in] pdrData - the response PDRs from GetPDR command
+ * @return pointer to Entity Auxiliary name info struct
+ */
+ std::shared_ptr<EntityAuxiliaryNames>
+ parseEntityAuxiliaryNamesPDR(const std::vector<uint8_t>& pdrData);
+
/** @brief Parse the compact numeric sensor PDRs
*
* @param[in] pdrData - the response PDRs from GetPDR command
@@ -155,6 +202,13 @@
/* @brief Sensor Auxiliary Name list */
std::vector<std::shared_ptr<SensorAuxiliaryNames>>
sensorAuxiliaryNamesTbl{};
+
+ /* @brief Entity Auxiliary Name list */
+ std::vector<std::shared_ptr<EntityAuxiliaryNames>>
+ entityAuxiliaryNamesTbl{};
+
+ /** @brief Terminus name */
+ EntityName terminusName{};
};
} // namespace platform_mc
} // namespace pldm