Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 3 | #include "occ_manager.hpp" |
| 4 | |
| 5 | #include "i2c_occ.hpp" |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 6 | #include "occ_dbus.hpp" |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 7 | #include "utils.hpp" |
| 8 | |
George Liu | b5ca101 | 2021-09-10 12:53:11 +0800 | [diff] [blame] | 9 | #include <phosphor-logging/elog-errors.hpp> |
| 10 | #include <phosphor-logging/log.hpp> |
| 11 | #include <xyz/openbmc_project/Common/error.hpp> |
| 12 | |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 13 | #include <chrono> |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 14 | #include <cmath> |
George Liu | bcef3b4 | 2021-09-10 12:39:02 +0800 | [diff] [blame] | 15 | #include <filesystem> |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 16 | #include <fstream> |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 17 | #include <regex> |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 18 | |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 19 | namespace open_power |
| 20 | { |
| 21 | namespace occ |
| 22 | { |
| 23 | |
Matt Spinler | 8b8abee | 2021-08-25 15:18:21 -0500 | [diff] [blame] | 24 | constexpr uint32_t fruTypeNotAvailable = 0xFF; |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 25 | constexpr auto fruTypeSuffix = "fru_type"; |
| 26 | constexpr auto faultSuffix = "fault"; |
| 27 | constexpr auto inputSuffix = "input"; |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 28 | constexpr auto maxSuffix = "max"; |
Matt Spinler | 8b8abee | 2021-08-25 15:18:21 -0500 | [diff] [blame] | 29 | |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 30 | const auto HOST_ON_FILE = "/run/openbmc/host@0-on"; |
| 31 | |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 32 | using namespace phosphor::logging; |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 33 | using namespace std::literals::chrono_literals; |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 34 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 35 | template <typename T> |
| 36 | T readFile(const std::string& path) |
| 37 | { |
| 38 | std::ifstream ifs; |
| 39 | ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit | |
| 40 | std::ifstream::eofbit); |
| 41 | T data; |
| 42 | |
| 43 | try |
| 44 | { |
| 45 | ifs.open(path); |
| 46 | ifs >> data; |
| 47 | ifs.close(); |
| 48 | } |
| 49 | catch (const std::exception& e) |
| 50 | { |
| 51 | auto err = errno; |
| 52 | throw std::system_error(err, std::generic_category()); |
| 53 | } |
| 54 | |
| 55 | return data; |
| 56 | } |
| 57 | |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 58 | void Manager::findAndCreateObjects() |
| 59 | { |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 60 | #ifndef POWER10 |
Deepak Kodihalli | 370f06b | 2017-10-25 04:26:07 -0500 | [diff] [blame] | 61 | for (auto id = 0; id < MAX_CPUS; ++id) |
| 62 | { |
Deepak Kodihalli | 30417a1 | 2017-12-04 00:54:01 -0600 | [diff] [blame] | 63 | // Create one occ per cpu |
| 64 | auto occ = std::string(OCC_NAME) + std::to_string(id); |
| 65 | createObjects(occ); |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 66 | } |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 67 | #else |
Chris Cain | 613dc90 | 2022-04-08 09:56:22 -0500 | [diff] [blame] | 68 | if (!pmode) |
| 69 | { |
| 70 | // Create the power mode object |
| 71 | pmode = std::make_unique<powermode::PowerMode>( |
| 72 | *this, powermode::PMODE_PATH, powermode::PIPS_PATH, event); |
| 73 | } |
| 74 | |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 75 | if (!fs::exists(HOST_ON_FILE)) |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 76 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 77 | static bool statusObjCreated = false; |
| 78 | if (!statusObjCreated) |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 79 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 80 | // Create the OCCs based on on the /dev/occX devices |
| 81 | auto occs = findOCCsInDev(); |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 82 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 83 | if (occs.empty() || (prevOCCSearch.size() != occs.size())) |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 84 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 85 | // Something changed or no OCCs yet, try again in 10s. |
| 86 | // Note on the first pass prevOCCSearch will be empty, |
| 87 | // so there will be at least one delay to give things |
| 88 | // a chance to settle. |
| 89 | prevOCCSearch = occs; |
| 90 | |
| 91 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 92 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 93 | "Manager::findAndCreateObjects(): Waiting for OCCs (currently {})", |
| 94 | occs.size()) |
| 95 | .c_str()); |
| 96 | |
| 97 | discoverTimer->restartOnce(10s); |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | // All OCCs appear to be available, create status objects |
| 102 | |
| 103 | // createObjects requires OCC0 first. |
| 104 | std::sort(occs.begin(), occs.end()); |
| 105 | |
| 106 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 107 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 108 | "Manager::findAndCreateObjects(): Creating {} OCC Status Objects", |
| 109 | occs.size()) |
| 110 | .c_str()); |
| 111 | for (auto id : occs) |
| 112 | { |
| 113 | createObjects(std::string(OCC_NAME) + std::to_string(id)); |
| 114 | } |
| 115 | statusObjCreated = true; |
Chris Cain | 6d8f37a | 2022-04-29 13:46:01 -0500 | [diff] [blame] | 116 | waitingForAllOccActiveSensors = true; |
Chris Cain | c86d80f | 2023-05-04 15:49:18 -0500 | [diff] [blame] | 117 | |
| 118 | // Find/update the processor path associated with each OCC |
| 119 | for (auto& obj : statusObjects) |
| 120 | { |
| 121 | obj->updateProcAssociation(); |
| 122 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
Chris Cain | 6d8f37a | 2022-04-29 13:46:01 -0500 | [diff] [blame] | 126 | if (statusObjCreated && waitingForAllOccActiveSensors) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 127 | { |
| 128 | static bool tracedHostWait = false; |
| 129 | if (utils::isHostRunning()) |
| 130 | { |
| 131 | if (tracedHostWait) |
| 132 | { |
| 133 | log<level::INFO>( |
| 134 | "Manager::findAndCreateObjects(): Host is running"); |
| 135 | tracedHostWait = false; |
| 136 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 137 | checkAllActiveSensors(); |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | if (!tracedHostWait) |
| 142 | { |
| 143 | log<level::INFO>( |
| 144 | "Manager::findAndCreateObjects(): Waiting for host to start"); |
| 145 | tracedHostWait = true; |
| 146 | } |
| 147 | discoverTimer->restartOnce(30s); |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 148 | } |
| 149 | } |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 150 | } |
| 151 | else |
| 152 | { |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 153 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 154 | std::format( |
Chris Cain | 1718fd8 | 2022-02-16 16:39:50 -0600 | [diff] [blame] | 155 | "Manager::findAndCreateObjects(): Waiting for {} to complete...", |
| 156 | HOST_ON_FILE) |
| 157 | .c_str()); |
| 158 | discoverTimer->restartOnce(10s); |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 159 | } |
| 160 | #endif |
| 161 | } |
| 162 | |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 163 | #ifdef POWER10 |
| 164 | // Check if all occActive sensors are available |
| 165 | void Manager::checkAllActiveSensors() |
| 166 | { |
| 167 | static bool allActiveSensorAvailable = false; |
| 168 | static bool tracedSensorWait = false; |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 169 | static bool waitingForHost = false; |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 170 | |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 171 | if (open_power::occ::utils::isHostRunning()) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 172 | { |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 173 | if (waitingForHost) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 174 | { |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 175 | waitingForHost = false; |
| 176 | log<level::INFO>("checkAllActiveSensors(): Host is now running"); |
| 177 | } |
| 178 | |
| 179 | // Start with the assumption that all are available |
| 180 | allActiveSensorAvailable = true; |
| 181 | for (auto& obj : statusObjects) |
| 182 | { |
| 183 | if ((!obj->occActive()) && (!obj->getPldmSensorReceived())) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 184 | { |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 185 | auto instance = obj->getOccInstanceID(); |
| 186 | // Check if sensor was queued while waiting for discovery |
| 187 | auto match = queuedActiveState.find(instance); |
| 188 | if (match != queuedActiveState.end()) |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 189 | { |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 190 | queuedActiveState.erase(match); |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 191 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 192 | std::format( |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 193 | "checkAllActiveSensors(): OCC{} is ACTIVE (queued)", |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 194 | instance) |
| 195 | .c_str()); |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 196 | obj->occActive(true); |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 197 | } |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 198 | else |
| 199 | { |
| 200 | allActiveSensorAvailable = false; |
| 201 | if (!tracedSensorWait) |
| 202 | { |
| 203 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 204 | std::format( |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 205 | "checkAllActiveSensors(): Waiting on OCC{} Active sensor", |
| 206 | instance) |
| 207 | .c_str()); |
| 208 | tracedSensorWait = true; |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame^] | 209 | // Make sure traces are not throttled |
| 210 | #ifdef PLDM |
| 211 | pldmHandle->setTraceThrottle(false); |
| 212 | // Start timer to throttle pldm traces when timer |
| 213 | // expires |
| 214 | throttleTraceTimer->restartOnce(5min); |
| 215 | #endif |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 216 | } |
Patrick Williams | fb0a5c3 | 2024-02-28 11:27:00 -0600 | [diff] [blame] | 217 | #ifdef PLDM |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 218 | pldmHandle->checkActiveSensor(obj->getOccInstanceID()); |
Patrick Williams | fb0a5c3 | 2024-02-28 11:27:00 -0600 | [diff] [blame] | 219 | #endif |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 220 | break; |
| 221 | } |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 222 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 223 | } |
| 224 | } |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 225 | else |
| 226 | { |
| 227 | if (!waitingForHost) |
| 228 | { |
| 229 | waitingForHost = true; |
| 230 | log<level::INFO>( |
| 231 | "checkAllActiveSensors(): Waiting for host to start"); |
| 232 | } |
| 233 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 234 | |
| 235 | if (allActiveSensorAvailable) |
| 236 | { |
| 237 | // All sensors were found, disable the discovery timer |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 238 | if (discoverTimer->isEnabled()) |
| 239 | { |
Chris Cain | f55f91a | 2022-05-27 13:40:15 -0500 | [diff] [blame] | 240 | discoverTimer->setEnabled(false); |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 241 | } |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame^] | 242 | #ifdef PLDM |
| 243 | if (throttleTraceTimer->isEnabled()) |
| 244 | { |
| 245 | // Disable throttle timer and make sure traces are not throttled |
| 246 | throttleTraceTimer->setEnabled(false); |
| 247 | pldmHandle->setTraceThrottle(false); |
| 248 | } |
| 249 | #endif |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 250 | |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 251 | if (waitingForAllOccActiveSensors) |
| 252 | { |
| 253 | log<level::INFO>( |
| 254 | "checkAllActiveSensors(): OCC Active sensors are available"); |
| 255 | waitingForAllOccActiveSensors = false; |
| 256 | } |
| 257 | queuedActiveState.clear(); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 258 | tracedSensorWait = false; |
| 259 | } |
| 260 | else |
| 261 | { |
| 262 | // Not all sensors were available, so keep waiting |
| 263 | if (!tracedSensorWait) |
| 264 | { |
| 265 | log<level::INFO>( |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 266 | "checkAllActiveSensors(): Waiting for OCC Active sensors to become available"); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 267 | tracedSensorWait = true; |
| 268 | } |
Chris Cain | f55f91a | 2022-05-27 13:40:15 -0500 | [diff] [blame] | 269 | discoverTimer->restartOnce(10s); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | #endif |
| 273 | |
Matt Spinler | d267cec | 2021-09-01 14:49:19 -0500 | [diff] [blame] | 274 | std::vector<int> Manager::findOCCsInDev() |
| 275 | { |
| 276 | std::vector<int> occs; |
| 277 | std::regex expr{R"(occ(\d+)$)"}; |
| 278 | |
| 279 | for (auto& file : fs::directory_iterator("/dev")) |
| 280 | { |
| 281 | std::smatch match; |
| 282 | std::string path{file.path().string()}; |
| 283 | if (std::regex_search(path, match, expr)) |
| 284 | { |
| 285 | auto num = std::stoi(match[1].str()); |
| 286 | |
| 287 | // /dev numbering starts at 1, ours starts at 0. |
| 288 | occs.push_back(num - 1); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | return occs; |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 293 | } |
| 294 | |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 295 | int Manager::cpuCreated(sdbusplus::message_t& msg) |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 296 | { |
George Liu | bcef3b4 | 2021-09-10 12:39:02 +0800 | [diff] [blame] | 297 | namespace fs = std::filesystem; |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 298 | |
| 299 | sdbusplus::message::object_path o; |
| 300 | msg.read(o); |
| 301 | fs::path cpuPath(std::string(std::move(o))); |
| 302 | |
| 303 | auto name = cpuPath.filename().string(); |
| 304 | auto index = name.find(CPU_NAME); |
| 305 | name.replace(index, std::strlen(CPU_NAME), OCC_NAME); |
| 306 | |
| 307 | createObjects(name); |
| 308 | |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | void Manager::createObjects(const std::string& occ) |
| 313 | { |
| 314 | auto path = fs::path(OCC_CONTROL_ROOT) / occ; |
| 315 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 316 | statusObjects.emplace_back(std::make_unique<Status>( |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 317 | event, path.c_str(), *this, |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 318 | #ifdef POWER10 |
| 319 | pmode, |
| 320 | #endif |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 321 | std::bind(std::mem_fn(&Manager::statusCallBack), this, |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 322 | std::placeholders::_1, std::placeholders::_2) |
Tom Joseph | 0032523 | 2020-07-29 17:51:48 +0530 | [diff] [blame] | 323 | #ifdef PLDM |
| 324 | , |
| 325 | std::bind(std::mem_fn(&pldm::Interface::resetOCC), pldmHandle.get(), |
| 326 | std::placeholders::_1) |
| 327 | #endif |
| 328 | )); |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 329 | |
Chris Cain | 40501a2 | 2022-03-14 17:33:27 -0500 | [diff] [blame] | 330 | // Create the power cap monitor object |
| 331 | if (!pcap) |
| 332 | { |
| 333 | pcap = std::make_unique<open_power::occ::powercap::PowerCap>( |
| 334 | *statusObjects.back()); |
| 335 | } |
| 336 | |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 337 | if (statusObjects.back()->isMasterOcc()) |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 338 | { |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 339 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 340 | std::format("Manager::createObjects(): OCC{} is the master", |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 341 | statusObjects.back()->getOccInstanceID()) |
| 342 | .c_str()); |
| 343 | _pollTimer->setEnabled(false); |
| 344 | |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 345 | #ifdef POWER10 |
Chris Cain | 6fa848a | 2022-01-24 14:54:38 -0600 | [diff] [blame] | 346 | // Set the master OCC on the PowerMode object |
| 347 | pmode->setMasterOcc(path); |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 348 | #endif |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | passThroughObjects.emplace_back(std::make_unique<PassThrough>(path.c_str() |
| 352 | #ifdef POWER10 |
| 353 | , |
| 354 | pmode |
| 355 | #endif |
| 356 | )); |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 357 | } |
| 358 | |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 359 | void Manager::statusCallBack(instanceID instance, bool status) |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 360 | { |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 361 | if (status == true) |
Eddie James | dae2d94 | 2017-12-20 10:50:03 -0600 | [diff] [blame] | 362 | { |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 363 | // OCC went active |
| 364 | ++activeCount; |
| 365 | |
| 366 | #ifdef POWER10 |
| 367 | if (activeCount == 1) |
Eddie James | dae2d94 | 2017-12-20 10:50:03 -0600 | [diff] [blame] | 368 | { |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 369 | // First OCC went active (allow some time for all OCCs to go active) |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 370 | waitForAllOccsTimer->restartOnce(60s); |
Matt Spinler | 53f6814 | 2021-08-25 15:47:31 -0500 | [diff] [blame] | 371 | } |
| 372 | #endif |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 373 | |
| 374 | if (activeCount == statusObjects.size()) |
| 375 | { |
| 376 | #ifdef POWER10 |
| 377 | // All OCCs are now running |
| 378 | if (waitForAllOccsTimer->isEnabled()) |
| 379 | { |
| 380 | // stop occ wait timer |
| 381 | waitForAllOccsTimer->setEnabled(false); |
| 382 | } |
| 383 | #endif |
| 384 | |
| 385 | // Verify master OCC and start presence monitor |
| 386 | validateOccMaster(); |
| 387 | } |
| 388 | |
| 389 | // Start poll timer if not already started |
| 390 | if (!_pollTimer->isEnabled()) |
| 391 | { |
| 392 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 393 | std::format("Manager: OCCs will be polled every {} seconds", |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 394 | pollInterval) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 395 | .c_str()); |
| 396 | |
| 397 | // Send poll and start OCC poll timer |
| 398 | pollerTimerExpired(); |
| 399 | } |
| 400 | } |
| 401 | else |
| 402 | { |
| 403 | // OCC went away |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 404 | if (activeCount > 0) |
| 405 | { |
| 406 | --activeCount; |
| 407 | } |
| 408 | else |
| 409 | { |
| 410 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 411 | std::format("OCC{} disabled, but currently no active OCCs", |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 412 | instance) |
| 413 | .c_str()); |
| 414 | } |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 415 | |
| 416 | if (activeCount == 0) |
| 417 | { |
| 418 | // No OCCs are running |
| 419 | |
| 420 | // Stop OCC poll timer |
| 421 | if (_pollTimer->isEnabled()) |
| 422 | { |
| 423 | log<level::INFO>( |
| 424 | "Manager::statusCallBack(): OCCs are not running, stopping poll timer"); |
| 425 | _pollTimer->setEnabled(false); |
| 426 | } |
| 427 | |
| 428 | #ifdef POWER10 |
| 429 | // stop wait timer |
| 430 | if (waitForAllOccsTimer->isEnabled()) |
| 431 | { |
| 432 | waitForAllOccsTimer->setEnabled(false); |
| 433 | } |
| 434 | #endif |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 435 | } |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 436 | #ifdef READ_OCC_SENSORS |
| 437 | // Clear OCC sensors |
Sheldon Bailey | c8dd459 | 2022-05-12 10:15:14 -0500 | [diff] [blame] | 438 | setSensorValueToNaN(instance); |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 439 | #endif |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 440 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 441 | |
| 442 | #ifdef POWER10 |
| 443 | if (waitingForAllOccActiveSensors) |
| 444 | { |
Chris Cain | 6d8f37a | 2022-04-29 13:46:01 -0500 | [diff] [blame] | 445 | if (utils::isHostRunning()) |
| 446 | { |
| 447 | checkAllActiveSensors(); |
| 448 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 449 | } |
| 450 | #endif |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | #ifdef I2C_OCC |
| 454 | void Manager::initStatusObjects() |
| 455 | { |
| 456 | // Make sure we have a valid path string |
| 457 | static_assert(sizeof(DEV_PATH) != 0); |
| 458 | |
| 459 | auto deviceNames = i2c_occ::getOccHwmonDevices(DEV_PATH); |
| 460 | for (auto& name : deviceNames) |
| 461 | { |
| 462 | i2c_occ::i2cToDbus(name); |
Lei YU | b5259a1 | 2017-09-01 16:22:40 +0800 | [diff] [blame] | 463 | name = std::string(OCC_NAME) + '_' + name; |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 464 | auto path = fs::path(OCC_CONTROL_ROOT) / name; |
| 465 | statusObjects.emplace_back( |
George Liu | f3b7514 | 2021-06-10 11:22:50 +0800 | [diff] [blame] | 466 | std::make_unique<Status>(event, path.c_str(), *this)); |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 467 | } |
Chris Cain | 40501a2 | 2022-03-14 17:33:27 -0500 | [diff] [blame] | 468 | // The first device is master occ |
| 469 | pcap = std::make_unique<open_power::occ::powercap::PowerCap>( |
| 470 | *statusObjects.front()); |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 471 | #ifdef POWER10 |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 472 | pmode = std::make_unique<powermode::PowerMode>(*this, powermode::PMODE_PATH, |
| 473 | powermode::PIPS_PATH); |
Chris Cain | 6fa848a | 2022-01-24 14:54:38 -0600 | [diff] [blame] | 474 | // Set the master OCC on the PowerMode object |
| 475 | pmode->setMasterOcc(path); |
Chris Cain | 78e8601 | 2021-03-04 16:15:31 -0600 | [diff] [blame] | 476 | #endif |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 477 | } |
| 478 | #endif |
| 479 | |
Tom Joseph | 815f9f5 | 2020-07-27 12:12:13 +0530 | [diff] [blame] | 480 | #ifdef PLDM |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 481 | void Manager::sbeTimeout(unsigned int instance) |
| 482 | { |
Eddie James | 2a751d7 | 2022-03-04 09:16:12 -0600 | [diff] [blame] | 483 | auto obj = std::find_if(statusObjects.begin(), statusObjects.end(), |
| 484 | [instance](const auto& obj) { |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 485 | return instance == obj->getOccInstanceID(); |
| 486 | }); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 487 | |
Eddie James | cb018da | 2022-03-05 11:49:37 -0600 | [diff] [blame] | 488 | if (obj != statusObjects.end() && (*obj)->occActive()) |
Eddie James | 2a751d7 | 2022-03-04 09:16:12 -0600 | [diff] [blame] | 489 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 490 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 491 | std::format("SBE timeout, requesting HRESET (OCC{})", instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 492 | .c_str()); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 493 | |
Eddie James | 2a751d7 | 2022-03-04 09:16:12 -0600 | [diff] [blame] | 494 | setSBEState(instance, SBE_STATE_NOT_USABLE); |
| 495 | |
| 496 | pldmHandle->sendHRESET(instance); |
| 497 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 498 | } |
| 499 | |
Tom Joseph | 815f9f5 | 2020-07-27 12:12:13 +0530 | [diff] [blame] | 500 | bool Manager::updateOCCActive(instanceID instance, bool status) |
| 501 | { |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 502 | auto obj = std::find_if(statusObjects.begin(), statusObjects.end(), |
| 503 | [instance](const auto& obj) { |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 504 | return instance == obj->getOccInstanceID(); |
| 505 | }); |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 506 | |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 507 | const bool hostRunning = open_power::occ::utils::isHostRunning(); |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 508 | if (obj != statusObjects.end()) |
| 509 | { |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 510 | if (!hostRunning && (status == true)) |
| 511 | { |
| 512 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 513 | std::format( |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 514 | "updateOCCActive: Host is not running yet (OCC{} active={}), clearing sensor received", |
| 515 | instance, status) |
| 516 | .c_str()); |
| 517 | (*obj)->setPldmSensorReceived(false); |
| 518 | if (!waitingForAllOccActiveSensors) |
| 519 | { |
| 520 | log<level::INFO>( |
| 521 | "updateOCCActive: Waiting for Host and all OCC Active Sensors"); |
| 522 | waitingForAllOccActiveSensors = true; |
| 523 | } |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame^] | 524 | #ifdef POWER10 |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 525 | discoverTimer->restartOnce(30s); |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame^] | 526 | #endif |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 527 | return false; |
| 528 | } |
| 529 | else |
| 530 | { |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 531 | log<level::INFO>(std::format("updateOCCActive: OCC{} active={}", |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 532 | instance, status) |
| 533 | .c_str()); |
| 534 | (*obj)->setPldmSensorReceived(true); |
| 535 | return (*obj)->occActive(status); |
| 536 | } |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 537 | } |
| 538 | else |
| 539 | { |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 540 | if (hostRunning) |
| 541 | { |
| 542 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 543 | std::format( |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 544 | "updateOCCActive: No status object to update for OCC{} (active={})", |
| 545 | instance, status) |
| 546 | .c_str()); |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | if (status == true) |
| 551 | { |
| 552 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 553 | std::format( |
Chris Cain | 082a6ca | 2023-03-21 10:27:26 -0500 | [diff] [blame] | 554 | "updateOCCActive: No status objects and Host is not running yet (OCC{} active={})", |
| 555 | instance, status) |
| 556 | .c_str()); |
| 557 | } |
| 558 | } |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 559 | if (status == true) |
| 560 | { |
| 561 | // OCC went active |
| 562 | queuedActiveState.insert(instance); |
| 563 | } |
| 564 | else |
| 565 | { |
| 566 | auto match = queuedActiveState.find(instance); |
| 567 | if (match != queuedActiveState.end()) |
| 568 | { |
| 569 | // OCC was disabled |
| 570 | queuedActiveState.erase(match); |
| 571 | } |
| 572 | } |
Chris Cain | 7e374fb | 2022-04-07 09:47:23 -0500 | [diff] [blame] | 573 | return false; |
| 574 | } |
Tom Joseph | 815f9f5 | 2020-07-27 12:12:13 +0530 | [diff] [blame] | 575 | } |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 576 | |
Sheldon Bailey | 31a2f13 | 2022-05-20 11:31:52 -0500 | [diff] [blame] | 577 | // Called upon pldm event To set powermode Safe Mode State for system. |
| 578 | void Manager::updateOccSafeMode(bool safeMode) |
| 579 | { |
| 580 | #ifdef POWER10 |
| 581 | pmode->updateDbusSafeMode(safeMode); |
| 582 | #endif |
Chris Cain | c86d80f | 2023-05-04 15:49:18 -0500 | [diff] [blame] | 583 | // Update the processor throttle status on dbus |
| 584 | for (auto& obj : statusObjects) |
| 585 | { |
| 586 | obj->updateThrottle(safeMode, THROTTLED_SAFE); |
| 587 | } |
Sheldon Bailey | 31a2f13 | 2022-05-20 11:31:52 -0500 | [diff] [blame] | 588 | } |
| 589 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 590 | void Manager::sbeHRESETResult(instanceID instance, bool success) |
| 591 | { |
| 592 | if (success) |
| 593 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 594 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 595 | std::format("HRESET succeeded (OCC{})", instance).c_str()); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 596 | |
| 597 | setSBEState(instance, SBE_STATE_BOOTED); |
| 598 | |
| 599 | return; |
| 600 | } |
| 601 | |
| 602 | setSBEState(instance, SBE_STATE_FAILED); |
| 603 | |
| 604 | if (sbeCanDump(instance)) |
| 605 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 606 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 607 | std::format("HRESET failed (OCC{}), triggering SBE dump", instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 608 | .c_str()); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 609 | |
| 610 | auto& bus = utils::getBus(); |
| 611 | uint32_t src6 = instance << 16; |
| 612 | uint32_t logId = |
| 613 | FFDC::createPEL("org.open_power.Processor.Error.SbeChipOpTimeout", |
| 614 | src6, "SBE command timeout"); |
| 615 | |
| 616 | try |
| 617 | { |
George Liu | f3a4a69 | 2021-12-28 13:59:51 +0800 | [diff] [blame] | 618 | constexpr auto path = "/org/openpower/dump"; |
| 619 | constexpr auto interface = "xyz.openbmc_project.Dump.Create"; |
| 620 | constexpr auto function = "CreateDump"; |
| 621 | |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 622 | std::string service = utils::getService(path, interface); |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 623 | auto method = bus.new_method_call(service.c_str(), path, interface, |
| 624 | function); |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 625 | |
| 626 | std::map<std::string, std::variant<std::string, uint64_t>> |
| 627 | createParams{ |
| 628 | {"com.ibm.Dump.Create.CreateParameters.ErrorLogId", |
| 629 | uint64_t(logId)}, |
| 630 | {"com.ibm.Dump.Create.CreateParameters.DumpType", |
| 631 | "com.ibm.Dump.Create.DumpType.SBE"}, |
| 632 | {"com.ibm.Dump.Create.CreateParameters.FailingUnitId", |
| 633 | uint64_t(instance)}, |
| 634 | }; |
| 635 | |
| 636 | method.append(createParams); |
| 637 | |
| 638 | auto response = bus.call(method); |
| 639 | } |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 640 | catch (const sdbusplus::exception_t& e) |
Eddie James | cbad219 | 2021-10-07 09:39:39 -0500 | [diff] [blame] | 641 | { |
| 642 | constexpr auto ERROR_DUMP_DISABLED = |
| 643 | "xyz.openbmc_project.Dump.Create.Error.Disabled"; |
| 644 | if (e.name() == ERROR_DUMP_DISABLED) |
| 645 | { |
| 646 | log<level::INFO>("Dump is disabled, skipping"); |
| 647 | } |
| 648 | else |
| 649 | { |
| 650 | log<level::ERR>("Dump failed"); |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | bool Manager::sbeCanDump(unsigned int instance) |
| 657 | { |
| 658 | struct pdbg_target* proc = getPdbgTarget(instance); |
| 659 | |
| 660 | if (!proc) |
| 661 | { |
| 662 | // allow the dump in the error case |
| 663 | return true; |
| 664 | } |
| 665 | |
| 666 | try |
| 667 | { |
| 668 | if (!openpower::phal::sbe::isDumpAllowed(proc)) |
| 669 | { |
| 670 | return false; |
| 671 | } |
| 672 | |
| 673 | if (openpower::phal::pdbg::isSbeVitalAttnActive(proc)) |
| 674 | { |
| 675 | return false; |
| 676 | } |
| 677 | } |
| 678 | catch (openpower::phal::exception::SbeError& e) |
| 679 | { |
| 680 | log<level::INFO>("Failed to query SBE state"); |
| 681 | } |
| 682 | |
| 683 | // allow the dump in the error case |
| 684 | return true; |
| 685 | } |
| 686 | |
| 687 | void Manager::setSBEState(unsigned int instance, enum sbe_state state) |
| 688 | { |
| 689 | struct pdbg_target* proc = getPdbgTarget(instance); |
| 690 | |
| 691 | if (!proc) |
| 692 | { |
| 693 | return; |
| 694 | } |
| 695 | |
| 696 | try |
| 697 | { |
| 698 | openpower::phal::sbe::setState(proc, state); |
| 699 | } |
| 700 | catch (const openpower::phal::exception::SbeError& e) |
| 701 | { |
| 702 | log<level::ERR>("Failed to set SBE state"); |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | struct pdbg_target* Manager::getPdbgTarget(unsigned int instance) |
| 707 | { |
| 708 | if (!pdbgInitialized) |
| 709 | { |
| 710 | try |
| 711 | { |
| 712 | openpower::phal::pdbg::init(); |
| 713 | pdbgInitialized = true; |
| 714 | } |
| 715 | catch (const openpower::phal::exception::PdbgError& e) |
| 716 | { |
| 717 | log<level::ERR>("pdbg initialization failed"); |
| 718 | return nullptr; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | struct pdbg_target* proc = nullptr; |
| 723 | pdbg_for_each_class_target("proc", proc) |
| 724 | { |
| 725 | if (pdbg_target_index(proc) == instance) |
| 726 | { |
| 727 | return proc; |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | log<level::ERR>("Failed to get pdbg target"); |
| 732 | return nullptr; |
| 733 | } |
Tom Joseph | 815f9f5 | 2020-07-27 12:12:13 +0530 | [diff] [blame] | 734 | #endif |
| 735 | |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 736 | void Manager::pollerTimerExpired() |
| 737 | { |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 738 | if (!_pollTimer) |
| 739 | { |
| 740 | log<level::ERR>( |
| 741 | "Manager::pollerTimerExpired() ERROR: Timer not defined"); |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | for (auto& obj : statusObjects) |
| 746 | { |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 747 | if (!obj->occActive()) |
| 748 | { |
| 749 | // OCC is not running yet |
| 750 | #ifdef READ_OCC_SENSORS |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 751 | auto id = obj->getOccInstanceID(); |
Sheldon Bailey | c8dd459 | 2022-05-12 10:15:14 -0500 | [diff] [blame] | 752 | setSensorValueToNaN(id); |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 753 | #endif |
| 754 | continue; |
| 755 | } |
| 756 | |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 757 | // Read sysfs to force kernel to poll OCC |
| 758 | obj->readOccState(); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 759 | |
| 760 | #ifdef READ_OCC_SENSORS |
| 761 | // Read occ sensor values |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 762 | getSensorValues(obj); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 763 | #endif |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 764 | } |
| 765 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 766 | if (activeCount > 0) |
| 767 | { |
| 768 | // Restart OCC poll timer |
| 769 | _pollTimer->restartOnce(std::chrono::seconds(pollInterval)); |
| 770 | } |
| 771 | else |
| 772 | { |
| 773 | // No OCCs running, so poll timer will not be restarted |
| 774 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 775 | std::format( |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 776 | "Manager::pollerTimerExpired: poll timer will not be restarted") |
| 777 | .c_str()); |
| 778 | } |
Chris Cain | a8857c5 | 2021-01-27 11:53:05 -0600 | [diff] [blame] | 779 | } |
| 780 | |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 781 | #ifdef READ_OCC_SENSORS |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 782 | void Manager::readTempSensors(const fs::path& path, uint32_t occInstance) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 783 | { |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 784 | // There may be more than one sensor with the same FRU type |
| 785 | // and label so make two passes: the first to read the temps |
| 786 | // from sysfs, and the second to put them on D-Bus after |
| 787 | // resolving any conflicts. |
| 788 | std::map<std::string, double> sensorData; |
| 789 | |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 790 | std::regex expr{"temp\\d+_label$"}; // Example: temp5_label |
| 791 | for (auto& file : fs::directory_iterator(path)) |
| 792 | { |
| 793 | if (!std::regex_search(file.path().string(), expr)) |
| 794 | { |
| 795 | continue; |
| 796 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 797 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 798 | uint32_t labelValue{0}; |
| 799 | |
| 800 | try |
| 801 | { |
| 802 | labelValue = readFile<uint32_t>(file.path()); |
| 803 | } |
| 804 | catch (const std::system_error& e) |
| 805 | { |
| 806 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 807 | std::format("readTempSensors: Failed reading {}, errno = {}", |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 808 | file.path().string(), e.code().value()) |
| 809 | .c_str()); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 810 | continue; |
| 811 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 812 | |
| 813 | const std::string& tempLabel = "label"; |
| 814 | const std::string filePathString = file.path().string().substr( |
| 815 | 0, file.path().string().length() - tempLabel.length()); |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 816 | |
| 817 | uint32_t fruTypeValue{0}; |
| 818 | try |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 819 | { |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 820 | fruTypeValue = readFile<uint32_t>(filePathString + fruTypeSuffix); |
| 821 | } |
| 822 | catch (const std::system_error& e) |
| 823 | { |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 824 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 825 | std::format("readTempSensors: Failed reading {}, errno = {}", |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 826 | filePathString + fruTypeSuffix, e.code().value()) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 827 | .c_str()); |
| 828 | continue; |
| 829 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 830 | |
Patrick Williams | a49c987 | 2023-05-10 07:50:35 -0500 | [diff] [blame] | 831 | std::string sensorPath = OCC_SENSORS_ROOT + |
| 832 | std::string("/temperature/"); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 833 | |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 834 | std::string dvfsTempPath; |
| 835 | |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 836 | if (fruTypeValue == VRMVdd) |
| 837 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 838 | sensorPath.append("vrm_vdd" + std::to_string(occInstance) + |
| 839 | "_temp"); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 840 | } |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 841 | else if (fruTypeValue == processorIoRing) |
| 842 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 843 | sensorPath.append("proc" + std::to_string(occInstance) + |
| 844 | "_ioring_temp"); |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 845 | dvfsTempPath = std::string{OCC_SENSORS_ROOT} + "/temperature/proc" + |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 846 | std::to_string(occInstance) + "_ioring_dvfs_temp"; |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 847 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 848 | else |
| 849 | { |
Matt Spinler | 14d1402 | 2021-08-25 15:38:29 -0500 | [diff] [blame] | 850 | uint16_t type = (labelValue & 0xFF000000) >> 24; |
| 851 | uint16_t instanceID = labelValue & 0x0000FFFF; |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 852 | |
| 853 | if (type == OCC_DIMM_TEMP_SENSOR_TYPE) |
| 854 | { |
Matt Spinler | 8b8abee | 2021-08-25 15:18:21 -0500 | [diff] [blame] | 855 | if (fruTypeValue == fruTypeNotAvailable) |
| 856 | { |
| 857 | // Not all DIMM related temps are available to read |
| 858 | // (no _input file in this case) |
| 859 | continue; |
| 860 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 861 | auto iter = dimmTempSensorName.find(fruTypeValue); |
| 862 | if (iter == dimmTempSensorName.end()) |
| 863 | { |
George Liu | b5ca101 | 2021-09-10 12:53:11 +0800 | [diff] [blame] | 864 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 865 | std::format( |
George Liu | b5ca101 | 2021-09-10 12:53:11 +0800 | [diff] [blame] | 866 | "readTempSensors: Fru type error! fruTypeValue = {}) ", |
| 867 | fruTypeValue) |
| 868 | .c_str()); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 869 | continue; |
| 870 | } |
| 871 | |
| 872 | sensorPath.append("dimm" + std::to_string(instanceID) + |
| 873 | iter->second); |
Matt Spinler | ad8f452 | 2023-10-25 11:14:46 -0500 | [diff] [blame] | 874 | |
| 875 | dvfsTempPath = std::string{OCC_SENSORS_ROOT} + "/temperature/" + |
| 876 | dimmDVFSSensorName.at(fruTypeValue); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 877 | } |
| 878 | else if (type == OCC_CPU_TEMP_SENSOR_TYPE) |
| 879 | { |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 880 | if (fruTypeValue == processorCore) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 881 | { |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 882 | // The OCC reports small core temps, of which there are |
| 883 | // two per big core. All current P10 systems are in big |
| 884 | // core mode, so use a big core name. |
| 885 | uint16_t coreNum = instanceID / 2; |
| 886 | uint16_t tempNum = instanceID % 2; |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 887 | sensorPath.append("proc" + std::to_string(occInstance) + |
| 888 | "_core" + std::to_string(coreNum) + "_" + |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 889 | std::to_string(tempNum) + "_temp"); |
| 890 | |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 891 | dvfsTempPath = |
| 892 | std::string{OCC_SENSORS_ROOT} + "/temperature/proc" + |
| 893 | std::to_string(occInstance) + "_core_dvfs_temp"; |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 894 | } |
| 895 | else |
| 896 | { |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 897 | continue; |
| 898 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 899 | } |
| 900 | else |
| 901 | { |
| 902 | continue; |
| 903 | } |
| 904 | } |
| 905 | |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 906 | // The dvfs temp file only needs to be read once per chip per type. |
| 907 | if (!dvfsTempPath.empty() && |
| 908 | !dbus::OccDBusSensors::getOccDBus().hasDvfsTemp(dvfsTempPath)) |
| 909 | { |
| 910 | try |
| 911 | { |
| 912 | auto dvfsValue = readFile<double>(filePathString + maxSuffix); |
| 913 | |
| 914 | dbus::OccDBusSensors::getOccDBus().setDvfsTemp( |
| 915 | dvfsTempPath, dvfsValue * std::pow(10, -3)); |
| 916 | } |
| 917 | catch (const std::system_error& e) |
| 918 | { |
| 919 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 920 | std::format( |
Matt Spinler | ace67d8 | 2021-10-18 13:41:57 -0500 | [diff] [blame] | 921 | "readTempSensors: Failed reading {}, errno = {}", |
| 922 | filePathString + maxSuffix, e.code().value()) |
| 923 | .c_str()); |
| 924 | } |
| 925 | } |
| 926 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 927 | uint32_t faultValue{0}; |
| 928 | try |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 929 | { |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 930 | faultValue = readFile<uint32_t>(filePathString + faultSuffix); |
| 931 | } |
| 932 | catch (const std::system_error& e) |
| 933 | { |
| 934 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 935 | std::format("readTempSensors: Failed reading {}, errno = {}", |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 936 | filePathString + faultSuffix, e.code().value()) |
| 937 | .c_str()); |
| 938 | continue; |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 939 | } |
| 940 | |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 941 | double tempValue{0}; |
| 942 | // NOTE: if OCC sends back 0xFF, kernal sets this fault value to 1. |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 943 | if (faultValue != 0) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 944 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 945 | tempValue = std::numeric_limits<double>::quiet_NaN(); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 946 | } |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 947 | else |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 948 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 949 | // Read the temperature |
| 950 | try |
Sheldon Bailey | cd0940b | 2022-04-26 14:24:05 -0500 | [diff] [blame] | 951 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 952 | tempValue = readFile<double>(filePathString + inputSuffix); |
Sheldon Bailey | cd0940b | 2022-04-26 14:24:05 -0500 | [diff] [blame] | 953 | } |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 954 | catch (const std::system_error& e) |
Sheldon Bailey | cd0940b | 2022-04-26 14:24:05 -0500 | [diff] [blame] | 955 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 956 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 957 | std::format( |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 958 | "readTempSensors: Failed reading {}, errno = {}", |
| 959 | filePathString + inputSuffix, e.code().value()) |
| 960 | .c_str()); |
| 961 | |
| 962 | // if errno == EAGAIN(Resource temporarily unavailable) then set |
| 963 | // temp to 0, to avoid using old temp, and affecting FAN |
| 964 | // Control. |
| 965 | if (e.code().value() == EAGAIN) |
| 966 | { |
| 967 | tempValue = 0; |
| 968 | } |
| 969 | // else the errno would be something like |
| 970 | // EBADF(Bad file descriptor) |
| 971 | // or ENOENT(No such file or directory) |
| 972 | else |
| 973 | { |
| 974 | continue; |
| 975 | } |
Sheldon Bailey | cd0940b | 2022-04-26 14:24:05 -0500 | [diff] [blame] | 976 | } |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 977 | } |
| 978 | |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 979 | // If this object path already has a value, only overwite |
| 980 | // it if the previous one was an NaN or a smaller value. |
| 981 | auto existing = sensorData.find(sensorPath); |
| 982 | if (existing != sensorData.end()) |
| 983 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 984 | // Multiple sensors found for this FRU type |
| 985 | if ((std::isnan(existing->second) && (tempValue == 0)) || |
| 986 | ((existing->second == 0) && std::isnan(tempValue))) |
| 987 | { |
| 988 | // One of the redundant sensors has failed (0xFF/nan), and the |
| 989 | // other sensor has no reading (0), so set the FRU to NaN to |
| 990 | // force fan increase |
| 991 | tempValue = std::numeric_limits<double>::quiet_NaN(); |
| 992 | existing->second = tempValue; |
| 993 | } |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 994 | if (std::isnan(existing->second) || (tempValue > existing->second)) |
| 995 | { |
| 996 | existing->second = tempValue; |
| 997 | } |
| 998 | } |
| 999 | else |
| 1000 | { |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 1001 | // First sensor for this FRU type |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 1002 | sensorData[sensorPath] = tempValue; |
| 1003 | } |
| 1004 | } |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1005 | |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 1006 | // Now publish the values on D-Bus. |
| 1007 | for (const auto& [objectPath, value] : sensorData) |
| 1008 | { |
| 1009 | dbus::OccDBusSensors::getOccDBus().setValue(objectPath, |
| 1010 | value * std::pow(10, -3)); |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1011 | |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 1012 | dbus::OccDBusSensors::getOccDBus().setOperationalStatus( |
| 1013 | objectPath, !std::isnan(value)); |
| 1014 | |
| 1015 | if (existingSensors.find(objectPath) == existingSensors.end()) |
Chris Cain | 6fa848a | 2022-01-24 14:54:38 -0600 | [diff] [blame] | 1016 | { |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1017 | dbus::OccDBusSensors::getOccDBus().setChassisAssociation( |
Matt Spinler | 818cc8d | 2023-10-23 11:43:39 -0500 | [diff] [blame] | 1018 | objectPath); |
Chris Cain | 6fa848a | 2022-01-24 14:54:38 -0600 | [diff] [blame] | 1019 | } |
| 1020 | |
Chris Cain | ae157b6 | 2024-01-23 16:05:12 -0600 | [diff] [blame] | 1021 | existingSensors[objectPath] = occInstance; |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1022 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1023 | } |
| 1024 | |
| 1025 | std::optional<std::string> |
| 1026 | Manager::getPowerLabelFunctionID(const std::string& value) |
| 1027 | { |
| 1028 | // If the value is "system", then the FunctionID is "system". |
| 1029 | if (value == "system") |
| 1030 | { |
| 1031 | return value; |
| 1032 | } |
| 1033 | |
| 1034 | // If the value is not "system", then the label value have 3 numbers, of |
| 1035 | // which we only care about the middle one: |
| 1036 | // <sensor id>_<function id>_<apss channel> |
| 1037 | // eg: The value is "0_10_5" , then the FunctionID is "10". |
| 1038 | if (value.find("_") == std::string::npos) |
| 1039 | { |
| 1040 | return std::nullopt; |
| 1041 | } |
| 1042 | |
| 1043 | auto powerLabelValue = value.substr((value.find("_") + 1)); |
| 1044 | |
| 1045 | if (powerLabelValue.find("_") == std::string::npos) |
| 1046 | { |
| 1047 | return std::nullopt; |
| 1048 | } |
| 1049 | |
| 1050 | return powerLabelValue.substr(0, powerLabelValue.find("_")); |
| 1051 | } |
| 1052 | |
| 1053 | void Manager::readPowerSensors(const fs::path& path, uint32_t id) |
| 1054 | { |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1055 | std::regex expr{"power\\d+_label$"}; // Example: power5_label |
| 1056 | for (auto& file : fs::directory_iterator(path)) |
| 1057 | { |
| 1058 | if (!std::regex_search(file.path().string(), expr)) |
| 1059 | { |
| 1060 | continue; |
| 1061 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1062 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1063 | std::string labelValue; |
| 1064 | try |
| 1065 | { |
| 1066 | labelValue = readFile<std::string>(file.path()); |
| 1067 | } |
| 1068 | catch (const std::system_error& e) |
| 1069 | { |
| 1070 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1071 | std::format("readPowerSensors: Failed reading {}, errno = {}", |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1072 | file.path().string(), e.code().value()) |
| 1073 | .c_str()); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1074 | continue; |
| 1075 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1076 | |
| 1077 | auto functionID = getPowerLabelFunctionID(labelValue); |
| 1078 | if (functionID == std::nullopt) |
| 1079 | { |
| 1080 | continue; |
| 1081 | } |
| 1082 | |
| 1083 | const std::string& tempLabel = "label"; |
| 1084 | const std::string filePathString = file.path().string().substr( |
| 1085 | 0, file.path().string().length() - tempLabel.length()); |
| 1086 | |
| 1087 | std::string sensorPath = OCC_SENSORS_ROOT + std::string("/power/"); |
| 1088 | |
| 1089 | auto iter = powerSensorName.find(*functionID); |
| 1090 | if (iter == powerSensorName.end()) |
| 1091 | { |
| 1092 | continue; |
| 1093 | } |
| 1094 | sensorPath.append(iter->second); |
| 1095 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1096 | double tempValue{0}; |
| 1097 | |
| 1098 | try |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1099 | { |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1100 | tempValue = readFile<double>(filePathString + inputSuffix); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1101 | } |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1102 | catch (const std::system_error& e) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1103 | { |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1104 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1105 | std::format("readPowerSensors: Failed reading {}, errno = {}", |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1106 | filePathString + inputSuffix, e.code().value()) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1107 | .c_str()); |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1108 | continue; |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1109 | } |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1110 | |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1111 | dbus::OccDBusSensors::getOccDBus().setUnit( |
Chris Cain | d84a833 | 2022-01-13 08:58:45 -0600 | [diff] [blame] | 1112 | sensorPath, "xyz.openbmc_project.Sensor.Value.Unit.Watts"); |
| 1113 | |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1114 | dbus::OccDBusSensors::getOccDBus().setValue( |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1115 | sensorPath, tempValue * std::pow(10, -3) * std::pow(10, -3)); |
| 1116 | |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1117 | dbus::OccDBusSensors::getOccDBus().setOperationalStatus(sensorPath, |
| 1118 | true); |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1119 | |
Matt Spinler | 5901abd | 2021-09-23 13:50:03 -0500 | [diff] [blame] | 1120 | if (existingSensors.find(sensorPath) == existingSensors.end()) |
| 1121 | { |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1122 | dbus::OccDBusSensors::getOccDBus().setChassisAssociation( |
| 1123 | sensorPath); |
Matt Spinler | 5901abd | 2021-09-23 13:50:03 -0500 | [diff] [blame] | 1124 | } |
| 1125 | |
Matt Spinler | a26f152 | 2021-08-25 15:50:20 -0500 | [diff] [blame] | 1126 | existingSensors[sensorPath] = id; |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1127 | } |
| 1128 | return; |
| 1129 | } |
| 1130 | |
Sheldon Bailey | c8dd459 | 2022-05-12 10:15:14 -0500 | [diff] [blame] | 1131 | void Manager::setSensorValueToNaN(uint32_t id) const |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1132 | { |
| 1133 | for (const auto& [sensorPath, occId] : existingSensors) |
| 1134 | { |
| 1135 | if (occId == id) |
| 1136 | { |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1137 | dbus::OccDBusSensors::getOccDBus().setValue( |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1138 | sensorPath, std::numeric_limits<double>::quiet_NaN()); |
Sheldon Bailey | c8dd459 | 2022-05-12 10:15:14 -0500 | [diff] [blame] | 1139 | |
| 1140 | dbus::OccDBusSensors::getOccDBus().setOperationalStatus(sensorPath, |
| 1141 | true); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | return; |
| 1145 | } |
| 1146 | |
Sheldon Bailey | 373af75 | 2022-02-21 15:14:00 -0600 | [diff] [blame] | 1147 | void Manager::setSensorValueToNonFunctional(uint32_t id) const |
| 1148 | { |
| 1149 | for (const auto& [sensorPath, occId] : existingSensors) |
| 1150 | { |
| 1151 | if (occId == id) |
| 1152 | { |
| 1153 | dbus::OccDBusSensors::getOccDBus().setValue( |
| 1154 | sensorPath, std::numeric_limits<double>::quiet_NaN()); |
| 1155 | |
| 1156 | dbus::OccDBusSensors::getOccDBus().setOperationalStatus(sensorPath, |
| 1157 | false); |
| 1158 | } |
| 1159 | } |
| 1160 | return; |
| 1161 | } |
| 1162 | |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1163 | void Manager::getSensorValues(std::unique_ptr<Status>& occ) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1164 | { |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 1165 | static bool tracedError[8] = {0}; |
| 1166 | const fs::path sensorPath = occ->getHwmonPath(); |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1167 | const uint32_t id = occ->getOccInstanceID(); |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1168 | |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 1169 | if (fs::exists(sensorPath)) |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1170 | { |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 1171 | // Read temperature sensors |
| 1172 | readTempSensors(sensorPath, id); |
| 1173 | |
| 1174 | if (occ->isMasterOcc()) |
| 1175 | { |
| 1176 | // Read power sensors |
| 1177 | readPowerSensors(sensorPath, id); |
| 1178 | } |
| 1179 | tracedError[id] = false; |
| 1180 | } |
| 1181 | else |
| 1182 | { |
| 1183 | if (!tracedError[id]) |
| 1184 | { |
| 1185 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1186 | std::format( |
Chris Cain | e2d0a43 | 2022-03-28 11:08:49 -0500 | [diff] [blame] | 1187 | "Manager::getSensorValues: OCC{} sensor path missing: {}", |
| 1188 | id, sensorPath.c_str()) |
| 1189 | .c_str()); |
| 1190 | tracedError[id] = true; |
| 1191 | } |
Chicago Duan | bb895cb | 2021-06-18 19:37:16 +0800 | [diff] [blame] | 1192 | } |
| 1193 | |
| 1194 | return; |
| 1195 | } |
| 1196 | #endif |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1197 | |
| 1198 | // Read the altitude from DBus |
| 1199 | void Manager::readAltitude() |
| 1200 | { |
| 1201 | static bool traceAltitudeErr = true; |
| 1202 | |
| 1203 | utils::PropertyValue altitudeProperty{}; |
| 1204 | try |
| 1205 | { |
| 1206 | altitudeProperty = utils::getProperty(ALTITUDE_PATH, ALTITUDE_INTERFACE, |
| 1207 | ALTITUDE_PROP); |
| 1208 | auto sensorVal = std::get<double>(altitudeProperty); |
| 1209 | if (sensorVal < 0xFFFF) |
| 1210 | { |
| 1211 | if (sensorVal < 0) |
| 1212 | { |
| 1213 | altitude = 0; |
| 1214 | } |
| 1215 | else |
| 1216 | { |
| 1217 | // Round to nearest meter |
| 1218 | altitude = uint16_t(sensorVal + 0.5); |
| 1219 | } |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1220 | log<level::DEBUG>(std::format("readAltitude: sensor={} ({}m)", |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1221 | sensorVal, altitude) |
| 1222 | .c_str()); |
| 1223 | traceAltitudeErr = true; |
| 1224 | } |
| 1225 | else |
| 1226 | { |
| 1227 | if (traceAltitudeErr) |
| 1228 | { |
| 1229 | traceAltitudeErr = false; |
| 1230 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1231 | std::format("Invalid altitude value: {}", sensorVal) |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1232 | .c_str()); |
| 1233 | } |
| 1234 | } |
| 1235 | } |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 1236 | catch (const sdbusplus::exception_t& e) |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1237 | { |
| 1238 | if (traceAltitudeErr) |
| 1239 | { |
| 1240 | traceAltitudeErr = false; |
| 1241 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1242 | std::format("Unable to read Altitude: {}", e.what()).c_str()); |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1243 | } |
| 1244 | altitude = 0xFFFF; // not available |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | // Callback function when ambient temperature changes |
Patrick Williams | af40808 | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 1249 | void Manager::ambientCallback(sdbusplus::message_t& msg) |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1250 | { |
| 1251 | double currentTemp = 0; |
| 1252 | uint8_t truncatedTemp = 0xFF; |
| 1253 | std::string msgSensor; |
| 1254 | std::map<std::string, std::variant<double>> msgData; |
| 1255 | msg.read(msgSensor, msgData); |
| 1256 | |
| 1257 | auto valPropMap = msgData.find(AMBIENT_PROP); |
| 1258 | if (valPropMap == msgData.end()) |
| 1259 | { |
| 1260 | log<level::DEBUG>("ambientCallback: Unknown ambient property changed"); |
| 1261 | return; |
| 1262 | } |
| 1263 | currentTemp = std::get<double>(valPropMap->second); |
| 1264 | if (std::isnan(currentTemp)) |
| 1265 | { |
| 1266 | truncatedTemp = 0xFF; |
| 1267 | } |
| 1268 | else |
| 1269 | { |
| 1270 | if (currentTemp < 0) |
| 1271 | { |
| 1272 | truncatedTemp = 0; |
| 1273 | } |
| 1274 | else |
| 1275 | { |
| 1276 | // Round to nearest degree C |
| 1277 | truncatedTemp = uint8_t(currentTemp + 0.5); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | // If ambient changes, notify OCCs |
| 1282 | if (truncatedTemp != ambient) |
| 1283 | { |
| 1284 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1285 | std::format("ambientCallback: Ambient change from {} to {}C", |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1286 | ambient, currentTemp) |
| 1287 | .c_str()); |
| 1288 | |
| 1289 | ambient = truncatedTemp; |
| 1290 | if (altitude == 0xFFFF) |
| 1291 | { |
| 1292 | // No altitude yet, try reading again |
| 1293 | readAltitude(); |
| 1294 | } |
| 1295 | |
| 1296 | log<level::DEBUG>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1297 | std::format("ambientCallback: Ambient: {}C, altitude: {}m", ambient, |
Chris Cain | 1725767 | 2021-10-22 13:41:03 -0500 | [diff] [blame] | 1298 | altitude) |
| 1299 | .c_str()); |
| 1300 | #ifdef POWER10 |
| 1301 | // Send ambient and altitude to all OCCs |
| 1302 | for (auto& obj : statusObjects) |
| 1303 | { |
| 1304 | if (obj->occActive()) |
| 1305 | { |
| 1306 | obj->sendAmbient(ambient, altitude); |
| 1307 | } |
| 1308 | } |
| 1309 | #endif // POWER10 |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | // return the current ambient and altitude readings |
| 1314 | void Manager::getAmbientData(bool& ambientValid, uint8_t& ambientTemp, |
| 1315 | uint16_t& altitudeValue) const |
| 1316 | { |
| 1317 | ambientValid = true; |
| 1318 | ambientTemp = ambient; |
| 1319 | altitudeValue = altitude; |
| 1320 | |
| 1321 | if (ambient == 0xFF) |
| 1322 | { |
| 1323 | ambientValid = false; |
| 1324 | } |
| 1325 | } |
| 1326 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1327 | #ifdef POWER10 |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 1328 | // Called when waitForAllOccsTimer expires |
| 1329 | // After the first OCC goes active, this timer will be started (60 seconds) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1330 | void Manager::occsNotAllRunning() |
| 1331 | { |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1332 | if (activeCount != statusObjects.size()) |
| 1333 | { |
| 1334 | // Not all OCCs went active |
| 1335 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1336 | std::format( |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1337 | "occsNotAllRunning: Active OCC count ({}) does not match expected count ({})", |
| 1338 | activeCount, statusObjects.size()) |
| 1339 | .c_str()); |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 1340 | // Procs may be garded, so may be expected |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1341 | } |
| 1342 | |
| 1343 | validateOccMaster(); |
| 1344 | } |
Chris Cain | 755af10 | 2024-02-27 16:09:51 -0600 | [diff] [blame^] | 1345 | |
| 1346 | #ifdef PLDM |
| 1347 | // Called when throttleTraceTimer expires. |
| 1348 | // If this timer expires, that indicates there is still no confirmed OCC status |
| 1349 | // which will trigger pldm traces to be throttled. |
| 1350 | void Manager::throttleTraceExpired() |
| 1351 | { |
| 1352 | // Throttle traces |
| 1353 | pldmHandle->setTraceThrottle(true); |
| 1354 | } |
| 1355 | #endif // PLDM |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1356 | #endif // POWER10 |
| 1357 | |
| 1358 | // Verify single master OCC and start presence monitor |
| 1359 | void Manager::validateOccMaster() |
| 1360 | { |
| 1361 | int masterInstance = -1; |
| 1362 | for (auto& obj : statusObjects) |
| 1363 | { |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1364 | auto instance = obj->getOccInstanceID(); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1365 | #ifdef POWER10 |
| 1366 | if (!obj->occActive()) |
| 1367 | { |
| 1368 | if (utils::isHostRunning()) |
| 1369 | { |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1370 | // Check if sensor was queued while waiting for discovery |
| 1371 | auto match = queuedActiveState.find(instance); |
| 1372 | if (match != queuedActiveState.end()) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1373 | { |
Chris Cain | 7f89e4d | 2022-05-09 13:27:45 -0500 | [diff] [blame] | 1374 | queuedActiveState.erase(match); |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1375 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1376 | std::format( |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1377 | "validateOccMaster: OCC{} is ACTIVE (queued)", |
| 1378 | instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1379 | .c_str()); |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1380 | obj->occActive(true); |
| 1381 | } |
| 1382 | else |
| 1383 | { |
| 1384 | // OCC does not appear to be active yet, check active sensor |
Patrick Williams | fb0a5c3 | 2024-02-28 11:27:00 -0600 | [diff] [blame] | 1385 | #ifdef PLDM |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1386 | pldmHandle->checkActiveSensor(instance); |
Patrick Williams | fb0a5c3 | 2024-02-28 11:27:00 -0600 | [diff] [blame] | 1387 | #endif |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1388 | if (obj->occActive()) |
| 1389 | { |
| 1390 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1391 | std::format( |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1392 | "validateOccMaster: OCC{} is ACTIVE after reading sensor", |
| 1393 | instance) |
| 1394 | .c_str()); |
| 1395 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1396 | } |
| 1397 | } |
| 1398 | else |
| 1399 | { |
| 1400 | log<level::WARNING>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1401 | std::format( |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1402 | "validateOccMaster: HOST is not running (OCC{})", |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1403 | instance) |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1404 | .c_str()); |
| 1405 | return; |
| 1406 | } |
| 1407 | } |
| 1408 | #endif // POWER10 |
| 1409 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1410 | if (obj->isMasterOcc()) |
| 1411 | { |
Chris Cain | 5d66a0a | 2022-02-09 08:52:10 -0600 | [diff] [blame] | 1412 | obj->addPresenceWatchMaster(); |
| 1413 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1414 | if (masterInstance == -1) |
| 1415 | { |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1416 | masterInstance = instance; |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1417 | } |
| 1418 | else |
| 1419 | { |
| 1420 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1421 | std::format( |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1422 | "validateOccMaster: Multiple OCC masters! ({} and {})", |
Chris Cain | bd551de | 2022-04-26 13:41:16 -0500 | [diff] [blame] | 1423 | masterInstance, instance) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1424 | .c_str()); |
| 1425 | // request reset |
Eddie James | 9789e71 | 2022-05-25 15:43:40 -0500 | [diff] [blame] | 1426 | obj->deviceError(Error::Descriptor(PRESENCE_ERROR_PATH)); |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1427 | } |
| 1428 | } |
| 1429 | } |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1430 | |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1431 | if (masterInstance < 0) |
| 1432 | { |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1433 | log<level::ERR>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1434 | std::format("validateOccMaster: Master OCC not found! (of {} OCCs)", |
Chris Cain | bae4d07 | 2022-02-28 09:46:50 -0600 | [diff] [blame] | 1435 | statusObjects.size()) |
| 1436 | .c_str()); |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1437 | // request reset |
Eddie James | 9789e71 | 2022-05-25 15:43:40 -0500 | [diff] [blame] | 1438 | statusObjects.front()->deviceError( |
| 1439 | Error::Descriptor(PRESENCE_ERROR_PATH)); |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1440 | } |
| 1441 | else |
| 1442 | { |
| 1443 | log<level::INFO>( |
Patrick Williams | 4800249 | 2024-02-13 21:43:32 -0600 | [diff] [blame] | 1444 | std::format("validateOccMaster: OCC{} is master of {} OCCs", |
Chris Cain | 36f9cde | 2021-11-22 11:18:21 -0600 | [diff] [blame] | 1445 | masterInstance, activeCount) |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1446 | .c_str()); |
Sheldon Bailey | 31a2f13 | 2022-05-20 11:31:52 -0500 | [diff] [blame] | 1447 | #ifdef POWER10 |
| 1448 | pmode->updateDbusSafeMode(false); |
| 1449 | #endif |
Chris Cain | a7b74dc | 2021-11-10 17:03:43 -0600 | [diff] [blame] | 1450 | } |
| 1451 | } |
| 1452 | |
Chris Cain | 40501a2 | 2022-03-14 17:33:27 -0500 | [diff] [blame] | 1453 | void Manager::updatePcapBounds() const |
| 1454 | { |
| 1455 | if (pcap) |
| 1456 | { |
| 1457 | pcap->updatePcapBounds(); |
| 1458 | } |
| 1459 | } |
| 1460 | |
Vishwanatha Subbanna | dfc7ec7 | 2017-09-07 18:18:01 +0530 | [diff] [blame] | 1461 | } // namespace occ |
| 1462 | } // namespace open_power |