Add SEL Logger Daemon
This change adds a SEL Logger daemon that handles all requests
to add new IPMI SEL records to the journal with the correct
metadata.
The expected metadata for a SEL record are
MESSAGE_ID = Used to identify SEL journal records, the SEL
MESSAGE_ID is b370836ccf2f4850ac5bee185b77893a
IPMI_SEL_RECORD_ID = Two byte unique SEL Record ID
IPMI_SEL_RECORD_TYPE = The type of SEL entry (system or OEM)
which determines the definition of the
remaining bytes
IPMI_SEL_GENERATOR_ID = The IPMI Generator ID (usually the
IPMB Slave Address) of the requester
IPMI_SEL_SENSOR_PATH = D-Bus path of the sensor in the event
IPMI_SEL_EVENT_DIR = Direction of the event (assert or deassert)
IPMI_SEL_DATA = Raw binary data included in the SEL record
It exposes an interface for manually adding System and OEM type SEL
events, and provides the capability to monitor for types of events
and log them automatically.
The interface for System type events requires a text message for the
journal entry, the sensor path, up to three bytes of SEL data, the
direction of the event, and the generator ID of the requester.
The interface for OEM type events requires a text message for the
journal entry, up to thirteen bytes of SEL data (depending on the
record type), and the record type.
The MESSAGE_ID and IPMI_SEL_RECORD_ID metadata are added by the
daemon.
Change-Id: Ib28af2e167826aaa39c0ad14ea1b2f03f51194bc
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/include/sel_logger.hpp b/include/sel_logger.hpp
new file mode 100644
index 0000000..aa9d8d6
--- /dev/null
+++ b/include/sel_logger.hpp
@@ -0,0 +1,39 @@
+/*
+// Copyright (c) 2018 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#pragma once
+
+static constexpr char const *ipmiSelObject = "xyz.openbmc_project.Logging.IPMI";
+static constexpr char const *ipmiSelPath = "/xyz/openbmc_project/Logging/IPMI";
+static constexpr char const *ipmiSelAddInterface =
+ "xyz.openbmc_project.Logging.IPMI";
+
+// ID string generated using journalctl to include in the MESSAGE_ID field for
+// SEL entries. Helps with filtering SEL entries in the journal.
+static constexpr char const *selMessageId = "b370836ccf2f4850ac5bee185b77893a";
+static constexpr int selPriority = 5; // notice
+static constexpr uint8_t selSystemType = 0x02;
+static constexpr uint16_t selBMCGenID = 0x0020;
+static constexpr uint16_t selInvalidRecID =
+ std::numeric_limits<uint16_t>::max();
+static constexpr size_t selEvtDataMaxSize = 3;
+static constexpr size_t selOemDataMaxSize = 13;
+
+static uint16_t selAddSystemRecord(const std::string &message,
+ const std::string &path,
+ const std::vector<uint8_t> &selData,
+ const bool &assert,
+ const uint16_t &genId = selBMCGenID);