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/common/utils.hpp b/common/utils.hpp
index 9964188..358d0d7 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -72,6 +72,7 @@
constexpr auto dbusProperties = "org.freedesktop.DBus.Properties";
constexpr auto mapperService = ObjectMapper::default_service;
constexpr auto inventoryPath = "/xyz/openbmc_project/inventory";
+
/** @struct CustomFD
*
* RAII wrapper for file descriptor.
@@ -174,7 +175,7 @@
using PropertyValue =
std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
uint64_t, double, std::string, std::vector<uint8_t>,
- std::vector<std::string>>;
+ std::vector<uint64_t>, std::vector<std::string>>;
using DbusProp = std::string;
using DbusChangedProps = std::map<DbusProp, PropertyValue>;
using DBusInterfaceAdded = std::vector<
@@ -194,6 +195,8 @@
using MapperServiceMap = std::vector<std::pair<ServiceName, Interfaces>>;
using GetSubTreeResponse = std::vector<std::pair<ObjectPath, MapperServiceMap>>;
using GetSubTreePathsResponse = std::vector<std::string>;
+using GetAssociatedSubTreeResponse =
+ std::map<std::string, std::map<std::string, std::vector<std::string>>>;
using GetAncestorsResponse =
std::vector<std::pair<ObjectPath, MapperServiceMap>>;
using PropertyMap = std::map<std::string, PropertyValue>;
@@ -232,6 +235,11 @@
virtual PropertyMap getDbusPropertiesVariant(
const char* serviceName, const char* objPath,
const char* dbusInterface) const = 0;
+
+ virtual GetAssociatedSubTreeResponse getAssociatedSubTree(
+ const sdbusplus::message::object_path& objectPath,
+ const sdbusplus::message::object_path& subtree, int depth,
+ const std::vector<std::string>& ifaceList) const = 0;
};
/**
@@ -362,6 +370,19 @@
return std::get<Property>(VariantValue);
}
+ /** @brief Get the associated subtree from the mapper
+ *
+ * @param[in] path - The D-Bus object path
+ *
+ * @param[in] interface - The D-Bus interface
+ *
+ * @return GetAssociatedSubtreeResponse - The associated subtree
+ */
+ GetAssociatedSubTreeResponse getAssociatedSubTree(
+ const sdbusplus::message::object_path& objectPath,
+ const sdbusplus::message::object_path& subtree, int depth,
+ const std::vector<std::string>& ifaceList) const override;
+
/** @brief Set Dbus property
*
* @param[in] dBusMap - Object path, property name, interface and property