oem-ibm: Support system reboot after inband code update
This commit adds a bmc effecter that causes a system reboot(
phyp, chassis and bmc)
After bmc sends an end update successful event, Host will
set this new effecter. Upon getting the setStateEffecterStates
call bmc-pldm does the following:
1. Set the power restore to reboot the host once the BMC
is rebooted
2. power off Host and Chassis
3. reboot the bmc
Tested with pldmtool
Steps after patching changes:
1. Boot host to STANDBY
2. Fetch the effecter to note the effecterId
Ex: ./pldmtool platform GetPDR -d 28
3. Trigger the system reboot by toggling the effecter
./pldmtool platform SetStateEffecterStates -i 10 -c 1
-d 1 1
Signed-off-by: Sagar Srinivas <sagar.srinivas@ibm.com>
Change-Id: Id2d4201a7d61ae335adc64f2583571a37dc7879d
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
index 854c96b..b574262 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.hpp
@@ -1,4 +1,5 @@
#pragma once
+#include "libpldm/entity.h"
#include "libpldm/platform.h"
#include "inband_code_update.hpp"
@@ -15,6 +16,7 @@
#define PLDM_OEM_IBM_FIRMWARE_UPDATE_STATE 32768
#define PLDM_OEM_IBM_BOOT_STATE 32769
+#define PLDM_OEM_IBM_SYSTEM_POWER_STATE 32771
static constexpr auto PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE = 24577;
static constexpr auto PLDM_OEM_IBM_VERIFICATION_STATE = 32770;
@@ -39,6 +41,11 @@
MIN_MIF_FAIL = 0x4,
};
+enum SystemPowerStates
+{
+ POWER_CYCLE_HARD = 0x1,
+};
+
class Handler : public oem_platform::Handler
{
public:
@@ -127,6 +134,13 @@
*/
void _processStartUpdate(sdeventplus::source::EventBase& source);
+ /** @brief _processSystemReboot processes the actual work that needs to be
+ * carried out after the System Power State effecter is set to reboot
+ * the system
+ * @param[in] source - sdeventplus event source
+ */
+ void _processSystemReboot(sdeventplus::source::EventBase& source);
+
~Handler() = default;
pldm::responder::CodeUpdate* codeUpdate; //!< pointer to CodeUpdate object
@@ -146,11 +160,16 @@
/** @brief sdeventplus event source */
std::unique_ptr<sdeventplus::source::Defer> assembleImageEvent;
std::unique_ptr<sdeventplus::source::Defer> startUpdateEvent;
+ std::unique_ptr<sdeventplus::source::Defer> systemRebootEvent;
/** @brief reference of main event loop of pldmd, primarily used to schedule
* work
*/
sdeventplus::Event& event;
+
+ private:
+ /** @brief D-Bus property changed signal match for CurrentPowerState*/
+ std::unique_ptr<sdbusplus::bus::match::match> chassisOffMatch;
};
/** @brief Method to encode code update event msg