Rohit PAI | d87bf7f | 2025-06-11 08:52:29 +0530 | [diff] [blame^] | 1 | #include "Inventory.hpp" |
| 2 | |
| 3 | #include "Utils.hpp" |
| 4 | |
| 5 | #include <phosphor-logging/lg2.hpp> |
| 6 | |
| 7 | static constexpr const char* inventoryPrefix = |
| 8 | "/xyz/openbmc_project/inventory/"; |
| 9 | static constexpr const char* acceleratorIfaceName = |
| 10 | "xyz.openbmc_project.Inventory.Item.Accelerator"; |
| 11 | static constexpr const char* assetIfaceName = |
| 12 | "xyz.openbmc_project.Inventory.Decorator.Asset"; |
| 13 | |
| 14 | Inventory::Inventory( |
| 15 | const std::shared_ptr<sdbusplus::asio::connection>& /*conn*/, |
| 16 | sdbusplus::asio::object_server& objectServer, |
| 17 | const std::string& inventoryName, mctp::MctpRequester& mctpRequester, |
| 18 | DeviceType deviceType, uint8_t eid) : |
| 19 | name(escapeName(inventoryName)), mctpRequester(mctpRequester), |
| 20 | deviceType(deviceType), eid(eid) |
| 21 | { |
| 22 | if (deviceType == DeviceType::GPU) |
| 23 | { |
| 24 | std::string path = std::string(inventoryPrefix) + name; |
| 25 | try |
| 26 | { |
| 27 | acceleratorInterface = |
| 28 | objectServer.add_interface(path, acceleratorIfaceName); |
| 29 | acceleratorInterface->register_property("Type", std::string("GPU")); |
| 30 | acceleratorInterface->initialize(); |
| 31 | } |
| 32 | catch (const std::exception& e) |
| 33 | { |
| 34 | lg2::error( |
| 35 | "Failed to add accelerator interface. path='{PATH}', error='{ERROR}'", |
| 36 | "PATH", path, "ERROR", e.what()); |
| 37 | } |
| 38 | } |
| 39 | } |