platform-mc: Added EventManager
Added eventManager to handle sensor event class(00h) which is defined in
table 11 of DSP0248 v1.3.0. In this commit, the eventManager supports to
receive event asynchronously. The commit will also log the Ipmitool SEL
log and Redfish log for PLDM sensor event messages.
Change-Id: I1b337ccae454067841ffbbd8754631216a995542
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Signed-off-by: Gilbert Chen <gilbertc@nvidia.com>
diff --git a/platform-mc/platform_manager.cpp b/platform-mc/platform_manager.cpp
index 35526fb..51a6b06 100644
--- a/platform-mc/platform_manager.cpp
+++ b/platform-mc/platform_manager.cpp
@@ -37,6 +37,29 @@
terminus->parseTerminusPDRs();
}
+ uint16_t terminusMaxBufferSize = terminus->maxBufferSize;
+ if (!terminus->doesSupportCommand(PLDM_PLATFORM,
+ PLDM_EVENT_MESSAGE_BUFFER_SIZE))
+ {
+ terminusMaxBufferSize = PLDM_PLATFORM_DEFAULT_MESSAGE_BUFFER_SIZE;
+ }
+ else
+ {
+ /* Get maxBufferSize use PLDM command eventMessageBufferSize */
+ auto rc = co_await eventMessageBufferSize(
+ tid, terminus->maxBufferSize, terminusMaxBufferSize);
+ if (rc != PLDM_SUCCESS)
+ {
+ lg2::error(
+ "Failed to get message buffer size for terminus with TID: {TID}, error: {ERROR}",
+ "TID", tid, "ERROR", rc);
+ terminusMaxBufferSize =
+ PLDM_PLATFORM_DEFAULT_MESSAGE_BUFFER_SIZE;
+ }
+ }
+ terminus->maxBufferSize =
+ std::min(terminus->maxBufferSize, terminusMaxBufferSize);
+
auto rc = co_await configEventReceiver(tid);
if (rc)
{
@@ -369,6 +392,57 @@
co_return completionCode;
}
+exec::task<int> PlatformManager::eventMessageBufferSize(
+ pldm_tid_t tid, uint16_t receiverMaxBufferSize,
+ uint16_t& terminusBufferSize)
+{
+ Request request(
+ sizeof(pldm_msg_hdr) + PLDM_EVENT_MESSAGE_BUFFER_SIZE_REQ_BYTES);
+ auto requestMsg = reinterpret_cast<pldm_msg*>(request.data());
+ auto rc = encode_event_message_buffer_size_req(0, receiverMaxBufferSize,
+ requestMsg);
+ if (rc)
+ {
+ lg2::error(
+ "Failed to encode request GetPDRRepositoryInfo for terminus ID {TID}, error {RC} ",
+ "TID", tid, "RC", rc);
+ co_return rc;
+ }
+
+ const pldm_msg* responseMsg = nullptr;
+ size_t responseLen = 0;
+ rc = co_await terminusManager.sendRecvPldmMsg(tid, request, &responseMsg,
+ &responseLen);
+ if (rc)
+ {
+ lg2::error(
+ "Failed to send EventMessageBufferSize message for terminus {TID}, error {RC}",
+ "TID", tid, "RC", rc);
+ co_return rc;
+ }
+
+ uint8_t completionCode;
+ rc = decode_event_message_buffer_size_resp(
+ responseMsg, responseLen, &completionCode, &terminusBufferSize);
+ if (rc)
+ {
+ lg2::error(
+ "Failed to decode response EventMessageBufferSize for terminus ID {TID}, error {RC} ",
+ "TID", tid, "RC", rc);
+ co_return rc;
+ }
+
+ if (completionCode != PLDM_SUCCESS)
+ {
+ lg2::error(
+ "Error : EventMessageBufferSize for terminus ID {TID}, complete code {CC}.",
+ "TID", tid, "CC", completionCode);
+ co_return completionCode;
+ }
+
+ co_return completionCode;
+}
+
exec::task<int> PlatformManager::setEventReceiver(
pldm_tid_t tid, pldm_event_message_global_enable eventMessageGlobalEnable,
pldm_transport_protocol_type protocolType, uint16_t heartbeatTimer)