Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 1 | #pragma once |
George Liu | bddcf85 | 2021-09-08 08:46:22 +0800 | [diff] [blame] | 2 | #include "config.h" |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 3 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 4 | #include "i2c_occ.hpp" |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 5 | #include "occ_command.hpp" |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 6 | #include "occ_device.hpp" |
| 7 | #include "occ_events.hpp" |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 8 | #include "powercap.hpp" |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 9 | #include "powermode.hpp" |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 10 | #include "utils.hpp" |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 11 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 12 | #include <org/open_power/Control/Host/server.hpp> |
| 13 | #include <org/open_power/OCC/Status/server.hpp> |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 14 | #include <sdbusplus/bus.hpp> |
| 15 | #include <sdbusplus/server/object.hpp> |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 16 | #ifdef POWER10 |
| 17 | #include <sdeventplus/event.hpp> |
| 18 | #include <sdeventplus/utility/timer.hpp> |
| 19 | #endif |
Lei YU | 0ab90ca | 2017-07-13 17:02:23 +0800 | [diff] [blame] | 20 | |
George Liu | b5ca101 | 2021-09-10 12:53:11 +0800 | [diff] [blame] | 21 | #include <functional> |
| 22 | |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 23 | namespace open_power |
| 24 | { |
| 25 | namespace occ |
| 26 | { |
| 27 | |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 28 | class Manager; |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 29 | namespace Base = sdbusplus::org::open_power::OCC::server; |
| 30 | using Interface = sdbusplus::server::object::object<Base::Status>; |
| 31 | |
Vishwanatha Subbanna | 30e329a | 2017-07-24 23:13:14 +0530 | [diff] [blame] | 32 | // IPMID's host control application |
| 33 | namespace Control = sdbusplus::org::open_power::Control::server; |
| 34 | |
| 35 | // For waiting on signals |
| 36 | namespace sdbusRule = sdbusplus::bus::match::rules; |
| 37 | |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame] | 38 | // OCC status instance. Ex. for "occ0", the instance is 0 |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 39 | using instanceID = unsigned int; |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame] | 40 | |
| 41 | // IPMI sensor ID for a given OCC instance |
| 42 | using sensorID = uint8_t; |
| 43 | |
Alexander Filippov | 1d69e19 | 2019-03-21 18:12:07 +0300 | [diff] [blame] | 44 | // Human readable sensor name for DBus tree. E.g. "CPU0_OCC" |
| 45 | using sensorName = std::string; |
| 46 | |
| 47 | // OCC sensors definitions in the map |
| 48 | using sensorDefs = std::tuple<sensorID, sensorName>; |
| 49 | |
Eddie James | e7d976b | 2018-02-26 13:42:45 -0600 | [diff] [blame] | 50 | // OCC sysfs name prefix |
| 51 | const std::string sysfsName = "occ-hwmon"; |
| 52 | |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 53 | /** @class Status |
| 54 | * @brief Implementation of OCC Active Status |
| 55 | */ |
| 56 | class Status : public Interface |
| 57 | { |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 58 | public: |
| 59 | Status() = delete; |
| 60 | ~Status() = default; |
| 61 | Status(const Status&) = delete; |
| 62 | Status& operator=(const Status&) = delete; |
| 63 | Status(Status&&) = default; |
| 64 | Status& operator=(Status&&) = default; |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 65 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 66 | /** @brief Constructs the Status object and |
| 67 | * the underlying device object |
| 68 | * |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 69 | * @param[in] event - sd_event unique pointer reference |
| 70 | * @param[in] path - DBus object path |
| 71 | * @param[in] manager - OCC manager instance |
| 72 | * @param[in] callBack - Callback handler to invoke during |
| 73 | * property change |
Tom Joseph | 0032523 | 2020-07-29 17:51:48 +0530 | [diff] [blame] | 74 | * @param[in] resetCallBack - callback handler to invoke for resetting the |
| 75 | * OCC if PLDM is the host communication |
| 76 | * protocol |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 77 | */ |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 78 | Status(EventPtr& event, const char* path, Manager& managerRef, |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 79 | #ifdef POWER10 |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 80 | std::unique_ptr<powermode::PowerMode>& powerModeRef, |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 81 | #endif |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 82 | std::function<void(instanceID, bool)> callBack = nullptr |
Tom Joseph | 0032523 | 2020-07-29 17:51:48 +0530 | [diff] [blame] | 83 | #ifdef PLDM |
| 84 | , |
| 85 | std::function<void(instanceID)> resetCallBack = nullptr |
| 86 | #endif |
| 87 | ) : |
| 88 | |
Patrick Williams | 1923a75 | 2022-04-05 21:35:45 -0500 | [diff] [blame] | 89 | Interface(utils::getBus(), getDbusPath(path).c_str(), |
| 90 | Interface::action::defer_emit), |
Chris Cain | 1be4337 | 2021-12-09 19:29:37 -0600 | [diff] [blame] | 91 | path(path), managerCallBack(callBack), instance(getInstance(path)), |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 92 | manager(managerRef), |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 93 | #ifdef POWER10 |
| 94 | pmode(powerModeRef), |
| 95 | #endif |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 96 | device(event, |
Lei YU | 0ab90ca | 2017-07-13 17:02:23 +0800 | [diff] [blame] | 97 | #ifdef I2C_OCC |
Eddie James | 774f9af | 2019-03-19 20:58:53 +0000 | [diff] [blame] | 98 | fs::path(DEV_PATH) / i2c_occ::getI2cDeviceName(path), |
Lei YU | 0ab90ca | 2017-07-13 17:02:23 +0800 | [diff] [blame] | 99 | #else |
Eddie James | 774f9af | 2019-03-19 20:58:53 +0000 | [diff] [blame] | 100 | fs::path(DEV_PATH) / |
| 101 | fs::path(sysfsName + "." + std::to_string(instance + 1)), |
Lei YU | 0ab90ca | 2017-07-13 17:02:23 +0800 | [diff] [blame] | 102 | #endif |
Sheldon Bailey | ea2b22e | 2022-04-04 12:24:46 -0500 | [diff] [blame] | 103 | managerRef, *this, |
| 104 | #ifdef POWER10 |
| 105 | powerModeRef, |
| 106 | #endif |
| 107 | instance), |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 108 | hostControlSignal( |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 109 | utils::getBus(), |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 110 | sdbusRule::type::signal() + sdbusRule::member("CommandComplete") + |
| 111 | sdbusRule::path("/org/open_power/control/host0") + |
| 112 | sdbusRule::interface("org.open_power.Control.Host") + |
| 113 | sdbusRule::argN(0, Control::convertForMessage( |
| 114 | Control::Host::Command::OCCReset)), |
| 115 | std::bind(std::mem_fn(&Status::hostControlEvent), this, |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 116 | std::placeholders::_1)), |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 117 | occCmd(instance, (fs::path(OCC_CONTROL_ROOT) / |
| 118 | (std::string(OCC_NAME) + std::to_string(instance))) |
| 119 | .c_str()) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 120 | #ifdef POWER10 |
| 121 | , |
| 122 | sdpEvent(sdeventplus::Event::get_default()), |
| 123 | safeStateDelayTimer( |
| 124 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>( |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 125 | sdpEvent, std::bind(&Status::safeStateDelayExpired, this))), |
| 126 | occReadStateFailTimer( |
| 127 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>( |
| 128 | sdpEvent, std::bind(&Status::occReadStateNow, this))) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 129 | #endif |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 130 | |
Tom Joseph | 0032523 | 2020-07-29 17:51:48 +0530 | [diff] [blame] | 131 | #ifdef PLDM |
| 132 | , |
| 133 | resetCallBack(resetCallBack) |
| 134 | #endif |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 135 | { |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 136 | // Announce that we are ready |
| 137 | this->emit_object_added(); |
| 138 | } |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 139 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 140 | /** @brief Since we are overriding the setter-occActive but not the |
| 141 | * getter-occActive, we need to have this using in order to |
| 142 | * allow passthrough usage of the getter-occActive |
| 143 | */ |
| 144 | using Base::Status::occActive; |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 145 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 146 | /** @brief SET OccActive to True or False |
| 147 | * |
| 148 | * @param[in] value - Intended value |
| 149 | * |
| 150 | * @return - Updated value of the property |
| 151 | */ |
| 152 | bool occActive(bool value) override; |
Vishwanatha Subbanna | 2dc9b1a | 2017-08-18 18:29:41 +0530 | [diff] [blame] | 153 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 154 | /** @brief Starts OCC error detection */ |
| 155 | inline void addErrorWatch() |
| 156 | { |
| 157 | return device.addErrorWatch(); |
| 158 | } |
Vishwanatha Subbanna | 2dc9b1a | 2017-08-18 18:29:41 +0530 | [diff] [blame] | 159 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 160 | /** @brief Stops OCC error detection */ |
| 161 | inline void removeErrorWatch() |
| 162 | { |
| 163 | return device.removeErrorWatch(); |
| 164 | } |
Eddie James | dae2d94 | 2017-12-20 10:50:03 -0600 | [diff] [blame] | 165 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 166 | /** @brief Starts to watch how many OCCs are present on the master */ |
| 167 | inline void addPresenceWatchMaster() |
| 168 | { |
| 169 | return device.addPresenceWatchMaster(); |
| 170 | } |
Vishwanatha Subbanna | 30e329a | 2017-07-24 23:13:14 +0530 | [diff] [blame] | 171 | |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 172 | /** @brief Gets the occ instance number */ |
| 173 | unsigned int getOccInstanceID() |
| 174 | { |
| 175 | return instance; |
| 176 | } |
| 177 | |
| 178 | /** @brief Is this OCC the master OCC */ |
| 179 | bool isMasterOcc() |
| 180 | { |
| 181 | return device.master(); |
| 182 | } |
| 183 | |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 184 | /** @brief Read OCC state (will trigger kernel to poll the OCC) */ |
| 185 | void readOccState(); |
| 186 | |
Eddie James | 9789e71 | 2022-05-25 15:43:40 -0500 | [diff] [blame] | 187 | /** @brief Called when device errors are detected |
| 188 | * |
| 189 | * @param[in] d - description of the error that occurred |
| 190 | */ |
| 191 | void deviceError(Error::Descriptor d = Error::Descriptor()); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 192 | |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 193 | #ifdef POWER10 |
| 194 | /** @brief Handle additional tasks when the OCCs reach active state */ |
| 195 | void occsWentActive(); |
| 196 | |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 197 | /** @brief Send Ambient & Altitude data to OCC |
| 198 | * |
| 199 | * @param[in] ambient - temperature to send (0xFF will force read |
| 200 | * of current temperature and altitude) |
| 201 | * @param[in] altitude - altitude to send (0xFFFF = unavailable) |
| 202 | * |
| 203 | * @return SUCCESS on success |
| 204 | */ |
| 205 | CmdStatus sendAmbient(const uint8_t ambient = 0xFF, |
| 206 | const uint16_t altitude = 0xFFFF); |
Chris Cain | 733b201 | 2022-05-04 11:54:06 -0500 | [diff] [blame] | 207 | |
| 208 | /** @brief Set flag indicating if PLDM sensor has been received |
| 209 | * |
| 210 | * @param[in] wasReceived - true if PLDM sensor was read |
| 211 | */ |
| 212 | void setPldmSensorReceived(const bool wasReceived) |
| 213 | { |
| 214 | pldmSensorStateReceived = wasReceived; |
| 215 | } |
| 216 | |
| 217 | /** @brief Read flag indicating if PLDM sensor has been read |
| 218 | * |
| 219 | * @return true if sensor has been read |
| 220 | */ |
| 221 | bool getPldmSensorReceived() |
| 222 | { |
| 223 | return pldmSensorStateReceived; |
| 224 | } |
| 225 | |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 226 | #endif // POWER10 |
| 227 | |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 228 | /** @brief Return the HWMON path for this OCC |
| 229 | * |
| 230 | * @return path or empty path if not found |
| 231 | */ |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 232 | fs::path getHwmonPath(); |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 233 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 234 | private: |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 235 | /** @brief OCC dbus object path */ |
| 236 | std::string path; |
Vishwanatha Subbanna | 32e84e9 | 2017-06-28 19:17:28 +0530 | [diff] [blame] | 237 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 238 | /** @brief Callback handler to be invoked during property change. |
| 239 | * This is a handler in Manager class |
| 240 | */ |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 241 | std::function<void(instanceID, bool)> managerCallBack; |
Vishwanatha Subbanna | 2dc9b1a | 2017-08-18 18:29:41 +0530 | [diff] [blame] | 242 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 243 | /** @brief OCC instance number. Ex, 0,1, etc */ |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 244 | unsigned int instance; |
| 245 | |
| 246 | /** @brief The last state read from the OCC */ |
| 247 | unsigned int lastState = 0; |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame] | 248 | |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 249 | /** @brief Number of retry attempts to open file and update state. */ |
| 250 | const unsigned int occReadRetries = 1; |
| 251 | |
| 252 | /** @brief Current number of retries attempted towards occReadRetries. */ |
| 253 | size_t currentOccReadRetriesCount = 0; |
| 254 | |
| 255 | /** @brief The Trigger to indicate OCC State is valid or not. */ |
| 256 | bool stateValid = false; |
| 257 | |
Alexander Filippov | 1d69e19 | 2019-03-21 18:12:07 +0300 | [diff] [blame] | 258 | /** @brief OCC instance to Sensor definitions mapping */ |
| 259 | static const std::map<instanceID, sensorDefs> sensorMap; |
Vishwanatha Subbanna | 6add0b8 | 2017-07-21 19:02:37 +0530 | [diff] [blame] | 260 | |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 261 | /** @brief OCC manager object */ |
| 262 | const Manager& manager; |
| 263 | |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 264 | #ifdef POWER10 |
| 265 | /** @brief OCC PowerMode object */ |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 266 | std::unique_ptr<powermode::PowerMode>& pmode; |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 267 | #endif |
| 268 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 269 | /** @brief OCC device object to do bind and unbind */ |
| 270 | Device device; |
Vishwanatha Subbanna | ee4d83d | 2017-06-29 18:35:00 +0530 | [diff] [blame] | 271 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 272 | /** @brief Subscribe to host control signal |
| 273 | * |
| 274 | * Once the OCC reset is requested, BMC sends that message to host. |
| 275 | * If the host does not ack the message, then there would be a timeout |
| 276 | * and we need to catch that to log an error |
| 277 | **/ |
| 278 | sdbusplus::bus::match_t hostControlSignal; |
Vishwanatha Subbanna | 30e329a | 2017-07-24 23:13:14 +0530 | [diff] [blame] | 279 | |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 280 | /** @brief Command object to send commands to the OCC */ |
| 281 | OccCommand occCmd; |
| 282 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 283 | #ifdef POWER10 |
| 284 | /** @brief timer event */ |
| 285 | sdeventplus::Event sdpEvent; |
| 286 | #endif |
| 287 | |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 288 | /** @brief hwmon path for this OCC */ |
| 289 | fs::path hwmonPath; |
| 290 | |
Chris Cain | 733b201 | 2022-05-04 11:54:06 -0500 | [diff] [blame] | 291 | /** @brief flag indicating if the OCC sensor has been received */ |
| 292 | bool pldmSensorStateReceived = false; |
| 293 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 294 | /** @brief Callback function on host control signals |
| 295 | * |
| 296 | * @param[in] msg - Data associated with subscribed signal |
| 297 | */ |
| 298 | void hostControlEvent(sdbusplus::message::message& msg); |
Vishwanatha Subbanna | 30e329a | 2017-07-24 23:13:14 +0530 | [diff] [blame] | 299 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 300 | /** @brief Sends a message to host control command handler to reset OCC |
| 301 | */ |
| 302 | void resetOCC(); |
Alexander Filippov | 1d69e19 | 2019-03-21 18:12:07 +0300 | [diff] [blame] | 303 | |
| 304 | /** @brief Determines the instance ID by specified object path. |
| 305 | * @param[in] path Estimated OCC Dbus object path |
| 306 | * @return Instance number |
| 307 | */ |
| 308 | static int getInstance(const std::string& path) |
| 309 | { |
| 310 | return (path.empty() ? 0 : path.back() - '0'); |
| 311 | } |
| 312 | |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 313 | #ifdef POWER10 |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 314 | /** |
| 315 | * @brief Timer that is started when OCC is detected to be in safe mode |
| 316 | */ |
| 317 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> |
| 318 | safeStateDelayTimer; |
| 319 | |
| 320 | /** @brief Callback for timer that is started when OCC was detected to be in |
| 321 | * safe mode. Called to verify and then disable and reset the OCCs. |
| 322 | */ |
| 323 | void safeStateDelayExpired(); |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 324 | |
| 325 | /** |
| 326 | * @brief Timer that is started when OCC read Valid state failed. |
| 327 | */ |
| 328 | sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> |
| 329 | occReadStateFailTimer; |
| 330 | |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 331 | #endif // POWER10 |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 332 | /** @brief Callback for timer that is started when OCC state |
| 333 | * was not able to be read. Called to attempt another read when needed. |
| 334 | */ |
| 335 | void occReadStateNow(); |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 336 | |
Alexander Filippov | 1d69e19 | 2019-03-21 18:12:07 +0300 | [diff] [blame] | 337 | /** @brief Override the sensor name with name from the definition. |
| 338 | * @param[in] estimatedPath - Estimated OCC Dbus object path |
| 339 | * @return Fixed OCC DBus object path |
| 340 | */ |
| 341 | static std::string getDbusPath(const std::string& estimatedPath) |
| 342 | { |
| 343 | if (!estimatedPath.empty()) |
| 344 | { |
| 345 | auto it = sensorMap.find(getInstance(estimatedPath)); |
| 346 | if (sensorMap.end() != it) |
| 347 | { |
| 348 | auto& name = std::get<1>(it->second); |
| 349 | if (!name.empty() && name != "None") |
| 350 | { |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 351 | auto objectPath = fs::path(estimatedPath); |
| 352 | objectPath.replace_filename(name); |
| 353 | return objectPath.string(); |
Alexander Filippov | 1d69e19 | 2019-03-21 18:12:07 +0300 | [diff] [blame] | 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | return estimatedPath; |
| 359 | } |
Tom Joseph | 0032523 | 2020-07-29 17:51:48 +0530 | [diff] [blame] | 360 | #ifdef PLDM |
| 361 | std::function<void(instanceID)> resetCallBack = nullptr; |
| 362 | #endif |
Vishwanatha Subbanna | 307d80b | 2017-06-28 15:56:09 +0530 | [diff] [blame] | 363 | }; |
| 364 | |
| 365 | } // namespace occ |
| 366 | } // namespace open_power |