blob: 14981c7cba02b5f8d1a3a374ad26ed63c754c38f [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
Chris Cain78e86012021-03-04 16:15:31 -060010#ifdef POWER10
11#include <com/ibm/Host/Target/server.hpp>
12#endif
Gunnar Mills94df8c92018-09-14 14:50:03 -050013#include <phosphor-logging/log.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060014
Chris Caine2d0a432022-03-28 11:08:49 -050015#include <filesystem>
16
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053017namespace open_power
18{
19namespace occ
20{
Chris Cain78e86012021-03-04 16:15:31 -060021
Chris Caina8857c52021-01-27 11:53:05 -060022using namespace phosphor::logging;
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053023
24// Handles updates to occActive property
25bool Status::occActive(bool value)
26{
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053027 if (value != this->occActive())
28 {
Chris Caina8857c52021-01-27 11:53:05 -060029 log<level::INFO>(fmt::format("Status::occActive OCC{} changed to {}",
30 instance, value)
31 .c_str());
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053032 if (value)
33 {
Eddie Jamesaced3092022-04-22 16:19:30 -050034 // Set the device active
35 device.setActive(true);
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053036
Chris Cain6d8f37a2022-04-29 13:46:01 -050037 // Update the OCC active sensor
38 Base::Status::occActive(value);
39
Edward A. James9fd2bdc2017-11-08 16:18:57 -060040 // Start watching for errors
41 addErrorWatch();
42
Chris Caina8857c52021-01-27 11:53:05 -060043 // Reset last OCC state
44 lastState = 0;
45
Chris Cain5d66a0a2022-02-09 08:52:10 -060046 if (device.master())
47 {
Chris Cain5d66a0a2022-02-09 08:52:10 -060048 // Update powercap bounds from OCC
Chris Cain40501a22022-03-14 17:33:27 -050049 manager.updatePcapBounds();
Chris Cain5d66a0a2022-02-09 08:52:10 -060050 }
51
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053052 // Call into Manager to let know that we have bound
Chris Cain1be43372021-12-09 19:29:37 -060053 if (this->managerCallBack)
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053054 {
Sheldon Bailey373af752022-02-21 15:14:00 -060055 this->managerCallBack(instance, value);
Edward A. James9fd2bdc2017-11-08 16:18:57 -060056 }
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053057 }
58 else
59 {
Chris Caina7b74dc2021-11-10 17:03:43 -060060#ifdef POWER10
Chris Cain1be43372021-12-09 19:29:37 -060061 if (pmode && device.master())
Chris Cain36f9cde2021-11-22 11:18:21 -060062 {
63 // Prevent mode changes
64 pmode->setMasterActive(false);
65 }
Chris Caina7b74dc2021-11-10 17:03:43 -060066 if (safeStateDelayTimer.isEnabled())
67 {
68 // stop safe delay timer
69 safeStateDelayTimer.setEnabled(false);
70 }
71#endif
Chris Cain36f9cde2021-11-22 11:18:21 -060072 // Call into Manager to let know that we will unbind.
Chris Cain1be43372021-12-09 19:29:37 -060073 if (this->managerCallBack)
Chris Cain36f9cde2021-11-22 11:18:21 -060074 {
Sheldon Bailey373af752022-02-21 15:14:00 -060075 this->managerCallBack(instance, value);
Chris Cain36f9cde2021-11-22 11:18:21 -060076 }
77
Edward A. James9fd2bdc2017-11-08 16:18:57 -060078 // Stop watching for errors
79 removeErrorWatch();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053080
Eddie Jamesaced3092022-04-22 16:19:30 -050081 // Set the device inactive
82 device.setActive(false);
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053083 }
84 }
Eddie Jamesaced3092022-04-22 16:19:30 -050085 else if (value && !device.active())
Edward A. James5e177972017-10-25 15:50:31 -050086 {
87 // Existing error watch is on a dead file descriptor.
Edward A. James9fd2bdc2017-11-08 16:18:57 -060088 removeErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -050089
90 /*
91 * In it's constructor, Status checks Device::bound() to see if OCC is
92 * active or not.
93 * Device::bound() checks for occX-dev0 directory.
94 * We will lose occX-dev0 directories during FSI rescan.
95 * So, if we start this application (and construct Status), and then
96 * later do FSI rescan, we will end up with occActive = true and device
97 * NOT bound. Lets correct that situation here.
98 */
Eddie Jamesaced3092022-04-22 16:19:30 -050099 device.setActive(true);
Edward A. James5e177972017-10-25 15:50:31 -0500100
101 // Add error watch again
Edward A. James9fd2bdc2017-11-08 16:18:57 -0600102 addErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -0500103 }
Eddie Jamesaced3092022-04-22 16:19:30 -0500104 else if (!value && device.active())
Eddie James6d6d1b32019-04-22 10:45:08 -0500105 {
106 removeErrorWatch();
107
108 // In the event that the application never receives the active signal
109 // even though the OCC is active (this can occur if the BMC is rebooted
110 // with the host on, since the initial OCC driver probe will discover
111 // the OCCs), this application needs to be able to unbind the device
112 // when we get the OCC inactive signal.
Eddie Jamesaced3092022-04-22 16:19:30 -0500113 device.setActive(false);
Eddie James6d6d1b32019-04-22 10:45:08 -0500114 }
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530115 return Base::Status::occActive(value);
116}
117
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530118// Callback handler when a device error is reported.
Eddie James9789e712022-05-25 15:43:40 -0500119void Status::deviceError(Error::Descriptor d)
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530120{
Chris Cain36f9cde2021-11-22 11:18:21 -0600121#ifdef POWER10
Chris Cain1be43372021-12-09 19:29:37 -0600122 if (pmode && device.master())
123 {
124 // Prevent mode changes
125 pmode->setMasterActive(false);
126 }
Chris Cain36f9cde2021-11-22 11:18:21 -0600127#endif
128
Eddie James9789e712022-05-25 15:43:40 -0500129 if (d.log)
130 {
131 FFDC::createOCCResetPEL(instance, d.path, d.err, d.callout);
132 }
133
Eddie Jamescbad2192021-10-07 09:39:39 -0500134 // This would deem OCC inactive
135 this->occActive(false);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530136
Eddie Jamescbad2192021-10-07 09:39:39 -0500137 // Reset the OCC
138 this->resetOCC();
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530139}
140
141// Sends message to host control command handler to reset OCC
142void Status::resetOCC()
143{
Chris Caina8857c52021-01-27 11:53:05 -0600144 log<level::INFO>(
145 fmt::format(">>Status::resetOCC() - requesting reset for OCC{}",
146 instance)
147 .c_str());
Tom Joseph00325232020-07-29 17:51:48 +0530148#ifdef PLDM
149 if (resetCallBack)
150 {
151 this->resetCallBack(instance);
152 }
153#else
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530154 constexpr auto CONTROL_HOST_PATH = "/org/open_power/control/host0";
155 constexpr auto CONTROL_HOST_INTF = "org.open_power.Control.Host";
156
157 // This will throw exception on failure
George Liuf3b75142021-06-10 11:22:50 +0800158 auto service = utils::getService(CONTROL_HOST_PATH, CONTROL_HOST_INTF);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530159
George Liuf3b75142021-06-10 11:22:50 +0800160 auto& bus = utils::getBus();
Gunnar Mills94df8c92018-09-14 14:50:03 -0500161 auto method = bus.new_method_call(service.c_str(), CONTROL_HOST_PATH,
162 CONTROL_HOST_INTF, "Execute");
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530163 // OCC Reset control command
Gunnar Mills94df8c92018-09-14 14:50:03 -0500164 method.append(convertForMessage(Control::Host::Command::OCCReset).c_str());
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530165
166 // OCC Sensor ID for callout reasons
Patrick Williamse0962702020-05-13 17:50:22 -0500167 method.append(std::variant<uint8_t>(std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530168 bus.call_noreply(method);
169 return;
Tom Joseph00325232020-07-29 17:51:48 +0530170#endif
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530171}
172
173// Handler called by Host control command handler to convey the
174// status of the executed command
175void Status::hostControlEvent(sdbusplus::message::message& msg)
176{
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530177 std::string cmdCompleted{};
178 std::string cmdStatus{};
179
180 msg.read(cmdCompleted, cmdStatus);
181
182 log<level::DEBUG>("Host control signal values",
Gunnar Mills94df8c92018-09-14 14:50:03 -0500183 entry("COMMAND=%s", cmdCompleted.c_str()),
184 entry("STATUS=%s", cmdStatus.c_str()));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530185
Gunnar Mills94df8c92018-09-14 14:50:03 -0500186 if (Control::Host::convertResultFromString(cmdStatus) !=
187 Control::Host::Result::Success)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530188 {
Gunnar Mills94df8c92018-09-14 14:50:03 -0500189 if (Control::Host::convertCommandFromString(cmdCompleted) ==
190 Control::Host::Command::OCCReset)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530191 {
Gunnar Mills85e65202018-04-08 15:01:54 -0500192 // Must be a Timeout. Log an Error trace
Alexander Filippov1d69e192019-03-21 18:12:07 +0300193 log<level::ERR>(
194 "Error resetting the OCC.", entry("PATH=%s", path.c_str()),
195 entry("SENSORID=0x%X", std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530196 }
197 }
198 return;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530199}
200
Sheldon Bailey373af752022-02-21 15:14:00 -0600201// Called from Manager::pollerTimerExpired() in preperation to POLL OCC.
Chris Caina8857c52021-01-27 11:53:05 -0600202void Status::readOccState()
203{
Sheldon Bailey373af752022-02-21 15:14:00 -0600204 currentOccReadRetriesCount = occReadRetries;
205 occReadStateNow();
Chris Caina8857c52021-01-27 11:53:05 -0600206}
207
Chris Cain78e86012021-03-04 16:15:31 -0600208#ifdef POWER10
Chris Cain78e86012021-03-04 16:15:31 -0600209// Special processing that needs to happen once the OCCs change to ACTIVE state
210void Status::occsWentActive()
211{
212 CmdStatus status = CmdStatus::SUCCESS;
213
Chris Cain36f9cde2021-11-22 11:18:21 -0600214 status = pmode->sendModeChange();
Chris Cain78e86012021-03-04 16:15:31 -0600215 if (status != CmdStatus::SUCCESS)
216 {
George Liub5ca1012021-09-10 12:53:11 +0800217 log<level::ERR>(
218 fmt::format(
219 "Status::occsWentActive: OCC mode change failed with status {}",
220 status)
221 .c_str());
Chris Cainc567dc82022-04-01 15:09:17 -0500222
223 // Disable and reset to try recovering
224 deviceError();
Chris Cain78e86012021-03-04 16:15:31 -0600225 }
226
Chris Cain36f9cde2021-11-22 11:18:21 -0600227 status = pmode->sendIpsData();
Chris Cain78e86012021-03-04 16:15:31 -0600228 if (status != CmdStatus::SUCCESS)
229 {
230 log<level::ERR>(
231 fmt::format(
George Liub5ca1012021-09-10 12:53:11 +0800232 "Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
Chris Cain78e86012021-03-04 16:15:31 -0600233 status)
234 .c_str());
Chris Cainc567dc82022-04-01 15:09:17 -0500235
236 if (status == CmdStatus::COMM_FAILURE)
237 {
238 // Disable and reset to try recovering
239 deviceError();
240 }
Chris Cain78e86012021-03-04 16:15:31 -0600241 }
242}
243
Chris Cain17257672021-10-22 13:41:03 -0500244// Send Ambient and Altitude to the OCC
245CmdStatus Status::sendAmbient(const uint8_t inTemp, const uint16_t inAltitude)
246{
247 CmdStatus status = CmdStatus::FAILURE;
248 bool ambientValid = true;
249 uint8_t ambientTemp = inTemp;
250 uint16_t altitude = inAltitude;
251
252 if (ambientTemp == 0xFF)
253 {
254 // Get latest readings from manager
255 manager.getAmbientData(ambientValid, ambientTemp, altitude);
256 log<level::DEBUG>(
257 fmt::format("sendAmbient: valid: {}, Ambient: {}C, altitude: {}m",
258 ambientValid, ambientTemp, altitude)
259 .c_str());
260 }
261
262 std::vector<std::uint8_t> cmd, rsp;
263 cmd.reserve(11);
264 cmd.push_back(uint8_t(CmdType::SEND_AMBIENT));
265 cmd.push_back(0x00); // Data Length (2 bytes)
266 cmd.push_back(0x08); //
267 cmd.push_back(0x00); // Version
268 cmd.push_back(ambientValid ? 0 : 0xFF); // Ambient Status
269 cmd.push_back(ambientTemp); // Ambient Temperature
270 cmd.push_back(altitude >> 8); // Altitude in meters (2 bytes)
271 cmd.push_back(altitude & 0xFF); //
272 cmd.push_back(0x00); // Reserved (3 bytes)
273 cmd.push_back(0x00);
274 cmd.push_back(0x00);
275 log<level::DEBUG>(fmt::format("sendAmbient: SEND_AMBIENT "
276 "command to OCC{} ({} bytes)",
277 instance, cmd.size())
278 .c_str());
279 status = occCmd.send(cmd, rsp);
280 if (status == CmdStatus::SUCCESS)
281 {
282 if (rsp.size() == 5)
283 {
284 if (RspStatus::SUCCESS != RspStatus(rsp[2]))
285 {
286 log<level::ERR>(
287 fmt::format(
Chris Cainc567dc82022-04-01 15:09:17 -0500288 "sendAmbient: SEND_AMBIENT failed with rspStatus 0x{:02X}",
Chris Cain17257672021-10-22 13:41:03 -0500289 rsp[2])
290 .c_str());
291 dump_hex(rsp);
292 status = CmdStatus::FAILURE;
293 }
294 }
295 else
296 {
Chris Cainc567dc82022-04-01 15:09:17 -0500297 log<level::ERR>(
298 fmt::format(
299 "sendAmbient: INVALID SEND_AMBIENT response length:{}",
300 rsp.size())
301 .c_str());
Chris Cain17257672021-10-22 13:41:03 -0500302 dump_hex(rsp);
303 status = CmdStatus::FAILURE;
304 }
305 }
306 else
307 {
Chris Cainc567dc82022-04-01 15:09:17 -0500308 log<level::ERR>(
309 fmt::format(
310 "sendAmbient: SEND_AMBIENT FAILED! with status 0x{:02X}",
311 status)
312 .c_str());
313
314 if (status == CmdStatus::COMM_FAILURE)
Chris Cain17257672021-10-22 13:41:03 -0500315 {
Chris Cainc567dc82022-04-01 15:09:17 -0500316 // Disable and reset to try recovering
317 deviceError();
Chris Cain17257672021-10-22 13:41:03 -0500318 }
319 }
320
321 return status;
322}
Chris Caina7b74dc2021-11-10 17:03:43 -0600323
324// Called when safe timer expires to determine if OCCs need to be reset
325void Status::safeStateDelayExpired()
326{
327 if (this->occActive())
328 {
329 log<level::INFO>(
330 fmt::format(
331 "safeStateDelayExpired: OCC{} is in SAFE state, requesting reset",
332 instance)
333 .c_str());
334 // Disable and reset to try recovering
Eddie James9789e712022-05-25 15:43:40 -0500335 deviceError(Error::Descriptor(SAFE_ERROR_PATH));
Chris Caina7b74dc2021-11-10 17:03:43 -0600336 }
337}
Chris Cain78e86012021-03-04 16:15:31 -0600338#endif // POWER10
339
Chris Caine2d0a432022-03-28 11:08:49 -0500340fs::path Status::getHwmonPath()
Chris Cain5d66a0a2022-02-09 08:52:10 -0600341{
342 using namespace std::literals::string_literals;
343
Chris Caine2d0a432022-03-28 11:08:49 -0500344 if (!fs::exists(hwmonPath))
345 {
346 static bool tracedFail[8] = {0};
Chris Cain5d66a0a2022-02-09 08:52:10 -0600347
Chris Caine2d0a432022-03-28 11:08:49 -0500348 if (!hwmonPath.empty())
349 {
350 log<level::ERR>(
351 fmt::format("Status::getHwmonPath(): path no longer exists: {}",
352 hwmonPath.c_str())
353 .c_str());
354 hwmonPath.clear();
355 }
356
357 // Build the base HWMON path
358 fs::path prefixPath =
359 fs::path{OCC_HWMON_PATH + "occ-hwmon."s +
360 std::to_string(instance + 1) + "/hwmon/"s};
361
362 // Get the hwmonXX directory name
363 try
364 {
365 // there should only be one directory
366 const int numDirs = std::distance(
367 fs::directory_iterator(prefixPath), fs::directory_iterator{});
368 if (numDirs == 1)
369 {
370 hwmonPath = *fs::directory_iterator(prefixPath);
371 tracedFail[instance] = false;
372 }
373 else
374 {
375 if (!tracedFail[instance])
376 {
377 log<level::ERR>(
378 fmt::format(
379 "Status::getHwmonPath(): Found multiple ({}) hwmon paths!",
380 numDirs)
381 .c_str());
382 tracedFail[instance] = true;
383 }
384 }
385 }
386 catch (const fs::filesystem_error& e)
387 {
388 if (!tracedFail[instance])
389 {
390 log<level::ERR>(
391 fmt::format(
392 "Status::getHwmonPath(): error accessing {}: {}",
393 prefixPath.c_str(), e.what())
394 .c_str());
395 tracedFail[instance] = true;
396 }
397 }
398 }
399
400 return hwmonPath;
Chris Cain5d66a0a2022-02-09 08:52:10 -0600401}
402
Sheldon Bailey373af752022-02-21 15:14:00 -0600403// Called to read state and upon failure to read after occReadStateFailTimer.
404void Status::occReadStateNow()
405{
406 unsigned int state;
407 const fs::path filename =
408 fs::path(DEV_PATH) /
409 fs::path(sysfsName + "." + std::to_string(instance + 1)) / "occ_state";
410
411 std::ifstream file;
412 bool goodFile = false;
413
414 // open file.
415 file.open(filename, std::ios::in);
416 const int openErrno = errno;
417
418 // File is open and state can be used.
419 if (file.is_open() && file.good())
420 {
421 goodFile = true;
422 file >> state;
423
424 if (state != lastState)
425 {
426 // Trace OCC state changes
427 log<level::INFO>(
Chris Cainbd551de2022-04-26 13:41:16 -0500428 fmt::format(
429 "Status::readOccState: OCC{} state 0x{:02X} (lastState: 0x{:02X})",
430 instance, state, lastState)
Sheldon Bailey373af752022-02-21 15:14:00 -0600431 .c_str());
432 lastState = state;
433#ifdef POWER10
434 if (OccState(state) == OccState::ACTIVE)
435 {
436 if (pmode && device.master())
437 {
438 // Set the master OCC on the PowerMode object
439 pmode->setMasterOcc(path);
440 // Enable mode changes
441 pmode->setMasterActive();
442
443 // Special processing by master OCC when it goes active
444 occsWentActive();
445 }
446
447 CmdStatus status = sendAmbient();
448 if (status != CmdStatus::SUCCESS)
449 {
450 log<level::ERR>(
451 fmt::format(
452 "readOccState: Sending Ambient failed with status {}",
453 status)
454 .c_str());
455 }
456 }
457
458 // If OCC in known Good State.
459 if ((OccState(state) == OccState::ACTIVE) ||
460 (OccState(state) == OccState::CHARACTERIZATION) ||
461 (OccState(state) == OccState::OBSERVATION))
462 {
463 // Good OCC State then sensors valid again
464 stateValid = true;
465
466 if (safeStateDelayTimer.isEnabled())
467 {
468 // stop safe delay timer (no longer in SAFE state)
469 safeStateDelayTimer.setEnabled(false);
470 }
471 }
472 // Else not Valid state We would be in SAFE mode.
473 // This captures both SAFE mode, and 0x00, or other invalid
474 // state values.
475 else
476 {
477 if (!safeStateDelayTimer.isEnabled())
478 {
479 // start safe delay timer (before requesting reset)
480 using namespace std::literals::chrono_literals;
481 safeStateDelayTimer.restartOnce(60s);
482 }
483 // Not valid state, update sensors to Nan & not functional.
484 stateValid = false;
485 }
486#else
487 // Before P10 state not checked, only used good file open.
488 stateValid = true;
489#endif
490 }
491 }
492 file.close();
493
494 // if failed to Read a state or not a valid state -> Attempt retry
495 // after 1 Second delay if allowed.
496 if ((!goodFile) || (!stateValid))
497 {
498 if (!goodFile)
499 {
500 // If not able to read, OCC may be offline
501 log<level::ERR>(
502 fmt::format("Status::readOccState: open failed (errno={})",
503 openErrno)
504 .c_str());
505 }
506 else
507 {
508 // else this failed due to state not valid.
Chris Cainbd551de2022-04-26 13:41:16 -0500509 if (state != lastState)
510 {
511 log<level::ERR>(
512 fmt::format(
513 "Status::readOccState: OCC{} Invalid state 0x{:02X} (last state: 0x{:02X})",
514 instance, state, lastState)
515 .c_str());
516 }
Sheldon Bailey373af752022-02-21 15:14:00 -0600517 }
518
519#ifdef READ_OCC_SENSORS
Sheldon Baileyc8dd4592022-05-12 10:15:14 -0500520 manager.setSensorValueToNaN(instance);
Sheldon Bailey373af752022-02-21 15:14:00 -0600521#endif
522
523 // See occReadRetries for number of retry attempts.
524 if (currentOccReadRetriesCount > 0)
525 {
526 --currentOccReadRetriesCount;
527#ifdef POWER10
528 using namespace std::chrono_literals;
529 occReadStateFailTimer.restartOnce(1s);
530#endif
531 }
532 else
533 {
Chris Cainbae4d072022-02-28 09:46:50 -0600534#ifdef POWER10
535 if (!stateValid && occActive())
536 {
537 if (!safeStateDelayTimer.isEnabled())
538 {
539 log<level::ERR>(
540 "Starting 60 sec delay timer before requesting a reset");
541 // start safe delay timer (before requesting reset)
542 using namespace std::literals::chrono_literals;
543 safeStateDelayTimer.restartOnce(60s);
544 }
545 }
546#else
Sheldon Bailey373af752022-02-21 15:14:00 -0600547 // State could not be determined, set it to NO State.
548 lastState = 0;
549
550 // Disable the ability to send Failed actions until OCC is
551 // Active again.
552 stateValid = false;
553
554 // Disable and reset to try recovering
555 deviceError();
Chris Cainbae4d072022-02-28 09:46:50 -0600556#endif
Sheldon Bailey373af752022-02-21 15:14:00 -0600557 }
558 }
559}
560
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530561} // namespace occ
562} // namespace open_power