blob: eaa60805bd842c533b2b322bba122028477a2096 [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#include "occ_status.hpp"
Gunnar Mills94df8c92018-09-14 14:50:03 -05002
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +05303#include "occ_sensor.hpp"
Chris Cain78e86012021-03-04 16:15:31 -06004#include "powermode.hpp"
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +05305#include "utils.hpp"
Gunnar Mills94df8c92018-09-14 14:50:03 -05006
Chris Caina8857c52021-01-27 11:53:05 -06007#include <fmt/core.h>
8
Chris Cain78e86012021-03-04 16:15:31 -06009#ifdef POWER10
10#include <com/ibm/Host/Target/server.hpp>
11#endif
Gunnar Mills94df8c92018-09-14 14:50:03 -050012#include <phosphor-logging/log.hpp>
Chris Cain78e86012021-03-04 16:15:31 -060013
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 {
31 // Bind the device
32 device.bind();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053033
Edward A. James9fd2bdc2017-11-08 16:18:57 -060034 // Start watching for errors
35 addErrorWatch();
36
Chris Caina8857c52021-01-27 11:53:05 -060037 // Reset last OCC state
38 lastState = 0;
39
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053040 // Call into Manager to let know that we have bound
Edward A. James9fd2bdc2017-11-08 16:18:57 -060041 if (this->callBack)
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053042 {
43 this->callBack(value);
Edward A. James9fd2bdc2017-11-08 16:18:57 -060044 }
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053045 }
46 else
47 {
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053048 // Call into Manager to let know that we will unbind.
Edward A. James9fd2bdc2017-11-08 16:18:57 -060049 if (this->callBack)
Vishwanatha Subbanna2dc9b1a2017-08-18 18:29:41 +053050 {
51 this->callBack(value);
Edward A. James9fd2bdc2017-11-08 16:18:57 -060052 }
53
54 // Stop watching for errors
55 removeErrorWatch();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053056
57 // Do the unbind.
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053058 device.unBind();
59 }
60 }
Edward A. James5e177972017-10-25 15:50:31 -050061 else if (value && !device.bound())
62 {
63 // Existing error watch is on a dead file descriptor.
Edward A. James9fd2bdc2017-11-08 16:18:57 -060064 removeErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -050065
66 /*
67 * In it's constructor, Status checks Device::bound() to see if OCC is
68 * active or not.
69 * Device::bound() checks for occX-dev0 directory.
70 * We will lose occX-dev0 directories during FSI rescan.
71 * So, if we start this application (and construct Status), and then
72 * later do FSI rescan, we will end up with occActive = true and device
73 * NOT bound. Lets correct that situation here.
74 */
75 device.bind();
76
77 // Add error watch again
Edward A. James9fd2bdc2017-11-08 16:18:57 -060078 addErrorWatch();
Edward A. James5e177972017-10-25 15:50:31 -050079 }
Eddie James6d6d1b32019-04-22 10:45:08 -050080 else if (!value && device.bound())
81 {
82 removeErrorWatch();
83
84 // In the event that the application never receives the active signal
85 // even though the OCC is active (this can occur if the BMC is rebooted
86 // with the host on, since the initial OCC driver probe will discover
87 // the OCCs), this application needs to be able to unbind the device
88 // when we get the OCC inactive signal.
89 device.unBind();
90 }
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053091 return Base::Status::occActive(value);
92}
93
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053094// Callback handler when a device error is reported.
Eddie Jamescbad2192021-10-07 09:39:39 -050095void Status::deviceError()
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053096{
Eddie Jamescbad2192021-10-07 09:39:39 -050097 // This would deem OCC inactive
98 this->occActive(false);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +053099
Eddie Jamescbad2192021-10-07 09:39:39 -0500100 // Reset the OCC
101 this->resetOCC();
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530102}
103
104// Sends message to host control command handler to reset OCC
105void Status::resetOCC()
106{
Chris Caina8857c52021-01-27 11:53:05 -0600107 log<level::INFO>(
108 fmt::format(">>Status::resetOCC() - requesting reset for OCC{}",
109 instance)
110 .c_str());
Tom Joseph00325232020-07-29 17:51:48 +0530111#ifdef PLDM
112 if (resetCallBack)
113 {
114 this->resetCallBack(instance);
115 }
116#else
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530117 constexpr auto CONTROL_HOST_PATH = "/org/open_power/control/host0";
118 constexpr auto CONTROL_HOST_INTF = "org.open_power.Control.Host";
119
120 // This will throw exception on failure
George Liuf3b75142021-06-10 11:22:50 +0800121 auto service = utils::getService(CONTROL_HOST_PATH, CONTROL_HOST_INTF);
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530122
George Liuf3b75142021-06-10 11:22:50 +0800123 auto& bus = utils::getBus();
Gunnar Mills94df8c92018-09-14 14:50:03 -0500124 auto method = bus.new_method_call(service.c_str(), CONTROL_HOST_PATH,
125 CONTROL_HOST_INTF, "Execute");
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530126 // OCC Reset control command
Gunnar Mills94df8c92018-09-14 14:50:03 -0500127 method.append(convertForMessage(Control::Host::Command::OCCReset).c_str());
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530128
129 // OCC Sensor ID for callout reasons
Patrick Williamse0962702020-05-13 17:50:22 -0500130 method.append(std::variant<uint8_t>(std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530131 bus.call_noreply(method);
132 return;
Tom Joseph00325232020-07-29 17:51:48 +0530133#endif
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530134}
135
136// Handler called by Host control command handler to convey the
137// status of the executed command
138void Status::hostControlEvent(sdbusplus::message::message& msg)
139{
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530140 std::string cmdCompleted{};
141 std::string cmdStatus{};
142
143 msg.read(cmdCompleted, cmdStatus);
144
145 log<level::DEBUG>("Host control signal values",
Gunnar Mills94df8c92018-09-14 14:50:03 -0500146 entry("COMMAND=%s", cmdCompleted.c_str()),
147 entry("STATUS=%s", cmdStatus.c_str()));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530148
Gunnar Mills94df8c92018-09-14 14:50:03 -0500149 if (Control::Host::convertResultFromString(cmdStatus) !=
150 Control::Host::Result::Success)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530151 {
Gunnar Mills94df8c92018-09-14 14:50:03 -0500152 if (Control::Host::convertCommandFromString(cmdCompleted) ==
153 Control::Host::Command::OCCReset)
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530154 {
Gunnar Mills85e65202018-04-08 15:01:54 -0500155 // Must be a Timeout. Log an Error trace
Alexander Filippov1d69e192019-03-21 18:12:07 +0300156 log<level::ERR>(
157 "Error resetting the OCC.", entry("PATH=%s", path.c_str()),
158 entry("SENSORID=0x%X", std::get<0>(sensorMap.at(instance))));
Vishwanatha Subbanna30e329a2017-07-24 23:13:14 +0530159 }
160 }
161 return;
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +0530162}
163
Chris Caina8857c52021-01-27 11:53:05 -0600164void Status::readOccState()
165{
166 unsigned int state;
167 const fs::path filename =
168 fs::path(DEV_PATH) /
169 fs::path(sysfsName + "." + std::to_string(instance + 1)) / "occ_state";
170
Chris Caina8857c52021-01-27 11:53:05 -0600171 std::ifstream file(filename, std::ios::in);
172 const int open_errno = errno;
173 if (file)
174 {
175 file >> state;
176 if (state != lastState)
177 {
178 // Trace OCC state changes
179 log<level::INFO>(
180 fmt::format("Status::readOccState: OCC{} state 0x{:02X}",
181 instance, state)
182 .c_str());
183 lastState = state;
Chris Cain78e86012021-03-04 16:15:31 -0600184
185#ifdef POWER10
186 if ((OccState(state) == OccState::ACTIVE) && (device.master()))
187 {
188 // Kernel detected that the master OCC went to active state
189 occsWentActive();
190 }
191#endif
Chris Caina8857c52021-01-27 11:53:05 -0600192 }
193 file.close();
194 }
195 else
196 {
197 // If not able to read, OCC may be offline
198 log<level::DEBUG>(
199 fmt::format("Status::readOccState: open failed (errno={})",
200 open_errno)
201 .c_str());
202 lastState = 0;
203 }
204}
205
Chris Cain78e86012021-03-04 16:15:31 -0600206#ifdef POWER10
207// Check if Hypervisor target is PowerVM
208bool Status::isPowerVM()
209{
210 using namespace open_power::occ::powermode;
211 namespace Hyper = sdbusplus::com::ibm::Host::server;
212 constexpr auto HYPE_PATH = "/com/ibm/host0/hypervisor";
213 constexpr auto HYPE_INTERFACE = "com.ibm.Host.Target";
214 constexpr auto HYPE_PROP = "Target";
215
216 bool powerVmTarget = false;
217
218 // This will throw exception on failure
219 auto& bus = utils::getBus();
220 auto service = utils::getService(HYPE_PATH, HYPE_INTERFACE);
221 auto method = bus.new_method_call(service.c_str(), HYPE_PATH,
222 "org.freedesktop.DBus.Properties", "Get");
223 method.append(HYPE_INTERFACE, HYPE_PROP);
224 auto reply = bus.call(method);
225
226 std::variant<std::string> hyperEntryValue;
227 reply.read(hyperEntryValue);
228 auto propVal = std::get<std::string>(hyperEntryValue);
229 if (Hyper::Target::convertHypervisorFromString(propVal) ==
230 Hyper::Target::Hypervisor::PowerVM)
231 {
232 powerVmTarget = true;
233 }
234
235 log<level::DEBUG>(
236 fmt::format("Status::isPowerVM returning {}", powerVmTarget).c_str());
237
238 return powerVmTarget;
239}
240
241// Get the requested power mode
242SysPwrMode Status::getMode()
243{
244 using namespace open_power::occ::powermode;
245 SysPwrMode pmode = SysPwrMode::NO_CHANGE;
246
247 // This will throw exception on failure
248 auto& bus = utils::getBus();
249 auto service = utils::getService(PMODE_PATH, PMODE_INTERFACE);
250 auto method = bus.new_method_call(service.c_str(), PMODE_PATH,
251 "org.freedesktop.DBus.Properties", "Get");
252 method.append(PMODE_INTERFACE, POWER_MODE_PROP);
253 auto reply = bus.call(method);
254
255 std::variant<std::string> stateEntryValue;
256 reply.read(stateEntryValue);
257 auto propVal = std::get<std::string>(stateEntryValue);
258 pmode = powermode::convertStringToMode(propVal);
259
260 log<level::DEBUG>(
261 fmt::format("Status::getMode returning {}", pmode).c_str());
262
263 return pmode;
264}
265
Chris Cain1d51da22021-09-21 14:13:41 -0500266// Get the requested power mode
267bool Status::getIPSParms(uint8_t& enterUtil, uint16_t& enterTime,
268 uint8_t& exitUtil, uint16_t& exitTime)
269{
270 using namespace open_power::occ::powermode;
271 // Defaults:
272 bool ipsEnabled = false; // Disabled
273 enterUtil = 8; // Enter Utilization (8%)
274 enterTime = 240; // Enter Delay Time (240s)
275 exitUtil = 12; // Exit Utilization (12%)
276 exitTime = 10; // Exit Delay Time (10s)
277
278 std::map<std::string, std::variant<bool, uint8_t, uint64_t>>
279 ipsProperties{};
280
281 // Get all IPS properties from DBus
282 try
283 {
284 auto& bus = utils::getBus();
285 auto service = utils::getService(PIPS_PATH, PIPS_INTERFACE);
286 auto method =
287 bus.new_method_call(service.c_str(), PIPS_PATH,
288 "org.freedesktop.DBus.Properties", "GetAll");
289 method.append(PIPS_INTERFACE);
290 auto reply = bus.call(method);
291 reply.read(ipsProperties);
292 }
293 catch (const sdbusplus::exception::exception& e)
294 {
295 log<level::ERR>(
296 fmt::format(
297 "Unable to read Idle Power Saver parameters so it will be disabled: {}",
298 e.what())
299 .c_str());
300 return ipsEnabled;
301 }
302
303 auto ipsEntry = ipsProperties.find(IPS_ENABLED_PROP);
304 if (ipsEntry != ipsProperties.end())
305 {
306 ipsEnabled = std::get<bool>(ipsEntry->second);
307 }
308 else
309 {
310 log<level::ERR>(
311 fmt::format("Status::getIPSParms could not find property: {}",
312 IPS_ENABLED_PROP)
313 .c_str());
314 }
315
316 ipsEntry = ipsProperties.find(IPS_ENTER_UTIL);
317 if (ipsEntry != ipsProperties.end())
318 {
319 enterUtil = std::get<uint8_t>(ipsEntry->second);
320 }
321 else
322 {
323 log<level::ERR>(
324 fmt::format("Status::getIPSParms could not find property: {}",
325 IPS_ENTER_UTIL)
326 .c_str());
327 }
328
329 ipsEntry = ipsProperties.find(IPS_ENTER_TIME);
330 if (ipsEntry != ipsProperties.end())
331 {
332 std::chrono::milliseconds ms(std::get<uint64_t>(ipsEntry->second));
333 enterTime =
334 std::chrono::duration_cast<std::chrono::seconds>(ms).count();
335 }
336 else
337 {
338 log<level::ERR>(
339 fmt::format("Status::getIPSParms could not find property: {}",
340 IPS_ENTER_TIME)
341 .c_str());
342 }
343
344 ipsEntry = ipsProperties.find(IPS_EXIT_UTIL);
345 if (ipsEntry != ipsProperties.end())
346 {
347 exitUtil = std::get<uint8_t>(ipsEntry->second);
348 }
349 else
350 {
351 log<level::ERR>(
352 fmt::format("Status::getIPSParms could not find property: {}",
353 IPS_EXIT_UTIL)
354 .c_str());
355 }
356
357 ipsEntry = ipsProperties.find(IPS_EXIT_TIME);
358 if (ipsEntry != ipsProperties.end())
359 {
360 std::chrono::milliseconds ms(std::get<uint64_t>(ipsEntry->second));
361 exitTime = std::chrono::duration_cast<std::chrono::seconds>(ms).count();
362 }
363 else
364 {
365 log<level::ERR>(
366 fmt::format("Status::getIPSParms could not find property: {}",
367 IPS_EXIT_TIME)
368 .c_str());
369 }
370
371 if (enterUtil > exitUtil)
372 {
373 log<level::ERR>(
374 fmt::format(
375 "ERROR: Idle Power Saver Enter Utilization ({}%) is > Exit Utilization ({}%) - using Exit for both",
376 enterUtil, exitUtil)
377 .c_str());
378 enterUtil = exitUtil;
379 }
380
381 return ipsEnabled;
382}
383
Chris Cain78e86012021-03-04 16:15:31 -0600384// Special processing that needs to happen once the OCCs change to ACTIVE state
385void Status::occsWentActive()
386{
387 CmdStatus status = CmdStatus::SUCCESS;
388
389 status = sendModeChange();
390 if (status != CmdStatus::SUCCESS)
391 {
George Liub5ca1012021-09-10 12:53:11 +0800392 log<level::ERR>(
393 fmt::format(
394 "Status::occsWentActive: OCC mode change failed with status {}",
395 status)
396 .c_str());
Chris Cain78e86012021-03-04 16:15:31 -0600397 }
398
399 status = sendIpsData();
400 if (status != CmdStatus::SUCCESS)
401 {
402 log<level::ERR>(
403 fmt::format(
George Liub5ca1012021-09-10 12:53:11 +0800404 "Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
Chris Cain78e86012021-03-04 16:15:31 -0600405 status)
406 .c_str());
407 }
408}
409
410// Send mode change request to the master OCC
411CmdStatus Status::sendModeChange()
412{
413 CmdStatus status = CmdStatus::FAILURE;
414
415 if (!device.master())
416 {
417 log<level::ERR>(
George Liub5ca1012021-09-10 12:53:11 +0800418 fmt::format(
419 "Status::sendModeChange: MODE CHANGE does not get sent to slave OCC{}",
420 instance)
Chris Cain78e86012021-03-04 16:15:31 -0600421 .c_str());
422 return status;
423 }
424 if (!isPowerVM())
425 {
426 // Mode change is only supported on PowerVM systems
George Liub5ca1012021-09-10 12:53:11 +0800427 log<level::DEBUG>(
428 "Status::sendModeChange: MODE CHANGE does not get sent on non-PowerVM systems");
Chris Cain78e86012021-03-04 16:15:31 -0600429 return CmdStatus::SUCCESS;
430 }
431
432 const SysPwrMode newMode = getMode();
433
434 if (VALID_POWER_MODE_SETTING(newMode))
435 {
436 std::vector<std::uint8_t> cmd, rsp;
Chris Cain1d51da22021-09-21 14:13:41 -0500437 cmd.reserve(9);
Chris Cain78e86012021-03-04 16:15:31 -0600438 cmd.push_back(uint8_t(CmdType::SET_MODE_AND_STATE));
439 cmd.push_back(0x00); // Data Length (2 bytes)
440 cmd.push_back(0x06);
441 cmd.push_back(0x30); // Data (Version)
442 cmd.push_back(uint8_t(OccState::NO_CHANGE));
443 cmd.push_back(uint8_t(newMode));
444 cmd.push_back(0x00); // Mode Data (Freq Point)
445 cmd.push_back(0x00); //
446 cmd.push_back(0x00); // reserved
George Liub5ca1012021-09-10 12:53:11 +0800447 log<level::INFO>(
448 fmt::format(
449 "Status::sendModeChange: SET_MODE({}) command to OCC{} ({} bytes)",
450 newMode, instance, cmd.size())
451 .c_str());
Chris Cain78e86012021-03-04 16:15:31 -0600452 status = occCmd.send(cmd, rsp);
453 if (status == CmdStatus::SUCCESS)
454 {
455 if (rsp.size() == 5)
456 {
Chris Cain1d51da22021-09-21 14:13:41 -0500457 if (RspStatus::SUCCESS != RspStatus(rsp[2]))
Chris Cain78e86012021-03-04 16:15:31 -0600458 {
459 log<level::ERR>(
George Liub5ca1012021-09-10 12:53:11 +0800460 fmt::format(
461 "Status::sendModeChange: SET MODE failed with status 0x{:02X}",
462 rsp[2])
Chris Cain78e86012021-03-04 16:15:31 -0600463 .c_str());
Chris Cain1d51da22021-09-21 14:13:41 -0500464 dump_hex(rsp);
465 status = CmdStatus::FAILURE;
Chris Cain78e86012021-03-04 16:15:31 -0600466 }
467 }
468 else
469 {
470 log<level::ERR>(
471 "Status::sendModeChange: INVALID SET MODE response");
472 dump_hex(rsp);
Chris Cain1d51da22021-09-21 14:13:41 -0500473 status = CmdStatus::FAILURE;
Chris Cain78e86012021-03-04 16:15:31 -0600474 }
475 }
476 else
477 {
478 if (status == CmdStatus::OPEN_FAILURE)
479 {
Chris Cain1d51da22021-09-21 14:13:41 -0500480 log<level::INFO>("Status::sendModeChange: OCC not active yet");
481 status = CmdStatus::SUCCESS;
Chris Cain78e86012021-03-04 16:15:31 -0600482 }
483 else
484 {
485 log<level::ERR>("Status::sendModeChange: SET_MODE FAILED!");
486 }
487 }
488 }
489 else
490 {
491 log<level::ERR>(
492 fmt::format(
493 "Status::sendModeChange: Unable to set power mode to {}",
494 newMode)
495 .c_str());
Chris Cain1d51da22021-09-21 14:13:41 -0500496 status = CmdStatus::FAILURE;
Chris Cain78e86012021-03-04 16:15:31 -0600497 }
498
499 return status;
500}
501
502// Send Idle Power Saver config data to the master OCC
503CmdStatus Status::sendIpsData()
504{
505 CmdStatus status = CmdStatus::FAILURE;
506
507 if (!device.master())
508 {
509 log<level::ERR>(
George Liub5ca1012021-09-10 12:53:11 +0800510 fmt::format(
511 "Status::sendIpsData: SET_CFG_DATA[IPS] does not get sent to slave OCC{}",
512 instance)
Chris Cain78e86012021-03-04 16:15:31 -0600513 .c_str());
514 return status;
515 }
516 if (!isPowerVM())
517 {
518 // Idle Power Saver data is only supported on PowerVM systems
George Liub5ca1012021-09-10 12:53:11 +0800519 log<level::DEBUG>(
520 "Status::sendIpsData: SET_CFG_DATA[IPS] does not get sent on non-PowerVM systems");
Chris Cain78e86012021-03-04 16:15:31 -0600521 return CmdStatus::SUCCESS;
522 }
523
Chris Cain1d51da22021-09-21 14:13:41 -0500524 uint8_t enterUtil, exitUtil;
525 uint16_t enterTime, exitTime;
526 const bool ipsEnabled =
527 getIPSParms(enterUtil, enterTime, exitUtil, exitTime);
528
George Liub5ca1012021-09-10 12:53:11 +0800529 log<level::INFO>(
530 fmt::format(
Chris Cain1d51da22021-09-21 14:13:41 -0500531 "Idle Power Saver Parameters: enabled:{}, enter:{}%/{}s, exit:{}%/{}s",
532 ipsEnabled, enterUtil, enterTime, exitUtil, exitTime)
George Liub5ca1012021-09-10 12:53:11 +0800533 .c_str());
Chris Cain1d51da22021-09-21 14:13:41 -0500534
535 std::vector<std::uint8_t> cmd, rsp;
536 cmd.reserve(12);
537 cmd.push_back(uint8_t(CmdType::SET_CONFIG_DATA));
538 cmd.push_back(0x00); // Data Length (2 bytes)
539 cmd.push_back(0x09); //
540 cmd.push_back(0x11); // Config Format: IPS Settings
541 cmd.push_back(0x00); // Version
542 cmd.push_back(ipsEnabled ? 1 : 0); // IPS Enable
543 cmd.push_back(enterTime >> 8); // Enter Delay Time
544 cmd.push_back(enterTime & 0xFF); //
545 cmd.push_back(enterUtil); // Enter Utilization
546 cmd.push_back(exitTime >> 8); // Exit Delay Time
547 cmd.push_back(exitTime & 0xFF); //
548 cmd.push_back(exitUtil); // Exit Utilization
549 log<level::INFO>(fmt::format("Status::sendIpsData: SET_CFG_DATA[IPS] "
550 "command to OCC{} ({} bytes)",
551 instance, cmd.size())
552 .c_str());
Chris Cain78e86012021-03-04 16:15:31 -0600553 status = occCmd.send(cmd, rsp);
554 if (status == CmdStatus::SUCCESS)
555 {
556 if (rsp.size() == 5)
557 {
Chris Cain1d51da22021-09-21 14:13:41 -0500558 if (RspStatus::SUCCESS != RspStatus(rsp[2]))
Chris Cain78e86012021-03-04 16:15:31 -0600559 {
560 log<level::ERR>(
George Liub5ca1012021-09-10 12:53:11 +0800561 fmt::format(
562 "Status::sendIpsData: SET_CFG_DATA[IPS] failed with status 0x{:02X}",
563 rsp[2])
Chris Cain78e86012021-03-04 16:15:31 -0600564 .c_str());
Chris Cain1d51da22021-09-21 14:13:41 -0500565 dump_hex(rsp);
566 status = CmdStatus::FAILURE;
Chris Cain78e86012021-03-04 16:15:31 -0600567 }
568 }
569 else
570 {
571 log<level::ERR>(
572 "Status::sendIpsData: INVALID SET_CFG_DATA[IPS] response");
573 dump_hex(rsp);
Chris Cain1d51da22021-09-21 14:13:41 -0500574 status = CmdStatus::FAILURE;
Chris Cain78e86012021-03-04 16:15:31 -0600575 }
576 }
577 else
578 {
579 if (status == CmdStatus::OPEN_FAILURE)
580 {
Chris Cain1d51da22021-09-21 14:13:41 -0500581 log<level::INFO>("Status::sendIpsData: OCC not active yet");
582 status = CmdStatus::SUCCESS;
Chris Cain78e86012021-03-04 16:15:31 -0600583 }
584 else
585 {
586 log<level::ERR>("Status::sendIpsData: SET_CFG_DATA[IPS] FAILED!");
587 }
588 }
589
590 return status;
591}
592
593#endif // POWER10
594
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +0530595} // namespace occ
596} // namespace open_power