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/common/utils.cpp b/common/utils.cpp
index 76755f2..11ce064 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -27,6 +27,11 @@
namespace utils
{
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
+
+constexpr const char* MCTP_INTERFACE_CC = "au.com.codeconstruct.MCTP.Endpoint1";
+constexpr const char* MCTP_ENDPOINT_RECOVER_METHOD = "Recover";
+
std::vector<std::vector<uint8_t>> findStateEffecterPDR(
uint8_t /*tid*/, uint16_t entityID, uint16_t stateSetId,
const pldm_pdr* repo)
@@ -542,6 +547,27 @@
return PLDM_SUCCESS;
}
+void recoverMctpEndpoint(const std::string& endpointObjPath)
+{
+ auto& bus = DBusHandler::getBus();
+ try
+ {
+ std::string service = DBusHandler().getService(endpointObjPath.c_str(),
+ MCTP_INTERFACE_CC);
+
+ auto method = bus.new_method_call(
+ service.c_str(), endpointObjPath.c_str(), MCTP_INTERFACE_CC,
+ MCTP_ENDPOINT_RECOVER_METHOD);
+ bus.call_noreply(method, dbusTimeout);
+ }
+ catch (const std::exception& e)
+ {
+ error(
+ "failed to make a D-Bus call to recover MCTP Endpoint, ERROR {ERR_EXCEP}",
+ "ERR_EXCEP", e);
+ }
+}
+
uint16_t findStateSensorId(const pldm_pdr* pdrRepo, uint8_t tid,
uint16_t entityType, uint16_t entityInstance,
uint16_t containerId, uint16_t stateSetId)