Call out GPUs using their inventory path

The existing code was calling out GPUs in the metadata
with 'GPU=GPUn' because at the time the GPUs were not
in the inventory.

Now that the GPUs are in the inventory, they can be called
out using their inventory objects which is the correct
way to do it.

Resolves openbmc/openbmc#2869

Change-Id: Ic7b3ac465d482aade532f75ef10cc05df4928767
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/elog-errors.hpp b/elog-errors.hpp
index 3582c49..150875a 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -1193,14 +1193,6 @@
     explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
     type _entry;
 };
-struct GPU
-{
-    static constexpr auto str = "GPU=%s";
-    static constexpr auto str_short = "GPU";
-    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
-    explicit constexpr GPU(const char* a) : _entry(entry(str, a)) {};
-    type _entry;
-};
 
 }  // namespace _GPUPowerFault
 
@@ -1208,8 +1200,8 @@
 {
     static constexpr auto L = level::ERR;
     using RAW_STATUS = _GPUPowerFault::RAW_STATUS;
-    using GPU = _GPUPowerFault::GPU;
-    using metadata_types = std::tuple<RAW_STATUS, GPU>;
+    using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+    using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
 
 };
 
@@ -1249,14 +1241,6 @@
     explicit constexpr RAW_STATUS(const char* a) : _entry(entry(str, a)) {};
     type _entry;
 };
-struct GPU
-{
-    static constexpr auto str = "GPU=%s";
-    static constexpr auto str_short = "GPU";
-    using type = std::tuple<std::decay_t<decltype(str)>,const char*>;
-    explicit constexpr GPU(const char* a) : _entry(entry(str, a)) {};
-    type _entry;
-};
 
 }  // namespace _GPUOverTemp
 
@@ -1264,8 +1248,8 @@
 {
     static constexpr auto L = level::ERR;
     using RAW_STATUS = _GPUOverTemp::RAW_STATUS;
-    using GPU = _GPUOverTemp::GPU;
-    using metadata_types = std::tuple<RAW_STATUS, GPU>;
+    using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH;
+    using metadata_types = std::tuple<RAW_STATUS, CALLOUT_INVENTORY_PATH>;
 
 };
 
diff --git a/org/open_power/Witherspoon/Fault.metadata.yaml b/org/open_power/Witherspoon/Fault.metadata.yaml
index bea9a8a..c8cdad0 100644
--- a/org/open_power/Witherspoon/Fault.metadata.yaml
+++ b/org/open_power/Witherspoon/Fault.metadata.yaml
@@ -83,13 +83,13 @@
   meta:
     - str: "RAW_STATUS=%s"
       type: string
-    - str: "GPU=%s"
-      type: string
+  inherits:
+    - xyz.openbmc_project.Common.Callout.Inventory
 
 - name: GPUOverTemp
   level: ERR
   meta:
     - str: "RAW_STATUS=%s"
       type: string
-    - str: "GPU=%s"
-      type: string
+  inherits:
+    - xyz.openbmc_project.Common.Callout.Inventory
diff --git a/power-sequencer/ucd90160.cpp b/power-sequencer/ucd90160.cpp
index 79f2915..7f098f7 100644
--- a/power-sequencer/ucd90160.cpp
+++ b/power-sequencer/ucd90160.cpp
@@ -37,6 +37,8 @@
 const auto DRIVER_NAME = "ucd9000"s;
 constexpr auto NUM_PAGES = 16;
 
+constexpr auto INVENTORY_OBJ_PATH = "/xyz/openbmc_project/inventory";
+
 namespace fs = std::experimental::filesystem;
 using namespace gpio;
 using namespace pmbus;
@@ -376,7 +378,8 @@
         {
             errorFound = true;
 
-            auto part = std::get<ucd90160::gpioCalloutField>(gpio);
+            std::string part{INVENTORY_OBJ_PATH};
+            part = part + std::get<ucd90160::gpioCalloutField>(gpio);
             PartCallout callout{type, part};
 
             if (isPartCalledOut(callout))
@@ -424,7 +427,7 @@
 
     report<power_error::GPUPowerFault>(
             metadata::RAW_STATUS(nv.get().c_str()),
-            metadata::GPU(callout.c_str()));
+            metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
 }
 
 void UCD90160::gpuOverTempError(const std::string& callout)
@@ -437,7 +440,7 @@
 
     report<power_error::GPUOverTemp>(
             metadata::RAW_STATUS(nv.get().c_str()),
-            metadata::GPU(callout.c_str()));
+            metadata::CALLOUT_INVENTORY_PATH(callout.c_str()));
 }
 
 }
diff --git a/power-sequencer/ucd90160_defs.cpp b/power-sequencer/ucd90160_defs.cpp
index 997650e..5696061 100644
--- a/power-sequencer/ucd90160_defs.cpp
+++ b/power-sequencer/ucd90160_defs.cpp
@@ -71,15 +71,22 @@
                         "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
                         "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
                         gpio::Value::low,
-                        [](auto& ucd, const auto& callout) { ucd.gpuPGOODError(callout); },
+                        [](auto& ucd, const auto& callout)
+                                { ucd.gpuPGOODError(callout); },
                         optionFlags::none,
                         GPIODefinitions{
-                            GPIODefinition{8, "GPU0"s},
-                            GPIODefinition{9, "GPU1"s},
-                            GPIODefinition{10, "GPU2"s},
-                            GPIODefinition{11, "GPU3"s},
-                            GPIODefinition{12, "GPU4"s},
-                            GPIODefinition{13, "GPU5"s}}
+                            GPIODefinition{8,
+                                "/system/chassis/motherboard/gv100card0"s},
+                            GPIODefinition{9,
+                                "/system/chassis/motherboard/gv100card1"s},
+                            GPIODefinition{10,
+                                "/system/chassis/motherboard/gv100card2"s},
+                            GPIODefinition{11,
+                                "/system/chassis/motherboard/gv100card3"s},
+                            GPIODefinition{12,
+                                "/system/chassis/motherboard/gv100card4"s},
+                            GPIODefinition{13,
+                                "/system/chassis/motherboard/gv100card5"s}}
                     }},
 
                 {extraAnalysisType::gpuOverTemp,
@@ -87,15 +94,22 @@
                         "/sys/devices/platform/ahb/ahb:apb/ahb:apb:i2c@"
                         "1e78a000/1e78a400.i2c-bus/i2c-11/11-0060",
                         gpio::Value::low,
-                        [](auto& ucd, const auto& callout) { ucd.gpuOverTempError(callout); },
+                        [](auto& ucd, const auto& callout)
+                                { ucd.gpuOverTempError(callout); },
                         optionFlags::shutdownOnFault,
                         GPIODefinitions{
-                            GPIODefinition{2, "GPU0"s},
-                            GPIODefinition{3, "GPU1"s},
-                            GPIODefinition{4, "GPU2"s},
-                            GPIODefinition{5, "GPU3"s},
-                            GPIODefinition{6, "GPU4"s},
-                            GPIODefinition{7, "GPU5"s}}
+                            GPIODefinition{2,
+                                "/system/chassis/motherboard/gv100card0"s},
+                            GPIODefinition{3,
+                                "/system/chassis/motherboard/gv100card1"s},
+                            GPIODefinition{4,
+                                "/system/chassis/motherboard/gv100card2"s},
+                            GPIODefinition{5,
+                                "/system/chassis/motherboard/gv100card3"s},
+                            GPIODefinition{6,
+                                "/system/chassis/motherboard/gv100card4"s},
+                            GPIODefinition{7,
+                                "/system/chassis/motherboard/gv100card5"s}}
                     }}
             }
         }