pel-quiesce: quiesce on error pels with callout

The PEL requirement is that if a nonInfo host PEL is logged, it has a
callout of any type within it, and the QuiesceOnHwError is enabled,
then the boot block / quiesce functionality should be executed.

Tested:

1) Verified nothing occurs when QuiesceOnHwError is not enabled

2) Injected info PEL with no callout and unrecoverable error with no
   callout with QuiesceOnHwError enabled and verified no actions were
   taken.

3) Injected Error PEL with callout and QuiesceOnHwError enabled
   and verified boot block logic was enabled.

Error inject which will create PEL with callout:
busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create Create ssa{ss} org.open_power.Logging.Error.TestError1 xyz.openbmc_project.Logging.Entry.Level.Error 0

Journal from fail:
Sep 09 14:03:30 w56 phosphor-log-manager[264]: Created PEL 0x50000266 (BMC ID 340) with SRC BD802003
Sep 09 14:03:30 w56 phosphor-log-manager[264]: QuiesceOnHwError enabled, PEL severity not nonError, and callout is present
Sep 09 14:03:30 w56 phosphor-log-manager[264]: QuiesceOnError set and callout present
Sep 09 14:03:30 w56 systemd[1]: Reached target Quiesce Target.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I09e3ced608ffd2661d9cf015a24d4e0d8a6a84bd
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index fa6bc59..3c9b2cb 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -156,6 +156,9 @@
             log<level::ERR>("Unable to add PEL to Repository",
                             entry("PEL_ID=0x%X", pel->id()));
         }
+
+        // Check if firmware should quiesce system due to error
+        checkPelAndQuiesce(pel);
     }
     else
     {
@@ -349,6 +352,9 @@
     // Activate any resulting service indicators if necessary
     auto policy = service_indicators::getPolicy(*_dataIface);
     policy->activate(*pel);
+
+    // Check if firmware should quiesce system due to error
+    checkPelAndQuiesce(pel);
 }
 
 sdbusplus::message::unix_fd Manager::getPEL(uint32_t pelID)
@@ -580,5 +586,29 @@
     return {0, 0};
 }
 
+void Manager::checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel)
+{
+    if (pel->userHeader().severity() ==
+        static_cast<uint8_t>(SeverityType::nonError))
+    {
+        log<level::DEBUG>("PEL severity informational. no quiesce needed");
+        return;
+    }
+    if (!_logManager.isQuiesceOnErrorEnabled())
+    {
+        log<level::DEBUG>("QuiesceOnHwError not enabled, no quiesce needed");
+        return;
+    }
+
+    // Now check if it has any type of callout
+    if (pel->isCalloutPresent())
+    {
+        log<level::INFO>("QuiesceOnHwError enabled, PEL severity not nonError, "
+                         "and callout is present");
+
+        _logManager.quiesceOnError(pel->obmcLogID());
+    }
+}
+
 } // namespace pels
 } // namespace openpower