PEL: Skip purging PEL if it has associated hw isolation entry

When PELs reaches to certain limits, either in total size or
total number of them, the code starts removing older pels
based on certain criteria. During this process make sure
no pel is removed that has an associated hardware isolation
entry record or error_log event record.

Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: Ia7c9af6911bcf2ac8f8ec046d4c7a7a12d9b2bbd
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index 1e9bd6f..b418c39 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -582,7 +582,8 @@
     return attributes;
 }
 
-std::vector<uint32_t> Repository::prune()
+std::vector<uint32_t>
+    Repository::prune(const std::vector<uint32_t>& idsWithHwIsoEntry)
 {
     std::vector<uint32_t> obmcLogIDs;
     std::string msg = "Pruning PEL repository that takes up " +
@@ -650,16 +651,19 @@
 
     // Check all 4 categories, which will result in at most 90%
     // usage (15 + 30 + 15 + 30).
-    removePELs(overBMCInfoLimit, isBMCInfo, obmcLogIDs);
-    removePELs(overBMCNonInfoLimit, isBMCNonInfo, obmcLogIDs);
-    removePELs(overNonBMCInfoLimit, isNonBMCInfo, obmcLogIDs);
-    removePELs(overNonBMCNonInfoLimit, isNonBMCNonInfo, obmcLogIDs);
+    removePELs(overBMCInfoLimit, isBMCInfo, idsWithHwIsoEntry, obmcLogIDs);
+    removePELs(overBMCNonInfoLimit, isBMCNonInfo, idsWithHwIsoEntry,
+               obmcLogIDs);
+    removePELs(overNonBMCInfoLimit, isNonBMCInfo, idsWithHwIsoEntry,
+               obmcLogIDs);
+    removePELs(overNonBMCNonInfoLimit, isNonBMCNonInfo, idsWithHwIsoEntry,
+               obmcLogIDs);
 
     // After the above pruning check if there are still too many PELs,
     // which can happen depending on PEL sizes.
     if (_pelAttributes.size() > _maxNumPELs)
     {
-        removePELs(tooManyPELsLimit, isAnyPEL, obmcLogIDs);
+        removePELs(tooManyPELsLimit, isAnyPEL, idsWithHwIsoEntry, obmcLogIDs);
     }
 
     if (!obmcLogIDs.empty())
@@ -674,6 +678,7 @@
 
 void Repository::removePELs(IsOverLimitFunc& isOverLimit,
                             IsPELTypeFunc& isPELType,
+                            const std::vector<uint32_t>& idsWithHwIsoEntry,
                             std::vector<uint32_t>& removedBMCLogIDs)
 {
     if (!isOverLimit())
@@ -712,6 +717,15 @@
             if (isPELType(pel.second) && stateCheck(pel.second))
             {
                 auto removedID = pel.first.obmcID.id;
+
+                auto idFound = std::find(idsWithHwIsoEntry.begin(),
+                                         idsWithHwIsoEntry.end(), removedID);
+                if (idFound != idsWithHwIsoEntry.end())
+                {
+                    ++it;
+                    continue;
+                }
+
                 remove(pel.first);
 
                 removedBMCLogIDs.push_back(removedID);