PEL: Logic to enqueue a PEL to send to host

Fill in the function to determine if a PEL needs to be placed on the
qeueue to be sent up to the host.  It involves checking both the host
and HMC transmission states, as well as the PEL action flags field.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I9f1a9fba1b7e6dc7a167f1c7e9dfd6c40d90883f
diff --git a/extensions/openpower-pels/host_notifier.cpp b/extensions/openpower-pels/host_notifier.cpp
index ec5db41..2956b66 100644
--- a/extensions/openpower-pels/host_notifier.cpp
+++ b/extensions/openpower-pels/host_notifier.cpp
@@ -76,6 +76,34 @@
 bool HostNotifier::enqueueRequired(uint32_t id) const
 {
     bool required = true;
+    Repository::LogID i{Repository::LogID::Pel{id}};
+
+    if (auto attributes = _repo.getPELAttributes(i); attributes)
+    {
+        auto a = attributes.value().get();
+
+        if ((a.hostState == TransmissionState::acked) ||
+            (a.hostState == TransmissionState::badPEL))
+        {
+            required = false;
+        }
+        else if (a.actionFlags.test(hiddenFlagBit) &&
+                 (a.hmcState == TransmissionState::acked))
+        {
+            required = false;
+        }
+        else if (a.actionFlags.test(dontReportToHostFlagBit))
+        {
+            required = false;
+        }
+    }
+    else
+    {
+        using namespace phosphor::logging;
+        log<level::ERR>("Host Enqueue: Unable to find PEL ID in repository",
+                        entry("PEL_ID=0x%X", id));
+        required = false;
+    }
 
     return required;
 }