Support new PDR layout in PLDM sensor handling

The OCC active PLDM sensors are changing from each having a unique PDR
instance ID to having different container IDs based on the DCM they are
present on and then the same instance IDs across the DCMs.

For example:
OCC   containerID  instanceID
0       20           0
1       20           1
2       21           0
3       21           1

There is some code that was relying on unique instance IDs to sort the
sensor IDs.  Instead, use ((containerID << 16) | instanceID) to give a
unique key.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ieda7732f3af94427f8392cab6060d3ca16f86fbe
diff --git a/pldm.cpp b/pldm.cpp
index 0c3b983..a65369a 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -48,15 +48,17 @@
         return;

     }

 

-    // To order SensorID based on the EntityInstance

-    std::map<EntityInstance, SensorID> entityInstMap{};

+    // To order SensorID based on the EntityInstance.

+    // Note that when a proc is on a DCM, the PDRs for these sensors

+    // could have the same instance IDs but different container IDs.

+    std::map<uint32_t, SensorID> entityInstMap{};

     for (auto& pdr : pdrs)

     {

         auto pdrPtr =

             reinterpret_cast<const pldm_state_sensor_pdr*>(pdr.data());

-        entityInstMap.emplace(

-            static_cast<EntityInstance>(pdrPtr->entity_instance),

-            static_cast<SensorID>(pdrPtr->sensor_id));

+        uint32_t key = (static_cast<uint32_t>(pdrPtr->container_id) << 16) |

+                       static_cast<uint32_t>(pdrPtr->entity_instance);

+        entityInstMap.emplace(key, static_cast<SensorID>(pdrPtr->sensor_id));

     }

 

     open_power::occ::instanceID count = start;

@@ -190,9 +192,9 @@
     {

         auto pdrPtr =

             reinterpret_cast<const pldm_state_effecter_pdr*>(pdr.data());

-        entityInstMap.emplace(

-            static_cast<EntityInstance>(pdrPtr->entity_instance),

-            static_cast<SensorID>(pdrPtr->effecter_id));

+        uint32_t key = (static_cast<uint32_t>(pdrPtr->container_id) << 16) |

+                       static_cast<uint32_t>(pdrPtr->entity_instance);

+        entityInstMap.emplace(key, static_cast<SensorID>(pdrPtr->effecter_id));

     }

 

     open_power::occ::instanceID position = start;