blob: 9522e429857f748856a349dfed082d766449c7c2 [file] [log] [blame]
Rohit PAId87bf7f2025-06-11 08:52:29 +05301#include "Inventory.hpp"
2
3#include "Utils.hpp"
4
5#include <phosphor-logging/lg2.hpp>
6
7static constexpr const char* inventoryPrefix =
8 "/xyz/openbmc_project/inventory/";
9static constexpr const char* acceleratorIfaceName =
10 "xyz.openbmc_project.Inventory.Item.Accelerator";
11static constexpr const char* assetIfaceName =
12 "xyz.openbmc_project.Inventory.Decorator.Asset";
13
14Inventory::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}