diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-03-22 10:05:20 +0530 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-04-11 04:39:18 +0000 |
commit | 80938497ab88b0e1201857f85dfe0ad82fa212ea (patch) | |
tree | b227c38208324a70282587cf526d090729e26b68 | |
parent | e3b815dae33db00617f667f57d75d8d58a6e9ec1 (diff) | |
download | phosphor-net-ipmid-80938497ab88b0e1201857f85dfe0ad82fa212ea.tar.gz phosphor-net-ipmid-80938497ab88b0e1201857f85dfe0ad82fa212ea.zip |
Implement get payload instance info command
Resolves openbmc/openbmc#2892
Change-Id: Id5f95df64bcdc97646f11d6d3630eead062c4193
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r-- | command/payload_cmds.cpp | 34 | ||||
-rw-r--r-- | command/payload_cmds.hpp | 35 | ||||
-rw-r--r-- | sol_module.cpp | 8 |
3 files changed, 77 insertions, 0 deletions
diff --git a/command/payload_cmds.cpp b/command/payload_cmds.cpp index 0cc52cc..2215046 100644 --- a/command/payload_cmds.cpp +++ b/command/payload_cmds.cpp @@ -189,6 +189,40 @@ std::vector<uint8_t> getPayloadStatus(const std::vector<uint8_t>& inPayload, return outPayload; } +std::vector<uint8_t> getPayloadInfo(const std::vector<uint8_t>& inPayload, + const message::Handler& handler) +{ + std::vector<uint8_t> outPayload(sizeof(GetPayloadInfoResponse)); + auto request = reinterpret_cast<const GetPayloadInfoRequest*> + (inPayload.data()); + auto response = reinterpret_cast<GetPayloadInfoResponse*> + (outPayload.data()); + + // SOL is the payload currently supported for payload status & only one + // instance of SOL is supported. + if (static_cast<uint8_t>(message::PayloadType::SOL) != request->payloadType + || request->payloadInstance != 1) + { + response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; + return outPayload; + } + + auto status = std::get<sol::Manager&>(singletonPool).isPayloadActive( + request->payloadInstance); + + if (!status) + { + response->completionCode = IPMI_CC_RESPONSE_ERROR; + return outPayload; + } + + auto& context = std::get<sol::Manager&>(singletonPool).getContext + (request->payloadInstance); + response->sessionID = context.sessionID; + + return outPayload; +} + } // namespace command } // namespace sol diff --git a/command/payload_cmds.hpp b/command/payload_cmds.hpp index 6901256..d751a95 100644 --- a/command/payload_cmds.hpp +++ b/command/payload_cmds.hpp @@ -251,6 +251,41 @@ struct GetPayloadStatusResponse std::vector<uint8_t> getPayloadStatus(const std::vector<uint8_t>& inPayload, const message::Handler& handler); +/** @struct GetPayloadInfoRequest + * + * IPMI payload for Get Payload Instance info command request. + */ +struct GetPayloadInfoRequest +{ + uint8_t payloadType; //!< Payload type + uint8_t payloadInstance;//!< Payload instance +} __attribute__((packed)); + +/** @struct GetPayloadInfoResponse + * + * IPMI payload for Get Payload Instance info command response. + */ +struct GetPayloadInfoResponse +{ + uint8_t completionCode; //!< Completion code. + uint32_t sessionID; //!< Session ID + uint8_t portNumber; //!< Port number + uint8_t reserved[7]; //!< Reserved +} __attribute__((packed)); + +/** @brief Get Payload Instance Info Command. + * + * This command returns information about a specific instance of a payload + * type. Session ID is returned by this command + * + * @param[in] inPayload - Request Data for the command. + * @param[in] handler - Reference to the Message Handler. + * + * @return Response data for the command + */ +std::vector<uint8_t> getPayloadInfo(const std::vector<uint8_t>& inPayload, + const message::Handler& handler); + } // namespace command } // namespace sol diff --git a/sol_module.cpp b/sol_module.cpp index 203ec72..e055817 100644 --- a/sol_module.cpp +++ b/sol_module.cpp @@ -44,6 +44,14 @@ void registerCommands() }, &getPayloadStatus, session::Privilege::USER, false }, + // Get Payload Instance Info Command + { + { + (static_cast<uint32_t>(message::PayloadType::IPMI) << 16) | + static_cast<uint16_t>(::command::NetFns::APP) | 0x4B + }, + &getPayloadInfo, session::Privilege::USER, false + }, // Set SOL Configuration Parameters { { |