blob: b5200d49bd063aa1cb9b06135653ad63de65e154 [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>
9//#include <cereal/archives/binary.hpp>
10#include <cereal/cereal.hpp>
11#include <cereal/types/string.hpp>
12#include <cereal/types/tuple.hpp>
13#include <cereal/types/vector.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060014#include <sdbusplus/bus.hpp>
15#include <sdbusplus/bus/match.hpp>
Chris Cain1be43372021-12-09 19:29:37 -060016#include <xyz/openbmc_project/Control/Power/IdlePowerSaver/server.hpp>
17#include <xyz/openbmc_project/Control/Power/Mode/server.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060018
George Liubcef3b42021-09-10 12:39:02 +080019#include <filesystem>
George Liub5ca1012021-09-10 12:53:11 +080020
Chris Cain78e86012021-03-04 16:15:31 -060021namespace open_power
22{
23namespace occ
24{
Chris Cain36f9cde2021-11-22 11:18:21 -060025
26class Manager;
27
Chris Cain78e86012021-03-04 16:15:31 -060028namespace powermode
29{
Chris Cain1be43372021-12-09 19:29:37 -060030namespace Base = sdbusplus::xyz::openbmc_project::Control::Power::server;
Patrick Williamsaf408082022-07-22 19:26:54 -050031using ModeInterface = sdbusplus::server::object_t<Base::Mode>;
32using IpsInterface = sdbusplus::server::object_t<Base::IdlePowerSaver>;
Chris Cain1be43372021-12-09 19:29:37 -060033using namespace std::literals::string_literals;
Chris Cain78e86012021-03-04 16:15:31 -060034
35constexpr auto PMODE_PATH = "/xyz/openbmc_project/control/host0/power_mode";
36constexpr auto PMODE_INTERFACE = "xyz.openbmc_project.Control.Power.Mode";
37constexpr auto POWER_MODE_PROP = "PowerMode";
Sheldon Bailey31a2f132022-05-20 11:31:52 -050038constexpr auto POWER_SAFE_MODE_PROP = "SafeMode";
Chris Cain78e86012021-03-04 16:15:31 -060039
Chris Cain1d51da22021-09-21 14:13:41 -050040constexpr auto PIPS_PATH = "/xyz/openbmc_project/control/host0/power_ips";
41constexpr auto PIPS_INTERFACE =
42 "xyz.openbmc_project.Control.Power.IdlePowerSaver";
Sheldon Baileyea2b22e2022-04-04 12:24:46 -050043constexpr auto IPS_ACTIVE_PROP = "Active";
Chris Cain1d51da22021-09-21 14:13:41 -050044constexpr auto IPS_ENABLED_PROP = "Enabled";
45constexpr auto IPS_ENTER_UTIL = "EnterUtilizationPercent";
46constexpr auto IPS_ENTER_TIME = "EnterDwellTime";
47constexpr auto IPS_EXIT_UTIL = "ExitUtilizationPercent";
48constexpr auto IPS_EXIT_TIME = "ExitDwellTime";
49
Chris Cain1be43372021-12-09 19:29:37 -060050const auto PMODE_DEFAULT_INTERFACE =
51 "xyz.openbmc_project.Configuration.PowerModeProperties"s;
52
Chris Cain36f9cde2021-11-22 11:18:21 -060053/** @brief Query the current Hypervisor target
54 * @return true if the current Hypervisor target is PowerVM
55 */
56bool isPowerVM();
57
Chris Cain78e86012021-03-04 16:15:31 -060058/** @brief Convert power mode string to OCC SysPwrMode value
59 *
60 * @param[in] i_modeString - power mode string
61 *
62 * @return SysPwrMode or SysPwrMode::NO_CHANGE if not found
63 */
64SysPwrMode convertStringToMode(const std::string& i_modeString);
65
Chris Cain1be43372021-12-09 19:29:37 -060066struct PowerModeData
Chris Cain36f9cde2021-11-22 11:18:21 -060067{
Chris Cain1be43372021-12-09 19:29:37 -060068 bool modeInitialized = false;
69 SysPwrMode mode = SysPwrMode::NO_CHANGE;
70 uint16_t oemModeData = 0x0000;
71 bool ipsInitialized = false;
72 bool ipsEnabled = true;
73 uint8_t ipsEnterUtil = 0;
74 uint16_t ipsEnterTime = 0;
75 uint8_t ipsExitUtil = 0;
76 uint16_t ipsExitTime = 0;
Ben Tyner3576d652022-05-22 18:05:53 -050077 bool modeLocked = false;
Chris Cain36f9cde2021-11-22 11:18:21 -060078
79 /** @brief Function specifying data to archive for cereal.
80 */
81 template <class Archive>
82 void serialize(Archive& archive)
83 {
Chris Cain1be43372021-12-09 19:29:37 -060084 archive(modeInitialized, mode, oemModeData, ipsInitialized, ipsEnabled,
Ben Tyner3576d652022-05-22 18:05:53 -050085 ipsEnterUtil, ipsEnterTime, ipsExitUtil, ipsExitTime,
86 modeLocked);
Chris Cain36f9cde2021-11-22 11:18:21 -060087 }
88};
89
90/** @class OccPersistData
91 * @brief Provides persistent container to store data for OCC
92 *
93 * Data is stored via cereal
94 */
95class OccPersistData
96{
97 public:
98 ~OccPersistData() = default;
99 OccPersistData(const OccPersistData&) = default;
100 OccPersistData& operator=(const OccPersistData&) = default;
101 OccPersistData(OccPersistData&&) = default;
102 OccPersistData& operator=(OccPersistData&&) = default;
103
Chris Cain1be43372021-12-09 19:29:37 -0600104 /** @brief Loads any saved power mode data */
Chris Cain36f9cde2021-11-22 11:18:21 -0600105 OccPersistData()
106 {
107 load();
108 }
109
110 /** @brief Save Power Mode data to persistent file
111 *
Chris Cain1be43372021-12-09 19:29:37 -0600112 * @param[in] newMode - desired System Power Mode
113 * @param[in] oemModeData - data required by some OEM Power Modes
Chris Cain36f9cde2021-11-22 11:18:21 -0600114 */
Chris Cain1be43372021-12-09 19:29:37 -0600115 void updateMode(const SysPwrMode newMode, const uint16_t oemModeData)
Chris Cain36f9cde2021-11-22 11:18:21 -0600116 {
Chris Cain1be43372021-12-09 19:29:37 -0600117 modeData.mode = newMode;
118 modeData.oemModeData = oemModeData;
119 modeData.modeInitialized = true;
Chris Cain36f9cde2021-11-22 11:18:21 -0600120 save();
121 }
122
Ben Tyner3576d652022-05-22 18:05:53 -0500123 /** @brief Save Power Mode Lock value to persistent file
124 *
125 * @param[in] modeLock - desired System Power Mode Lock
126 */
127 void updateModeLock(const bool modeLock)
128 {
129 modeData.modeLocked = modeLock;
130 save();
131 }
Chris Cain1be43372021-12-09 19:29:37 -0600132 /** @brief Write Idle Power Saver parameters to persistent file
Chris Cain36f9cde2021-11-22 11:18:21 -0600133 *
Chris Cain1be43372021-12-09 19:29:37 -0600134 * @param[in] enabled - Idle Power Save status (true = enabled)
135 * @param[in] enterUtil - IPS Enter Utilization (%)
136 * @param[in] enterTime - IPS Enter Time (seconds)
137 * @param[in] exitUtil - IPS Exit Utilization (%)
138 * @param[in] exitTime - IPS Exit Time (seconds)
Chris Cain36f9cde2021-11-22 11:18:21 -0600139 */
Chris Cain1be43372021-12-09 19:29:37 -0600140 void updateIPS(const bool enabled, const uint8_t enterUtil,
141 const uint16_t enterTime, const uint8_t exitUtil,
142 const uint16_t exitTime)
Chris Cain36f9cde2021-11-22 11:18:21 -0600143 {
Chris Cain1be43372021-12-09 19:29:37 -0600144 modeData.ipsEnabled = enabled;
145 modeData.ipsEnterUtil = enterUtil;
146 modeData.ipsEnterTime = enterTime;
147 modeData.ipsExitUtil = exitUtil;
148 modeData.ipsExitTime = exitTime;
149 modeData.ipsInitialized = true;
150 save();
151 }
152
153 /** @brief Return the Power Mode and mode data
154 *
155 * @param[out] mode - current system power mode
156 * @param[out] oemModeData - frequency data for some OEM mode
157 *
158 * @returns true if mode was available
159 */
160 bool getMode(SysPwrMode& mode, uint16_t& oemModeData) const
161 {
162 if (!modeData.modeInitialized)
Chris Cain36f9cde2021-11-22 11:18:21 -0600163 {
164 return false;
165 }
166
Chris Cain1be43372021-12-09 19:29:37 -0600167 mode = modeData.mode;
168 oemModeData = modeData.oemModeData;
Chris Cain36f9cde2021-11-22 11:18:21 -0600169 return true;
170 }
171
Chris Cain1be43372021-12-09 19:29:37 -0600172 /** @brief Get the Idle Power Saver properties from DBus
173 *
174 * @param[out] enabled - Idle Power Save status (true = enabled)
175 * @param[out] enterUtil - IPS Enter Utilization (%)
176 * @param[out] enterTime - IPS Enter Time (seconds)
177 * @param[out] exitUtil - IPS Exit Utilization (%)
178 * @param[out] exitTime - IPS Exit Time (seconds)
179 *
180 * @return true if parameters were read successfully
181 */
182 bool getIPS(bool& enabled, uint8_t& enterUtil, uint16_t& enterTime,
183 uint8_t& exitUtil, uint16_t& exitTime)
184 {
185 if (!modeData.ipsInitialized)
186 {
187 return false;
188 }
189
190 enabled = modeData.ipsEnabled;
191 enterUtil = modeData.ipsEnterUtil;
192 enterTime = modeData.ipsEnterTime;
193 exitUtil = modeData.ipsExitUtil;
194 exitTime = modeData.ipsExitTime;
195 return true;
196 }
197
Ben Tyner3576d652022-05-22 18:05:53 -0500198 /** @brief Return persisted mode lock */
199 bool getModeLock()
200 {
201 return modeData.modeLocked;
202 }
203
Chris Cain1be43372021-12-09 19:29:37 -0600204 /** @brief Return true if the power mode is available */
205 bool modeAvailable()
206 {
207 return (modeData.modeInitialized);
208 }
209
Chris Caincde7bea2022-01-28 15:54:24 -0600210 /** @brief Return true if the IPS data is available */
Chris Cain1be43372021-12-09 19:29:37 -0600211 bool ipsAvailable()
212 {
213 return (modeData.ipsInitialized);
214 }
215
Chris Cain36f9cde2021-11-22 11:18:21 -0600216 /** @brief Saves the Power Mode data in the filesystem using cereal. */
217 void save();
218
Chris Cain1be43372021-12-09 19:29:37 -0600219 /** @brief Trace the Power Mode and IPS parameters. */
220 void print();
Chris Cain36f9cde2021-11-22 11:18:21 -0600221
222 private:
Chris Cain1be43372021-12-09 19:29:37 -0600223 /** @brief Power Mode data filename to store persistent data */
224 static constexpr auto powerModeFilename = "powerModeData";
Chris Cain36f9cde2021-11-22 11:18:21 -0600225
Chris Cain1be43372021-12-09 19:29:37 -0600226 /** @brief Power Mode data object to be persisted */
227 PowerModeData modeData;
Chris Cain36f9cde2021-11-22 11:18:21 -0600228
229 /** @brief Loads the OEM mode data in the filesystem using cereal. */
230 void load();
231};
232
Chris Cain78e86012021-03-04 16:15:31 -0600233/** @class PowerMode
234 * @brief Monitors for changes to the power mode and notifies occ
235 *
236 * The customer power mode is provided to the OCC by host TMGT when the occ
237 * first goes active or is reset. This code is responsible for sending
238 * the power mode to the OCC if the mode is changed while the occ is active.
239 */
240
Chris Cain1be43372021-12-09 19:29:37 -0600241class PowerMode : public ModeInterface, public IpsInterface
Chris Cain78e86012021-03-04 16:15:31 -0600242{
243 public:
244 /** @brief PowerMode object to inform occ of changes to mode
245 *
246 * This object will monitor for changes to the power mode setting.
247 * If a change is detected, and the occ is active, then this object will
248 * notify the OCC of the change.
249 *
Chris Cain1be43372021-12-09 19:29:37 -0600250 * @param[in] managerRef - manager object reference
251 * @param[in] modePath - Power Mode dbus path
252 * @param[in] ipsPath - Idle Power Saver dbus path
Chris Cain78e86012021-03-04 16:15:31 -0600253 */
Chris Cain1be43372021-12-09 19:29:37 -0600254 explicit PowerMode(const Manager& managerRef, const char* modePath,
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500255 const char* ipsPath
256#ifdef POWER10
257 ,
258 EventPtr& event
259#endif
260 ) :
Andrew Geisslercdaf9982022-04-21 11:57:20 -0400261 ModeInterface(utils::getBus(), modePath,
262 ModeInterface::action::emit_no_signals),
263 IpsInterface(utils::getBus(), ipsPath,
264 IpsInterface::action::emit_no_signals),
265 manager(managerRef),
Chris Cain78e86012021-03-04 16:15:31 -0600266 pmodeMatch(utils::getBus(),
267 sdbusplus::bus::match::rules::propertiesChanged(
268 PMODE_PATH, PMODE_INTERFACE),
Chris Cain36f9cde2021-11-22 11:18:21 -0600269 [this](auto& msg) { this->modeChanged(msg); }),
270 ipsMatch(utils::getBus(),
271 sdbusplus::bus::match::rules::propertiesChanged(
272 PIPS_PATH, PIPS_INTERFACE),
273 [this](auto& msg) { this->ipsChanged(msg); }),
Chris Cain1be43372021-12-09 19:29:37 -0600274 defaultsUpdateMatch(
275 utils::getBus(),
276 sdbusplus::bus::match::rules::propertiesChangedNamespace(
277 "/xyz/openbmc_project/inventory", PMODE_DEFAULT_INTERFACE),
278 [this](auto& msg) { this->defaultsReady(msg); }),
279 masterOccSet(false), masterActive(false)
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500280#ifdef POWER10
281 ,
282 event(event)
283#endif
Chris Cain1be43372021-12-09 19:29:37 -0600284 {
285 // restore Power Mode to DBus
286 SysPwrMode currentMode;
287 uint16_t oemModeData = 0;
288 if (getMode(currentMode, oemModeData))
289 {
290 updateDbusMode(currentMode);
291 }
292 // restore Idle Power Saver parameters to DBus
293 uint8_t enterUtil, exitUtil;
294 uint16_t enterTime, exitTime;
295 bool ipsEnabled;
296 if (getIPSParms(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime))
297 {
298 updateDbusIPS(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime);
299 }
300 };
Chris Cain36f9cde2021-11-22 11:18:21 -0600301
Chris Cain1be43372021-12-09 19:29:37 -0600302 /** @brief Initialize the persistent data with default values
303 *
304 * @return true if initialization completed
305 */
306 bool initPersistentData();
307
Ben Tyner3576d652022-05-22 18:05:53 -0500308 /** @brief Set the power mode lock (dbus method)
309 *
310 * @return true if successful
311 */
312 bool powerModeLock();
313
314 /** @brief Get the power mode lock status (dbus method)
315 *
316 * @return true if locked
317 */
318 bool powerModeLockStatus();
319
Chris Cain1be43372021-12-09 19:29:37 -0600320 /** @brief Set the current power mode property
321 *
322 * @param[in] newMode - desired system power mode
323 * @param[in] oemModeData - data required by some OEM Power Modes
324 *
325 * @return true if mode accepted
326 */
327 bool setMode(const SysPwrMode newMode, const uint16_t oemModeData);
Chris Cain36f9cde2021-11-22 11:18:21 -0600328
329 /** @brief Send mode change command to the master OCC
330 * @return SUCCESS on success
331 */
332 CmdStatus sendModeChange();
333
334 /** @brief Send Idle Power Saver config data to the master OCC
335 * @return SUCCESS on success
336 */
337 CmdStatus sendIpsData();
338
Chris Cain6fa848a2022-01-24 14:54:38 -0600339 /** @brief Set the master OCC path
340 *
341 * @param[in] occPath - hwmon path for master OCC
342 */
343 void setMasterOcc(const std::string& occPath);
344
Chris Cain36f9cde2021-11-22 11:18:21 -0600345 /** @brief Notify object of master OCC state. If not acitve, no
346 * commands will be sent to the master OCC
347 *
348 * @param[in] isActive - true when master OCC is active
349 */
350 void setMasterActive(const bool isActive = true)
351 {
352 masterActive = isActive;
353 };
Chris Cain78e86012021-03-04 16:15:31 -0600354
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500355#ifdef POWER10
356 /** @brief Starts to monitor for IPS active state change conditions
357 *
358 * @param[in] poll - Indicates whether or not the IPS state file should
359 * actually be read for changes.
360 */
361 void addIpsWatch(bool poll = true);
362
363 /** @brief Removes IPS active watch */
364 void removeIpsWatch();
365#endif
366
Sheldon Bailey31a2f132022-05-20 11:31:52 -0500367 /** @brief Set dbus property to SAFE Mode(true) or clear SAFE Mode(false)*/
368 void updateDbusSafeMode(const bool safeMode);
369
Ben Tyner3576d652022-05-22 18:05:53 -0500370 /** @brief override the set/get MODE function
371 *
372 * @param[in] value - Intended value
373 *
374 * @return - the value or Updated value of the property
375 */
376 Base::Mode::PowerMode powerMode(Base::Mode::PowerMode value) override;
377
Chris Cain78e86012021-03-04 16:15:31 -0600378 private:
Chris Cain36f9cde2021-11-22 11:18:21 -0600379 /** @brief OCC manager object */
380 const Manager& manager;
381
382 /** @brief Pass-through occ path on the bus */
383 std::string path;
384
385 /** @brief OCC instance number */
386 int occInstance;
387
388 /** @brief Object to send commands to the OCC */
Chris Cain6fa848a2022-01-24 14:54:38 -0600389 std::unique_ptr<open_power::occ::OccCommand> occCmd;
Chris Cain36f9cde2021-11-22 11:18:21 -0600390
391 /** @brief Used to subscribe to dbus pmode property changes **/
392 sdbusplus::bus::match_t pmodeMatch;
393
394 /** @brief Used to subscribe to dbus IPS property changes **/
395 sdbusplus::bus::match_t ipsMatch;
396
Chris Cain1be43372021-12-09 19:29:37 -0600397 /** @brief Used to subscribe to dbus defaults property changes **/
398 sdbusplus::bus::match_t defaultsUpdateMatch;
399
Chris Cain36f9cde2021-11-22 11:18:21 -0600400 OccPersistData persistedData;
401
Chris Cain6fa848a2022-01-24 14:54:38 -0600402 /** @brief True when the master OCC has been established */
403 bool masterOccSet;
404
405 /** @brief True when the master OCC is active */
Chris Cain36f9cde2021-11-22 11:18:21 -0600406 bool masterActive;
407
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500408#ifdef POWER10
409 /** @brief IPS status data filename to read */
410 const fs::path ipsStatusFile = std::filesystem::path{OCC_HWMON_PATH} /
411 std::filesystem::path{OCC_MASTER_NAME} /
412 "occ_ips_status";
413
414 /** @brief Current state of error watching */
415 bool watching = false;
416
417 /** @brief register for the callback from the POLL IPS changed event */
418 void registerIpsStatusCallBack();
419#endif
420
Chris Cain78e86012021-03-04 16:15:31 -0600421 /** @brief Callback for pmode setting changes
422 *
423 * Process change and inform OCC
424 *
425 * @param[in] msg - Data associated with pmode change signal
426 *
427 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500428 void modeChanged(sdbusplus::message_t& msg);
Chris Cain78e86012021-03-04 16:15:31 -0600429
Chris Cain1be43372021-12-09 19:29:37 -0600430 /** @brief Get the current power mode property
431 *
432 * @param[out] currentMode - current system power mode
433 * @param[out] oemModeData - frequency data for some OEM mode
434 *
435 * @return true if data read successfully
Chris Cain1d51da22021-09-21 14:13:41 -0500436 */
Chris Cain1be43372021-12-09 19:29:37 -0600437 bool getMode(SysPwrMode& currentMode, uint16_t& oemModeData);
Chris Cain1d51da22021-09-21 14:13:41 -0500438
Chris Cain36f9cde2021-11-22 11:18:21 -0600439 /** @brief Update the power mode property on DBus
440 *
441 * @param[in] newMode - desired power mode
442 *
443 * @return true on success
444 */
445 bool updateDbusMode(const SysPwrMode newMode);
446
Chris Cain1d51da22021-09-21 14:13:41 -0500447 /** @brief Callback for IPS setting changes
448 *
449 * Process change and inform OCC
450 *
Chris Cain36f9cde2021-11-22 11:18:21 -0600451 * @param[in] msg - Data associated with IPS change signal
Chris Cain1d51da22021-09-21 14:13:41 -0500452 *
453 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500454 void ipsChanged(sdbusplus::message_t& msg);
Chris Cain1d51da22021-09-21 14:13:41 -0500455
Chris Cain1be43372021-12-09 19:29:37 -0600456 /** @brief Get the Idle Power Saver properties
457 *
458 * @param[out] enabled - Idle Power Save status (true = enabled)
459 * @param[out] enterUtil - IPS Enter Utilization (%)
460 * @param[out] enterTime - IPS Enter Time (seconds)
461 * @param[out] exitUtil - IPS Exit Utilization (%)
462 * @param[out] exitTime - IPS Exit Time (seconds)
463 *
464 * @return true if data read successfully
Chris Cain36f9cde2021-11-22 11:18:21 -0600465 */
Chris Cain1be43372021-12-09 19:29:37 -0600466 bool getIPSParms(bool& enabled, uint8_t& enterUtil, uint16_t& enterTime,
467 uint8_t& exitUtil, uint16_t& exitTime);
468
469 /** Update the Idle Power Saver data on DBus
470 *
471 * @param[in] enabled - Idle Power Save status (true = enabled)
472 * @param[in] enterUtil - IPS Enter Utilization (%)
473 * @param[in] enterTime - IPS Enter Time (seconds)
474 * @param[in] exitUtil - IPS Exit Utilization (%)
475 * @param[in] exitTime - IPS Exit Time (seconds)
476 *
477 * @return true if parameters were set successfully
478 */
479 bool updateDbusIPS(const bool enabled, const uint8_t enterUtil,
480 const uint16_t enterTime, const uint8_t exitUtil,
481 const uint16_t exitTime);
482
483 /** @brief Callback for entity manager default changes
484 *
485 * Called when PowerModeProperties defaults are available
486 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500487 void defaultsReady(sdbusplus::message_t& msg);
Chris Cain1be43372021-12-09 19:29:37 -0600488
489 /** @brief Get the default power mode property for this system type
490 *
491 * @param[out] defaultMode - default system power mode
492 *
493 * @return true if data read successfully
494 */
495 bool getDefaultMode(SysPwrMode& defaultMode);
496
497 /** @brief Get the default Idle Power Saver properties for this system type
498 *
499 * @param[out] enabled - Idle Power Save status (true = enabled)
500 * @param[out] enterUtil - IPS Enter Utilization (%)
501 * @param[out] enterTime - IPS Enter Time (seconds)
502 * @param[out] exitUtil - IPS Exit Utilization (%)
503 * @param[out] exitTime - IPS Exit Time (seconds)
504 *
505 * @return true if parameters were read successfully
506 */
507 bool getDefaultIPSParms(bool& enabled, uint8_t& enterUtil,
508 uint16_t& enterTime, uint8_t& exitUtil,
509 uint16_t& exitTime);
Chris Caincde7bea2022-01-28 15:54:24 -0600510
511 /** @brief Read the default Idle Power Saver parameters and save them to the
512 * DBUS so they will get used
513 *
514 * @return true if restore was successful
515 */
516 bool useDefaultIPSParms();
Sheldon Baileyea2b22e2022-04-04 12:24:46 -0500517
518#ifdef POWER10
519 /** @brief callback for the POLL IPS changed event
520 *
521 * @param[in] es - Populated event source
522 * @param[in] fd - Associated File descriptor
523 * @param[in] revents - Type of event
524 * @param[in] userData - User data that was passed during registration
525 */
526 static int ipsStatusCallBack(sd_event_source* es, int fd, uint32_t revents,
527 void* userData);
528
529 /** @brief Opens the IPS file and populates fd */
530 bool openIpsFile();
531
532 /** @brief sd_event wrapped in unique_ptr */
533 EventPtr& event;
534
535 /** @brief event source wrapped in unique_ptr */
536 EventSourcePtr eventSource;
537
538 /** @brief When the ips status event is received, analyzes it */
539 virtual void analyzeIpsEvent();
540
541 protected:
542 /** @brief File descriptor to watch for errors */
543 int fd = -1;
544#endif
Chris Cain1d51da22021-09-21 14:13:41 -0500545};
546
Chris Cain78e86012021-03-04 16:15:31 -0600547} // namespace powermode
548
549} // namespace occ
550
551} // namespace open_power
552#endif