oem/pldm: Implement GetAlertStatus command
Implement the GetAlertStatus PLDM OEM command on BMC, the command can
just return the hardcoded data:
00 (PLDM_SUCCESS)
FF 00 00 30
00 00 80 30
Tested:
./pldmtool raw -d 0x80 0x3f 0xf0 0x00
Request Message:
08 01 80 3f f0 00
Response Message:
08 01 00 3f f0 00 30 00 00 ff 30 80 00 00
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9d231fcc5a7bb77e1abdfaa1b46ba044c6e8bbe8
diff --git a/oem/ibm/libpldmresponder/file_io.cpp b/oem/ibm/libpldmresponder/file_io.cpp
index c35084c..bf622c3 100644
--- a/oem/ibm/libpldmresponder/file_io.cpp
+++ b/oem/ibm/libpldmresponder/file_io.cpp
@@ -699,6 +699,42 @@
return response;
}
+Response Handler::getAlertStatus(const pldm_msg* request, size_t payloadLength)
+{
+ Response response(sizeof(pldm_msg_hdr) + PLDM_GET_ALERT_STATUS_RESP_BYTES);
+ auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
+ if (payloadLength != PLDM_GET_ALERT_STATUS_REQ_BYTES)
+ {
+ return CmdHandler::ccOnlyResponse(request, PLDM_ERROR_INVALID_LENGTH);
+ }
+
+ uint8_t versionId{};
+
+ auto rc = decode_get_alert_status_req(request, payloadLength, &versionId);
+ if (rc != PLDM_SUCCESS)
+ {
+ return CmdHandler::ccOnlyResponse(request, rc);
+ }
+
+ if (versionId != 0)
+ {
+ return CmdHandler::ccOnlyResponse(request,
+ PLDM_HOST_UNSUPPORTED_FORMAT_VERSION);
+ }
+
+ constexpr uint32_t rackEntry = 0xFF000030;
+ constexpr uint32_t priCecNode = 0x00008030;
+ rc = encode_get_alert_status_resp(request->hdr.instance_id, PLDM_SUCCESS,
+ rackEntry, priCecNode, responsePtr,
+ PLDM_GET_ALERT_STATUS_RESP_BYTES);
+ if (rc != PLDM_SUCCESS)
+ {
+ return CmdHandler::ccOnlyResponse(request, rc);
+ }
+
+ return response;
+}
+
} // namespace oem_ibm
} // namespace responder
} // namespace pldm
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index 4e0cad4..f0555d7 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -17,6 +17,7 @@
#include "libpldm/base.h"
#include "oem/ibm/libpldm/file_io.h"
+#include "oem/ibm/libpldm/host.h"
namespace pldm
{
@@ -143,7 +144,6 @@
namespace oem_ibm
{
-
class Handler : public CmdHandler
{
public:
@@ -189,6 +189,11 @@
[this](const pldm_msg* request, size_t payloadLength) {
return this->fileAck(request, payloadLength);
});
+ handlers.emplace(PLDM_HOST_GET_ALERT_STATUS,
+ [this](const pldm_msg* request, size_t payloadLength) {
+ return this->getAlertStatus(request,
+ payloadLength);
+ });
}
/** @brief Handler for readFileIntoMemory command
@@ -267,6 +272,15 @@
Response writeFile(const pldm_msg* request, size_t payloadLength);
Response fileAck(const pldm_msg* request, size_t payloadLength);
+
+ /** @brief Handler for getAlertStatus command
+ *
+ * @param[in] request - PLDM request msg
+ * @param[in] payloadLength - length of the message payload
+ *
+ * @return PLDM response message
+ */
+ Response getAlertStatus(const pldm_msg* request, size_t payloadLength);
};
} // namespace oem_ibm