blob: aefc85cb6d4de047ee88b42970c445a0d88fc910 [file] [log] [blame]
Jason M. Bills99b78ec2019-01-18 10:42:18 -08001/*
2// Copyright (c) 2019 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
17#pragma once
Agnieszka Szlendakd2220cc2020-04-17 15:00:12 +020018#include <boost/algorithm/string/join.hpp>
19#include <phosphor-logging/log.hpp>
Jason M. Bills99b78ec2019-01-18 10:42:18 -080020#include <storagecommands.hpp>
21
22namespace intel_oem::ipmi::sel
23{
Jason M. Bills6dd8f042019-04-11 10:39:02 -070024bool checkRedfishHooks(uint16_t recordID, uint8_t recordType,
25 uint32_t timestamp, uint16_t generatorID, uint8_t evmRev,
26 uint8_t sensorType, uint8_t sensorNum, uint8_t eventType,
27 uint8_t eventData1, uint8_t eventData2,
28 uint8_t eventData3);
Sujoy Ray9e58cfe2021-11-01 13:17:27 -070029bool checkRedfishHooks(uint16_t generatorID, uint8_t evmRev, uint8_t sensorType,
Jason M. Bills99b78ec2019-01-18 10:42:18 -080030 uint8_t sensorNum, uint8_t eventType, uint8_t eventData1,
31 uint8_t eventData2, uint8_t eventData3);
32namespace redfish_hooks
33{
34struct SELData
35{
36 int generatorID;
37 int sensorNum;
38 int eventType;
39 int offset;
40 int eventData2;
41 int eventData3;
42};
43
44enum class BIOSSensors
45{
46 memoryRASConfigStatus = 0x02,
47 biosPOSTError = 0x06,
48 intelUPILinkWidthReduced = 0x09,
49 memoryRASModeSelect = 0x12,
50 bootEvent = 0x83,
51};
52
53enum class BIOSSMISensors
54{
55 mirroringRedundancyState = 0x01,
56 memoryECCError = 0x02,
57 legacyPCIError = 0x03,
58 pcieFatalError = 0x04,
59 pcieCorrectableError = 0x05,
60 sparingRedundancyState = 0x11,
61 memoryParityError = 0x13,
62 pcieFatalError2 = 0x14,
63 biosRecovery = 0x15,
64 adddcError = 0x20,
65};
66
67enum class BIOSEventTypes
68{
69 digitalDiscrete = 0x09,
70 discreteRedundancyStates = 0x0b,
71 sensorSpecificOffset = 0x6f,
72 oemDiscrete0 = 0x70,
73 oemDiscrete1 = 0x71,
74 oemDiscrete6 = 0x76,
75 oemDiscrete7 = 0x77,
76 reservedA0 = 0xa0,
77 reservedF0 = 0xf0,
78};
Agnieszka Szlendakd2220cc2020-04-17 15:00:12 +020079
80static inline bool defaultMessageHook(const std::string& ipmiRaw)
81{
82 // Log the record as a default Redfish message instead of a SEL record
83
84 static const std::string openBMCMessageRegistryVersion("0.1");
Patrick Williamsb37abfb2023-05-10 07:50:33 -050085 std::string messageID = "OpenBMC." + openBMCMessageRegistryVersion +
86 ".SELEntryAdded";
Agnieszka Szlendakd2220cc2020-04-17 15:00:12 +020087
88 std::vector<std::string> messageArgs;
89 messageArgs.push_back(ipmiRaw);
90
91 // Log the Redfish message to the journal with the appropriate metadata
92 std::string journalMsg = "SEL Entry Added: " + ipmiRaw;
93 std::string messageArgsString = boost::algorithm::join(messageArgs, ",");
94 phosphor::logging::log<phosphor::logging::level::INFO>(
95 journalMsg.c_str(),
96 phosphor::logging::entry("REDFISH_MESSAGE_ID=%s", messageID.c_str()),
97 phosphor::logging::entry("REDFISH_MESSAGE_ARGS=%s",
98 messageArgsString.c_str()));
99
100 return true;
101}
102
Jason M. Bills99b78ec2019-01-18 10:42:18 -0800103} // namespace redfish_hooks
104} // namespace intel_oem::ipmi::sel