PEL: Maintenance procedure callout definitions
A maintenance procedure is a short string that resides in the FRU
identity structure in the SRC section of a PEL that maps to a service
procedure in the service documentation.
This commit adds the initial framework for dealing with these by adding
an enum type to specify them, and a pel_values.hpp function to get the
actual string value of the maintenance procedure based on its enum.
A single procedure is created in this commit, NoVPDforFRU, which will
be used in a future commit when the location code, part number, etc,
aren't available when trying to do a callout and so this procedure will
be used instead.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I45f366e98794462c70d851f743e4f497c0af77b4
diff --git a/extensions/openpower-pels/pel_types.hpp b/extensions/openpower-pels/pel_types.hpp
index 9a33ccf..d23ebe8 100644
--- a/extensions/openpower-pels/pel_types.hpp
+++ b/extensions/openpower-pels/pel_types.hpp
@@ -130,5 +130,13 @@
acked = 3
};
+/**
+ * @brief Maintenance procedure enums
+ */
+enum class MaintProcedure
+{
+ noVPDforFRU
+};
+
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/pel_values.cpp b/extensions/openpower-pels/pel_values.cpp
index 7e7f93b..9fb6f05 100644
--- a/extensions/openpower-pels/pel_values.cpp
+++ b/extensions/openpower-pels/pel_values.cpp
@@ -16,6 +16,7 @@
#include "pel_values.hpp"
#include <algorithm>
+#include <cassert>
namespace openpower
{
@@ -24,9 +25,6 @@
namespace pel_values
{
-// Note: The description fields will be filled in as part of the
-// PEL parser work.
-
/**
* The possible values for the subsystem field in the User Header.
*/
@@ -213,6 +211,12 @@
{0x43, "medium_group_c", "Medium Priority C, replace these as a group"},
{0x4C, "low", "Lowest priority replacement"}};
+/**
+ * @brief The possible maintenance procedures.
+ */
+const MaintenanceProcedureValues maintenanceProcedures = {
+ {MaintProcedure::noVPDforFRU, "no_vpd_for_fru", "BMCSP01"}};
+
PELValues::const_iterator findByValue(uint32_t value, const PELValues& fields)
{
return std::find_if(fields.begin(), fields.end(),
@@ -324,6 +328,21 @@
});
return foundValues;
}
+
+MaintenanceProcedureValues::const_iterator
+ getMaintProcedure(MaintProcedure procedure)
+{
+ auto proc =
+ std::find_if(maintenanceProcedures.begin(), maintenanceProcedures.end(),
+ [procedure](const auto& entry) {
+ return std::get<mpEnumPos>(entry) == procedure;
+ });
+
+ assert(proc != maintenanceProcedures.end());
+
+ return proc;
+}
+
} // namespace pel_values
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/pel_values.hpp b/extensions/openpower-pels/pel_values.hpp
index d7d4226..163c6da 100644
--- a/extensions/openpower-pels/pel_values.hpp
+++ b/extensions/openpower-pels/pel_values.hpp
@@ -26,6 +26,19 @@
using PELFieldValue = std::tuple<uint32_t, const char*, const char*>;
using PELValues = std::vector<PELFieldValue>;
+// The maintenance procedure enum
+const int mpEnumPos = 0;
+
+// The maintenance procedure value from the registry
+const int mpRegistryNamePos = 1;
+
+// The string name of the maintenance procedure
+const int mpNamePos = 2;
+
+using MaintenanceProcedureValue =
+ std::tuple<MaintProcedure, const char*, const char*>;
+using MaintenanceProcedureValues = std::vector<MaintenanceProcedureValue>;
+
const std::string sectionVer = "Section Version";
const std::string subSection = "Sub-section type";
const std::string createdBy = "Created by";
@@ -72,6 +85,19 @@
const PELValues& fields);
/**
+ * @brief Finds the entry in the maintenance procedure list
+ * based on the enum passed in.
+ *
+ * The function asserts that a result is found.
+ *
+ * @param[in] procedure - The procedure enum
+ *
+ * @return const_iterator - Iterator for that list entry
+ */
+MaintenanceProcedureValues::const_iterator
+ getMaintProcedure(MaintProcedure procedure);
+
+/**
* @brief The values for the 'subsystem' field in the User Header
*/
extern const PELValues subsystemValues;
@@ -131,6 +157,13 @@
*/
extern const std::map<bool, std::string> boolString;
+/**
+ * @brief All maintenance procedures.
+ *
+ * The procedure enum, registry name, and actual string value.
+ */
+extern const MaintenanceProcedureValues maintenanceProcedures;
+
} // namespace pel_values
} // namespace pels
} // namespace openpower
diff --git a/extensions/openpower-pels/registry/schema/registry_example.json b/extensions/openpower-pels/registry/schema/registry_example.json
index 89ae168..84071ec 100644
--- a/extensions/openpower-pels/registry/schema/registry_example.json
+++ b/extensions/openpower-pels/registry/schema/registry_example.json
@@ -63,7 +63,7 @@
[
{
"Priority": "high",
- "Procedure": "PSUPPLY"
+ "Procedure": "no_vpd_for_fru"
}
]
}
diff --git a/extensions/openpower-pels/registry/schema/schema.json b/extensions/openpower-pels/registry/schema/schema.json
index 035e538..1921ebd 100644
--- a/extensions/openpower-pels/registry/schema/schema.json
+++ b/extensions/openpower-pels/registry/schema/schema.json
@@ -394,9 +394,9 @@
"procedure":
{
- "description": "The 7 character procedure callout name.",
+ "description": "The maintenance procedure callout.",
"type": "string",
- "pattern": "^[A-Z0-9]{7}$"
+ "enum": ["no_vpd_for_fru"]
},
"calloutType":
diff --git a/test/openpower-pels/pel_values_test.cpp b/test/openpower-pels/pel_values_test.cpp
index 843cb07..b90ccca 100644
--- a/test/openpower-pels/pel_values_test.cpp
+++ b/test/openpower-pels/pel_values_test.cpp
@@ -17,6 +17,7 @@
#include <gtest/gtest.h>
+using namespace openpower::pels;
using namespace openpower::pels::pel_values;
TEST(PELFieldsTest, TestFindFields)
@@ -37,4 +38,9 @@
s = findByName("foo", subsystemValues);
ASSERT_EQ(s, subsystemValues.end());
+
+ auto p = getMaintProcedure(MaintProcedure::noVPDforFRU);
+ ASSERT_NE(p, maintenanceProcedures.end());
+ ASSERT_EQ("no_vpd_for_fru", std::get<mpRegistryNamePos>(*p));
+ ASSERT_EQ("BMCSP01", std::get<mpNamePos>(*p));
}