Move root cause filter support to separate source file
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I73527c672bab5bd33ec48cf6d07a1cc7d746faa3
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index 05d9f42..5df6295 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -1,21 +1,13 @@
#include <assert.h>
-#include <libpdbg.h>
#include <unistd.h>
#include <analyzer/ras-data/ras-data-parser.hpp>
#include <analyzer/service_data.hpp>
#include <attn/attn_dump.hpp>
#include <hei_main.hpp>
-#include <phosphor-logging/log.hpp>
#include <util/pdbg.hpp>
#include <util/trace.hpp>
-#include <algorithm>
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <string>
-
namespace analyzer
{
@@ -30,6 +22,15 @@
void initializeIsolator(std::vector<libhei::Chip>& o_chips);
/**
+ * @brief Will get the list of active chip and initialize the isolator.
+ * @param i_isoData The data gathered during isolation (for FFDC).
+ * @param o_rootCause The returned root cause signature.
+ * @return True, if root cause has been found. False, otherwise.
+ */
+bool filterRootCause(const libhei::IsolationData& i_isoData,
+ libhei::Signature& o_rootCause);
+
+/**
* @brief Will create and submit a PEL using the given data.
* @param i_isoData The data gathered during isolation (for FFDC).
* @param i_servData Data regarding service actions gathered during analysis.
@@ -69,59 +70,6 @@
//------------------------------------------------------------------------------
-bool __filterRootCause(const libhei::IsolationData& i_isoData,
- libhei::Signature& o_signature)
-{
- // We'll need to make a copy of the list so that the original list is
- // maintained for the log.
- std::vector<libhei::Signature> sigList{i_isoData.getSignatureList()};
-
- // For debug, trace out the original list of signatures before filtering.
- for (const auto& sig : sigList)
- {
- trace::inf("Signature: %s 0x%0" PRIx32 " %s",
- util::pdbg::getPath(sig.getChip()), sig.toUint32(),
- __attn(sig.getAttnType()));
- }
-
- // Special and host attentions are not supported by this user application.
- auto newEndItr =
- std::remove_if(sigList.begin(), sigList.end(), [&](const auto& t) {
- return (libhei::ATTN_TYPE_SP_ATTN == t.getAttnType() ||
- libhei::ATTN_TYPE_HOST_ATTN == t.getAttnType());
- });
-
- // Shrink the vector, if needed.
- sigList.resize(std::distance(sigList.begin(), newEndItr));
-
- // START WORKAROUND
- // TODO: Filtering should be determined by the RAS Data Files provided by
- // the host firmware via the PNOR (similar to the Chip Data Files).
- // Until that support is available, use a rudimentary filter that
- // first looks for any recoverable attention, then any unit checkstop,
- // and then any system checkstop. This is built on the premise that
- // recoverable errors could be the root cause of an system checkstop
- // attentions. Fortunately, we just need to sort the list by the
- // greater attention type value.
- std::sort(sigList.begin(), sigList.end(),
- [&](const auto& a, const auto& b) {
- return a.getAttnType() > b.getAttnType();
- });
- // END WORKAROUND
-
- // Check if a root cause attention was found.
- if (!sigList.empty())
- {
- // The entry at the front of the list will be the root cause.
- o_signature = sigList.front();
- return true;
- }
-
- return false; // default, no active attentions found.
-}
-
-//------------------------------------------------------------------------------
-
bool analyzeHardware(attn::DumpParameters& o_dumpParameters)
{
bool attnFound = false;
@@ -144,9 +92,17 @@
libhei::IsolationData isoData{};
libhei::isolate(chips, isoData);
+ // For debug, trace out the original list of signatures before filtering.
+ for (const auto& sig : isoData.getSignatureList())
+ {
+ trace::inf("Signature: %s 0x%0" PRIx32 " %s",
+ util::pdbg::getPath(sig.getChip()), sig.toUint32(),
+ __attn(sig.getAttnType()));
+ }
+
// Filter for root cause attention.
libhei::Signature rootCause{};
- attnFound = __filterRootCause(isoData, rootCause);
+ attnFound = filterRootCause(isoData, rootCause);
if (!attnFound)
{
diff --git a/analyzer/filter-root-cause.cpp b/analyzer/filter-root-cause.cpp
new file mode 100644
index 0000000..421c674
--- /dev/null
+++ b/analyzer/filter-root-cause.cpp
@@ -0,0 +1,54 @@
+#include <assert.h>
+
+#include <hei_main.hpp>
+
+#include <algorithm>
+#include <limits>
+#include <string>
+
+namespace analyzer
+{
+
+//------------------------------------------------------------------------------
+
+bool filterRootCause(const libhei::IsolationData& i_isoData,
+ libhei::Signature& o_rootCause)
+{
+ // We'll need to make a copy of the list so that the original list is
+ // maintained for the log.
+ std::vector<libhei::Signature> list{i_isoData.getSignatureList()};
+
+ // START WORKAROUND
+ // TODO: Filtering should be data driven. Until that support is available,
+ // use the following isolation rules.
+
+ // Special and host attentions are not supported by this user application.
+ auto itr = std::remove_if(list.begin(), list.end(), [&](const auto& t) {
+ return (libhei::ATTN_TYPE_SP_ATTN == t.getAttnType() ||
+ libhei::ATTN_TYPE_HOST_ATTN == t.getAttnType());
+ });
+ list.resize(std::distance(list.begin(), itr));
+
+ // TODO: This is a rudimentary filter that first looks for any recoverable
+ // attention, then any unit checkstop, and then any system checkstop.
+ // This is built on the premise that recoverable errors could be the
+ // root cause of an system checkstop attentions. Fortunately, we
+ // just need to sort the list by the greater attention type value.
+ std::sort(list.begin(), list.end(), [&](const auto& a, const auto& b) {
+ return a.getAttnType() > b.getAttnType();
+ });
+ if (!list.empty())
+ {
+ // The entry at the front of the list will be the root cause.
+ o_rootCause = list.front();
+ return true;
+ }
+
+ // END WORKAROUND
+
+ return false; // default, no active attentions found.
+}
+
+//------------------------------------------------------------------------------
+
+} // namespace analyzer
diff --git a/analyzer/meson.build b/analyzer/meson.build
index 18fb57c..9324392 100644
--- a/analyzer/meson.build
+++ b/analyzer/meson.build
@@ -2,6 +2,7 @@
analyzer_src = files(
'analyzer_main.cpp',
'create_pel.cpp',
+ 'filter-root-cause.cpp',
'guard.cpp',
'hei_user_interface.cpp',
'initialize_isolator.cpp',