print zone failsafe reason when enter failsafe mode
Tested:
```
Jun 24 01:52:45 bmc sel-logger[640]: cpu0_nbm critical high threshold assert. Reading=49.000000 Threshold=45.000000.
Jun 24 01:52:46 bmc swampd[2944]: Zone 2 fans, entering failsafe mode, output pwm: 100
Jun 24 01:52:46 bmc swampd[2944]: Fail sensor: cpu0_nbm, reason: Sensor threshold asserted
Jun 24 01:52:46 bmc swampd[2944]: Zone 0 fans, entering failsafe mode, output pwm: 100
Jun 24 01:52:46 bmc swampd[2944]: Fail sensor: cpu0_nbm, reason: Sensor threshold asserted
```
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: I607d01b6bed11b00a40153db6521a9c9d23da519
diff --git a/pid/zone.hpp b/pid/zone.hpp
index 14017b8..325eb6c 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -36,6 +36,10 @@
sdbusplus::xyz::openbmc_project::Debug::Pid::server::ThermalPower;
using ProcessObject =
ServerObject<ProcessInterface, DebugThermalPowerInterface>;
+using FailSafeSensorsMap =
+ std::map<std::string, std::pair<std::string, double>>;
+using FailSafeSensorPair =
+ std::pair<std::string, std::pair<std::string, double>>;
namespace pid_control
{
@@ -74,7 +78,8 @@
bool getRedundantWrite(void) const override;
void setManualMode(bool mode);
bool getFailSafeMode(void) const override;
- void markSensorMissing(const std::string& name);
+ void markSensorMissing(const std::string& name,
+ const std::string& failReason);
bool getAccSetPoint(void) const override;
int64_t getZoneID(void) const override;
@@ -84,6 +89,7 @@
void clearSetPoints(void) override;
void clearRPMCeilings(void) override;
double getFailSafePercent(void) override;
+ FailSafeSensorsMap getFailSafeSensors(void) const override;
double getMinThermalSetPoint(void) const;
uint64_t getCycleIntervalTime(void) const override;
uint64_t getUpdateThermalsCycle(void) const override;
@@ -171,7 +177,7 @@
// check if fan fail.
if (sensor->getFailed())
{
- markSensorMissing(sensorInput);
+ markSensorMissing(sensorInput, sensor->getFailReason());
if (debugEnabled)
{
@@ -180,7 +186,7 @@
}
else if (timeout != 0 && duration >= period)
{
- markSensorMissing(sensorInput);
+ markSensorMissing(sensorInput, "Sensor timeout");
if (debugEnabled)
{
@@ -225,7 +231,10 @@
const double _zoneFailSafePercent;
const conf::CycleTime _cycleTime;
- std::map<std::string, double> _failSafeSensors;
+ /*
+ * <map key = sensor name, value = sensor fail reason and failsafe percent>
+ */
+ FailSafeSensorsMap _failSafeSensors;
std::set<std::string> _missingAcceptable;
std::map<std::string, double> _SetPoints;