platform-mc: Call MCTP `.Recover` in the request timeout
In the current implementation, `pldmd` will register the request
messages to sendRecvPldmMsg. This API will returns the return error code
from sendRecvPldmMsgOverMctp directly to the caller but not handle the
timeout error code.
From Mctp codeConstruct version 2.0 [1], the MCTP D-Bus interface
`au.com.codeconstruct.MCTP.Endpoint1` supports `.Recover` method to
recover the communication to one terminus. The `pldmd` should call this
method in time out.
[1] https://github.com/CodeConstruct/mctp/blob/v2.0/docs/endpoint-recovery.md#recover-method-design-considerations
Supports handling the timeout error code by calling to the `.Recover`
method under `au.com.codeconstruct.MCTP.Endpoint1` brought by mctpd.
This action will check if the endpoint is still available. pldm will
handle accordingly by continuing to communicate or removing the endpoint
based on mctpd upcoming behaviors.
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I71cc33a3630b5adbd65c485fe98148669ce635f6
diff --git a/platform-mc/terminus_manager.cpp b/platform-mc/terminus_manager.cpp
index be70740..0aacf33 100644
--- a/platform-mc/terminus_manager.cpp
+++ b/platform-mc/terminus_manager.cpp
@@ -140,6 +140,14 @@
}
}
+std::string TerminusManager::constructEndpointObjPath(const MctpInfo& mctpInfo)
+{
+ std::string eidStr = std::to_string(std::get<0>(mctpInfo));
+ std::string networkIDStr = std::to_string(std::get<3>(mctpInfo));
+ return std::format("{}/networks/{}/endpoints/{}", MCTPPath, networkIDStr,
+ eidStr);
+}
+
void TerminusManager::discoverMctpTerminus(const MctpInfos& mctpInfos)
{
queuedMctpInfos.emplace(mctpInfos);
@@ -662,6 +670,18 @@
auto rc = co_await sendRecvPldmMsgOverMctp(eid, request, responseMsg,
responseLen);
+ if (rc == PLDM_ERROR_NOT_READY)
+ {
+ // Call Recover() to check enpoint's availability
+ // Set endpoint's availability in mctpInfoTable to false in advance
+ // to prevent message forwarding through this endpoint while mctpd
+ // is checking the endpoint.
+ std::string endpointObjPath =
+ constructEndpointObjPath(mctpInfo.value());
+ pldm::utils::recoverMctpEndpoint(endpointObjPath);
+ updateMctpEndpointAvailability(mctpInfo.value(), false);
+ }
+
co_return rc;
}