host-bmc: Implement Chassis interface
Adding support to host Chassis dbus interface. Based on the PDRs
received from remote PLDM terminus, PLDM hosts the dbus interface based
on the entity type. The Chassis 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/Chassis.interface.yaml
Change-Id: Ia07c5974ae78314e0812cb09fbc6c738b4853cb9
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/chassis.cpp b/host-bmc/dbus/chassis.cpp
new file mode 100644
index 0000000..74f7371
--- /dev/null
+++ b/host-bmc/dbus/chassis.cpp
@@ -0,0 +1,21 @@
+#include "chassis.hpp"
+
+namespace pldm
+{
+namespace dbus
+{
+
+auto ItemChassis::type() const -> ChassisType
+{
+ return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Chassis::
+ type();
+}
+
+auto ItemChassis::type(ChassisType value) -> ChassisType
+{
+ return sdbusplus::xyz::openbmc_project::Inventory::Item::server::Chassis::
+ type(value);
+}
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/dbus/chassis.hpp b/host-bmc/dbus/chassis.hpp
new file mode 100644
index 0000000..55997df
--- /dev/null
+++ b/host-bmc/dbus/chassis.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Chassis/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemChassisIntf = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Inventory::Item::server::Chassis>;
+
+class ItemChassis : public ItemChassisIntf
+{
+ public:
+ ItemChassis() = delete;
+ ~ItemChassis() = default;
+ ItemChassis(const ItemChassis&) = delete;
+ ItemChassis& operator=(const ItemChassis&) = delete;
+ ItemChassis(ItemChassis&&) = delete;
+ ItemChassis& operator=(ItemChassis&&) = delete;
+
+ ItemChassis(sdbusplus::bus_t& bus, const std::string& objPath) :
+ ItemChassisIntf(bus, objPath.c_str())
+ {}
+
+ /** Get value of Type */
+ ChassisType type() const override;
+
+ /** Set value of Type */
+ ChassisType type(ChassisType value) override;
+};
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index e0d4fbf..b02ed36 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -137,5 +137,15 @@
}
}
+void CustomDBus::implementChassisInterface(const std::string& path)
+{
+ if (!chassis.contains(path))
+ {
+ chassis.emplace(path,
+ std::make_unique<ItemChassis>(
+ 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 02807a1..9ca8926 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "cable.hpp"
+#include "chassis.hpp"
#include "common/utils.hpp"
#include "cpu_core.hpp"
#include "fan.hpp"
@@ -143,9 +144,15 @@
*/
void implementFanInterface(const std::string& path);
+ /** @brief Implement Chassis Interface
+ * @param[in] path - the object path
+ */
+ void implementChassisInterface(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<Cable>> cable;
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 94f6328..7cbbe85 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1134,6 +1134,10 @@
CustomDBus::getCustomDBus().implementCpuCoreInterface(
entity.first);
break;
+ case PLDM_ENTITY_SYSTEM_CHASSIS:
+ CustomDBus::getCustomDBus().implementChassisInterface(
+ entity.first);
+ break;
case PLDM_ENTITY_SLOT:
CustomDBus::getCustomDBus().implementPCIeSlotInterface(
entity.first);
diff --git a/host-bmc/test/meson.build b/host-bmc/test/meson.build
index c1d429d..ab7c9a8 100644
--- a/host-bmc/test/meson.build
+++ b/host-bmc/test/meson.build
@@ -8,6 +8,7 @@
'../utils.cpp',
'../dbus/custom_dbus.cpp',
'../dbus/cable.cpp',
+ '../dbus/chassis.cpp',
'../dbus/cpu_core.cpp',
'../dbus/pcie_device.cpp',
'../dbus/pcie_slot.cpp',