Handle entity association records from host

- Get the PDRs from host, traverse the entity association structure
  and construct the D-Bus object path according to the entity type ID
  and container type ID.

- eg:
 /xyz/openbmc_project/inventory/system1/chassis1/io_board1/powersupply1
 /xyz/openbmc_project/inventory/system1/chassis1/io_board1/powersupply2
 /xyz/openbmc_project/inventory/system1/chassis2/io_board2/powersupply1
 /xyz/openbmc_project/inventory/system1/chassis2/io_board2/powersupply2

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I1c606ea943624f2601be4f5f6b5c30d1bf71cd11
diff --git a/common/utils.hpp b/common/utils.hpp
index 2ae7b86..d78d172 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -4,6 +4,8 @@
 
 #include <libpldm/base.h>
 #include <libpldm/bios.h>
+#include <libpldm/entity.h>
+#include <libpldm/pdr.h>
 #include <libpldm/platform.h>
 #include <libpldm/utils.h>
 #include <stdint.h>
@@ -14,9 +16,11 @@
 #include <sdbusplus/server.hpp>
 #include <xyz/openbmc_project/Logging/Entry/server.hpp>
 
+#include <deque>
 #include <exception>
 #include <filesystem>
 #include <iostream>
+#include <map>
 #include <string>
 #include <variant>
 #include <vector>
@@ -33,6 +37,40 @@
 constexpr bool Tx = true;
 constexpr bool Rx = false;
 
+using EntityName = std::string;
+using EntityType = uint16_t;
+
+using Entities = std::vector<pldm_entity_node*>;
+using EntityAssociations = std::vector<Entities>;
+using ObjectPathMaps = std::map<fs::path, pldm_entity_node*>;
+
+const std::map<EntityType, EntityName> entityMaps = {
+    {PLDM_ENTITY_SYSTEM_CHASSIS, "chassis"},
+    {PLDM_ENTITY_BOARD, "io_board"},
+    {PLDM_ENTITY_SYS_BOARD, "motherboard"},
+    {PLDM_ENTITY_POWER_SUPPLY, "powersupply"},
+    {PLDM_ENTITY_PROC, "cpu"},
+    {PLDM_ENTITY_SYSTEM_CHASSIS | 0x8000, "system"},
+    {PLDM_ENTITY_PROC_MODULE, "dcm"},
+    {PLDM_ENTITY_PROC | 0x8000, "core"},
+    {PLDM_ENTITY_IO_MODULE, "io_module"},
+    {PLDM_ENTITY_FAN, "fan"},
+    {PLDM_ENTITY_SYS_MGMT_MODULE, "system_management_module"},
+    {PLDM_ENTITY_POWER_CONVERTER, "power_converter"},
+    {PLDM_ENTITY_SLOT, "slot"},
+    {PLDM_ENTITY_CONNECTOR, "connector"}};
+
+/** @brief Vector a entity name to pldm_entity from entity association tree
+ *  @param[in]  entityAssoc    - Vector of associated pldm entities
+ *  @param[in]  entityTree     - entity association tree
+ *  @param[out] objPathMap     - maps an object path to pldm_entity from the
+ *                               BMC's entity association tree
+ *  @return
+ */
+void updateEntityAssociation(const EntityAssociations& entityAssoc,
+                             pldm_entity_association_tree* entityTree,
+                             ObjectPathMaps& objPathMap);
+
 /** @struct CustomFD
  *
  *  RAII wrapper for file descriptor.