blob: 901eca12e00cc1d0cb8b3eeffedd55e54e4756b8 [file] [log] [blame]
Rohit PAI0a888262025-06-11 08:52:29 +05301#include "Inventory.hpp"
2
3#include "Utils.hpp"
4
5#include <NvidiaGpuMctpVdm.hpp>
6#include <phosphor-logging/lg2.hpp>
7#include <sdbusplus/asio/connection.hpp>
8#include <sdbusplus/asio/object_server.hpp>
9
10#include <exception>
11#include <memory>
12#include <string>
13
14constexpr const char* inventoryPrefix = "/xyz/openbmc_project/inventory/";
15constexpr const char* acceleratorIfaceName =
16 "xyz.openbmc_project.Inventory.Item.Accelerator";
17
18Inventory::Inventory(
19 const std::shared_ptr<sdbusplus::asio::connection>& /*conn*/,
20 sdbusplus::asio::object_server& objectServer,
21 const std::string& inventoryName,
22 const gpu::DeviceIdentification deviceType) :
23 name(escapeName(inventoryName))
24{
25 if (deviceType == gpu::DeviceIdentification::DEVICE_GPU)
26 {
27 std::string path = inventoryPrefix + name;
28 try
29 {
30 acceleratorInterface =
31 objectServer.add_interface(path, acceleratorIfaceName);
32 acceleratorInterface->register_property("Type", std::string("GPU"));
33 acceleratorInterface->initialize();
34 }
35 catch (const std::exception& e)
36 {
37 lg2::error(
38 "Failed to add accelerator interface. path='{PATH}', error='{ERROR}'",
39 "PATH", path, "ERROR", e.what());
40 }
41 }
42}