platform-mc: Handle `Connectivity` propertiesChanged signal
From Mctp codeConstruct version 2.0 [1], mctpd supports `.Connectivity`
property under `au.com.CodeConstruct.MCTP.Endpoint` interface of the
endpoint. This commit handles the propertiesChanged signal from this
interface, and updates the Availability of the MCTP Endpoint accordingly
in the source to enable or disable message sending/receiving via that
endpoint of the terminus.
[1] https://github.com/CodeConstruct/mctp/blob/v2.0/docs/endpoint-recovery.md#proposed-design
When the discovery process first starts, it will only handle the
endpoints that have `Available` `.Connectivity`. It lets the
propertiesChanged signal trigger the adding of the endpoints when they
are back to` Available`.
On interfaceAdded signal, it assumes that mctpd only publishes available
endpoints to D-Bus, so it adds the endpoints to the terminus anyway.
Tested:
1. Enable `unsafe-writable-connectivity` option in PACKAGECONFIG of mctp
recipe.
2. After PLDM discovers all the endpoints, write `Degraded` to
`.Connectivity` of one of the endpoint.
3. Write it back to `Available` to see how message is stopped from being
sent/received via the endpoint.
Signed-off-by: Chau Ly <chaul@amperecomputing.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: I5b7a38ae72e655b60d71396a1118f2809aaa3838
diff --git a/platform-mc/test/event_manager_test.cpp b/platform-mc/test/event_manager_test.cpp
index 5fb53e5..5ba9d80 100644
--- a/platform-mc/test/event_manager_test.cpp
+++ b/platform-mc/test/event_manager_test.cpp
@@ -359,6 +359,9 @@
sizeof(eventMessageSupportedResp));
EXPECT_EQ(rc, PLDM_SUCCESS);
+ terminusManager.updateMctpEndpointAvailability(
+ pldm::MctpInfo(10, "", "", 1), true);
+
// queue SetEventReceiver response
const size_t SetEventReceiverLen = 1;
PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES;
@@ -483,6 +486,9 @@
sizeof(pollForPlatformEventMessage3Resp));
EXPECT_EQ(rc, PLDM_SUCCESS);
+ terminusManager.updateMctpEndpointAvailability(
+ pldm::MctpInfo(10, "", "", 1), true);
+
EXPECT_CALL(eventManager, processCperEvent(_, _, _, _))
.Times(1)
.WillRepeatedly(Return(1));
diff --git a/platform-mc/test/platform_manager_test.cpp b/platform-mc/test/platform_manager_test.cpp
index 09f94e5..cf6567d 100644
--- a/platform-mc/test/platform_manager_test.cpp
+++ b/platform-mc/test/platform_manager_test.cpp
@@ -183,8 +183,12 @@
sizeof(getPdrAuxNameResp));
EXPECT_EQ(rc, PLDM_SUCCESS);
+ mockTerminusManager.updateMctpEndpointAvailability(
+ pldm::MctpInfo(10, "", "", 1), true);
+
stdexec::sync_wait(platformManager.initTerminus());
EXPECT_EQ(true, terminus->initialized);
+ EXPECT_EQ(true, terminus->doesSupportCommand(PLDM_PLATFORM, PLDM_GET_PDR));
EXPECT_EQ(2, terminus->pdrs.size());
EXPECT_EQ(1, terminus->numericSensors.size());
EXPECT_EQ("S0", terminus->getTerminusName().value());
@@ -342,6 +346,9 @@
sizeof(getPdrAuxNameResp));
EXPECT_EQ(rc, PLDM_SUCCESS);
+ mockTerminusManager.updateMctpEndpointAvailability(
+ pldm::MctpInfo(10, "", "", 1), true);
+
stdexec::sync_wait(platformManager.initTerminus());
EXPECT_EQ(true, terminus->initialized);
EXPECT_EQ(2, terminus->pdrs.size());