blob: b11756d9b26ebf20c92094e89b6c1cf56f4b772c [file] [log] [blame]
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05301#pragma once
2
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +05303#include "occ_pass_through.hpp"
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05304#include "occ_status.hpp"
Tom Joseph815f9f52020-07-27 12:12:13 +05305#ifdef PLDM
6#include "pldm.hpp"
Eddie Jamescbad2192021-10-07 09:39:39 -05007
Chris Cain720a3842025-01-09 10:23:36 -06008#ifdef PHAL_SUPPORT
Eddie Jamescbad2192021-10-07 09:39:39 -05009#include <libphal.H>
Tom Joseph815f9f52020-07-27 12:12:13 +053010#endif
Chris Cain720a3842025-01-09 10:23:36 -060011#endif
Chris Cain40501a22022-03-14 17:33:27 -050012#include "powercap.hpp"
George Liuf3b75142021-06-10 11:22:50 +080013#include "utils.hpp"
Chris Cain78e86012021-03-04 16:15:31 -060014#ifdef POWER10
15#include "powermode.hpp"
16#endif
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053017
Gunnar Mills94df8c92018-09-14 14:50:03 -050018#include <sdbusplus/bus.hpp>
Chris Caina8857c52021-01-27 11:53:05 -060019#include <sdeventplus/event.hpp>
20#include <sdeventplus/utility/timer.hpp>
George Liub5ca1012021-09-10 12:53:11 +080021
22#include <cstring>
23#include <functional>
Gunnar Mills94df8c92018-09-14 14:50:03 -050024#include <vector>
25
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053026namespace sdbusRule = sdbusplus::bus::match::rules;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053027namespace open_power
28{
29namespace occ
30{
31
Chicago Duanbb895cb2021-06-18 19:37:16 +080032#ifdef READ_OCC_SENSORS
33enum occFruType
34{
35 processorCore = 0,
36 internalMemCtlr = 1,
37 dimm = 2,
38 memCtrlAndDimm = 3,
39 VRMVdd = 6,
40 PMIC = 7,
Matt Spinlerace67d82021-10-18 13:41:57 -050041 memCtlrExSensor = 8,
42 processorIoRing = 9
Chicago Duanbb895cb2021-06-18 19:37:16 +080043};
44#endif
45
Chris Caina8857c52021-01-27 11:53:05 -060046/** @brief Default time, in seconds, between OCC poll commands */
Matt Spinler37923462021-09-24 11:38:05 -050047#ifndef POWER10
Chicago Duanbb895cb2021-06-18 19:37:16 +080048constexpr unsigned int defaultPollingInterval = 1;
Matt Spinler37923462021-09-24 11:38:05 -050049#else
50constexpr unsigned int defaultPollingInterval = 5;
51#endif
Chris Caina8857c52021-01-27 11:53:05 -060052
Chris Cain17257672021-10-22 13:41:03 -050053constexpr auto AMBIENT_PATH =
54 "/xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp";
55constexpr auto AMBIENT_INTERFACE = "xyz.openbmc_project.Sensor.Value";
56constexpr auto AMBIENT_PROP = "Value";
57constexpr auto ALTITUDE_PATH = "/xyz/openbmc_project/sensors/altitude/Altitude";
58constexpr auto ALTITUDE_INTERFACE = "xyz.openbmc_project.Sensor.Value";
59constexpr auto ALTITUDE_PROP = "Value";
60
Sheldon Baileyd2b044f2025-02-12 11:50:24 -060061constexpr auto EXTN_LABEL_PWRM_MEMORY_POWER = "5057524d";
62constexpr auto EXTN_LABEL_PWRP_PROCESSOR_POWER = "50575250";
63
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053064/** @class Manager
65 * @brief Builds and manages OCC objects
66 */
67struct Manager
68{
Gunnar Mills94df8c92018-09-14 14:50:03 -050069 public:
70 Manager() = delete;
71 Manager(const Manager&) = delete;
72 Manager& operator=(const Manager&) = delete;
73 Manager(Manager&&) = delete;
74 Manager& operator=(Manager&&) = delete;
75 ~Manager() = default;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +053076
Gunnar Mills94df8c92018-09-14 14:50:03 -050077 /** @brief Adds OCC pass-through and status objects on the bus
78 * when corresponding CPU inventory is created.
79 *
Gunnar Mills94df8c92018-09-14 14:50:03 -050080 * @param[in] event - Unique ptr reference to sd_event
81 */
George Liuf3a4a692021-12-28 13:59:51 +080082 explicit Manager(EventPtr& event) :
George Liuf3b75142021-06-10 11:22:50 +080083 event(event), pollInterval(defaultPollingInterval),
Chris Caina8857c52021-01-27 11:53:05 -060084 sdpEvent(sdeventplus::Event::get_default()),
85 _pollTimer(
86 std::make_unique<
87 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Cain17257672021-10-22 13:41:03 -050088 sdpEvent, std::bind(&Manager::pollerTimerExpired, this))),
89 ambientPropChanged(
90 utils::getBus(),
91 sdbusRule::member("PropertiesChanged") +
92 sdbusRule::path(AMBIENT_PATH) +
93 sdbusRule::argN(0, AMBIENT_INTERFACE) +
94 sdbusRule::interface("org.freedesktop.DBus.Properties"),
95 std::bind(&Manager::ambientCallback, this, std::placeholders::_1))
Matt Spinlerd267cec2021-09-01 14:49:19 -050096#ifdef POWER10
97 ,
98 discoverTimer(
99 std::make_unique<
100 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Caina7b74dc2021-11-10 17:03:43 -0600101 sdpEvent, std::bind(&Manager::findAndCreateObjects, this))),
102 waitForAllOccsTimer(
103 std::make_unique<
104 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
105 sdpEvent, std::bind(&Manager::occsNotAllRunning, this)))
Chris Cain755af102024-02-27 16:09:51 -0600106#ifdef PLDM
107 ,
Chris Cainc33171b2024-05-24 16:14:50 -0500108 throttlePldmTraceTimer(
Chris Cain755af102024-02-27 16:09:51 -0600109 std::make_unique<
110 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>(
Chris Cainc33171b2024-05-24 16:14:50 -0500111 sdpEvent, std::bind(&Manager::throttlePldmTraceExpired, this)))
Matt Spinlerd267cec2021-09-01 14:49:19 -0500112#endif
Chris Cain755af102024-02-27 16:09:51 -0600113#endif // POWER10
Gunnar Mills94df8c92018-09-14 14:50:03 -0500114 {
Lei YU0ab90ca2017-07-13 17:02:23 +0800115#ifdef I2C_OCC
Gunnar Mills94df8c92018-09-14 14:50:03 -0500116 // I2C OCC status objects are initialized directly
117 initStatusObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800118#else
Gunnar Mills94df8c92018-09-14 14:50:03 -0500119 findAndCreateObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800120#endif
Chris Cain17257672021-10-22 13:41:03 -0500121 readAltitude();
Gunnar Mills94df8c92018-09-14 14:50:03 -0500122 }
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530123
Chris Cain720a3842025-01-09 10:23:36 -0600124 void createPldmHandle();
125
Chris Caina8857c52021-01-27 11:53:05 -0600126 /** @brief Return the number of bound OCCs */
Gunnar Mills94df8c92018-09-14 14:50:03 -0500127 inline auto getNumOCCs() const
128 {
129 return activeCount;
130 }
Edward A. James636577f2017-10-06 10:53:55 -0500131
Eddie Jamescbad2192021-10-07 09:39:39 -0500132#ifdef PLDM
133 /** @brief Called by a Device to report that the SBE timed out
134 * and appropriate action should be taken
135 *
136 * @param[in] instance - the OCC instance id
137 */
138 void sbeTimeout(unsigned int instance);
139#endif
140
Chris Cain17257672021-10-22 13:41:03 -0500141 /** @brief Return the latest ambient and altitude readings
142 *
143 * @param[out] ambientValid - true if ambientTemp is valid
144 * @param[out] ambient - ambient temperature in degrees C
145 * @param[out] altitude - altitude in meters
146 */
147 void getAmbientData(bool& ambientValid, uint8_t& ambientTemp,
148 uint16_t& altitude) const;
149
Chris Cain40501a22022-03-14 17:33:27 -0500150 /** @brief Notify pcap object to update bounds */
151 void updatePcapBounds() const;
152
Sheldon Baileyc8dd4592022-05-12 10:15:14 -0500153 /**
154 * @brief Set all sensor values of this OCC to NaN.
155 * @param[in] id - Id of the OCC.
156 * */
157 void setSensorValueToNaN(uint32_t id) const;
158
Sheldon Bailey373af752022-02-21 15:14:00 -0600159 /** @brief Set all sensor values of this OCC to NaN and non functional.
160 *
161 * @param[in] id - Id of the OCC.
162 */
163 void setSensorValueToNonFunctional(uint32_t id) const;
164
Chris Cainc488bac2025-03-17 09:01:15 -0500165 /** @brief Clear any state flags that need to be reset when the host state
166 * is off */
167 void hostPoweredOff();
168
Gunnar Mills94df8c92018-09-14 14:50:03 -0500169 private:
Matt Spinlerd267cec2021-09-01 14:49:19 -0500170 /** @brief Creates the OCC D-Bus objects.
Gunnar Mills94df8c92018-09-14 14:50:03 -0500171 */
172 void findAndCreateObjects();
Vishwanatha Subbannadfc7ec72017-09-07 18:18:01 +0530173
Gunnar Mills94df8c92018-09-14 14:50:03 -0500174 /** @brief Callback that responds to cpu creation in the inventory -
175 * by creating the needed objects.
176 *
177 * @param[in] msg - bus message
178 *
179 * @returns 0 to indicate success
180 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500181 int cpuCreated(sdbusplus::message_t& msg);
Deepak Kodihalli5f031f32017-07-26 08:25:59 -0500182
Gunnar Mills94df8c92018-09-14 14:50:03 -0500183 /** @brief Create child OCC objects.
184 *
185 * @param[in] occ - the occ name, such as occ0.
186 */
187 void createObjects(const std::string& occ);
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530188
Gunnar Mills94df8c92018-09-14 14:50:03 -0500189 /** @brief Callback handler invoked by Status object when the OccActive
190 * property is changed. This is needed to make sure that the
191 * error detection is started only after all the OCCs are bound.
192 * Similarly, when one of the OCC gets its OccActive property
193 * un-set, then the OCC error detection needs to be stopped on
194 * all the OCCs
195 *
196 * @param[in] status - OccActive status
197 */
Sheldon Bailey373af752022-02-21 15:14:00 -0600198 void statusCallBack(instanceID instance, bool status);
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530199
Chris Cainf0295f52024-09-12 15:41:14 -0500200 /** @brief Set flag that a PM Complex reset is needed (to be initiated
201 * later) */
202 void resetOccRequest(instanceID instance);
203
204 /** @brief Initiate the request to reset the PM Complex (PLDM -> HBRT) */
205 void initiateOccRequest(instanceID instance);
206
Gunnar Mills94df8c92018-09-14 14:50:03 -0500207 /** @brief Sends a Heartbeat command to host control command handler */
208 void sendHeartBeat();
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530209
Gunnar Mills94df8c92018-09-14 14:50:03 -0500210 /** @brief reference to sd_event wrapped in unique_ptr */
211 EventPtr& event;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530212
Gunnar Mills94df8c92018-09-14 14:50:03 -0500213 /** @brief OCC pass-through objects */
214 std::vector<std::unique_ptr<PassThrough>> passThroughObjects;
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530215
Gunnar Mills94df8c92018-09-14 14:50:03 -0500216 /** @brief OCC Status objects */
217 std::vector<std::unique_ptr<Status>> statusObjects;
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530218
Chris Cain40501a22022-03-14 17:33:27 -0500219 /** @brief Power cap monitor and occ notification object */
220 std::unique_ptr<open_power::occ::powercap::PowerCap> pcap;
221
Chris Cain78e86012021-03-04 16:15:31 -0600222#ifdef POWER10
223 /** @brief Power mode monitor and notification object */
224 std::unique_ptr<open_power::occ::powermode::PowerMode> pmode;
225#endif
226
Gunnar Mills94df8c92018-09-14 14:50:03 -0500227 /** @brief sbdbusplus match objects */
228 std::vector<sdbusplus::bus::match_t> cpuMatches;
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +0530229
Gunnar Mills94df8c92018-09-14 14:50:03 -0500230 /** @brief Number of OCCs that are bound */
231 uint8_t activeCount = 0;
Lei YU0ab90ca2017-07-13 17:02:23 +0800232
Chris Caina8857c52021-01-27 11:53:05 -0600233 /** @brief Number of seconds between poll commands */
234 uint8_t pollInterval;
235
Chris Cain17257672021-10-22 13:41:03 -0500236 /** @brief Ambient temperature of the system in degrees C */
237 uint8_t ambient = 0xFF; // default: not available
238
239 /** @brief Altitude of the system in meters */
240 uint16_t altitude = 0xFFFF; // default: not available
241
Chris Caina8857c52021-01-27 11:53:05 -0600242 /** @brief Poll timer event */
243 sdeventplus::Event sdpEvent;
244
Chris Cainbae4d072022-02-28 09:46:50 -0600245 /** @brief Flags to indicate if waiting for all of the OCC active sensors to
246 * come online */
247 bool waitingForAllOccActiveSensors = false;
248
Chris Cainbd551de2022-04-26 13:41:16 -0500249 /** @brief Set containing intance numbers of any OCCs that became active
250 * while waiting for status objects to be created */
251 std::set<uint8_t> queuedActiveState;
252
Chris Caina8857c52021-01-27 11:53:05 -0600253 /**
254 * @brief The timer to be used once the OCC goes active. When it expires,
255 * a POLL command will be sent to the OCC and then timer restarted.
256 */
257 std::unique_ptr<
258 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
259 _pollTimer;
260
Chris Cain17257672021-10-22 13:41:03 -0500261 /** @brief Subscribe to ambient temperature changed events */
262 sdbusplus::bus::match_t ambientPropChanged;
263
Chris Cainf0295f52024-09-12 15:41:14 -0500264 /** @brief Flag to indicate that a PM complex reset needs to happen */
265 bool resetRequired = false;
266 /** @brief Instance number of the OCC/processor that triggered the reset */
267 uint8_t resetInstance = 255;
268 /** @brief Set when a PM complex reset has been issued (to prevent multiple
269 * requests) */
270 bool resetInProgress = false;
271
Lei YU0ab90ca2017-07-13 17:02:23 +0800272#ifdef I2C_OCC
Gunnar Mills94df8c92018-09-14 14:50:03 -0500273 /** @brief Init Status objects for I2C OCC devices
274 *
275 * It iterates in /sys/bus/i2c/devices, finds all occ hwmon devices
276 * and creates status objects.
277 */
278 void initStatusObjects();
Lei YU0ab90ca2017-07-13 17:02:23 +0800279#endif
Tom Joseph815f9f52020-07-27 12:12:13 +0530280
281#ifdef PLDM
282 /** @brief Callback handler invoked by the PLDM event handler when state of
283 * the OCC is toggled by the host. The caller passes the instance
284 * of the OCC and state of the OCC.
285 *
286 * @param[in] instance - instance of the OCC
287 * @param[in] status - true when the OCC goes active and false when the OCC
288 * goes inactive
289 *
290 * @return true if setting the state of OCC is successful and false if it
291 * fails.
292 */
293 bool updateOCCActive(instanceID instance, bool status);
294
Sheldon Bailey31a2f132022-05-20 11:31:52 -0500295 /** @brief Callback handler invoked by the PLDM event handler when mode of
296 * the OCC SAFE MODE is inacted or cleared.
297 */
298 void updateOccSafeMode(bool safeState);
299
Eddie Jamescbad2192021-10-07 09:39:39 -0500300 /** @brief Callback handler invoked by PLDM sensor change when
301 * the HRESET succeeds or fails.
302 *
303 * @param[in] instance - the SBE instance id
304 * @param[in] success - true if the HRESET succeeded, otherwise false
305 */
306 void sbeHRESETResult(instanceID instance, bool success);
307
Chris Cain720a3842025-01-09 10:23:36 -0600308#ifdef PHAL_SUPPORT
Eddie Jamescbad2192021-10-07 09:39:39 -0500309 /** @brief Helper function to check whether an SBE dump should be collected
310 * now.
311 *
312 * @param[in] instance - the SBE instance id
313 *
314 * @return true if an SBE dump should be collected and false if not
315 */
316 bool sbeCanDump(unsigned int instance);
317
318 /** @brief Helper function to set the SBE state through PDBG/PHAL
319 *
320 * @param[in] instance - instance of the SBE
321 * @param[in] state - the state to which the SBE should be set
322 *
323 */
324 void setSBEState(unsigned int instance, enum sbe_state state);
325
326 /** @brief Helper function to get the SBE instance PDBG processor target
327 *
328 * @param[in] instance - the SBE instance id
329 *
330 * @return a pointer to the PDBG target
331 */
332 struct pdbg_target* getPdbgTarget(unsigned int instance);
333
334 /** @brief Whether pdbg_targets_init has been called */
335 bool pdbgInitialized = false;
Chris Cain720a3842025-01-09 10:23:36 -0600336#endif
Eddie Jamescbad2192021-10-07 09:39:39 -0500337
Tom Joseph815f9f52020-07-27 12:12:13 +0530338 std::unique_ptr<pldm::Interface> pldmHandle = nullptr;
339#endif
Chris Caina8857c52021-01-27 11:53:05 -0600340
Matt Spinlerd267cec2021-09-01 14:49:19 -0500341#ifdef POWER10
342 /**
343 * @brief Timer used when discovering OCCs in /dev.
344 */
345 std::unique_ptr<
346 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
347 discoverTimer;
348
349 /**
350 * @brief Used when discovering /dev/occ objects to know if
351 * any were added since the last check.
352 */
353 std::vector<int> prevOCCSearch;
Chris Caina7b74dc2021-11-10 17:03:43 -0600354
355 /**
356 * @brief Timer used when waiting for OCCs to go active.
357 */
358 std::unique_ptr<
359 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
360 waitForAllOccsTimer;
361
Chris Cain755af102024-02-27 16:09:51 -0600362#ifdef PLDM
363 /**
364 * @brief Timer used to throttle PLDM traces when there are problems
Chris Cainc488bac2025-03-17 09:01:15 -0500365 determining the OCC status via pldm. Used to prevent excessive
366 journal traces.
Chris Cain755af102024-02-27 16:09:51 -0600367 */
368 std::unique_ptr<
369 sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>>
Chris Cainc33171b2024-05-24 16:14:50 -0500370 throttlePldmTraceTimer;
371 /**
372 * @brief onPldmTimeoutCreatePel flag will be used to indicate if
373 * a PEL should get created when the throttlePldmTraceTimer expires.
374 * The first time the throttlePldmTraceTimer expires, the traces
375 * will be throttled and then the timer gets restarted. The
376 * next time the timer expires, a PEL will get created.
377 */
378 bool onPldmTimeoutCreatePel = false;
Chris Cain755af102024-02-27 16:09:51 -0600379
380 /** @brief Check if all of the OCC Active sensors are available and if not
381 * restart the discoverTimer
382 */
Chris Cainc33171b2024-05-24 16:14:50 -0500383 void throttlePldmTraceExpired();
Chris Cain4b82f3e2024-04-22 14:44:29 -0500384
385 /** @brief Create a PEL when the code is not able to obtain the OCC PDRs
Chris Cainc33171b2024-05-24 16:14:50 -0500386 * via PLDM. This is called when the throttlePldmTraceTimer expires.
Chris Cain4b82f3e2024-04-22 14:44:29 -0500387 */
388 void createPldmSensorPEL();
Chris Cain755af102024-02-27 16:09:51 -0600389#endif
390
Chris Caina7b74dc2021-11-10 17:03:43 -0600391 /** @brief Called when code times out waiting for all OCCs to be running or
392 * after the app is restarted (Status does not callback into
393 * Manager).
394 */
395 void occsNotAllRunning();
Chris Cainbae4d072022-02-28 09:46:50 -0600396
397 /** @brief Check if all of the OCC Active sensors are available and if not
398 * restart the discoverTimer
399 */
400 void checkAllActiveSensors();
Chris Cain755af102024-02-27 16:09:51 -0600401#endif // POWER10
Matt Spinlerd267cec2021-09-01 14:49:19 -0500402
Chris Caina8857c52021-01-27 11:53:05 -0600403 /**
404 * @brief Called when poll timer expires and forces a POLL command to the
405 * OCC. The poll timer will then be restarted.
406 * */
407 void pollerTimerExpired();
Chicago Duanbb895cb2021-06-18 19:37:16 +0800408
Matt Spinlerd267cec2021-09-01 14:49:19 -0500409 /**
410 * @brief Finds the OCC devices in /dev
411 *
412 * @return The IDs of the OCCs - 0, 1, etc.
413 */
414 std::vector<int> findOCCsInDev();
415
Chicago Duanbb895cb2021-06-18 19:37:16 +0800416#ifdef READ_OCC_SENSORS
417 /**
418 * @brief Gets the occ sensor values.
Chris Cain5d66a0a2022-02-09 08:52:10 -0600419 * @param[in] occ - pointer to OCCs Status object
Chicago Duanbb895cb2021-06-18 19:37:16 +0800420 * */
Chris Cain5d66a0a2022-02-09 08:52:10 -0600421 void getSensorValues(std::unique_ptr<Status>& occ);
Chicago Duanbb895cb2021-06-18 19:37:16 +0800422
423 /**
424 * @brief Trigger OCC driver to read the temperature sensors.
425 * @param[in] path - path of the OCC sensors.
426 * @param[in] id - Id of the OCC.
427 * */
428 void readTempSensors(const fs::path& path, uint32_t id);
429
430 /**
Sheldon Baileyd2b044f2025-02-12 11:50:24 -0600431 * @brief Trigger OCC driver to read the extended sensors.
432 * @param[in] path - path of the OCC sensors.
433 * @param[in] id - Id of the OCC.
434 * */
435 void readExtnSensors(const fs::path& path, uint32_t id);
436
437 /**
Chicago Duanbb895cb2021-06-18 19:37:16 +0800438 * @brief Trigger OCC driver to read the power sensors.
439 * @param[in] path - path of the OCC sensors.
440 * @param[in] id - Id of the OCC.
441 * */
442 void readPowerSensors(const fs::path& path, uint32_t id);
443
Chicago Duanbb895cb2021-06-18 19:37:16 +0800444 /** @brief Store the existing OCC sensors on D-BUS */
445 std::map<std::string, uint32_t> existingSensors;
446
447 /** @brief Get FunctionID from the `powerX_label` file.
448 * @param[in] value - the value of the `powerX_label` file.
449 * @returns FunctionID of the power sensors.
450 */
Patrick Williams2d6ec902025-02-01 08:22:13 -0500451 std::optional<std::string> getPowerLabelFunctionID(
452 const std::string& value);
Chicago Duanbb895cb2021-06-18 19:37:16 +0800453
454 /** @brief The power sensor names map */
455 const std::map<std::string, std::string> powerSensorName = {
456 {"system", "total_power"}, {"1", "p0_mem_power"},
457 {"2", "p1_mem_power"}, {"3", "p2_mem_power"},
458 {"4", "p3_mem_power"}, {"5", "p0_power"},
459 {"6", "p1_power"}, {"7", "p2_power"},
460 {"8", "p3_power"}, {"9", "p0_cache_power"},
461 {"10", "p1_cache_power"}, {"11", "p2_cache_power"},
462 {"12", "p3_cache_power"}, {"13", "io_a_power"},
463 {"14", "io_b_power"}, {"15", "io_c_power"},
464 {"16", "fans_a_power"}, {"17", "fans_b_power"},
465 {"18", "storage_a_power"}, {"19", "storage_b_power"},
466 {"23", "mem_cache_power"}, {"25", "p0_mem_0_power"},
Sheldon Bailey11fd1312022-04-19 10:16:58 -0500467 {"26", "p0_mem_1_power"}, {"27", "p0_mem_2_power"},
468 {"35", "pcie_dcm0_power"}, {"36", "pcie_dcm1_power"},
469 {"37", "pcie_dcm2_power"}, {"38", "pcie_dcm3_power"},
470 {"39", "io_dcm0_power"}, {"40", "io_dcm1_power"},
471 {"41", "io_dcm2_power"}, {"42", "io_dcm3_power"},
472 {"43", "avdd_total_power"}};
Chicago Duanbb895cb2021-06-18 19:37:16 +0800473
Sheldon Bailey11fd1312022-04-19 10:16:58 -0500474 /** @brief The dimm temperature sensor names map */
Chicago Duanbb895cb2021-06-18 19:37:16 +0800475 const std::map<uint32_t, std::string> dimmTempSensorName = {
476 {internalMemCtlr, "_intmb_temp"},
477 {dimm, "_dram_temp"},
478 {memCtrlAndDimm, "_dram_extmb_temp"},
479 {PMIC, "_pmic_temp"},
480 {memCtlrExSensor, "_extmb_temp"}};
Matt Spinlerad8f4522023-10-25 11:14:46 -0500481
482 /** @brief The dimm DVFS temperature sensor names map */
483 const std::map<uint32_t, std::string> dimmDVFSSensorName = {
484 {internalMemCtlr, "dimm_intmb_dvfs_temp"},
485 {dimm, "dimm_dram_dvfs_temp"},
486 {memCtrlAndDimm, "dimm_dram_extmb_dvfs_temp"},
487 {PMIC, "dimm_pmic_dvfs_temp"},
488 {memCtlrExSensor, "dimm_extmb_dvfs_temp"}};
Chicago Duanbb895cb2021-06-18 19:37:16 +0800489#endif
Chris Cain17257672021-10-22 13:41:03 -0500490
491 /** @brief Read the altitude from DBus */
492 void readAltitude();
493
494 /** @brief Callback function when ambient temperature changes
495 *
496 * @param[in] msg - Data associated with subscribed signal
497 */
Patrick Williamsaf408082022-07-22 19:26:54 -0500498 void ambientCallback(sdbusplus::message_t& msg);
Chris Caina7b74dc2021-11-10 17:03:43 -0600499
500 /** @brief Confirm that a single OCC master was found and start presence
501 * monitoring
502 */
503 void validateOccMaster();
Vishwanatha Subbanna2180b2d2017-06-28 14:05:57 +0530504};
505
506} // namespace occ
507} // namespace open_power