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