Add UNC crossing option for FailSafe condition
Added a unc-failsafe meson option that if set to true, would then check
if any temperature sensor PIDs exceed their upper non-critical
threshold. If a sensor is detected to have exceeded their UNC, then the
zone associated with that PID would go to FailSafe.
By default, this option will be set to false for backwards
compatibility.
Change-Id: I2fbc6000e8d37b34c51d3578becdaf18d449b0e8
Signed-off-by: Jonico Eustaquio <jonico.eustaquio@fii-na.com>
diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp
index 54c75ca..038e784 100644
--- a/dbus/dbushelper.cpp
+++ b/dbus/dbushelper.cpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
#include "dbushelper.hpp"
@@ -160,7 +161,9 @@
catch (const sdbusplus::exception_t&)
{
// do nothing, sensors don't have to expose critical thresholds
+#ifndef UNC_FAILSAFE
return false;
+#endif
}
auto findCriticalLow = criticalMap.find("CriticalAlarmLow");
@@ -178,6 +181,32 @@
{
asserted = std::get<bool>(findCriticalHigh->second);
}
+#ifdef UNC_FAILSAFE
+ if (!asserted)
+ {
+ auto warning = _bus.new_method_call(service.c_str(), path.c_str(),
+ propertiesintf, "GetAll");
+ warning.append(warningThreshInf);
+ PropertyMap warningMap;
+
+ try
+ {
+ auto msg = _bus.call(warning);
+ msg.read(warningMap);
+ }
+ catch (const sdbusplus::exception_t&)
+ {
+ // sensors don't have to expose non-critical thresholds
+ return false;
+ }
+ auto findWarningHigh = warningMap.find("WarningAlarmHigh");
+
+ if (findWarningHigh != warningMap.end())
+ {
+ asserted = std::get<bool>(findWarningHigh->second);
+ }
+ }
+#endif
return asserted;
}
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index 5086826..7d2be2d 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -18,6 +18,8 @@
static constexpr char propertiesintf[] = "org.freedesktop.DBus.Properties";
static constexpr char criticalThreshInf[] =
"xyz.openbmc_project.Sensor.Threshold.Critical";
+ static constexpr char warningThreshInf[] =
+ "xyz.openbmc_project.Sensor.Threshold.Warning";
static constexpr char availabilityIntf[] =
"xyz.openbmc_project.State.Decorator.Availability";
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index ac0d5cf..0963736 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+
#include "dbuspassive.hpp"
#include "dbushelper_interface.hpp"
@@ -305,6 +307,23 @@
}
owner->setFailed(asserted);
}
+#ifdef UNC_FAILSAFE
+ else if (msgSensor == "xyz.openbmc_project.Sensor.Threshold.Warning")
+ {
+ auto warningAlarmHigh = msgData.find("WarningAlarmHigh");
+ if (warningAlarmHigh == msgData.end())
+ {
+ return 0;
+ }
+
+ bool asserted = false;
+ if (warningAlarmHigh != msgData.end())
+ {
+ asserted = std::get<bool>(warningAlarmHigh->second);
+ }
+ owner->setFailed(asserted);
+ }
+#endif
else if (msgSensor == "xyz.openbmc_project.State.Decorator.Availability")
{
auto available = msgData.find("Available");
diff --git a/meson.build b/meson.build
index 2a1b06c..57c25dc 100644
--- a/meson.build
+++ b/meson.build
@@ -19,6 +19,7 @@
conf_data.set('SYSTEMD_TARGET', get_option('systemd_target'))
conf_data.set('STRICT_FAILSAFE_PWM', get_option('strict-failsafe-pwm'))
conf_data.set('OFFLINE_FAILSAFE_PWM', get_option('offline-failsafe-pwm'))
+conf_data.set('UNC_FAILSAFE', get_option('unc-failsafe'))
configure_file(output: 'config.h',
configuration: conf_data
diff --git a/meson.options b/meson.options
index fc65cdb..a33730f 100644
--- a/meson.options
+++ b/meson.options
@@ -3,3 +3,4 @@
option('strict-failsafe-pwm', type: 'boolean', value: false, description: 'Set the fans strictly at the failsafe PWM when in failsafe mode')
option('offline-failsafe-pwm', type: 'boolean', value: false, description: 'Set the fans at the failsafe PWM when reloading or terminated.')
option('systemd_target', type: 'string', value: 'multi-user.target', description: 'Target for starting this service')
+option('unc-failsafe', type: 'boolean', value: false, description: 'Set the fans to failsafe mode when a temp sensor is above upper non-critical threshold')