blob: d815cde72e84e845f01c72bf13089ee12fa6f46c [file] [log] [blame]
George Hungfee51df2020-07-14 20:58:04 +08001From 9deb72959477700216326c033c930236e58f965f Mon Sep 17 00:00:00 2001
2From: Ren Yu <yux.ren@intel.com>
3Date: Tue, 28 May 2019 17:11:17 +0800
4Subject: [PATCH] Save the pre-timeout interrupt in dbus property
5
6Get the watchdog pre-timeout interrupt value from ipmi watchdog set command,
7and store it into dbus property.
8
9Tested:
10Config IPMI watchdog: BIOS FRB2 Power Cycle after 1 seconds:
11ipmitool raw 0x06 0x24 0x01 0x13 0x0 0x2 0xa 0x00
12Start watchdog:
13Ipmitool mc watchdog reset
14Check the watchdog pre-timeout interrupt in below:
15https://BMCIP/redfish/v1/Systems/system/LogServices/EventLog/Entries
16
17Signed-off-by: Ren Yu <yux.ren@intel.com>
18
19---
20 app/watchdog.cpp | 47 ++++++++++++++++++++++++++++++++++++++++
21 app/watchdog_service.cpp | 6 +++++
22 app/watchdog_service.hpp | 9 ++++++++
23 3 files changed, 62 insertions(+)
24
25diff --git a/app/watchdog.cpp b/app/watchdog.cpp
26index 03c373e..cb0b1fd 100644
27--- a/app/watchdog.cpp
28+++ b/app/watchdog.cpp
29@@ -80,6 +80,7 @@ ipmi::RspType<> ipmiAppResetWatchdogTimer()
30
31 static constexpr uint8_t wd_dont_stop = 0x1 << 6;
32 static constexpr uint8_t wd_timeout_action_mask = 0x3;
33+static constexpr uint8_t wdPreTimeoutInterruptMask = 0x3;
34
35 static constexpr uint8_t wdTimerUseResTimer1 = 0x0;
36 static constexpr uint8_t wdTimerUseResTimer2 = 0x6;
37@@ -127,6 +128,45 @@ WatchdogService::Action ipmiActionToWdAction(IpmiAction ipmi_action)
38 }
39 }
40
41+enum class IpmiPreTimeoutInterrupt : uint8_t
42+{
43+ None = 0x0,
44+ SMI = 0x1,
45+ NMI = 0x2,
46+ MI = 0x3,
47+};
48+/** @brief Converts an IPMI Watchdog PreTimeoutInterrupt to DBUS defined action
49+ * @param[in] ipmi_action The IPMI Watchdog PreTimeoutInterrupt
50+ * @return The Watchdog PreTimeoutInterrupt that the ipmi_action maps to
51+ */
52+WatchdogService::PreTimeoutInterruptAction ipmiPreTimeoutInterruptToWdAction(
53+ IpmiPreTimeoutInterrupt ipmiPreTimeOutInterrupt)
54+{
55+ switch (ipmiPreTimeOutInterrupt)
56+ {
57+ case IpmiPreTimeoutInterrupt::None:
58+ {
59+ return WatchdogService::PreTimeoutInterruptAction::None;
60+ }
61+ case IpmiPreTimeoutInterrupt::SMI:
62+ {
63+ return WatchdogService::PreTimeoutInterruptAction::SMI;
64+ }
65+ case IpmiPreTimeoutInterrupt::NMI:
66+ {
67+ return WatchdogService::PreTimeoutInterruptAction::NMI;
68+ }
69+ case IpmiPreTimeoutInterrupt::MI:
70+ {
71+ return WatchdogService::PreTimeoutInterruptAction::MI;
72+ }
73+ default:
74+ {
75+ throw std::domain_error("IPMI PreTimeoutInterrupt is invalid");
76+ }
77+ }
78+}
79+
80 enum class IpmiTimerUse : uint8_t
81 {
82 Reserved = 0x0,
83@@ -250,6 +290,13 @@ ipmi::RspType<>
84 // Mark as initialized so that future resets behave correctly
85 wd_service.setInitialized(true);
86
87+ // pretimeOutAction
88+ const auto ipmiPreTimeoutInterrupt =
89+ static_cast<IpmiPreTimeoutInterrupt>(wdPreTimeoutInterruptMask &
90+ (static_cast<uint8_t>(preTimeoutInterrupt)));
91+ wd_service.setPreTimeoutInterrupt(
92+ ipmiPreTimeoutInterruptToWdAction(ipmiPreTimeoutInterrupt));
93+
94 lastCallSuccessful = true;
95 return ipmi::responseSuccess();
96 }
97diff --git a/app/watchdog_service.cpp b/app/watchdog_service.cpp
98index 3534e89..4df1ab6 100644
99--- a/app/watchdog_service.cpp
100+++ b/app/watchdog_service.cpp
101@@ -198,3 +198,9 @@ void WatchdogService::setInterval(uint64_t interval)
102 {
103 setProperty("Interval", interval);
104 }
105+
106+void WatchdogService::setPreTimeoutInterrupt(
107+ PreTimeoutInterruptAction preTimeoutInterrupt)
108+{
109+ setProperty("PreTimeoutInterrupt", convertForMessage(preTimeoutInterrupt));
110+}
111\ No newline at end of file
112diff --git a/app/watchdog_service.hpp b/app/watchdog_service.hpp
113index 141bdb7..32b7461 100644
114--- a/app/watchdog_service.hpp
115+++ b/app/watchdog_service.hpp
116@@ -15,6 +15,8 @@ class WatchdogService
117
118 using Action =
119 sdbusplus::xyz::openbmc_project::State::server::Watchdog::Action;
120+ using PreTimeoutInterruptAction = sdbusplus::xyz::openbmc_project::State::
121+ server::Watchdog::PreTimeoutInterruptAction;
122 using TimerUse =
123 sdbusplus::xyz::openbmc_project::State::server::Watchdog::TimerUse;
124
125@@ -92,6 +94,13 @@ class WatchdogService
126 */
127 void setInterval(uint64_t interval);
128
129+ /** @brief Sets the value of the PreTimeoutInterrupt property on the host
130+ * watchdog
131+ *
132+ * @param[in] PreTimeoutInterrupt - The new PreTimeoutInterrupt value
133+ */
134+ void setPreTimeoutInterrupt(PreTimeoutInterruptAction preTimeoutInterrupt);
135+
136 private:
137 /** @brief sdbusplus handle */
138 sdbusplus::bus::bus bus;