blob: 85b70ee2e92b3f2c0372f3f1542e114274ac38f2 [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#include "occ_status.hpp"
Gunnar Mills94df8c92018-09-14 14:50:03 -05002
Chris Cain17257672021-10-22 13:41:03 -05003#include "occ_manager.hpp"
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +05304#include "occ_sensor.hpp"
Chris Cain78e86012021-03-04 16:15:31 -06005#include "powermode.hpp"
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +05306#include "utils.hpp"
Gunnar Mills94df8c92018-09-14 14:50:03 -05007
Chris Caina8857c52021-01-27 11:53:05 -06008#include <fmt/core.h>
9
Gunnar Mills94df8c92018-09-14 14:50:03 -050010#include <phosphor-logging/log.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060011
Chris Caine2d0a432022-03-28 11:08:49 -050012#include <filesystem>
13
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053014namespace open_power
15{
16namespace occ
17{
Chris Cain78e86012021-03-04 16:15:31 -060018
Chris Caina8857c52021-01-27 11:53:05 -060019using namespace phosphor::logging;
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053020
21// Handles updates to occActive property
22bool Status::occActive(bool value)
23{
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053024 if (value != this->occActive())
25 {
Chris Caina8857c52021-01-27 11:53:05 -060026 log<level::INFO>(fmt::format("Status::occActive OCC{} changed to {}",
27 instance, value)
28 .c_str());
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053029 if (value)
30 {
Eddie Jamesaced3092022-04-22 16:19:30 -050031 // Set the device active
32 device.setActive(true);
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053033
Chris Cain6d8f37a2022-04-29 13:46:01 -050034 // Update the OCC active sensor
35 Base::Status::occActive(value);
36
Edward A. James9fd2bdc2017-11-08 16:18:57 -060037 // Start watching for errors
38 addErrorWatch();
39
Chris Caina8857c52021-01-27 11:53:05 -060040 // Reset last OCC state
41 lastState = 0;
42
Chris Cain5d66a0a2022-02-09 08:52:10 -060043 if (device.master())
44 {
Chris Cain5d66a0a2022-02-09 08:52:10 -060045 // Update powercap bounds from OCC
Chris Cain40501a22022-03-14 17:33:27 -050046 manager.updatePcapBounds();
Chris Cain5d66a0a2022-02-09 08:52:10 -060047 }
48
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053049 // Call into Manager to let know that we have bound
Chris Cain1be43372021-12-09 19:29:37 -060050 if (this->managerCallBack)
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053051 {
Sheldon Bailey373af752022-02-21 15:14:00 -060052 this->managerCallBack(instance, value);
Edward A. James9fd2bdc2017-11-08 16:18:57 -060053 }
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053054 }
55 else
56 {
Chris Caina7b74dc2021-11-10 17:03:43 -060057#ifdef POWER10
Chris Cain1be43372021-12-09 19:29:37 -060058 if (pmode && device.master())
Chris Cain36f9cde2021-11-22 11:18:21 -060059 {
60 // Prevent mode changes
61 pmode->setMasterActive(false);
62 }
Chris Caina7b74dc2021-11-10 17:03:43 -060063 if (safeStateDelayTimer.isEnabled())
64 {
65 // stop safe delay timer
66 safeStateDelayTimer.setEnabled(false);
67 }
68#endif
Chris Cain36f9cde2021-11-22 11:18:21 -060069 // Call into Manager to let know that we will unbind.
Chris Cain1be43372021-12-09 19:29:37 -060070 if (this->managerCallBack)
Chris Cain36f9cde2021-11-22 11:18:21 -060071 {
Sheldon Bailey373af752022-02-21 15:14:00 -060072 this->managerCallBack(instance, value);
Chris Cain36f9cde2021-11-22 11:18:21 -060073 }
74
Edward A. James9fd2bdc2017-11-08 16:18:57 -060075 // Stop watching for errors
76 removeErrorWatch();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053077
Eddie Jamesaced3092022-04-22 16:19:30 -050078 // Set the device inactive
79 device.setActive(false);
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053080 }
81 }
Eddie Jamesaced3092022-04-22 16:19:30 -050082 else if (value && !device.active())
Edward A. James5e177972017-10-25 15:50:31 -050083 {
84 // Existing error watch is on a dead file descriptor.
Edward A. James9fd2bdc2017-11-08 16:18:57 -060085 removeErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -050086
87 /*
88 * In it's constructor, Status checks Device::bound() to see if OCC is
89 * active or not.
90 * Device::bound() checks for occX-dev0 directory.
91 * We will lose occX-dev0 directories during FSI rescan.
92 * So, if we start this application (and construct Status), and then
93 * later do FSI rescan, we will end up with occActive = true and device
94 * NOT bound. Lets correct that situation here.
95 */
Eddie Jamesaced3092022-04-22 16:19:30 -050096 device.setActive(true);
Edward A. James5e177972017-10-25 15:50:31 -050097
98 // Add error watch again
Edward A. James9fd2bdc2017-11-08 16:18:57 -060099 addErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -0500100 }
Eddie Jamesaced3092022-04-22 16:19:30 -0500101 else if (!value && device.active())
Eddie James6d6d1b32019-04-22 10:45:08 -0500102 {
103 removeErrorWatch();
104
105 // In the event that the application never receives the active signal
106 // even though the OCC is active (this can occur if the BMC is rebooted
107 // with the host on, since the initial OCC driver probe will discover
108 // the OCCs), this application needs to be able to unbind the device
109 // when we get the OCC inactive signal.
Eddie Jamesaced3092022-04-22 16:19:30 -0500110 device.setActive(false);
Eddie James6d6d1b32019-04-22 10:45:08 -0500111 }
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530112 return Base::Status::occActive(value);
113}
114
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530115// Callback handler when a device error is reported.
Eddie James9789e712022-05-25 15:43:40 -0500116void Status::deviceError(Error::Descriptor d)
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530117{
Chris Cain36f9cde2021-11-22 11:18:21 -0600118#ifdef POWER10
Chris Cain1be43372021-12-09 19:29:37 -0600119 if (pmode && device.master())
120 {
121 // Prevent mode changes
122 pmode->setMasterActive(false);
123 }
Chris Cain36f9cde2021-11-22 11:18:21 -0600124#endif
125
Eddie James9789e712022-05-25 15:43:40 -0500126 if (d.log)
127 {
128 FFDC::createOCCResetPEL(instance, d.path, d.err, d.callout);
129 }
130
Eddie Jamescbad2192021-10-07 09:39:39 -0500131 // This would deem OCC inactive
132 this->occActive(false);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530133
Eddie Jamescbad2192021-10-07 09:39:39 -0500134 // Reset the OCC
135 this->resetOCC();
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530136}
137
138// Sends message to host control command handler to reset OCC
139void Status::resetOCC()
140{
Chris Caina8857c52021-01-27 11:53:05 -0600141 log<level::INFO>(
142 fmt::format(">>Status::resetOCC() - requesting reset for OCC{}",
143 instance)
144 .c_str());
Tom Joseph00325232020-07-29 17:51:48 +0530145#ifdef PLDM
146 if (resetCallBack)
147 {
148 this->resetCallBack(instance);
149 }
150#else
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530151 constexpr auto CONTROL_HOST_PATH = "/org/open_power/control/host0";
152 constexpr auto CONTROL_HOST_INTF = "org.open_power.Control.Host";
153
154 // This will throw exception on failure
George Liuf3b75142021-06-10 11:22:50 +0800155 auto service = utils::getService(CONTROL_HOST_PATH, CONTROL_HOST_INTF);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530156
George Liuf3b75142021-06-10 11:22:50 +0800157 auto& bus = utils::getBus();
Gunnar Mills94df8c92018-09-14 14:50:03 -0500158 auto method = bus.new_method_call(service.c_str(), CONTROL_HOST_PATH,
159 CONTROL_HOST_INTF, "Execute");
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530160 // OCC Reset control command
Gunnar Mills94df8c92018-09-14 14:50:03 -0500161 method.append(convertForMessage(Control::Host::Command::OCCReset).c_str());
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530162
163 // OCC Sensor ID for callout reasons
Patrick Williamse0962702020-05-13 17:50:22 -0500164 method.append(std::variant<uint8_t>(std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530165 bus.call_noreply(method);
166 return;
Tom Joseph00325232020-07-29 17:51:48 +0530167#endif
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530168}
169
170// Handler called by Host control command handler to convey the
171// status of the executed command
Patrick Williamsaf408082022-07-22 19:26:54 -0500172void Status::hostControlEvent(sdbusplus::message_t& msg)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530173{
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530174 std::string cmdCompleted{};
175 std::string cmdStatus{};
176
177 msg.read(cmdCompleted, cmdStatus);
178
179 log<level::DEBUG>("Host control signal values",
Gunnar Mills94df8c92018-09-14 14:50:03 -0500180 entry("COMMAND=%s", cmdCompleted.c_str()),
181 entry("STATUS=%s", cmdStatus.c_str()));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530182
Gunnar Mills94df8c92018-09-14 14:50:03 -0500183 if (Control::Host::convertResultFromString(cmdStatus) !=
184 Control::Host::Result::Success)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530185 {
Gunnar Mills94df8c92018-09-14 14:50:03 -0500186 if (Control::Host::convertCommandFromString(cmdCompleted) ==
187 Control::Host::Command::OCCReset)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530188 {
Gunnar Mills85e65202018-04-08 15:01:54 -0500189 // Must be a Timeout. Log an Error trace
Alexander Filippov1d69e192019-03-21 18:12:07 +0300190 log<level::ERR>(
191 "Error resetting the OCC.", entry("PATH=%s", path.c_str()),
192 entry("SENSORID=0x%X", std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530193 }
194 }
195 return;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530196}
197
Sheldon Bailey373af752022-02-21 15:14:00 -0600198// Called from Manager::pollerTimerExpired() in preperation to POLL OCC.
Chris Caina8857c52021-01-27 11:53:05 -0600199void Status::readOccState()
200{
Sheldon Bailey373af752022-02-21 15:14:00 -0600201 currentOccReadRetriesCount = occReadRetries;
202 occReadStateNow();
Chris Caina8857c52021-01-27 11:53:05 -0600203}
204
Chris Cain78e86012021-03-04 16:15:31 -0600205#ifdef POWER10
Chris Cain78e86012021-03-04 16:15:31 -0600206// Special processing that needs to happen once the OCCs change to ACTIVE state
207void Status::occsWentActive()
208{
209 CmdStatus status = CmdStatus::SUCCESS;
210
Chris Cain36f9cde2021-11-22 11:18:21 -0600211 status = pmode->sendModeChange();
Chris Cain78e86012021-03-04 16:15:31 -0600212 if (status != CmdStatus::SUCCESS)
213 {
George Liub5ca1012021-09-10 12:53:11 +0800214 log<level::ERR>(
215 fmt::format(
216 "Status::occsWentActive: OCC mode change failed with status {}",
217 status)
218 .c_str());
Chris Cainc567dc82022-04-01 15:09:17 -0500219
220 // Disable and reset to try recovering
221 deviceError();
Chris Cain78e86012021-03-04 16:15:31 -0600222 }
223
Chris Cain36f9cde2021-11-22 11:18:21 -0600224 status = pmode->sendIpsData();
Chris Cain78e86012021-03-04 16:15:31 -0600225 if (status != CmdStatus::SUCCESS)
226 {
227 log<level::ERR>(
228 fmt::format(
George Liub5ca1012021-09-10 12:53:11 +0800229 "Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
Chris Cain78e86012021-03-04 16:15:31 -0600230 status)
231 .c_str());
Chris Cainc567dc82022-04-01 15:09:17 -0500232
233 if (status == CmdStatus::COMM_FAILURE)
234 {
235 // Disable and reset to try recovering
236 deviceError();
237 }
Chris Cain78e86012021-03-04 16:15:31 -0600238 }
239}
240
Chris Cain17257672021-10-22 13:41:03 -0500241// Send Ambient and Altitude to the OCC
242CmdStatus Status::sendAmbient(const uint8_t inTemp, const uint16_t inAltitude)
243{
244 CmdStatus status = CmdStatus::FAILURE;
245 bool ambientValid = true;
246 uint8_t ambientTemp = inTemp;
247 uint16_t altitude = inAltitude;
248
249 if (ambientTemp == 0xFF)
250 {
251 // Get latest readings from manager
252 manager.getAmbientData(ambientValid, ambientTemp, altitude);
253 log<level::DEBUG>(
254 fmt::format("sendAmbient: valid: {}, Ambient: {}C, altitude: {}m",
255 ambientValid, ambientTemp, altitude)
256 .c_str());
257 }
258
259 std::vector<std::uint8_t> cmd, rsp;
260 cmd.reserve(11);
261 cmd.push_back(uint8_t(CmdType::SEND_AMBIENT));
262 cmd.push_back(0x00); // Data Length (2 bytes)
263 cmd.push_back(0x08); //
264 cmd.push_back(0x00); // Version
265 cmd.push_back(ambientValid ? 0 : 0xFF); // Ambient Status
266 cmd.push_back(ambientTemp); // Ambient Temperature
267 cmd.push_back(altitude >> 8); // Altitude in meters (2 bytes)
268 cmd.push_back(altitude & 0xFF); //
269 cmd.push_back(0x00); // Reserved (3 bytes)
270 cmd.push_back(0x00);
271 cmd.push_back(0x00);
272 log<level::DEBUG>(fmt::format("sendAmbient: SEND_AMBIENT "
273 "command to OCC{} ({} bytes)",
274 instance, cmd.size())
275 .c_str());
276 status = occCmd.send(cmd, rsp);
277 if (status == CmdStatus::SUCCESS)
278 {
279 if (rsp.size() == 5)
280 {
281 if (RspStatus::SUCCESS != RspStatus(rsp[2]))
282 {
283 log<level::ERR>(
284 fmt::format(
Chris Cainc567dc82022-04-01 15:09:17 -0500285 "sendAmbient: SEND_AMBIENT failed with rspStatus 0x{:02X}",
Chris Cain17257672021-10-22 13:41:03 -0500286 rsp[2])
287 .c_str());
288 dump_hex(rsp);
289 status = CmdStatus::FAILURE;
290 }
291 }
292 else
293 {
Chris Cainc567dc82022-04-01 15:09:17 -0500294 log<level::ERR>(
295 fmt::format(
296 "sendAmbient: INVALID SEND_AMBIENT response length:{}",
297 rsp.size())
298 .c_str());
Chris Cain17257672021-10-22 13:41:03 -0500299 dump_hex(rsp);
300 status = CmdStatus::FAILURE;
301 }
302 }
303 else
304 {
Chris Cainc567dc82022-04-01 15:09:17 -0500305 log<level::ERR>(
306 fmt::format(
307 "sendAmbient: SEND_AMBIENT FAILED! with status 0x{:02X}",
308 status)
309 .c_str());
310
311 if (status == CmdStatus::COMM_FAILURE)
Chris Cain17257672021-10-22 13:41:03 -0500312 {
Chris Cainc567dc82022-04-01 15:09:17 -0500313 // Disable and reset to try recovering
314 deviceError();
Chris Cain17257672021-10-22 13:41:03 -0500315 }
316 }
317
318 return status;
319}
Chris Caina7b74dc2021-11-10 17:03:43 -0600320
321// Called when safe timer expires to determine if OCCs need to be reset
322void Status::safeStateDelayExpired()
323{
324 if (this->occActive())
325 {
326 log<level::INFO>(
327 fmt::format(
328 "safeStateDelayExpired: OCC{} is in SAFE state, requesting reset",
329 instance)
330 .c_str());
331 // Disable and reset to try recovering
Eddie James9789e712022-05-25 15:43:40 -0500332 deviceError(Error::Descriptor(SAFE_ERROR_PATH));
Chris Caina7b74dc2021-11-10 17:03:43 -0600333 }
334}
Chris Cain78e86012021-03-04 16:15:31 -0600335#endif // POWER10
336
Chris Caine2d0a432022-03-28 11:08:49 -0500337fs::path Status::getHwmonPath()
Chris Cain5d66a0a2022-02-09 08:52:10 -0600338{
339 using namespace std::literals::string_literals;
340
Chris Caine2d0a432022-03-28 11:08:49 -0500341 if (!fs::exists(hwmonPath))
342 {
343 static bool tracedFail[8] = {0};
Chris Cain5d66a0a2022-02-09 08:52:10 -0600344
Chris Caine2d0a432022-03-28 11:08:49 -0500345 if (!hwmonPath.empty())
346 {
347 log<level::ERR>(
348 fmt::format("Status::getHwmonPath(): path no longer exists: {}",
349 hwmonPath.c_str())
350 .c_str());
351 hwmonPath.clear();
352 }
353
354 // Build the base HWMON path
Patrick Williamsa49c9872023-05-10 07:50:35 -0500355 fs::path prefixPath = fs::path{OCC_HWMON_PATH + "occ-hwmon."s +
356 std::to_string(instance + 1) +
357 "/hwmon/"s};
Chris Caine2d0a432022-03-28 11:08:49 -0500358
359 // Get the hwmonXX directory name
360 try
361 {
362 // there should only be one directory
363 const int numDirs = std::distance(
364 fs::directory_iterator(prefixPath), fs::directory_iterator{});
365 if (numDirs == 1)
366 {
367 hwmonPath = *fs::directory_iterator(prefixPath);
368 tracedFail[instance] = false;
369 }
370 else
371 {
372 if (!tracedFail[instance])
373 {
374 log<level::ERR>(
375 fmt::format(
376 "Status::getHwmonPath(): Found multiple ({}) hwmon paths!",
377 numDirs)
378 .c_str());
379 tracedFail[instance] = true;
380 }
381 }
382 }
383 catch (const fs::filesystem_error& e)
384 {
385 if (!tracedFail[instance])
386 {
387 log<level::ERR>(
388 fmt::format(
389 "Status::getHwmonPath(): error accessing {}: {}",
390 prefixPath.c_str(), e.what())
391 .c_str());
392 tracedFail[instance] = true;
393 }
394 }
395 }
396
397 return hwmonPath;
Chris Cain5d66a0a2022-02-09 08:52:10 -0600398}
399
Sheldon Bailey373af752022-02-21 15:14:00 -0600400// Called to read state and upon failure to read after occReadStateFailTimer.
401void Status::occReadStateNow()
402{
403 unsigned int state;
404 const fs::path filename =
405 fs::path(DEV_PATH) /
406 fs::path(sysfsName + "." + std::to_string(instance + 1)) / "occ_state";
407
408 std::ifstream file;
409 bool goodFile = false;
410
411 // open file.
412 file.open(filename, std::ios::in);
413 const int openErrno = errno;
414
415 // File is open and state can be used.
416 if (file.is_open() && file.good())
417 {
418 goodFile = true;
419 file >> state;
420
421 if (state != lastState)
422 {
423 // Trace OCC state changes
424 log<level::INFO>(
Chris Cainbd551de2022-04-26 13:41:16 -0500425 fmt::format(
426 "Status::readOccState: OCC{} state 0x{:02X} (lastState: 0x{:02X})",
427 instance, state, lastState)
Sheldon Bailey373af752022-02-21 15:14:00 -0600428 .c_str());
429 lastState = state;
430#ifdef POWER10
431 if (OccState(state) == OccState::ACTIVE)
432 {
433 if (pmode && device.master())
434 {
435 // Set the master OCC on the PowerMode object
436 pmode->setMasterOcc(path);
437 // Enable mode changes
438 pmode->setMasterActive();
439
440 // Special processing by master OCC when it goes active
441 occsWentActive();
442 }
443
444 CmdStatus status = sendAmbient();
445 if (status != CmdStatus::SUCCESS)
446 {
447 log<level::ERR>(
448 fmt::format(
449 "readOccState: Sending Ambient failed with status {}",
450 status)
451 .c_str());
452 }
453 }
454
455 // If OCC in known Good State.
456 if ((OccState(state) == OccState::ACTIVE) ||
457 (OccState(state) == OccState::CHARACTERIZATION) ||
458 (OccState(state) == OccState::OBSERVATION))
459 {
460 // Good OCC State then sensors valid again
461 stateValid = true;
462
463 if (safeStateDelayTimer.isEnabled())
464 {
465 // stop safe delay timer (no longer in SAFE state)
466 safeStateDelayTimer.setEnabled(false);
467 }
468 }
469 // Else not Valid state We would be in SAFE mode.
470 // This captures both SAFE mode, and 0x00, or other invalid
471 // state values.
472 else
473 {
474 if (!safeStateDelayTimer.isEnabled())
475 {
476 // start safe delay timer (before requesting reset)
477 using namespace std::literals::chrono_literals;
478 safeStateDelayTimer.restartOnce(60s);
479 }
480 // Not valid state, update sensors to Nan & not functional.
481 stateValid = false;
482 }
483#else
484 // Before P10 state not checked, only used good file open.
485 stateValid = true;
486#endif
487 }
488 }
489 file.close();
490
491 // if failed to Read a state or not a valid state -> Attempt retry
492 // after 1 Second delay if allowed.
493 if ((!goodFile) || (!stateValid))
494 {
495 if (!goodFile)
496 {
497 // If not able to read, OCC may be offline
498 log<level::ERR>(
499 fmt::format("Status::readOccState: open failed (errno={})",
500 openErrno)
501 .c_str());
502 }
503 else
504 {
505 // else this failed due to state not valid.
Chris Cainbd551de2022-04-26 13:41:16 -0500506 if (state != lastState)
507 {
508 log<level::ERR>(
509 fmt::format(
510 "Status::readOccState: OCC{} Invalid state 0x{:02X} (last state: 0x{:02X})",
511 instance, state, lastState)
512 .c_str());
513 }
Sheldon Bailey373af752022-02-21 15:14:00 -0600514 }
515
516#ifdef READ_OCC_SENSORS
Sheldon Baileyc8dd4592022-05-12 10:15:14 -0500517 manager.setSensorValueToNaN(instance);
Sheldon Bailey373af752022-02-21 15:14:00 -0600518#endif
519
520 // See occReadRetries for number of retry attempts.
521 if (currentOccReadRetriesCount > 0)
522 {
523 --currentOccReadRetriesCount;
524#ifdef POWER10
525 using namespace std::chrono_literals;
526 occReadStateFailTimer.restartOnce(1s);
527#endif
528 }
529 else
530 {
Chris Cainbae4d072022-02-28 09:46:50 -0600531#ifdef POWER10
532 if (!stateValid && occActive())
533 {
534 if (!safeStateDelayTimer.isEnabled())
535 {
536 log<level::ERR>(
537 "Starting 60 sec delay timer before requesting a reset");
538 // start safe delay timer (before requesting reset)
539 using namespace std::literals::chrono_literals;
540 safeStateDelayTimer.restartOnce(60s);
541 }
542 }
543#else
Sheldon Bailey373af752022-02-21 15:14:00 -0600544 // State could not be determined, set it to NO State.
545 lastState = 0;
546
547 // Disable the ability to send Failed actions until OCC is
548 // Active again.
549 stateValid = false;
550
551 // Disable and reset to try recovering
552 deviceError();
Chris Cainbae4d072022-02-28 09:46:50 -0600553#endif
Sheldon Bailey373af752022-02-21 15:14:00 -0600554 }
555 }
556}
557
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530558} // namespace occ
559} // namespace open_power