1 #pragma once 2 3 #include "config.h" 4 5 #ifdef POWER10 6 #include "occ_status.hpp" 7 8 #include <sdbusplus/bus.hpp> 9 #include <sdbusplus/bus/match.hpp> 10 11 #include <filesystem> 12 13 namespace open_power 14 { 15 namespace occ 16 { 17 namespace powermode 18 { 19 20 constexpr auto PMODE_PATH = "/xyz/openbmc_project/control/host0/power_mode"; 21 constexpr auto PMODE_INTERFACE = "xyz.openbmc_project.Control.Power.Mode"; 22 constexpr auto POWER_MODE_PROP = "PowerMode"; 23 24 constexpr auto PIPS_PATH = "/xyz/openbmc_project/control/host0/power_ips"; 25 constexpr auto PIPS_INTERFACE = 26 "xyz.openbmc_project.Control.Power.IdlePowerSaver"; 27 constexpr auto IPS_ENABLED_PROP = "Enabled"; 28 constexpr auto IPS_ENTER_UTIL = "EnterUtilizationPercent"; 29 constexpr auto IPS_ENTER_TIME = "EnterDwellTime"; 30 constexpr auto IPS_EXIT_UTIL = "ExitUtilizationPercent"; 31 constexpr auto IPS_EXIT_TIME = "ExitDwellTime"; 32 33 /** @brief Convert power mode string to OCC SysPwrMode value 34 * 35 * @param[in] i_modeString - power mode string 36 * 37 * @return SysPwrMode or SysPwrMode::NO_CHANGE if not found 38 */ 39 SysPwrMode convertStringToMode(const std::string& i_modeString); 40 41 /** @class PowerMode 42 * @brief Monitors for changes to the power mode and notifies occ 43 * 44 * The customer power mode is provided to the OCC by host TMGT when the occ 45 * first goes active or is reset. This code is responsible for sending 46 * the power mode to the OCC if the mode is changed while the occ is active. 47 */ 48 49 class PowerMode 50 { 51 public: 52 /** @brief PowerMode object to inform occ of changes to mode 53 * 54 * This object will monitor for changes to the power mode setting. 55 * If a change is detected, and the occ is active, then this object will 56 * notify the OCC of the change. 57 * 58 * @param[in] occStatus - The occ status object 59 */ 60 PowerMode(Status& occStatus) : 61 occStatus(occStatus), 62 pmodeMatch(utils::getBus(), 63 sdbusplus::bus::match::rules::propertiesChanged( 64 PMODE_PATH, PMODE_INTERFACE), 65 [this](auto& msg) { this->modeChanged(msg); }){}; 66 67 private: 68 /** @brief Callback for pmode setting changes 69 * 70 * Process change and inform OCC 71 * 72 * @param[in] msg - Data associated with pmode change signal 73 * 74 */ 75 void modeChanged(sdbusplus::message::message& msg); 76 77 /* @brief OCC Status object */ 78 Status& occStatus; 79 80 /** @brief Used to subscribe to dbus pmode property changes **/ 81 sdbusplus::bus::match_t pmodeMatch; 82 }; 83 84 class PowerIPS 85 { 86 public: 87 /** @brief PowerIPS object to inform occ of changes to Idle Power Saver 88 * parms 89 * 90 * This object will monitor for changes to the Idle Power Saver settings. 91 * If a change is detected, and the occ is active, then this object will 92 * notify the OCC of the change. 93 * 94 * @param[in] occStatus - The occ status object 95 */ 96 PowerIPS(Status& occStatus) : 97 occStatus(occStatus), 98 ipsMatch(utils::getBus(), 99 sdbusplus::bus::match::rules::propertiesChanged( 100 PIPS_PATH, PIPS_INTERFACE), 101 [this](auto& msg) { this->ipsChanged(msg); }){}; 102 103 private: 104 /** @brief Callback for IPS setting changes 105 * 106 * Process change and inform OCC 107 * 108 * @param[in] msg - Data associated with IPS change signal 109 * 110 */ 111 void ipsChanged(sdbusplus::message::message& msg); 112 113 /* @brief OCC Status object */ 114 Status& occStatus; 115 116 /** @brief Used to subscribe to dbus IPS property changes **/ 117 sdbusplus::bus::match_t ipsMatch; 118 }; 119 120 } // namespace powermode 121 122 } // namespace occ 123 124 } // namespace open_power 125 #endif 126