oem-ampere: eventManager: Handle VR status sensor event
This commit adds the handler and needed APIs to handle VR status event
as Numeric Sensor Event in Ampere's OemEventManager class. The handler
will decode the event data, parse them to readable info and log to
Redfish Event Log.
Change-Id: I368fca2f7cdd0d13ce6f7cc6242ce44db5fb9cb9
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
diff --git a/oem/ampere/event/oem_event_manager.cpp b/oem/ampere/event/oem_event_manager.cpp
index 1aae241..c87659a 100644
--- a/oem/ampere/event/oem_event_manager.cpp
+++ b/oem/ampere/event/oem_event_manager.cpp
@@ -72,9 +72,13 @@
A map between sensor IDs and their names in string.
Using pldm::oem::sensor_ids
*/
-EventToMsgMap_t sensorIdToStrMap = {{DDR_STATUS, "DDR_STATUS"},
- {PCIE_HOT_PLUG, "PCIE_HOT_PLUG"},
- {BOOT_OVERALL, "BOOT_OVERALL"}};
+EventToMsgMap_t sensorIdToStrMap = {
+ {DDR_STATUS, "DDR_STATUS"}, {PCP_VR_STATE, "PCP_VR_STATE"},
+ {SOC_VR_STATE, "SOC_VR_STATE"}, {DPHY_VR1_STATE, "DPHY_VR1_STATE"},
+ {DPHY_VR2_STATE, "DPHY_VR2_STATE"}, {D2D_VR_STATE, "D2D_VR_STATE"},
+ {IOC_VR1_STATE, "IOC_VR1_STATE"}, {IOC_VR2_STATE, "IOC_VR2_STATE"},
+ {PCI_D_VR_STATE, "PCI_D_VR_STATE"}, {PCI_A_VR_STATE, "PCI_A_VR_STATE"},
+ {PCIE_HOT_PLUG, "PCIE_HOT_PLUG"}, {BOOT_OVERALL, "BOOT_OVERALL"}};
/*
A map between the boot stages and logging strings.
@@ -363,6 +367,17 @@
case DDR_STATUS:
handleDDRStatusEvent(tid, sensorId, presentReading);
break;
+ case PCP_VR_STATE:
+ case SOC_VR_STATE:
+ case DPHY_VR1_STATE:
+ case DPHY_VR2_STATE:
+ case D2D_VR_STATE:
+ case IOC_VR1_STATE:
+ case IOC_VR2_STATE:
+ case PCI_D_VR_STATE:
+ case PCI_A_VR_STATE:
+ handleVRDStatusEvent(tid, sensorId, presentReading);
+ break;
default:
std::string description;
std::stringstream strStream;
@@ -724,5 +739,54 @@
sendJournalRedfish(description, logLevel);
}
+void OemEventManager::handleVRDStatusEvent(pldm_tid_t tid, uint16_t sensorId,
+ uint32_t presentReading)
+{
+ log_level logLevel{log_level::WARNING};
+ std::string description;
+ std::stringstream strStream;
+
+ description += prefixMsgStrCreation(tid, sensorId);
+
+ VRDStatus_t status{presentReading};
+
+ if (status.bits.warning && status.bits.critical)
+ {
+ description += "A VR warning and a VR critical";
+ logLevel = log_level::CRITICAL;
+ }
+ else
+ {
+ if (status.bits.warning)
+ {
+ description += "A VR warning";
+ }
+ else if (status.bits.critical)
+ {
+ description += "A VR critical";
+ logLevel = log_level::CRITICAL;
+ }
+ else
+ {
+ description += "No VR warning or critical";
+ logLevel = log_level::OK;
+ }
+ }
+ description += " condition observed";
+
+ strStream << "; VR status byte high is 0x" << std::setfill('0') << std::hex
+ << std::setw(2)
+ << static_cast<uint32_t>(status.bits.vr_status_byte_high)
+ << "; VR status byte low is 0x" << std::setw(2)
+ << static_cast<uint32_t>(status.bits.vr_status_byte_low)
+ << "; Reading is 0x" << std::setw(2)
+ << static_cast<uint32_t>(presentReading) << ";";
+
+ description += strStream.str();
+
+ // Log to Redfish event
+ sendJournalRedfish(description, logLevel);
+}
+
} // namespace oem_ampere
} // namespace pldm
diff --git a/oem/ampere/event/oem_event_manager.hpp b/oem/ampere/event/oem_event_manager.hpp
index 93186cf..de925af 100644
--- a/oem/ampere/event/oem_event_manager.hpp
+++ b/oem/ampere/event/oem_event_manager.hpp
@@ -20,6 +20,15 @@
enum sensor_ids
{
DDR_STATUS = 51,
+ PCP_VR_STATE = 75,
+ SOC_VR_STATE = 80,
+ DPHY_VR1_STATE = 85,
+ DPHY_VR2_STATE = 90,
+ D2D_VR_STATE = 95,
+ IOC_VR1_STATE = 100,
+ IOC_VR2_STATE = 105,
+ PCI_D_VR_STATE = 110,
+ PCI_A_VR_STATE = 115,
PCIE_HOT_PLUG = 169,
BOOT_OVERALL = 175,
};
@@ -182,6 +191,32 @@
} // namespace training_failure
} // namespace dimm
+/*
+ * PresentReading value format
+ * FIELD | COMMENT
+ * Bit 31:30 | Reserved (2 bits)
+ * Bit 29 | A VR Critical condition observed (1 bit)
+ * Bit 28 | A VR Warning condition observed (1 bit)
+ * Bit 27:16 | Reserved (12 bits)
+ * Bit 15:8 | VR status byte high - The bit definition is the same as the
+ * | corresponding VR PMBUS STATUS_WORD (upper byte) (8 bits)
+ * Bit 7:0 | VR status byte low - The bit definition is the same as the
+ * | corresponding VR PMBUS STATUS_WORD (lower byte) (8 bits)
+ */
+typedef union
+{
+ uint32_t value;
+ struct
+ {
+ uint32_t vr_status_byte_low:8;
+ uint32_t vr_status_byte_high:8;
+ uint32_t reserved_1:12;
+ uint32_t warning:1;
+ uint32_t critical:1;
+ uint32_t reserved_2:2;
+ } __attribute__((packed)) bits;
+} VRDStatus_t;
+
/**
* @brief OemEventManager
*
@@ -287,6 +322,15 @@
void handleDDRStatusEvent(pldm_tid_t tid, uint16_t sensorId,
uint32_t presentReading);
+ /** @brief Handle numeric sensor event message from VRD status sensor.
+ *
+ * @param[in] tid - TID
+ * @param[in] sensorId - Sensor ID
+ * @param[in] presentReading - the present reading of the sensor
+ */
+ void handleVRDStatusEvent(pldm_tid_t tid, uint16_t sensorId,
+ uint32_t presentReading);
+
/** @brief Handle numeric sensor event messages.
*
* @param[in] tid - TID