Jason M. Bills | 99b78ec | 2019-01-18 10:42:18 -0800 | [diff] [blame] | 1 | /* |
| 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 Szlendak | d2220cc | 2020-04-17 15:00:12 +0200 | [diff] [blame] | 18 | #include <boost/algorithm/string/join.hpp> |
| 19 | #include <phosphor-logging/log.hpp> |
Jason M. Bills | 99b78ec | 2019-01-18 10:42:18 -0800 | [diff] [blame] | 20 | #include <storagecommands.hpp> |
| 21 | |
| 22 | namespace intel_oem::ipmi::sel |
| 23 | { |
Jason M. Bills | 6dd8f04 | 2019-04-11 10:39:02 -0700 | [diff] [blame] | 24 | bool 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 Ray | 9e58cfe | 2021-11-01 13:17:27 -0700 | [diff] [blame] | 29 | bool checkRedfishHooks(uint16_t generatorID, uint8_t evmRev, uint8_t sensorType, |
Jason M. Bills | 99b78ec | 2019-01-18 10:42:18 -0800 | [diff] [blame] | 30 | uint8_t sensorNum, uint8_t eventType, uint8_t eventData1, |
| 31 | uint8_t eventData2, uint8_t eventData3); |
| 32 | namespace redfish_hooks |
| 33 | { |
| 34 | struct SELData |
| 35 | { |
| 36 | int generatorID; |
| 37 | int sensorNum; |
| 38 | int eventType; |
| 39 | int offset; |
| 40 | int eventData2; |
| 41 | int eventData3; |
| 42 | }; |
| 43 | |
| 44 | enum class BIOSSensors |
| 45 | { |
| 46 | memoryRASConfigStatus = 0x02, |
| 47 | biosPOSTError = 0x06, |
| 48 | intelUPILinkWidthReduced = 0x09, |
| 49 | memoryRASModeSelect = 0x12, |
| 50 | bootEvent = 0x83, |
| 51 | }; |
| 52 | |
| 53 | enum 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 | |
| 67 | enum 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 Szlendak | d2220cc | 2020-04-17 15:00:12 +0200 | [diff] [blame] | 79 | |
| 80 | static 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 Williams | b37abfb | 2023-05-10 07:50:33 -0500 | [diff] [blame] | 85 | std::string messageID = "OpenBMC." + openBMCMessageRegistryVersion + |
| 86 | ".SELEntryAdded"; |
Agnieszka Szlendak | d2220cc | 2020-04-17 15:00:12 +0200 | [diff] [blame] | 87 | |
| 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. Bills | 99b78ec | 2019-01-18 10:42:18 -0800 | [diff] [blame] | 103 | } // namespace redfish_hooks |
| 104 | } // namespace intel_oem::ipmi::sel |