summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2019-02-04 14:06:58 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2019-02-04 14:21:37 +0530
commite19540e6d8e96e205978712a698e83f676553360 (patch)
treee16ef41c24770c7771268e96130b81f7258348da
parent73906b9c9123218a7f8fc86db34957b965c53870 (diff)
downloadphosphor-host-ipmid-e19540e6d8e96e205978712a698e83f676553360.zip
phosphor-host-ipmid-e19540e6d8e96e205978712a698e83f676553360.tar.gz
Revert "eSEL: Remove unused code related to logging eSEL"
This reverts commit 54fad6de0541c2f98e9b511f1d30bbcbcd743db6. This commit is reverted because the mapping of D-Bus object path to sensor information is still needed. The mapping is needed to serve the SEL commands which translate D-Bus logging objects to SEL entries. Change-Id: I2505299671db1f0bd7f116ef0e2ca4a0273eead8
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac4
-rwxr-xr-xscripts/inventory-sensor-example.yaml340
-rwxr-xr-xscripts/inventory-sensor.py60
-rw-r--r--scripts/inventorysensor.mako.cpp27
-rw-r--r--storageaddsel.cpp220
-rw-r--r--storageaddsel.hpp2
-rw-r--r--storagehandler.cpp4
8 files changed, 658 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 9a16082..48aa48f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@ nodist_ipmid_SOURCES = ipmiwhitelist.cpp
libipmi20_BUILT_LIST = \
sensor-gen.cpp \
+ inventory-sensor-gen.cpp \
fru-read-gen.cpp \
channel-gen.cpp
diff --git a/configure.ac b/configure.ac
index 1935135..8d5e6dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,10 @@ AS_IF([test "x$SENSOR_YAML_GEN" == "x"], [SENSOR_YAML_GEN="sensor-example.yaml"]
SENSORGEN="$PYTHON ${srcdir}/scripts/sensor_gen.py -i $SENSOR_YAML_GEN"
AC_SUBST(SENSORGEN)
+AS_IF([test "x$INVSENSOR_YAML_GEN" == "x"], [INVSENSOR_YAML_GEN="inventory-sensor-example.yaml"])
+INVSENSORGEN="$PYTHON ${srcdir}/scripts/inventory-sensor.py -i $INVSENSOR_YAML_GEN"
+AC_SUBST(INVSENSORGEN)
+
AS_IF([test "x$FRU_YAML_GEN" == "x"], [FRU_YAML_GEN="fru-read-example.yaml"])
FRUGEN="$PYTHON $srcdir/scripts/fru_gen.py -i $FRU_YAML_GEN"
AC_SUBST(FRUGEN)
diff --git a/scripts/inventory-sensor-example.yaml b/scripts/inventory-sensor-example.yaml
new file mode 100755
index 0000000..7ff78fb
--- /dev/null
+++ b/scripts/inventory-sensor-example.yaml
@@ -0,0 +1,340 @@
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0:
+ sensorID: 0xa6
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1:
+ sensorID: 0xa8
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm10:
+ sensorID: 0xba
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm11:
+ sensorID: 0xbc
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm12:
+ sensorID: 0xbe
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm13:
+ sensorID: 0xc0
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm14:
+ sensorID: 0xc2
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm15:
+ sensorID: 0xc4
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm2:
+ sensorID: 0xaa
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm3:
+ sensorID: 0xac
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm4:
+ sensorID: 0xae
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm5:
+ sensorID: 0xb0
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm6:
+ sensorID: 0xb2
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm7:
+ sensorID: 0xb4
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm8:
+ sensorID: 0xb6
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm9:
+ sensorID: 0xb8
+ sensorType: 0x0C
+ eventReadingType: 0x6F
+ offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0:
+ sensorID: 0x5a
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0:
+ sensorID: 0x12
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1:
+ sensorID: 0x15
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core2:
+ sensorID: 0x18
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core3:
+ sensorID: 0x1b
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core4:
+ sensorID: 0x1e
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core5:
+ sensorID: 0x21
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core6:
+ sensorID: 0x24
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core7:
+ sensorID: 0x27
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core8:
+ sensorID: 0x2a
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core9:
+ sensorID: 0x2d
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core10:
+ sensorID: 0x30
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core11:
+ sensorID: 0x33
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core12:
+ sensorID: 0x36
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core13:
+ sensorID: 0x39
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core14:
+ sensorID: 0x3c
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core15:
+ sensorID: 0x3f
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core16:
+ sensorID: 0x42
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core17:
+ sensorID: 0x45
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core18:
+ sensorID: 0x48
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core19:
+ sensorID: 0x4b
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core20:
+ sensorID: 0x4e
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core21:
+ sensorID: 0x51
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core22:
+ sensorID: 0x54
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core23:
+ sensorID: 0x57
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1:
+ sensorID: 0xa4
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core0:
+ sensorID: 0x5c
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core1:
+ sensorID: 0x5f
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core2:
+ sensorID: 0x62
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core3:
+ sensorID: 0x65
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core4:
+ sensorID: 0x68
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core5:
+ sensorID: 0x6b
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core6:
+ sensorID: 0x6e
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core7:
+ sensorID: 0x71
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core8:
+ sensorID: 0x74
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core9:
+ sensorID: 0x77
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core10:
+ sensorID: 0x7a
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core11:
+ sensorID: 0x7d
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core12:
+ sensorID: 0x80
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core13:
+ sensorID: 0x83
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core14:
+ sensorID: 0x86
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core15:
+ sensorID: 0x89
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core16:
+ sensorID: 0x8c
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core17:
+ sensorID: 0x8f
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core18:
+ sensorID: 0x92
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core19:
+ sensorID: 0x95
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core20:
+ sensorID: 0x98
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core21:
+ sensorID: 0x9b
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core22:
+ sensorID: 0x9e
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core23:
+ sensorID: 0xa1
+ sensorType: 0x07
+ eventReadingType: 0x6F
+ offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard:
+ sensorID: 0x0c
+ sensorType: 0xC7
+ eventReadingType: 0x03
+ offset: 0x00
+/xyz/openbmc_project/inventory/system:
+ sensorID: 0x01
+ sensorType: 0x12
+ eventReadingType: 0x6F
+ offset: 0x02
diff --git a/scripts/inventory-sensor.py b/scripts/inventory-sensor.py
new file mode 100755
index 0000000..77222f5
--- /dev/null
+++ b/scripts/inventory-sensor.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import yaml
+import argparse
+from mako.template import Template
+
+
+def generate_cpp(sensor_yaml, output_dir):
+ with open(os.path.join(script_dir, sensor_yaml), 'r') as f:
+ ifile = yaml.safe_load(f)
+ if not isinstance(ifile, dict):
+ ifile = {}
+
+ # Render the mako template
+
+ t = Template(filename=os.path.join(
+ script_dir,
+ "inventorysensor.mako.cpp"))
+
+ output_cpp = os.path.join(output_dir, "inventory-sensor-gen.cpp")
+ with open(output_cpp, 'w') as fd:
+ fd.write(t.render(sensorDict=ifile))
+
+
+def main():
+
+ valid_commands = {
+ 'generate-cpp': generate_cpp
+ }
+ parser = argparse.ArgumentParser(
+ description="Inventory Object to IPMI SensorID code generator")
+
+ parser.add_argument(
+ '-i', '--sensor_yaml', dest='sensor_yaml',
+ default='example.yaml', help='input sensor yaml file to parse')
+
+ parser.add_argument(
+ "-o", "--output-dir", dest="outputdir",
+ default=".",
+ help="output directory")
+
+ parser.add_argument(
+ 'command', metavar='COMMAND', type=str,
+ choices=valid_commands.keys(),
+ help='Command to run.')
+
+ args = parser.parse_args()
+
+ if (not (os.path.isfile(os.path.join(script_dir, args.sensor_yaml)))):
+ sys.exit("Can not find input yaml file " + args.sensor_yaml)
+
+ function = valid_commands[args.command]
+ function(args.sensor_yaml, args.outputdir)
+
+
+if __name__ == '__main__':
+ script_dir = os.path.dirname(os.path.realpath(__file__))
+ main()
diff --git a/scripts/inventorysensor.mako.cpp b/scripts/inventorysensor.mako.cpp
new file mode 100644
index 0000000..000f758
--- /dev/null
+++ b/scripts/inventorysensor.mako.cpp
@@ -0,0 +1,27 @@
+## This file is a template. The comment below is emitted
+## into the rendered file; feel free to edit this file.
+
+// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
+
+#include "types.hpp"
+using namespace ipmi::sensor;
+
+extern const InvObjectIDMap invSensors = {
+% for key in sensorDict.iterkeys():
+ % if key:
+{"${key}",
+ {
+<%
+ objectPath = sensorDict[key]
+ sensorID = objectPath["sensorID"]
+ sensorType = objectPath["sensorType"]
+ eventReadingType = objectPath["eventReadingType"]
+ offset = objectPath["offset"]
+%>
+ ${sensorID},${sensorType},${eventReadingType},${offset}
+ }
+},
+ % endif
+% endfor
+};
+
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 5cdf535..1dde2a4 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -21,6 +21,7 @@
using namespace std;
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Logging::server;
+extern const ipmi::sensor::InvObjectIDMap invSensors;
//////////////////////////
struct esel_section_headers_t
@@ -32,6 +33,225 @@ struct esel_section_headers_t
uint8_t compid;
};
+struct severity_values_t
+{
+ uint8_t type;
+ Entry::Level level;
+};
+
+const std::vector<severity_values_t> g_sev_desc = {
+ {0x10, Entry::Level::Warning}, // recoverable error
+ {0x20, Entry::Level::Warning}, // predictive error
+ // TODO via github issue 3066 : map level
+ // below to Level::Unrecoverable
+ {0x40, Entry::Level::Error}, // unrecoverable error
+ // TODO via github issue 3066 : map level below
+ // to Level::Critical
+ {0x50, Entry::Level::Error}, // critical error
+ {0x60, Entry::Level::Error}, // error from a diagnostic test
+ {0x70, Entry::Level::Warning}, // recoverable symptom
+ {0xFF, Entry::Level::Error}, // unknown error
+};
+
+Entry::Level sev_lookup(uint8_t n)
+{
+ auto i =
+ std::find_if(std::begin(g_sev_desc), std::end(g_sev_desc),
+ [n](auto p) { return p.type == n || p.type == 0xFF; });
+ return i->level;
+}
+
+int find_sensor_type_string(uint8_t sensor_number, char** s)
+{
+
+ dbus_interface_t a;
+ int r;
+
+ r = find_openbmc_path(sensor_number, &a);
+
+ if ((r < 0) || (a.bus[0] == 0))
+ {
+ // Just make a generic message for errors that
+ // occur on sensors that don't exist
+ r = asprintf(s, "Unknown Sensor (0x%02x)", sensor_number);
+ }
+ else
+ {
+ const char* p;
+
+ if ((p = strrchr(a.path, '/')) == NULL)
+ {
+ p = "/Unknown Sensor";
+ }
+
+ *s = strdup(p + 1);
+ }
+
+ return 0;
+}
+
+size_t getfilestream(const char* fn, uint8_t** buffer)
+{
+
+ FILE* fp;
+ ssize_t size = 0;
+ int r;
+
+ if ((fp = fopen(fn, "rb")) != NULL)
+ {
+
+ r = fseek(fp, 0, SEEK_END);
+ if (r)
+ {
+ log<level::ERR>("Fseek failed");
+ goto fclose_fp;
+ }
+
+ size = ftell(fp);
+ if (size == -1L)
+ {
+ log<level::ERR>("Ftell failed", entry("ERROR=%s", strerror(errno)));
+ size = 0;
+ goto fclose_fp;
+ }
+
+ r = fseek(fp, 0, SEEK_SET);
+ if (r)
+ {
+ log<level::ERR>("Fseek failed");
+ size = 0;
+ goto fclose_fp;
+ }
+
+ *buffer = new uint8_t[size];
+
+ r = fread(*buffer, 1, size, fp);
+ if (r != size)
+ {
+ size = 0;
+ log<level::ERR>("Fread failed\n");
+ }
+
+ fclose_fp:
+ fclose(fp);
+ }
+
+ return static_cast<size_t>(size);
+}
+
+Entry::Level create_esel_severity(const uint8_t* buffer)
+{
+
+ uint8_t severity;
+ // Dive in to the IBM log to find the severity
+ severity = (0xF0 & buffer[0x4A]);
+
+ return sev_lookup(severity);
+}
+
+int create_esel_association(const uint8_t* buffer, std::string& inventoryPath)
+{
+ auto p = reinterpret_cast<const ipmi_add_sel_request_t*>(buffer);
+
+ uint8_t sensor = p->sensornumber;
+
+ inventoryPath = {};
+
+ /*
+ * Search the sensor number to inventory path mapping to figure out the
+ * inventory associated with the ESEL.
+ */
+ auto found = std::find_if(invSensors.begin(), invSensors.end(),
+ [&sensor](const auto& iter) {
+ return (iter.second.sensorID == sensor);
+ });
+ if (found != invSensors.end())
+ {
+ inventoryPath = found->first;
+ }
+
+ return 0;
+}
+
+int create_esel_description(const uint8_t* buffer, Entry::Level level,
+ char** message)
+{
+ char* m;
+ int r;
+
+ auto p = reinterpret_cast<const ipmi_add_sel_request_t*>(buffer);
+
+ find_sensor_type_string(p->sensornumber, &m);
+
+ r = asprintf(message, "A %s has experienced an error of level %d", m,
+ static_cast<uint32_t>(level));
+ if (r == -1)
+ {
+ log<level::ERR>("Failed to allocate memory for ESEL description");
+ }
+
+ free(m);
+
+ return 0;
+}
+
+int send_esel_to_dbus(const char* desc, Entry::Level level,
+ const std::string& inventoryPath, uint8_t* debug,
+ size_t debuglen)
+{
+
+ // Allocate enough space to represent the data in hex separated by spaces,
+ // to mimic how IPMI would display the data.
+ unique_ptr<char[]> selData(new char[(debuglen * 3) + 1]());
+ uint32_t i = 0;
+ for (i = 0; i < debuglen; i++)
+ {
+ sprintf(&selData[i * 3], "%02x ", 0xFF & ((char*)debug)[i]);
+ }
+ selData[debuglen * 3] = '\0';
+
+ using error = sdbusplus::org::open_power::Host::Error::Event;
+ using metadata = org::open_power::Host::Event;
+
+ report<error>(level, metadata::ESEL(selData.get()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
+
+ return 0;
+}
+
+void send_esel(uint16_t recordid)
+{
+ char* desc;
+ uint8_t* buffer = NULL;
+ const char* path = "/tmp/esel";
+ ssize_t sz;
+ int r;
+ std::string inventoryPath;
+
+ sz = getfilestream(path, &buffer);
+ if (sz == 0)
+ {
+ log<level::ERR>("Error file does not exist",
+ entry("FILENAME=%s", path));
+ return;
+ }
+
+ auto sev = create_esel_severity(buffer);
+ create_esel_association(buffer, inventoryPath);
+ create_esel_description(buffer, sev, &desc);
+
+ r = send_esel_to_dbus(desc, sev, inventoryPath, buffer, sz);
+ if (r < 0)
+ {
+ log<level::ERR>("Failed to send esel to dbus");
+ }
+
+ free(desc);
+ delete[] buffer;
+
+ return;
+}
+
std::string readESEL(const char* fileName)
{
std::string content;
diff --git a/storageaddsel.hpp b/storageaddsel.hpp
index e3065b0..c25ead3 100644
--- a/storageaddsel.hpp
+++ b/storageaddsel.hpp
@@ -2,6 +2,8 @@
#include <stdint.h>
+void send_esel(uint16_t recordid);
+
/** @brief Read eSEL data into a string
*
* @param[in] filename - filename of file containing eSEL
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 36449ab..ebd0a20 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -631,6 +631,10 @@ ipmi_ret_t ipmi_storage_add_sel(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
// procedure number.
createProcedureLogEntry(p->sensortype);
}
+ else
+ {
+ send_esel(recordid);
+ }
return rc;
}
OpenPOWER on IntegriCloud