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