nvme_manager: Read WCTEMP to set threshold dynamically
Signed-off-by: George Hung <george.hung@quantatw.com>
Change-Id: Ib240ed69fbf7d4b135dea91839153b333183347d
diff --git a/nvme_manager.cpp b/nvme_manager.cpp
index 9f4aa17..e73d849 100644
--- a/nvme_manager.cpp
+++ b/nvme_manager.cpp
@@ -259,7 +259,8 @@
nvmeData.statusFlags = intToHex(rsp_data_command_0[1]);
nvmeData.smartWarnings = intToHex(rsp_data_command_0[2]);
nvmeData.driveLifeUsed = intToHex(rsp_data_command_0[4]);
- nvmeData.sensorValue = (int8_t)rsp_data_command_0[3];
+ nvmeData.sensorValue = static_cast<int8_t>(rsp_data_command_0[3]);
+ nvmeData.wcTemp = static_cast<int8_t>(rsp_data_command_0[5]);
tx_data = COMMAND_CODE_8;
@@ -537,6 +538,11 @@
setNvmeInventoryProperties(true, nvmeData, inventoryPath);
nvmeSSD->setSensorValueToDbus(nvmeData.sensorValue);
+ if (nvmeData.wcTemp != 0)
+ {
+ config.criticalHigh = nvmeData.wcTemp;
+ config.warningHigh = nvmeData.wcTemp;
+ }
nvmeSSD->setSensorThreshold(config.criticalHigh, config.criticalLow,
config.maxValue, config.minValue,
config.warningHigh, config.warningLow);
diff --git a/nvme_manager.hpp b/nvme_manager.hpp
index 7017475..97ef204 100644
--- a/nvme_manager.hpp
+++ b/nvme_manager.hpp
@@ -80,6 +80,10 @@
int8_t sensorValue; /* Sensor value, if sensor value didn't be
update, means sensor failure, default set to
129(0x81) accroding to NVMe-MI SPEC*/
+ int8_t wcTemp; /* Indicates over temperature warning threshold.
+ This is intended to initially match the temperature
+ reported in the WCTEMP field in the NVMe Identify
+ Controller data structure */
};
/** @brief Setup polling timer in a sd event loop and attach to D-Bus