1 #include <config.h> 2 3 #include <chrono> 4 #include <functional> 5 #include <host-interface.hpp> 6 #include <host-ipmid/ipmid-host-cmd-utils.hpp> 7 #include <host-ipmid/ipmid-host-cmd.hpp> 8 #include <oemhandler.hpp> 9 #include <phosphor-logging/log.hpp> 10 namespace open_power 11 { 12 namespace host 13 { 14 namespace command 15 { 16 17 // IPMI command 18 // https://github.com/openbmc/openbmc/issues/2082 for handling 19 // Non-OEM commands that need to send SMS_ATN 20 using OEMCmd = uint8_t; 21 22 // Map of IPMI OEM command to its equivalent interface command. 23 // This is needed when invoking the callback handler to indicate 24 // the status of the executed command. 25 static const std::map<OEMCmd, Host::Command> intfCommand = { 26 {IPMI_CMD_OCC_RESET, Base::Host::Command::OCCReset}}; 27 28 // Called at user request 29 void Host::execute(Base::Host::Command command, 30 sdbusplus::message::variant<uint8_t> data) 31 { 32 using namespace phosphor::logging; 33 34 log<level::INFO>( 35 "Pushing cmd on to queue", 36 entry("CONTROL_HOST_CMD=%s", convertForMessage(command).c_str())); 37 38 // If the command is OCCReset, then all we need is just sensor ID 39 // This is the only command that is being used now. 40 if (command == Base::Host::Command::OCCReset) 41 { 42 auto sensorID = sdbusplus::message::variant_ns::get<uint8_t>(data); 43 44 auto cmd = std::make_tuple(std::make_pair(IPMI_CMD_OCC_RESET, sensorID), 45 std::bind(&Host::commandStatusHandler, this, 46 std::placeholders::_1, 47 std::placeholders::_2)); 48 49 return ipmid_send_cmd_to_host(std::move(cmd)); 50 } 51 return; 52 } 53 54 // Called into by Command Manager 55 void Host::commandStatusHandler(IpmiCmdData cmd, bool status) 56 { 57 // Need to convert <cmd> to the equivalent one mentioned in spec 58 auto value = status ? Result::Success : Result::Failure; 59 60 // Fire a signal 61 this->commandComplete(intfCommand.at(std::get<0>(cmd)), value); 62 } 63 64 } // namespace command 65 } // namespace host 66 } // namespace open_power 67