PEL: Create FailingMTMS section for new PELs

When a PEL is created from an OpenBMC event log, add the FailingMTMS
section to the PEL. This contains the machine type, model, and serial
number fields.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I8d08e6dda00260efebd2c6ac165270d2aaf98d67
diff --git a/extensions/openpower-pels/failing_mtms.cpp b/extensions/openpower-pels/failing_mtms.cpp
index 1b15c16..b60ce31 100644
--- a/extensions/openpower-pels/failing_mtms.cpp
+++ b/extensions/openpower-pels/failing_mtms.cpp
@@ -20,6 +20,8 @@
     _header.version = failingMTMSVersion;
     _header.subType = 0;
     _header.componentID = static_cast<uint16_t>(ComponentID::phosphorLogging);
+
+    _valid = true;
 }
 
 FailingMTMS::FailingMTMS(Stream& pel)
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 2141a71..bc62bd3 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -116,8 +116,8 @@
     {
         AdditionalData ad{additionalData};
 
-        auto pel =
-            std::make_unique<PEL>(*entry, obmcLogID, timestamp, severity, ad);
+        auto pel = std::make_unique<PEL>(*entry, obmcLogID, timestamp, severity,
+                                         ad, *_dataIface);
 
         _repo.add(pel);
     }
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index 157af5a..ffd4974 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -1,6 +1,7 @@
 #include "pel.hpp"
 
 #include "bcd_time.hpp"
+#include "failing_mtms.hpp"
 #include "log_id.hpp"
 #include "section_factory.hpp"
 #include "src.hpp"
@@ -16,7 +17,8 @@
 
 PEL::PEL(const message::Entry& entry, uint32_t obmcLogID, uint64_t timestamp,
          phosphor::logging::Entry::Level severity,
-         const AdditionalData& additionalData)
+         const AdditionalData& additionalData,
+         const DataInterfaceBase& dataIface)
 {
     _ph = std::make_unique<PrivateHeader>(entry.componentID, obmcLogID,
                                           timestamp);
@@ -25,7 +27,8 @@
     auto src = std::make_unique<SRC>(entry, additionalData);
     _optionalSections.push_back(std::move(src));
 
-    // Add future sections here
+    auto mtms = std::make_unique<FailingMTMS>(dataIface);
+    _optionalSections.push_back(std::move(mtms));
 
     _ph->sectionCount() = 2 + _optionalSections.size();
 }
diff --git a/extensions/openpower-pels/pel.hpp b/extensions/openpower-pels/pel.hpp
index 9f34b62..bc857e2 100644
--- a/extensions/openpower-pels/pel.hpp
+++ b/extensions/openpower-pels/pel.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "additional_data.hpp"
+#include "data_interface.hpp"
 #include "private_header.hpp"
 #include "registry.hpp"
 #include "src.hpp"
@@ -85,10 +86,12 @@
      * @param[in] timestamp - Timestamp from the event log
      * @param[in] severity - Severity from the event log
      * @param[in] additionalData - The AdditionalData contents
+     * @param[in] dataIface - The data interface object
      */
     PEL(const openpower::pels::message::Entry& entry, uint32_t obmcLogID,
         uint64_t timestamp, phosphor::logging::Entry::Level severity,
-        const AdditionalData& additionalData);
+        const AdditionalData& additionalData,
+        const DataInterfaceBase& dataIface);
 
     /**
      * @brief Convenience function to return the log ID field from the
diff --git a/test/openpower-pels/pel_test.cpp b/test/openpower-pels/pel_test.cpp
index 1f9917a..b0c6528 100644
--- a/test/openpower-pels/pel_test.cpp
+++ b/test/openpower-pels/pel_test.cpp
@@ -1,6 +1,7 @@
 #include "elog_entry.hpp"
 #include "extensions/openpower-pels/generic.hpp"
 #include "extensions/openpower-pels/pel.hpp"
+#include "mocks.hpp"
 #include "pel_utils.hpp"
 
 #include <filesystem>
@@ -121,9 +122,10 @@
     regEntry.src.reasonCode = 0x1234;
 
     AdditionalData ad;
+    MockDataInterface dataIface;
 
-    PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error,
-            ad};
+    PEL pel{regEntry, 42, timestamp, phosphor::logging::Entry::Level::Error, ad,
+            dataIface};
 
     EXPECT_TRUE(pel.valid());
     EXPECT_EQ(pel.privateHeader()->obmcLogID(), 42);
@@ -131,8 +133,6 @@
 
     EXPECT_EQ(pel.primarySRC().value()->asciiString(),
               "BD051234                        ");
-
-    // Add more checks as more sections are added
 }
 
 // Test that we'll create Generic optional sections for sections that