smbios-mdr: Associate with the motherboard

The change associates the objects such as processor, memory and PCIe
slots published by smbios-mdr with the motherboard inventory object.
Presently objects paths created by smbios-mdr have the motherboard path
as the prefix -- "/xyz/openbmc_project/inventory/chassis/motherboard".
For machine with entity-manager dynamic stack, that hardcoded
motherboard path would probably not be the object path of the
motherboard.

We have implemented a DBus method in EM that can return the inventory
object path of the root board in the system. Such associations can be
assembled in Redfish resources can indicate the machine topology.

Tested:
DBus call on the Association interface of a CPU object.

busctl get-property xyz.openbmc_project.Smbios.MDR_V2 \
/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0 \
xyz.openbmc_project.Association.Definitions Associations
a(sss) 1 "chassis" "processors" \
"/xyz/openbmc_project/inventory/system/board/GSZ"

Signed-off-by: Jie Yang <jjy@google.com>
Change-Id: Ia95159a87c2ce5e69e90e622cf341a68e7db13d4
diff --git a/include/pcieslot.hpp b/include/pcieslot.hpp
index d16d75e..7ed083f 100644
--- a/include/pcieslot.hpp
+++ b/include/pcieslot.hpp
@@ -1,6 +1,7 @@
 #pragma once
 #include "smbios_mdrv2.hpp"
 
+#include <xyz/openbmc_project/Association/Definitions/server.hpp>
 #include <xyz/openbmc_project/Inventory/Connector/Embedded/server.hpp>
 #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
 #include <xyz/openbmc_project/Inventory/Item/PCIeSlot/server.hpp>
@@ -27,8 +28,11 @@
 using location =
     sdbusplus::xyz::openbmc_project::Inventory::Decorator::server::LocationCode;
 using item = sdbusplus::xyz::openbmc_project::Inventory::server::Item;
+using association =
+    sdbusplus::xyz::openbmc_project::Association::server::Definitions;
 
-class Pcie : sdbusplus::server::object_t<PCIeSlot, location, embedded, item>
+class Pcie :
+    sdbusplus::server::object_t<PCIeSlot, location, embedded, item, association>
 {
   public:
     Pcie() = delete;
@@ -39,10 +43,12 @@
     ~Pcie() = default;
 
     Pcie(sdbusplus::bus::bus& bus, const std::string& objPath,
-         const uint8_t& pcieId, uint8_t* smbiosTableStorage) :
-        sdbusplus::server::object_t<PCIeSlot, location, embedded, item>(
-            bus, objPath.c_str()),
-        pcieNum(pcieId), storage(smbiosTableStorage)
+         const uint8_t& pcieId, uint8_t* smbiosTableStorage,
+         const std::string& motherboard) :
+        sdbusplus::server::object_t<PCIeSlot, location, embedded, item,
+                                    association>(bus, objPath.c_str()),
+        pcieNum(pcieId), storage(smbiosTableStorage),
+        motherboardPath(motherboard)
     {
         pcieInfoUpdate();
     }
@@ -52,6 +58,7 @@
   private:
     uint8_t pcieNum;
     uint8_t* storage;
+    std::string motherboardPath;
 
     struct SystemSlotInfo
     {