requester: associate Entity Manager configs with MCTP endpoints
Currently, pldmd listens for new MCTP endpoint exposed by mctpd, but
they only shows their EID, Network Id, and SupportedMessageTypes, which
cannot fulfill some requirements, e.g., get the device's name or which
board it belongs to.
In openbmc, the additional information are exposed by Entity
Manager[1][2], so add this ability to `MctpDiscovery, it queries the
association between MCTP endpoints and Entity Manager configurations
from MCTP Reactor, when a new MCTP endpoint has been register by mctpd.
Added unit test for this commit to validate the association does work,
passed.
[1]: https://github.com/openbmc/entity-manager/blob/master/schemas/mctp.json
[2]: https://gerrit.openbmc.org/c/openbmc/dbus-sensors/+/69111
Change-Id: Ibf1717f1840e527f21bd8397e747ae121e2dcd25
Signed-off-by: Unive Tien <unive.tien.wiwynn@gmail.com>
diff --git a/requester/mctp_endpoint_discovery.hpp b/requester/mctp_endpoint_discovery.hpp
index 026e155..7692849 100644
--- a/requester/mctp_endpoint_discovery.hpp
+++ b/requester/mctp_endpoint_discovery.hpp
@@ -11,6 +11,8 @@
#include <initializer_list>
#include <vector>
+class TestMctpDiscovery;
+
namespace pldm
{
@@ -21,6 +23,12 @@
constexpr const char* MCTPPath = "/au/com/codeconstruct/mctp1";
constexpr const char* MCTPInterfaceCC = "au.com.codeconstruct.MCTP.Endpoint1";
constexpr const char* MCTPConnectivityProp = "Connectivity";
+constexpr const char* inventorySubtreePathStr =
+ "/xyz/openbmc_project/inventory/system";
+
+const std::vector<std::string> interfaceFilter = {
+ "xyz.openbmc_project.Configuration.MCTPI2CTarget",
+ "xyz.openbmc_project.Configuration.MCTPI3CTarget"};
/** @class MctpDiscoveryHandlerIntf
*
@@ -42,6 +50,8 @@
virtual std::optional<mctp_eid_t> getActiveEidByName(
const std::string& terminusName) = 0;
+ virtual void handleConfigurations(const Configurations& /*configurations*/)
+ {}
virtual ~MctpDiscoveryHandlerIntf() {}
};
@@ -156,6 +166,8 @@
void removeFromExistingMctpInfos(MctpInfos& mctpInfos,
MctpInfos& removedInfos);
+ friend class ::TestMctpDiscovery;
+
private:
/** @brief Get MCTP Endpoint D-Bus Properties in the
* `xyz.openbmc_project.MCTP.Endpoint` D-Bus interface
@@ -190,6 +202,39 @@
Availability getEndpointConnectivityProp(const std::string& path);
static constexpr uint8_t mctpTypePLDM = 1;
+
+ /** @brief Construct the MCTP reactor object path
+ *
+ * @param[in] mctpInfo - information of discovered MCTP endpoint
+ *
+ * @return the MCTP reactor object path
+ */
+ std::string constructMctpReactorObjectPath(const MctpInfo& mctpInfo);
+
+ /** @brief Search for associated configuration for the MctpInfo.
+ *
+ * @param[in] mctpInfo - information of discovered MCTP endpoint
+ */
+ void searchConfigurationFor(const pldm::utils::DBusHandler& handler,
+ MctpInfo& mctpInfo);
+
+ /** @brief Remove configuration associated with the removed MCTP endpoint.
+ *
+ * @param[in] removedInfos - the removed MCTP endpoints
+ */
+ void removeConfigs(const MctpInfos& removedInfos);
+
+ /** @brief An internal helper function to get the name property from the
+ * properties
+ * @param[in] properties - the properties of the D-Bus object
+ * @return the name property
+ */
+ std::string getNameFromProperties(const utils::PropertyMap& properties);
+
+ /** @brief The configuration contains D-Bus path and the MCTP endpoint
+ * information.
+ */
+ Configurations configurations;
};
} // namespace pldm