host-bmc: Implement PowerSupply interface
Adding support to host Powersupply dbus interface.
Based on the PDRs received from remote PLDM terminus,
PLDM hosts the dbus interface based on the entity type.
The powersuppply 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/PowerSupply.interface.yaml
Change-Id: I2f8c57a2db7e6ffffe14b7dff646e73164f84f86
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 b02ed36..16b822a 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -127,6 +127,16 @@
}
}
+void CustomDBus::implementPowerSupplyInterface(const std::string& path)
+{
+ if (!powersupply.contains(path))
+ {
+ powersupply.emplace(
+ path, std::make_unique<PowerSupply>(
+ pldm::utils::DBusHandler::getBus(), path.c_str()));
+ }
+}
+
void CustomDBus::implementFanInterface(const std::string& path)
{
if (!fan.contains(path))
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index 9ca8926..80ffda9 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -8,6 +8,7 @@
#include "motherboard.hpp"
#include "pcie_device.hpp"
#include "pcie_slot.hpp"
+#include "power_supply.hpp"
#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
@@ -149,12 +150,20 @@
*/
void implementChassisInterface(const std::string& path);
+ /** @brief Implement PowerSupply Interface
+ *
+ * @param[in] path - The object path
+ *
+ */
+ void implementPowerSupplyInterface(const std::string& path);
+
private:
std::unordered_map<ObjectPath, std::unique_ptr<LocationIntf>> location;
std::unordered_map<ObjectPath, std::unique_ptr<CPUCore>> cpuCore;
std::unordered_map<ObjectPath, std::unique_ptr<ItemChassis>> chassis;
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<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/power_supply.hpp b/host-bmc/dbus/power_supply.hpp
new file mode 100644
index 0000000..40e26e3
--- /dev/null
+++ b/host-bmc/dbus/power_supply.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/PowerSupply/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemPowerSupply = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Inventory::Item::server::PowerSupply>;
+
+class PowerSupply : public ItemPowerSupply
+{
+ public:
+ PowerSupply() = delete;
+ ~PowerSupply() = default;
+ PowerSupply(const PowerSupply&) = delete;
+ PowerSupply& operator=(const PowerSupply&) = delete;
+ PowerSupply(PowerSupply&&) = delete;
+ PowerSupply& operator=(PowerSupply&&) = delete;
+
+ PowerSupply(sdbusplus::bus_t& bus, const std::string& objPath) :
+ ItemPowerSupply(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 7cbbe85..7c5e33d 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1138,6 +1138,10 @@
CustomDBus::getCustomDBus().implementChassisInterface(
entity.first);
break;
+ case PLDM_ENTITY_POWER_SUPPLY:
+ CustomDBus::getCustomDBus().implementPowerSupplyInterface(
+ entity.first);
+ break;
case PLDM_ENTITY_SLOT:
CustomDBus::getCustomDBus().implementPCIeSlotInterface(
entity.first);