oem_ibm: Implement timer for Surveillance Pings
This commit introduces a timer for surveillance pings sent by the
remote terminus to monitor the BMC. If a ping is not received
within 120 seconds, an informational error will be logged.
Signed-off-by: Sagar Srinivas <sagar.srinivas@ibm.com>
Change-Id: Ia52ed2461b2c2f8ea0102e60ed2a22c7691b2d2a
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index 4f3969c..8e207be 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -650,6 +650,43 @@
this->setEventReceiver();
}
+void pldm::responder::oem_ibm_platform::Handler::startStopTimer(bool value)
+{
+ if (value)
+ {
+ timer.restart(
+ std::chrono::seconds(HEARTBEAT_TIMEOUT + HEARTBEAT_TIMEOUT_DELTA));
+ }
+ else
+ {
+ timer.setEnabled(value);
+ }
+}
+
+void pldm::responder::oem_ibm_platform::Handler::setSurvTimer(uint8_t tid,
+ bool value)
+{
+ if ((hostOff || hostTransitioningToOff || (tid != HYPERVISOR_TID)) &&
+ timer.isEnabled())
+ {
+ startStopTimer(false);
+ return;
+ }
+ if (value)
+ {
+ startStopTimer(value);
+ }
+ else if (timer.isEnabled())
+ {
+ info(
+ "Failed to stop surveillance timer while remote terminus status is ‘{HOST_TRANST_OFF}’ with Terminus ID ‘{TID}’ ",
+ "HOST_TRANST_OFF", hostTransitioningToOff, "TID", tid);
+ startStopTimer(value);
+ pldm::utils::reportError(
+ "xyz.openbmc_project.PLDM.Error.setSurvTimer.RecvSurveillancePingFail");
+ }
+}
+
} // namespace oem_ibm_platform
} // namespace responder
} // namespace pldm