Create GPU Inventory device
adds Item.accelerator interface for GPU devices
Tested
```
root@gb200nvl-obmc:~# busctl introspect xyz.openbmc_project.GpuSensor /xyz/openbmc_project/inventory/NVIDIA_GB200_GPU_0
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
xyz.openbmc_project.Inventory.Item.Accelerator interface - - -
.Type property s "GPU" emits-change
```
Change-Id: I20434529860cb37889e63651bbcd97cadfa9d54e
Signed-off-by: Rohit PAI <ropai@nvidia.com>
diff --git a/src/nvidia-gpu/Inventory.cpp b/src/nvidia-gpu/Inventory.cpp
new file mode 100644
index 0000000..9522e42
--- /dev/null
+++ b/src/nvidia-gpu/Inventory.cpp
@@ -0,0 +1,39 @@
+#include "Inventory.hpp"
+
+#include "Utils.hpp"
+
+#include <phosphor-logging/lg2.hpp>
+
+static constexpr const char* inventoryPrefix =
+ "/xyz/openbmc_project/inventory/";
+static constexpr const char* acceleratorIfaceName =
+ "xyz.openbmc_project.Inventory.Item.Accelerator";
+static constexpr const char* assetIfaceName =
+ "xyz.openbmc_project.Inventory.Decorator.Asset";
+
+Inventory::Inventory(
+ const std::shared_ptr<sdbusplus::asio::connection>& /*conn*/,
+ sdbusplus::asio::object_server& objectServer,
+ const std::string& inventoryName, mctp::MctpRequester& mctpRequester,
+ DeviceType deviceType, uint8_t eid) :
+ name(escapeName(inventoryName)), mctpRequester(mctpRequester),
+ deviceType(deviceType), eid(eid)
+{
+ if (deviceType == DeviceType::GPU)
+ {
+ std::string path = std::string(inventoryPrefix) + name;
+ try
+ {
+ acceleratorInterface =
+ objectServer.add_interface(path, acceleratorIfaceName);
+ acceleratorInterface->register_property("Type", std::string("GPU"));
+ acceleratorInterface->initialize();
+ }
+ catch (const std::exception& e)
+ {
+ lg2::error(
+ "Failed to add accelerator interface. path='{PATH}', error='{ERROR}'",
+ "PATH", path, "ERROR", e.what());
+ }
+ }
+}