Log a PEL for communication, presence mismatch, and safe state errors
Add code to log a PEL in various error scenarios. Refactor some of the
error handling to get the return code out of the driver.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Change-Id: Ifd91cfc063718e484ec8886df8357d115c6b41e3
diff --git a/occ_ffdc.cpp b/occ_ffdc.cpp
index 0dc8d3c..3ec42be 100644
--- a/occ_ffdc.cpp
+++ b/occ_ffdc.cpp
@@ -5,6 +5,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <fmt/core.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -24,7 +25,8 @@
static constexpr size_t sbe_status_header_size = 8;
static constexpr auto loggingObjectPath = "/xyz/openbmc_project/logging";
-static constexpr auto loggingInterface = "org.open_power.Logging.PEL";
+static constexpr auto loggingInterface = "xyz.openbmc_project.Logging.Create";
+static constexpr auto opLoggingInterface = "org.open_power.Logging.PEL";
using namespace phosphor::logging;
using namespace sdbusplus::org::open_power::OCC::Device::Error;
@@ -60,10 +62,10 @@
try
{
std::string service =
- utils::getService(loggingObjectPath, loggingInterface);
+ utils::getService(loggingObjectPath, opLoggingInterface);
auto method =
bus.new_method_call(service.c_str(), loggingObjectPath,
- loggingInterface, "CreatePELWithFFDCFiles");
+ opLoggingInterface, "CreatePELWithFFDCFiles");
auto level =
sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
@@ -83,6 +85,47 @@
return plid;
}
+void FFDC::createOCCResetPEL(unsigned int instance, const char* path, int err,
+ const char* callout)
+{
+ std::map<std::string, std::string> additionalData;
+
+ additionalData.emplace("_PID", std::to_string(getpid()));
+
+ if (err)
+ {
+ additionalData.emplace("CALLOUT_ERRNO", std::to_string(-err));
+ }
+
+ if (callout)
+ {
+ additionalData.emplace("CALLOUT_DEVICE_PATH", std::string(callout));
+ }
+
+ additionalData.emplace("OCC", std::to_string(instance));
+
+ auto& bus = utils::getBus();
+
+ try
+ {
+ std::string service =
+ utils::getService(loggingObjectPath, loggingInterface);
+ auto method = bus.new_method_call(service.c_str(), loggingObjectPath,
+ loggingInterface, "Create");
+ auto level =
+ sdbusplus::xyz::openbmc_project::Logging::server::convertForMessage(
+ sdbusplus::xyz::openbmc_project::Logging::server::Entry::Level::
+ Error);
+ method.append(path, level, additionalData);
+ bus.call(method);
+ }
+ catch (const sdbusplus::exception::exception& e)
+ {
+ log<level::ERR>(
+ fmt::format("Failed to create PEL: {}", e.what()).c_str());
+ }
+}
+
// Reads the FFDC file and create an error log
void FFDC::analyzeEvent()
{