blob: 9a191f7c7f6044ba55374498e612090a1ddbee0e [file] [log] [blame]
Chris Cain78e86012021-03-04 16:15:31 -06001#pragma once
2
Chris Cain78e86012021-03-04 16:15:31 -06003#include "config.h"
4
George Liubddcf852021-09-08 08:46:22 +08005#ifdef POWER10
Chris Cain36f9cde2021-11-22 11:18:21 -06006#include "occ_command.hpp"
Chris Cain78e86012021-03-04 16:15:31 -06007
Chris Cain36f9cde2021-11-22 11:18:21 -06008#include <cereal/archives/json.hpp>
Chris Cain36f9cde2021-11-22 11:18:21 -06009#include <cereal/cereal.hpp>
10#include <cereal/types/string.hpp>
11#include <cereal/types/tuple.hpp>
12#include <cereal/types/vector.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060013#include <sdbusplus/bus.hpp>
14#include <sdbusplus/bus/match.hpp>
Chris Cain1be43372021-12-09 19:29:37 -060015#include <xyz/openbmc_project/Control/Power/IdlePowerSaver/server.hpp>
16#include <xyz/openbmc_project/Control/Power/Mode/server.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060017
George Liubcef3b42021-09-10 12:39:02 +080018#include <filesystem>
George Liub5ca1012021-09-10 12:53:11 +080019
Chris Cain78e86012021-03-04 16:15:31 -060020namespace open_power
21{
22namespace occ
23{
Chris Cain36f9cde2021-11-22 11:18:21 -060024
25class Manager;
26
Chris Cain78e86012021-03-04 16:15:31 -060027namespace powermode
28{
Chris Cain1be43372021-12-09 19:29:37 -060029namespace Base = sdbusplus::xyz::openbmc_project::Control::Power::server;
Patrick Williamsaf408082022-07-22 19:26:54 -050030using ModeInterface = sdbusplus::server::object_t<Base::Mode>;
31using IpsInterface = sdbusplus::server::object_t<Base::IdlePowerSaver>;
Chris Cain1be43372021-12-09 19:29:37 -060032using namespace std::literals::string_literals;
Chris Cain78e86012021-03-04 16:15:31 -060033
34constexpr auto PMODE_PATH = "/xyz/openbmc_project/control/host0/power_mode";
35constexpr auto PMODE_INTERFACE = "xyz.openbmc_project.Control.Power.Mode";
36constexpr auto POWER_MODE_PROP = "PowerMode";
Sheldon Bailey31a2f132022-05-20 11:31:52 -050037constexpr auto POWER_SAFE_MODE_PROP = "SafeMode";
Chris Cain78e86012021-03-04 16:15:31 -060038
Chris Cain1d51da22021-09-21 14:13:41 -050039constexpr auto PIPS_PATH = "/xyz/openbmc_project/control/host0/power_ips";
40constexpr auto PIPS_INTERFACE =
41 "xyz.openbmc_project.Control.Power.IdlePowerSaver";
Sheldon Baileyea2b22e2022-04-04 12:24:46 -050042constexpr auto IPS_ACTIVE_PROP = "Active";
Chris Cain1d51da22021-09-21 14:13:41 -050043constexpr auto IPS_ENABLED_PROP = "Enabled";
44constexpr auto IPS_ENTER_UTIL = "EnterUtilizationPercent";
45constexpr auto IPS_ENTER_TIME = "EnterDwellTime";
46constexpr auto IPS_EXIT_UTIL = "ExitUtilizationPercent";
47constexpr auto IPS_EXIT_TIME = "ExitDwellTime";
48
Chris Cain1be43372021-12-09 19:29:37 -060049const auto PMODE_DEFAULT_INTERFACE =
50 "xyz.openbmc_project.Configuration.PowerModeProperties"s;
51
Chris Cain36f9cde2021-11-22 11:18:21 -060052/** @brief Query the current Hypervisor target
53 * @return true if the current Hypervisor target is PowerVM
54 */
55bool isPowerVM();
56
Chris Cain78e86012021-03-04 16:15:31 -060057/** @brief Convert power mode string to OCC SysPwrMode value
58 *
59 * @param[in] i_modeString - power mode string
60 *
61 * @return SysPwrMode or SysPwrMode::NO_CHANGE if not found
62 */
63SysPwrMode convertStringToMode(const std::string& i_modeString);
64
Chris Cain1be43372021-12-09 19:29:37 -060065struct PowerModeData
Chris Cain36f9cde2021-11-22 11:18:21 -060066{
Chris Cain1be43372021-12-09 19:29:37 -060067 bool modeInitialized = false;
68 SysPwrMode mode = SysPwrMode::NO_CHANGE;
69 uint16_t oemModeData = 0x0000;
70 bool ipsInitialized = false;
71 bool ipsEnabled = true;
72 uint8_t ipsEnterUtil = 0;
73 uint16_t ipsEnterTime = 0;
74 uint8_t ipsExitUtil = 0;
75 uint16_t ipsExitTime = 0;
Ben Tyner3576d652022-05-22 18:05:53 -050076 bool modeLocked = false;
Chris Cain36f9cde2021-11-22 11:18:21 -060077
78 /** @brief Function specifying data to archive for cereal.
79 */
80 template <class Archive>
81 void serialize(Archive& archive)
82 {
Chris Cain1be43372021-12-09 19:29:37 -060083 archive(modeInitialized, mode, oemModeData, ipsInitialized, ipsEnabled,
Ben Tyner3576d652022-05-22 18:05:53 -050084 ipsEnterUtil, ipsEnterTime, ipsExitUtil, ipsExitTime,
85 modeLocked);
Chris Cain36f9cde2021-11-22 11:18:21 -060086 }
87};
88
89/** @class OccPersistData
90 * @brief Provides persistent container to store data for OCC
91 *
92 * Data is stored via cereal
93 */
94class OccPersistData
95{
96 public:
97 ~OccPersistData() = default;
98 OccPersistData(const OccPersistData&) = default;
99 OccPersistData& operator=(const OccPersistData&) = default;
100 OccPersistData(OccPersistData&&) = default;
101 OccPersistData& operator=(OccPersistData&&) = default;
102
Chris Cain1be43372021-12-09 19:29:37 -0600103 /** @brief Loads any saved power mode data */
Chris Cain36f9cde2021-11-22 11:18:21 -0600104 OccPersistData()
105 {
106 load();
107 }
108
109 /** @brief Save Power Mode data to persistent file
110 *
Chris Cain1be43372021-12-09 19:29:37 -0600111 * @param[in] newMode - desired System Power Mode
112 * @param[in] oemModeData - data required by some OEM Power Modes
Chris Cain36f9cde2021-11-22 11:18:21 -0600113 */
Chris Cain1be43372021-12-09 19:29:37 -0600114 void updateMode(const SysPwrMode newMode, const uint16_t oemModeData)
Chris Cain36f9cde2021-11-22 11:18:21 -0600115 {
Chris Cain1be43372021-12-09 19:29:37 -0600116 modeData.mode = newMode;
117 modeData.oemModeData = oemModeData;
118 modeData.modeInitialized = true;
Chris Cain36f9cde2021-11-22 11:18:21 -0600119 save();
120 }
121
Ben Tyner3576d652022-05-22 18:05:53 -0500122 /** @brief Save Power Mode Lock value to persistent file
123 *
124 * @param[in] modeLock - desired System Power Mode Lock
125 */
126 void updateModeLock(const bool modeLock)
127 {
128 modeData.modeLocked = modeLock;
129 save();
130 }
Chris Cain1be43372021-12-09 19:29:37 -0600131 /** @brief Write Idle Power Saver parameters to persistent file
Chris Cain36f9cde2021-11-22 11:18:21 -0600132 *
Chris Cain1be43372021-12-09 19:29:37 -0600133 * @param[in] enabled - Idle Power Save status (true = enabled)
134 * @param[in] enterUtil - IPS Enter Utilization (%)
135 * @param[in] enterTime - IPS Enter Time (seconds)
136 * @param[in] exitUtil - IPS Exit Utilization (%)
137 * @param[in] exitTime - IPS Exit Time (seconds)
Chris Cain36f9cde2021-11-22 11:18:21 -0600138 */
Chris Cain1be43372021-12-09 19:29:37 -0600139 void updateIPS(const bool enabled, const uint8_t enterUtil,
140 const uint16_t enterTime, const uint8_t exitUtil,
141 const uint16_t exitTime)
Chris Cain36f9cde2021-11-22 11:18:21 -0600142 {
Chris Cain1be43372021-12-09 19:29:37 -0600143 modeData.ipsEnabled = enabled;
144 modeData.ipsEnterUtil = enterUtil;
145 modeData.ipsEnterTime = enterTime;
146 modeData.ipsExitUtil = exitUtil;
147 modeData.ipsExitTime = exitTime;
148 modeData.ipsInitialized = true;
149 save();
150 }
151
152 /** @brief Return the Power Mode and mode data
153 *
154 * @param[out] mode - current system power mode
155 * @param[out] oemModeData - frequency data for some OEM mode
156 *
157 * @returns true if mode was available
158 */
159 bool getMode(SysPwrMode& mode, uint16_t& oemModeData) const
160 {
161 if (!modeData.modeInitialized)
Chris Cain36f9cde2021-11-22 11:18:21 -0600162 {
163 return false;
164 }
165
Chris Cain1be43372021-12-09 19:29:37 -0600166 mode = modeData.mode;
167 oemModeData = modeData.oemModeData;
Chris Cain36f9cde2021-11-22 11:18:21 -0600168 return true;
169 }
170
Chris Cain1be43372021-12-09 19:29:37 -0600171 /** @brief Get the Idle Power Saver properties from DBus
172 *
173 * @param[out] enabled - Idle Power Save status (true = enabled)
174 * @param[out] enterUtil - IPS Enter Utilization (%)
175 * @param[out] enterTime - IPS Enter Time (seconds)
176 * @param[out] exitUtil - IPS Exit Utilization (%)
177 * @param[out] exitTime - IPS Exit Time (seconds)
178 *
179 * @return true if parameters were read successfully
180 */
181 bool getIPS(bool& enabled, uint8_t& enterUtil, uint16_t& enterTime,
182 uint8_t& exitUtil, uint16_t& exitTime)
183 {
184 if (!modeData.ipsInitialized)
185 {
186 return false;
187 }
188
189 enabled = modeData.ipsEnabled;
190 enterUtil = modeData.ipsEnterUtil;
191 enterTime = modeData.ipsEnterTime;
192 exitUtil = modeData.ipsExitUtil;
193 exitTime = modeData.ipsExitTime;
194 return true;
195 }
196
Ben Tyner3576d652022-05-22 18:05:53 -0500197 /** @brief Return persisted mode lock */
198 bool getModeLock()
199 {
200 return modeData.modeLocked;
201 }
202
Chris Cain1be43372021-12-09 19:29:37 -0600203 /** @brief Return true if the power mode is available */
204 bool modeAvailable()
205 {
206 return (modeData.modeInitialized);
207 }
208
Chris Caincde7bea2022-01-28 15:54:24 -0600209 /** @brief Return true if the IPS data is available */
Chris Cain1be43372021-12-09 19:29:37 -0600210 bool ipsAvailable()
211 {
212 return (modeData.ipsInitialized);
213 }
214
Chris Cain36f9cde2021-11-22 11:18:21 -0600215 /** @brief Saves the Power Mode data in the filesystem using cereal. */
216 void save();
217
Chris Cain1be43372021-12-09 19:29:37 -0600218 /** @brief Trace the Power Mode and IPS parameters. */
219 void print();
Chris Cain36f9cde2021-11-22 11:18:21 -0600220
221 private:
Chris Cain1be43372021-12-09 19:29:37 -0600222 /** @brief Power Mode data filename to store persistent data */
223 static constexpr auto powerModeFilename = "powerModeData";
Chris Cain36f9cde2021-11-22 11:18:21 -0600224
Chris Cain1be43372021-12-09 19:29:37 -0600225 /** @brief Power Mode data object to be persisted */
226 PowerModeData modeData;
Chris Cain36f9cde2021-11-22 11:18:21 -0600227
228 /** @brief Loads the OEM mode data in the filesystem using cereal. */
229 void load();
230};
231
Chris Cain78e86012021-03-04 16:15:31 -0600232/** @class PowerMode
233 * @brief Monitors for changes to the power mode and notifies occ
234 *
235 * The customer power mode is provided to the OCC by host TMGT when the occ
236 * first goes active or is reset. This code is responsible for sending
237 * the power mode to the OCC if the mode is changed while the occ is active.
238 */
239
Chris Cain1be43372021-12-09 19:29:37 -0600240class PowerMode : public ModeInterface, public IpsInterface
Chris Cain78e86012021-03-04 16:15:31 -0600241{
242 public:
243 /** @brief PowerMode object to inform occ of changes to mode
244 *
245 * This object will monitor for changes to the power mode setting.
246 * If a change is detected, and the occ is active, then this object will
247 * notify the OCC of the change.
248 *
Chris Cain1be43372021-12-09 19:29:37 -0600249 * @param[in] managerRef - manager object reference
250 * @param[in] modePath - Power Mode dbus path
251 * @param[in] ipsPath - Idle Power Saver dbus path
Chris Cain78e86012021-03-04 16:15:31 -0600252 */
Chris Cain1be43372021-12-09 19:29:37 -0600253 explicit PowerMode(const Manager& managerRef, const char* modePath,
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500254 const char* ipsPath
255#ifdef POWER10
256 ,
257 EventPtr& event
258#endif
259 ) :
Andrew Geisslercdaf9982022-04-21 11:57:20 -0400260 ModeInterface(utils::getBus(), modePath,
261 ModeInterface::action::emit_no_signals),
262 IpsInterface(utils::getBus(), ipsPath,
263 IpsInterface::action::emit_no_signals),
264 manager(managerRef),
Chris Cain78e86012021-03-04 16:15:31 -0600265 pmodeMatch(utils::getBus(),
266 sdbusplus::bus::match::rules::propertiesChanged(
267 PMODE_PATH, PMODE_INTERFACE),
Chris Cain36f9cde2021-11-22 11:18:21 -0600268 [this](auto& msg) { this->modeChanged(msg); }),
269 ipsMatch(utils::getBus(),
270 sdbusplus::bus::match::rules::propertiesChanged(
271 PIPS_PATH, PIPS_INTERFACE),
272 [this](auto& msg) { this->ipsChanged(msg); }),
Chris Cain1be43372021-12-09 19:29:37 -0600273 defaultsUpdateMatch(
274 utils::getBus(),
275 sdbusplus::bus::match::rules::propertiesChangedNamespace(
276 "/xyz/openbmc_project/inventory", PMODE_DEFAULT_INTERFACE),
277 [this](auto& msg) { this->defaultsReady(msg); }),
278 masterOccSet(false), masterActive(false)
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500279#ifdef POWER10
280 ,
281 event(event)
282#endif
Chris Cain1be43372021-12-09 19:29:37 -0600283 {
Chris Cain015f1be2024-02-14 10:50:57 -0600284 using Mode =
285 sdbusplus::xyz::openbmc_project::Control::Power::server::Mode;
286 ModeInterface::allowedPowerModes({Mode::PowerMode::Static,
287 Mode::PowerMode::MaximumPerformance,
288 Mode::PowerMode::PowerSaving});
289
Chris Cain1be43372021-12-09 19:29:37 -0600290 // restore Power Mode to DBus
291 SysPwrMode currentMode;
292 uint16_t oemModeData = 0;
293 if (getMode(currentMode, oemModeData))
294 {
295 updateDbusMode(currentMode);
296 }
297 // restore Idle Power Saver parameters to DBus
298 uint8_t enterUtil, exitUtil;
299 uint16_t enterTime, exitTime;
300 bool ipsEnabled;
301 if (getIPSParms(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime))
302 {
303 updateDbusIPS(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime);
304 }
305 };
Chris Cain36f9cde2021-11-22 11:18:21 -0600306
Chris Cain1be43372021-12-09 19:29:37 -0600307 /** @brief Initialize the persistent data with default values
308 *
309 * @return true if initialization completed
310 */
311 bool initPersistentData();
312
Ben Tyner3576d652022-05-22 18:05:53 -0500313 /** @brief Set the power mode lock (dbus method)
314 *
315 * @return true if successful
316 */
317 bool powerModeLock();
318
319 /** @brief Get the power mode lock status (dbus method)
320 *
321 * @return true if locked
322 */
323 bool powerModeLockStatus();
324
Chris Cain1be43372021-12-09 19:29:37 -0600325 /** @brief Set the current power mode property
326 *
327 * @param[in] newMode - desired system power mode
328 * @param[in] oemModeData - data required by some OEM Power Modes
329 *
330 * @return true if mode accepted
331 */
332 bool setMode(const SysPwrMode newMode, const uint16_t oemModeData);
Chris Cain36f9cde2021-11-22 11:18:21 -0600333
334 /** @brief Send mode change command to the master OCC
335 * @return SUCCESS on success
336 */
337 CmdStatus sendModeChange();
338
339 /** @brief Send Idle Power Saver config data to the master OCC
340 * @return SUCCESS on success
341 */
342 CmdStatus sendIpsData();
343
Chris Cain6fa848a2022-01-24 14:54:38 -0600344 /** @brief Set the master OCC path
345 *
346 * @param[in] occPath - hwmon path for master OCC
347 */
348 void setMasterOcc(const std::string& occPath);
349
Chris Cain36f9cde2021-11-22 11:18:21 -0600350 /** @brief Notify object of master OCC state. If not acitve, no
351 * commands will be sent to the master OCC
352 *
353 * @param[in] isActive - true when master OCC is active
354 */
355 void setMasterActive(const bool isActive = true)
356 {
357 masterActive = isActive;
358 };
Chris Cain78e86012021-03-04 16:15:31 -0600359
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500360#ifdef POWER10
361 /** @brief Starts to monitor for IPS active state change conditions
362 *
363 * @param[in] poll - Indicates whether or not the IPS state file should
364 * actually be read for changes.
365 */
366 void addIpsWatch(bool poll = true);
367
368 /** @brief Removes IPS active watch */
369 void removeIpsWatch();
370#endif
371
Sheldon Bailey31a2f132022-05-20 11:31:52 -0500372 /** @brief Set dbus property to SAFE Mode(true) or clear SAFE Mode(false)*/
373 void updateDbusSafeMode(const bool safeMode);
374
Ben Tyner3576d652022-05-22 18:05:53 -0500375 /** @brief override the set/get MODE function
376 *
377 * @param[in] value - Intended value
378 *
379 * @return - the value or Updated value of the property
380 */
381 Base::Mode::PowerMode powerMode(Base::Mode::PowerMode value) override;
382
Chris Cain78e86012021-03-04 16:15:31 -0600383 private:
Chris Cain36f9cde2021-11-22 11:18:21 -0600384 /** @brief OCC manager object */
385 const Manager& manager;
386
387 /** @brief Pass-through occ path on the bus */
388 std::string path;
389
390 /** @brief OCC instance number */
391 int occInstance;
392
393 /** @brief Object to send commands to the OCC */
Chris Cain6fa848a2022-01-24 14:54:38 -0600394 std::unique_ptr<open_power::occ::OccCommand> occCmd;
Chris Cain36f9cde2021-11-22 11:18:21 -0600395
396 /** @brief Used to subscribe to dbus pmode property changes **/
397 sdbusplus::bus::match_t pmodeMatch;
398
399 /** @brief Used to subscribe to dbus IPS property changes **/
400 sdbusplus::bus::match_t ipsMatch;
401
Chris Cain1be43372021-12-09 19:29:37 -0600402 /** @brief Used to subscribe to dbus defaults property changes **/
403 sdbusplus::bus::match_t defaultsUpdateMatch;
404
Chris Cain36f9cde2021-11-22 11:18:21 -0600405 OccPersistData persistedData;
406
Chris Cain6fa848a2022-01-24 14:54:38 -0600407 /** @brief True when the master OCC has been established */
408 bool masterOccSet;
409
410 /** @brief True when the master OCC is active */
Chris Cain36f9cde2021-11-22 11:18:21 -0600411 bool masterActive;
412
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500413#ifdef POWER10
414 /** @brief IPS status data filename to read */
415 const fs::path ipsStatusFile = std::filesystem::path{OCC_HWMON_PATH} /
416 std::filesystem::path{OCC_MASTER_NAME} /
417 "occ_ips_status";
418
419 /** @brief Current state of error watching */
420 bool watching = false;
421
422 /** @brief register for the callback from the POLL IPS changed event */
423 void registerIpsStatusCallBack();
424#endif
425
Chris Cain78e86012021-03-04 16:15:31 -0600426 /** @brief Callback for pmode setting changes
427 *
428 * Process change and inform OCC
429 *
430 * @param[in] msg - Data associated with pmode change signal
431 *
432 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500433 void modeChanged(sdbusplus::message_t& msg);
Chris Cain78e86012021-03-04 16:15:31 -0600434
Chris Cain1be43372021-12-09 19:29:37 -0600435 /** @brief Get the current power mode property
436 *
437 * @param[out] currentMode - current system power mode
438 * @param[out] oemModeData - frequency data for some OEM mode
439 *
440 * @return true if data read successfully
Chris Cain1d51da22021-09-21 14:13:41 -0500441 */
Chris Cain1be43372021-12-09 19:29:37 -0600442 bool getMode(SysPwrMode& currentMode, uint16_t& oemModeData);
Chris Cain1d51da22021-09-21 14:13:41 -0500443
Chris Cain36f9cde2021-11-22 11:18:21 -0600444 /** @brief Update the power mode property on DBus
445 *
446 * @param[in] newMode - desired power mode
447 *
448 * @return true on success
449 */
450 bool updateDbusMode(const SysPwrMode newMode);
451
Chris Cain1d51da22021-09-21 14:13:41 -0500452 /** @brief Callback for IPS setting changes
453 *
454 * Process change and inform OCC
455 *
Chris Cain36f9cde2021-11-22 11:18:21 -0600456 * @param[in] msg - Data associated with IPS change signal
Chris Cain1d51da22021-09-21 14:13:41 -0500457 *
458 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500459 void ipsChanged(sdbusplus::message_t& msg);
Chris Cain1d51da22021-09-21 14:13:41 -0500460
Chris Cain1be43372021-12-09 19:29:37 -0600461 /** @brief Get the Idle Power Saver properties
462 *
463 * @param[out] enabled - Idle Power Save status (true = enabled)
464 * @param[out] enterUtil - IPS Enter Utilization (%)
465 * @param[out] enterTime - IPS Enter Time (seconds)
466 * @param[out] exitUtil - IPS Exit Utilization (%)
467 * @param[out] exitTime - IPS Exit Time (seconds)
468 *
469 * @return true if data read successfully
Chris Cain36f9cde2021-11-22 11:18:21 -0600470 */
Chris Cain1be43372021-12-09 19:29:37 -0600471 bool getIPSParms(bool& enabled, uint8_t& enterUtil, uint16_t& enterTime,
472 uint8_t& exitUtil, uint16_t& exitTime);
473
474 /** Update the Idle Power Saver data on DBus
475 *
476 * @param[in] enabled - Idle Power Save status (true = enabled)
477 * @param[in] enterUtil - IPS Enter Utilization (%)
478 * @param[in] enterTime - IPS Enter Time (seconds)
479 * @param[in] exitUtil - IPS Exit Utilization (%)
480 * @param[in] exitTime - IPS Exit Time (seconds)
481 *
482 * @return true if parameters were set successfully
483 */
484 bool updateDbusIPS(const bool enabled, const uint8_t enterUtil,
485 const uint16_t enterTime, const uint8_t exitUtil,
486 const uint16_t exitTime);
487
488 /** @brief Callback for entity manager default changes
489 *
490 * Called when PowerModeProperties defaults are available
491 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500492 void defaultsReady(sdbusplus::message_t& msg);
Chris Cain1be43372021-12-09 19:29:37 -0600493
494 /** @brief Get the default power mode property for this system type
495 *
496 * @param[out] defaultMode - default system power mode
497 *
498 * @return true if data read successfully
499 */
500 bool getDefaultMode(SysPwrMode& defaultMode);
501
502 /** @brief Get the default Idle Power Saver properties for this system type
503 *
504 * @param[out] enabled - Idle Power Save status (true = enabled)
505 * @param[out] enterUtil - IPS Enter Utilization (%)
506 * @param[out] enterTime - IPS Enter Time (seconds)
507 * @param[out] exitUtil - IPS Exit Utilization (%)
508 * @param[out] exitTime - IPS Exit Time (seconds)
509 *
510 * @return true if parameters were read successfully
511 */
512 bool getDefaultIPSParms(bool& enabled, uint8_t& enterUtil,
513 uint16_t& enterTime, uint8_t& exitUtil,
514 uint16_t& exitTime);
Chris Caincde7bea2022-01-28 15:54:24 -0600515
516 /** @brief Read the default Idle Power Saver parameters and save them to the
517 * DBUS so they will get used
518 *
519 * @return true if restore was successful
520 */
521 bool useDefaultIPSParms();
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500522
523#ifdef POWER10
524 /** @brief callback for the POLL IPS changed event
525 *
526 * @param[in] es - Populated event source
527 * @param[in] fd - Associated File descriptor
528 * @param[in] revents - Type of event
529 * @param[in] userData - User data that was passed during registration
530 */
531 static int ipsStatusCallBack(sd_event_source* es, int fd, uint32_t revents,
532 void* userData);
533
534 /** @brief Opens the IPS file and populates fd */
535 bool openIpsFile();
536
537 /** @brief sd_event wrapped in unique_ptr */
538 EventPtr& event;
539
540 /** @brief event source wrapped in unique_ptr */
541 EventSourcePtr eventSource;
542
543 /** @brief When the ips status event is received, analyzes it */
544 virtual void analyzeIpsEvent();
545
546 protected:
547 /** @brief File descriptor to watch for errors */
548 int fd = -1;
549#endif
Chris Cain1d51da22021-09-21 14:13:41 -0500550};
551
Chris Cain78e86012021-03-04 16:15:31 -0600552} // namespace powermode
553
554} // namespace occ
555
556} // namespace open_power
557#endif