blob: 47e4437fa5eb436ba65bece9f7b0bf14faefb10d [file] [log] [blame]
#include <config.h>
#include <host-interface.hpp>
#include <ipmid-host/cmd-utils.hpp>
#include <ipmid-host/cmd.hpp>
#include <oemhandler.hpp>
#include <phosphor-logging/log.hpp>
#include <chrono>
#include <functional>
namespace open_power
{
namespace host
{
namespace command
{
// IPMI command
// https://github.com/openbmc/openbmc/issues/2082 for handling
// Non-OEM commands that need to send SMS_ATN
using OEMCmd = uint8_t;
// Map of IPMI OEM command to its equivalent interface command.
// This is needed when invoking the callback handler to indicate
// the status of the executed command.
static const std::map<OEMCmd, Host::Command> intfCommand = {
{IPMI_CMD_OCC_RESET, Base::Host::Command::OCCReset}};
// Called at user request
void Host::execute(Base::Host::Command command, std::variant<uint8_t> data)
{
using namespace phosphor::logging;
log<level::INFO>(
"Pushing cmd on to queue",
entry("CONTROL_HOST_CMD=%s", convertForMessage(command).c_str()));
// If the command is OCCReset, then all we need is just sensor ID
// This is the only command that is being used now.
if (command == Base::Host::Command::OCCReset)
{
auto sensorID = std::get<uint8_t>(data);
auto cmd = std::make_tuple(std::make_pair(IPMI_CMD_OCC_RESET, sensorID),
std::bind(&Host::commandStatusHandler, this,
std::placeholders::_1,
std::placeholders::_2));
return ipmid_send_cmd_to_host(std::move(cmd));
}
return;
}
// Called into by Command Manager
void Host::commandStatusHandler(IpmiCmdData cmd, bool status)
{
// Need to convert <cmd> to the equivalent one mentioned in spec
auto value = status ? Result::Success : Result::Failure;
// Fire a signal
this->commandComplete(intfCommand.at(std::get<0>(cmd)), value);
}
} // namespace command
} // namespace host
} // namespace open_power