Handle response from host for soft power off request
Change-Id: Ia923eff57f855dc88cb04db13590ae1a58a502fd
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/softoff/softoff.cpp b/softoff/softoff.cpp
index 49b6f26..e88096f 100644
--- a/softoff/softoff.cpp
+++ b/softoff/softoff.cpp
@@ -46,5 +46,42 @@
return;
}
+/** @brief Host Response handler */
+auto SoftPowerOff::responseReceived(HostResponse response) -> HostResponse
+{
+ using namespace std::chrono;
+ using namespace phosphor::logging;
+
+ if (response == HostResponse::SoftOffReceived)
+ {
+ // Need to stop the running timer and then start a new timer
+ auto time = duration_cast<microseconds>(
+ seconds(IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS));
+ auto r = timer.startTimer(time);
+ if (r < 0)
+ {
+ log<level::ERR>("Failure to start HostQuiesce wait timer",
+ entry("ERROR=%s", strerror(-r)));
+ }
+ }
+ else if (response == HostResponse::HostShutdown)
+ {
+ // Disable the timer since Host has quiesced and we are
+ // done with soft power off part
+ auto r = timer.setTimer(SD_EVENT_OFF);
+ if (r < 0)
+ {
+ log<level::ERR>("Failure to STOP the timer",
+ entry("ERROR=%s", strerror(-r)));
+ }
+
+ // This marks the completion of soft power off sequence.
+ completed = true;
+ }
+
+ return sdbusplus::xyz::openbmc_project::Ipmi::Internal
+ ::server::SoftPowerOff::responseReceived(response);
+}
+
} // namespace ipmi
} // namespace phosphor