Jayanth Othayoth | e8bdeea | 2021-06-03 03:01:16 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2021 IBM 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 | #include "sbe_ffdc_handler.hpp" |
| 18 | |
| 19 | #include <fmt/format.h> |
| 20 | |
| 21 | #include <phosphor-logging/log.hpp> |
| 22 | |
| 23 | namespace openpower |
| 24 | { |
| 25 | namespace pels |
| 26 | { |
| 27 | namespace sbe |
| 28 | { |
| 29 | |
| 30 | using namespace phosphor::logging; |
| 31 | |
| 32 | SbeFFDC::SbeFFDC(const AdditionalData& aData, const PelFFDC& files) |
| 33 | { |
| 34 | log<level::INFO>("SBE FFDC processing requested"); |
| 35 | |
| 36 | // SRC6 field in the additional data contains Processor position |
| 37 | // associated to the SBE FFDC |
| 38 | //"[0:15] chip position" |
| 39 | auto src6 = aData.getValue("SRC6"); |
| 40 | if (src6 == std::nullopt) |
| 41 | { |
| 42 | log<level::ERR>("Fail to extract SRC6 data: failing to get proc index"); |
| 43 | return; |
| 44 | } |
| 45 | try |
| 46 | { |
| 47 | procPos = std::stoi((src6.value()).substr(0, 4)); |
| 48 | } |
| 49 | catch (std::exception& err) |
| 50 | { |
| 51 | log<level::ERR>( |
| 52 | fmt::format("Conversion failure errormsg({})", err.what()).c_str()); |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | if (files.empty()) |
| 57 | { |
| 58 | log<level::INFO>("SbeFFDC : No files found, skipping ffdc processing"); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | for (const auto& file : files) |
| 63 | { |
| 64 | if ((file.format == UserDataFormat::custom) && |
| 65 | (file.subType == sbeFFDCSubType)) |
| 66 | { |
| 67 | // TODO Process SBE file. |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | } // namespace sbe |
| 73 | } // namespace pels |
| 74 | } // namespace openpower |