pldm: Implement Fan Interface
Adding support to host Fan dbus interface.
Based on the PDRs received from remote PLDM terminus,
PLDM hosts the dbus interface based on the entity type.
The Fan 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/Fan.interface.yaml
Change-Id: I353085817abb3646e607659d116207660d0bd0d4
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 d0979e9..e0d4fbf 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -126,5 +126,16 @@
pldm::utils::DBusHandler::getBus(), path));
}
}
+
+void CustomDBus::implementFanInterface(const std::string& path)
+{
+ if (!fan.contains(path))
+ {
+ fan.emplace(path,
+ std::make_unique<Fan>(pldm::utils::DBusHandler::getBus(),
+ path.c_str()));
+ }
+}
+
} // namespace dbus
} // namespace pldm
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index 9baa1dc..02807a1 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -3,6 +3,7 @@
#include "cable.hpp"
#include "common/utils.hpp"
#include "cpu_core.hpp"
+#include "fan.hpp"
#include "motherboard.hpp"
#include "pcie_device.hpp"
#include "pcie_slot.hpp"
@@ -135,6 +136,13 @@
*/
void implementMotherboardInterface(const std::string& path);
+ /** @brief Implement Fan Interface
+ *
+ * @param[in] path - The object path
+ *
+ */
+ void implementFanInterface(const std::string& path);
+
private:
std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
@@ -142,6 +150,7 @@
std::unordered_map<ObjectPath, std::unique_ptr<PCIeSlot>> pcieSlot;
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;
};
} // namespace dbus
diff --git a/host-bmc/dbus/fan.hpp b/host-bmc/dbus/fan.hpp
new file mode 100644
index 0000000..61a995d
--- /dev/null
+++ b/host-bmc/dbus/fan.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Fan/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemFan = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Inventory::Item::server::Fan>;
+
+class Fan : public ItemFan
+{
+ public:
+ Fan() = delete;
+ ~Fan() = default;
+ Fan(const Fan&) = delete;
+ Fan& operator=(const Fan&) = delete;
+ Fan(Fan&&) = delete;
+ Fan& operator=(Fan&&) = delete;
+
+ Fan(sdbusplus::bus_t& bus, const std::string& objPath) :
+ ItemFan(bus, objPath.c_str())
+ {}
+};
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 40bb057..94f6328 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1146,6 +1146,9 @@
CustomDBus::getCustomDBus().implementMotherboardInterface(
entity.first);
break;
+ case PLDM_ENTITY_FAN:
+ CustomDBus::getCustomDBus().implementFanInterface(entity.first);
+ break;
default:
break;
}