spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 1 | /** |
Patrick Venture | e84b4dd | 2018-11-01 16:06:31 -0700 | [diff] [blame] | 2 | * Copyright (C) 2017 IBM Corporation |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 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 | */ |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 16 | #include "cfam_access.hpp" |
| 17 | #include "p9_cfam.hpp" |
| 18 | #include "registration.hpp" |
| 19 | #include "targeting.hpp" |
| 20 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 21 | #include <phosphor-logging/log.hpp> |
| 22 | |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 23 | namespace openpower |
| 24 | { |
| 25 | namespace p9 |
| 26 | { |
| 27 | namespace debug |
| 28 | { |
| 29 | // SBE messaging register - cfam 2809 |
| 30 | union sbeMsgReg_t |
| 31 | { |
| 32 | uint32_t data32; |
| 33 | |
| 34 | struct |
| 35 | { |
| 36 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 37 | uint32_t reserved2 : 6; |
| 38 | uint32_t minorStep : 6; |
| 39 | uint32_t majorStep : 8; |
| 40 | uint32_t currState : 4; |
| 41 | uint32_t prevState : 4; |
| 42 | uint32_t reserved1 : 2; |
| 43 | uint32_t asyncFFDC : 1; |
| 44 | uint32_t sbeBooted : 1; |
| 45 | #else |
| 46 | uint32_t sbeBooted : 1; |
| 47 | uint32_t asyncFFDC : 1; |
| 48 | uint32_t reserved1 : 2; |
| 49 | uint32_t prevState : 4; |
| 50 | uint32_t currState : 4; |
| 51 | uint32_t majorStep : 8; |
| 52 | uint32_t minorStep : 6; |
| 53 | uint32_t reserved2 : 6; |
| 54 | #endif |
Lakshminarayana R. Kammath | 75912e8 | 2020-04-28 07:37:17 -0500 | [diff] [blame] | 55 | } PACK; |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | // HB mailbox scratch register 5 - cfam 283C |
| 59 | union MboxScratch5_HB_t |
| 60 | { |
| 61 | uint32_t data32; |
| 62 | struct |
| 63 | { |
| 64 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 65 | uint32_t minorStep : 8; // 24:31 |
| 66 | uint32_t majorStep : 8; // 16:23 |
| 67 | uint32_t internalStep : 4; // 12:15 |
| 68 | uint32_t reserved : 2; // 10:11 |
| 69 | uint32_t stepFinish : 1; // 9 |
| 70 | uint32_t stepStart : 1; // 8 |
| 71 | uint32_t magic : 8; // 0:7 |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 72 | #else |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 73 | uint32_t magic : 8; // 0:7 |
| 74 | uint32_t stepStart : 1; // 8 |
| 75 | uint32_t stepFinish : 1; // 9 |
| 76 | uint32_t reserved : 2; // 10:11 |
| 77 | uint32_t internalStep : 4; // 12:15 |
| 78 | uint32_t majorStep : 8; // 16:23 |
| 79 | uint32_t minorStep : 8; // 24:31 |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 80 | #endif |
Lakshminarayana R. Kammath | 75912e8 | 2020-04-28 07:37:17 -0500 | [diff] [blame] | 81 | } PACK; |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | static constexpr uint8_t HB_MBX5_VALID_FLAG = 0xAA; |
| 85 | |
| 86 | /** |
| 87 | * @brief Capture SBE and HB istep information on watchdog timeout |
| 88 | * @return void |
| 89 | */ |
| 90 | void collectSBEHBData() |
| 91 | { |
| 92 | using namespace openpower::targeting; |
| 93 | using namespace openpower::cfam::p9; |
| 94 | using namespace openpower::cfam::access; |
| 95 | using namespace phosphor::logging; |
| 96 | |
| 97 | Targeting targets; |
| 98 | |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 99 | for (const auto& proc : targets) |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 100 | { |
| 101 | // Read and parse SBE messaging register |
| 102 | try |
| 103 | { |
| 104 | auto readData = readReg(proc, P9_SBE_MSG_REGISTER); |
| 105 | auto msg = reinterpret_cast<const sbeMsgReg_t*>(&readData); |
| 106 | log<level::INFO>("SBE status register", |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 107 | entry("PROC=%d", proc->getPos()), |
Lakshminarayana R. Kammath | 75912e8 | 2020-04-28 07:37:17 -0500 | [diff] [blame] | 108 | entry("SBE_MAJOR_ISTEP=%d", msg->PACK.majorStep), |
| 109 | entry("SBE_MINOR_ISTEP=%d", msg->PACK.minorStep), |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 110 | entry("REG_VAL=0x%08X", msg->data32)); |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 111 | } |
| 112 | catch (const std::exception& e) |
| 113 | { |
| 114 | log<level::ERR>(e.what()); |
| 115 | // We want to continue - capturing as much info as possible |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | const auto& master = *(targets.begin()); |
| 120 | // Read and parse HB messaging register |
| 121 | try |
| 122 | { |
| 123 | auto readData = readReg(master, P9_HB_MBX5_REG); |
| 124 | auto msg = reinterpret_cast<const MboxScratch5_HB_t*>(&readData); |
Lakshminarayana R. Kammath | 75912e8 | 2020-04-28 07:37:17 -0500 | [diff] [blame] | 125 | if (HB_MBX5_VALID_FLAG == msg->PACK.magic) |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 126 | { |
| 127 | log<level::INFO>("HB MBOX 5 register", |
Lakshminarayana R. Kammath | 75912e8 | 2020-04-28 07:37:17 -0500 | [diff] [blame] | 128 | entry("HB_MAJOR_ISTEP=%d", msg->PACK.majorStep), |
| 129 | entry("HB_MINOR_ISTEP=%d", msg->PACK.minorStep), |
Patrick Venture | f78d904 | 2018-11-01 15:39:53 -0700 | [diff] [blame] | 130 | entry("REG_VAL=0x%08X", msg->data32)); |
spashabk-in | 6ebf5ca | 2017-09-19 04:11:38 -0500 | [diff] [blame] | 131 | } |
| 132 | } |
| 133 | catch (const std::exception& e) |
| 134 | { |
| 135 | log<level::ERR>(e.what()); |
| 136 | // We want to continue - capturing as much info as possible |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | REGISTER_PROCEDURE("collectSBEHBData", collectSBEHBData); |
| 141 | |
| 142 | } // namespace debug |
| 143 | } // namespace p9 |
| 144 | } // namespace openpower |