host-bmc: Implement fabric adapter interface
Adding support to host fabric adapter dbus interface. Based on the PDRs
received from remote PLDM terminus, PLDM hosts the dbus interface based
on the entity type. The Fabric adapter interface is defined at [1].
Tested:
Functional test passed
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Item/FabricAdapter.interface.yaml
Change-Id: I72a7e3198dbbf78521eeeb37b926562064f733b9
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index 54dd076..08f9750 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -127,6 +127,16 @@
}
}
+void CustomDBus::implementFabricAdapter(const std::string& path)
+{
+ if (!fabricAdapter.contains(path))
+ {
+ fabricAdapter.emplace(
+ path, std::make_unique<FabricAdapter>(
+ pldm::utils::DBusHandler::getBus(), path.c_str()));
+ }
+}
+
void CustomDBus::implementPowerSupplyInterface(const std::string& path)
{
if (!powersupply.contains(path))
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index 2d4ac6b..e292462 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -7,6 +7,7 @@
#include "common/utils.hpp"
#include "connector.hpp"
#include "cpu_core.hpp"
+#include "fabric_adapter.hpp"
#include "fan.hpp"
#include "motherboard.hpp"
#include "pcie_device.hpp"
@@ -167,6 +168,13 @@
*/
void implementConnecterInterface(const std::string& path);
+ /** @brief Implement Fabric Adapter Interface
+ *
+ * @param[in] path - The object path
+ *
+ */
+ void implementFabricAdapter(const std::string& path);
+
/** @brief Implement Asset Interface
*
* @param[in] path - The object path
@@ -192,6 +200,8 @@
std::unordered_map<ObjectPath, std::unique_ptr<PCIeDevice>> pcieDevice;
std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
std::unordered_map<ObjectPath, std::unique_ptr<PowerSupply>> powersupply;
+ std::unordered_map<ObjectPath, std::unique_ptr<FabricAdapter>>
+ fabricAdapter;
std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
diff --git a/host-bmc/dbus/fabric_adapter.hpp b/host-bmc/dbus/fabric_adapter.hpp
new file mode 100644
index 0000000..bc2e5c1
--- /dev/null
+++ b/host-bmc/dbus/fabric_adapter.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/FabricAdapter/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemFabricAdapter = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Inventory::Item::server::FabricAdapter>;
+
+class FabricAdapter : public ItemFabricAdapter
+{
+ public:
+ FabricAdapter() = delete;
+ ~FabricAdapter() = default;
+ FabricAdapter(const FabricAdapter&) = delete;
+ FabricAdapter& operator=(const FabricAdapter&) = delete;
+ FabricAdapter(FabricAdapter&&) = delete;
+ FabricAdapter& operator=(FabricAdapter&&) = delete;
+
+ FabricAdapter(sdbusplus::bus_t& bus, const std::string& objPath) :
+ ItemFabricAdapter(bus, objPath.c_str()), path(objPath)
+ {}
+
+ private:
+ std::string path;
+};
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index cf2652f..53ea526 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1183,6 +1183,10 @@
case PLDM_ENTITY_FAN:
CustomDBus::getCustomDBus().implementFanInterface(entity.first);
break;
+ case PLDM_ENTITY_IO_MODULE:
+ CustomDBus::getCustomDBus().implementFabricAdapter(
+ entity.first);
+ break;
default:
break;
}