summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-02-09 16:12:53 -0800
committerWilliam A. Kennington III <wak@google.com>2018-02-21 23:54:59 +0000
commitb638de22154aa4cae788d9117d2507394388f839 (patch)
tree6445adf4a1e1914dcf05d35d467961f14de940c0 /app
parentde14a027c06d93dadf05322529bec9d83f4cd181 (diff)
downloadphosphor-host-ipmid-b638de22154aa4cae788d9117d2507394388f839.zip
phosphor-host-ipmid-b638de22154aa4cae788d9117d2507394388f839.tar.gz
watchdog: Implement watchdog action setting
We now respect the action set during the SetTimeout command. This maps to one of the actions defined by the dbus Watchdog interface Change-Id: I4d13d2539a2d955a4340bf5f915ca6f3b694550a Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'app')
-rw-r--r--app/watchdog.cpp39
-rw-r--r--app/watchdog_service.cpp10
-rw-r--r--app/watchdog_service.hpp10
3 files changed, 52 insertions, 7 deletions
diff --git a/app/watchdog.cpp b/app/watchdog.cpp
index f28ff80..84d80b9 100644
--- a/app/watchdog.cpp
+++ b/app/watchdog.cpp
@@ -66,6 +66,37 @@ enum class IpmiAction : uint8_t {
PowerCycle = 0x3,
};
+/** @brief Converts an IPMI Watchdog Action to DBUS defined action
+ * @param[in] ipmi_action The IPMI Watchdog Action
+ * @return The Watchdog Action that the ipmi_action maps to
+ */
+WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action)
+{
+ switch(ipmi_action)
+ {
+ case IpmiAction::None:
+ {
+ return WatchdogService::Action::None;
+ }
+ case IpmiAction::HardReset:
+ {
+ return WatchdogService::Action::HardReset;
+ }
+ case IpmiAction::PowerOff:
+ {
+ return WatchdogService::Action::PowerOff;
+ }
+ case IpmiAction::PowerCycle:
+ {
+ return WatchdogService::Action::PowerCycle;
+ }
+ default:
+ {
+ throw std::domain_error("IPMI Action is invalid");
+ }
+ }
+}
+
struct wd_set_req {
uint8_t timer_use;
uint8_t timer_action;
@@ -106,15 +137,9 @@ ipmi_ret_t ipmi_app_watchdog_set(
}
// Set the action based on the request
- // Unfortunately we only really support enable or disable
- // and don't actually support a real action. Until we have proper
- // action support just map NONE as a disable action.
const auto ipmi_action = static_cast<IpmiAction>(
req.timer_action & wd_timeout_action_mask);
- if (ipmi_action == IpmiAction::None)
- {
- wd_service.setEnabled(false);
- }
+ wd_service.setExpireAction(ipmiActionToWdAction(ipmi_action));
// Set the new interval and the time remaining deci -> mill seconds
const uint64_t interval = req.initial_countdown * 100;
diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
index 36a967c..f11c4bf 100644
--- a/app/watchdog_service.cpp
+++ b/app/watchdog_service.cpp
@@ -3,12 +3,15 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
#include <string>
+#include <xyz/openbmc_project/State/Watchdog/server.hpp>
#include "host-ipmid/ipmid-api.h"
#include "utils.hpp"
using sdbusplus::message::variant_ns::get;
using sdbusplus::message::variant_ns::variant;
+using sdbusplus::xyz::openbmc_project::State::server::convertForMessage;
+using sdbusplus::xyz::openbmc_project::State::server::Watchdog;
static constexpr char wd_path[] = "/xyz/openbmc_project/watchdog/host0";
static constexpr char wd_intf[] = "xyz.openbmc_project.State.Watchdog";
@@ -36,6 +39,8 @@ WatchdogService::Properties WatchdogService::getProperties()
Properties wd_prop;
wd_prop.initialized = get<bool>(properties.at("Initialized"));
wd_prop.enabled = get<bool>(properties.at("Enabled"));
+ wd_prop.expireAction = Watchdog::convertActionFromString(
+ get<std::string>(properties.at("ExpireAction")));
wd_prop.interval = get<uint64_t>(properties.at("Interval"));
wd_prop.timeRemaining = get<uint64_t>(properties.at("TimeRemaining"));
return wd_prop;
@@ -64,6 +69,11 @@ void WatchdogService::setEnabled(bool enabled)
setProperty("Enabled", enabled);
}
+void WatchdogService::setExpireAction(Action expireAction)
+{
+ setProperty("ExpireAction", convertForMessage(expireAction));
+}
+
void WatchdogService::setInterval(uint64_t interval)
{
setProperty("Interval", interval);
diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
index 1d5ffb8..432c7ce 100644
--- a/app/watchdog_service.hpp
+++ b/app/watchdog_service.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/State/Watchdog/server.hpp>
/** @class WatchdogService
* @brief Access to the running OpenBMC watchdog implementation.
@@ -10,12 +11,15 @@ class WatchdogService {
public:
WatchdogService();
+ using Action = sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
+
/** @brief Contains a copy of the properties enumerated by the
* watchdog service.
*/
struct Properties {
bool initialized;
bool enabled;
+ Action expireAction;
uint64_t interval;
uint64_t timeRemaining;
};
@@ -40,6 +44,12 @@ class WatchdogService {
*/
void setEnabled(bool enabled);
+ /** @brief Sets the value of the expireAction property on the host watchdog
+ *
+ * @param[in] expireAction - The new expireAction value
+ */
+ void setExpireAction(Action expireAction);
+
/** @brief Sets the value of the interval property on the host watchdog
*
* @param[in] interval - The new interval value
OpenPOWER on IntegriCloud