Use Idle Power Saver parameters from DBus
Allows users to enable and update the IPS parameters instead of
using hardcoded values.
Change-Id: I9010c4b4d3dbdf130a4a778f71c87279681a9f1a
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powermode.hpp b/powermode.hpp
index fd7d466..c9d3f0e 100644
--- a/powermode.hpp
+++ b/powermode.hpp
@@ -21,6 +21,15 @@
constexpr auto PMODE_INTERFACE = "xyz.openbmc_project.Control.Power.Mode";
constexpr auto POWER_MODE_PROP = "PowerMode";
+constexpr auto PIPS_PATH = "/xyz/openbmc_project/control/host0/power_ips";
+constexpr auto PIPS_INTERFACE =
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver";
+constexpr auto IPS_ENABLED_PROP = "Enabled";
+constexpr auto IPS_ENTER_UTIL = "EnterUtilizationPercent";
+constexpr auto IPS_ENTER_TIME = "EnterDwellTime";
+constexpr auto IPS_EXIT_UTIL = "ExitUtilizationPercent";
+constexpr auto IPS_EXIT_TIME = "ExitDwellTime";
+
/** @brief Convert power mode string to OCC SysPwrMode value
*
* @param[in] i_modeString - power mode string
@@ -72,6 +81,42 @@
sdbusplus::bus::match_t pmodeMatch;
};
+class PowerIPS
+{
+ public:
+ /** @brief PowerIPS object to inform occ of changes to Idle Power Saver
+ * parms
+ *
+ * This object will monitor for changes to the Idle Power Saver settings.
+ * If a change is detected, and the occ is active, then this object will
+ * notify the OCC of the change.
+ *
+ * @param[in] occStatus - The occ status object
+ */
+ PowerIPS(Status& occStatus) :
+ occStatus(occStatus),
+ ipsMatch(utils::getBus(),
+ sdbusplus::bus::match::rules::propertiesChanged(
+ PIPS_PATH, PIPS_INTERFACE),
+ [this](auto& msg) { this->ipsChanged(msg); }){};
+
+ private:
+ /** @brief Callback for IPS setting changes
+ *
+ * Process change and inform OCC
+ *
+ * @param[in] msg - Data associated with IPS change signal
+ *
+ */
+ void ipsChanged(sdbusplus::message::message& msg);
+
+ /* @brief OCC Status object */
+ Status& occStatus;
+
+ /** @brief Used to subscribe to dbus IPS property changes **/
+ sdbusplus::bus::match_t ipsMatch;
+};
+
} // namespace powermode
} // namespace occ