Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 1 | #include <analyzer/resolution.hpp> |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 2 | #include <util/pdbg.hpp> |
| 3 | #include <util/trace.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 4 | |
| 5 | namespace analyzer |
| 6 | { |
| 7 | |
Zane Shelley | 2d11432 | 2021-08-25 17:06:12 -0500 | [diff] [blame] | 8 | //------------------------------------------------------------------------------ |
| 9 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 10 | // Helper function to get the root cause chip target from the service data. |
| 11 | pdbg_target* __getRootCauseChipTarget(const ServiceData& i_sd) |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 12 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 13 | auto target = util::pdbg::getTrgt(i_sd.getRootCause().getChip()); |
| 14 | assert(nullptr != target); // This would be a really bad bug. |
| 15 | return target; |
| 16 | } |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 17 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 18 | //------------------------------------------------------------------------------ |
| 19 | |
| 20 | // Helper function to get a unit target from the given unit path, which is a |
| 21 | // devtree path relative the the containing chip. An empty string indicates the |
| 22 | // chip target should be returned. |
| 23 | pdbg_target* __getUnitTarget(pdbg_target* i_chipTarget, |
| 24 | const std::string& i_unitPath) |
| 25 | { |
| 26 | assert(nullptr != i_chipTarget); |
| 27 | |
| 28 | auto target = i_chipTarget; // default, if i_unitPath is empty |
| 29 | |
| 30 | if (!i_unitPath.empty()) |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 31 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 32 | auto path = std::string{util::pdbg::getPath(target)} + "/" + i_unitPath; |
| 33 | |
| 34 | target = util::pdbg::getTrgt(path); |
| 35 | if (nullptr == target) |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 36 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 37 | // Likely a bug the RAS data files. |
| 38 | throw std::logic_error("Unable to find target for " + path); |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 39 | } |
| 40 | } |
| 41 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 42 | return target; |
| 43 | } |
| 44 | |
| 45 | //------------------------------------------------------------------------------ |
| 46 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 47 | // Helper function to get the connected target on the other side of the |
| 48 | // given bus. |
| 49 | pdbg_target* __getConnectedTarget(pdbg_target* i_rxTarget, |
| 50 | const callout::BusType& i_busType) |
| 51 | { |
| 52 | assert(nullptr != i_rxTarget); |
| 53 | |
| 54 | pdbg_target* txTarget = nullptr; |
| 55 | |
| 56 | auto rxType = util::pdbg::getTrgtType(i_rxTarget); |
| 57 | std::string rxPath = util::pdbg::getPath(i_rxTarget); |
| 58 | |
| 59 | if (callout::BusType::SMP_BUS == i_busType && |
| 60 | util::pdbg::TYPE_IOLINK == rxType) |
| 61 | { |
| 62 | // TODO: Will need to reference some sort of data that can tell us how |
| 63 | // the processors are connected in the system. For now, return the |
| 64 | // RX target to avoid returning a nullptr. |
| 65 | trace::inf("No support to get peer target on SMP bus"); |
| 66 | txTarget = i_rxTarget; |
| 67 | } |
Zane Shelley | be619c0 | 2021-09-30 17:56:42 -0500 | [diff] [blame] | 68 | else if (callout::BusType::SMP_BUS == i_busType && |
| 69 | util::pdbg::TYPE_IOHS == rxType) |
| 70 | { |
| 71 | // TODO: Will need to reference some sort of data that can tell us how |
| 72 | // the processors are connected in the system. For now, return the |
| 73 | // RX target to avoid returning a nullptr. |
| 74 | trace::inf("No support to get peer target on SMP bus"); |
| 75 | txTarget = i_rxTarget; |
| 76 | } |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 77 | else if (callout::BusType::OMI_BUS == i_busType && |
| 78 | util::pdbg::TYPE_OMI == rxType) |
| 79 | { |
| 80 | // This is a bit clunky. The pdbg APIs only give us the ability to |
| 81 | // iterate over the children instead of just returning a list. So we'll |
| 82 | // push all the children to a list and go from there. |
| 83 | std::vector<pdbg_target*> childList; |
| 84 | |
| 85 | pdbg_target* childTarget = nullptr; |
| 86 | pdbg_for_each_target("ocmb", i_rxTarget, childTarget) |
| 87 | { |
| 88 | if (nullptr != childTarget) |
| 89 | { |
| 90 | childList.push_back(childTarget); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // We know there should only be one OCMB per OMI. |
| 95 | if (1 != childList.size()) |
| 96 | { |
| 97 | throw std::logic_error("Invalid child list size for " + rxPath); |
| 98 | } |
| 99 | |
| 100 | // Get the connected target. |
| 101 | txTarget = childList.front(); |
| 102 | } |
| 103 | else if (callout::BusType::OMI_BUS == i_busType && |
| 104 | util::pdbg::TYPE_OCMB == rxType) |
| 105 | { |
| 106 | txTarget = pdbg_target_parent("omi", i_rxTarget); |
| 107 | if (nullptr == txTarget) |
| 108 | { |
| 109 | throw std::logic_error("No parent OMI found for " + rxPath); |
| 110 | } |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | // This would be a code bug. |
| 115 | throw std::logic_error("Unsupported config: i_rxTarget=" + rxPath + |
| 116 | " i_busType=" + i_busType.getString()); |
| 117 | } |
| 118 | |
| 119 | assert(nullptr != txTarget); // just in case we missed something above |
| 120 | |
| 121 | return txTarget; |
| 122 | } |
| 123 | |
| 124 | //------------------------------------------------------------------------------ |
| 125 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 126 | void HardwareCalloutResolution::resolve(ServiceData& io_sd) const |
| 127 | { |
| 128 | // Get the target for the hardware callout. |
| 129 | auto target = __getUnitTarget(__getRootCauseChipTarget(io_sd), iv_unitPath); |
| 130 | |
Zane Shelley | 9513582 | 2021-08-23 09:00:05 -0500 | [diff] [blame] | 131 | // Get the location code and entity path for this target. |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 132 | auto locCode = util::pdbg::getLocationCode(target); |
| 133 | auto entityPath = util::pdbg::getPhysDevPath(target); |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 134 | |
| 135 | // Add the actual callout to the service data. |
| 136 | nlohmann::json callout; |
| 137 | callout["LocationCode"] = locCode; |
| 138 | callout["Priority"] = iv_priority.getUserDataString(); |
| 139 | io_sd.addCallout(callout); |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 140 | |
Zane Shelley | 9513582 | 2021-08-23 09:00:05 -0500 | [diff] [blame] | 141 | // Add the guard info to the service data. |
Zane Shelley | 2d11432 | 2021-08-25 17:06:12 -0500 | [diff] [blame] | 142 | Guard guard = io_sd.addGuard(entityPath, iv_guard); |
| 143 | |
| 144 | // Add the callout FFDC to the service data. |
| 145 | nlohmann::json ffdc; |
| 146 | ffdc["Callout Type"] = "Hardware Callout"; |
| 147 | ffdc["Target"] = entityPath; |
| 148 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 149 | ffdc["Guard Type"] = guard.getString(); |
| 150 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 151 | } |
| 152 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 153 | //------------------------------------------------------------------------------ |
| 154 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 155 | void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const |
| 156 | { |
| 157 | // Get the chip target from the root cause signature. |
| 158 | auto chipTarget = __getRootCauseChipTarget(io_sd); |
| 159 | |
| 160 | // Get the endpoint target for the receiving side of the bus. |
| 161 | auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath); |
| 162 | |
| 163 | // Get the endpoint target for the transfer side of the bus. |
| 164 | auto txTarget = __getConnectedTarget(rxTarget, iv_busType); |
| 165 | |
| 166 | // Callout the TX endpoint. |
| 167 | nlohmann::json txCallout; |
| 168 | txCallout["LocationCode"] = util::pdbg::getLocationCode(txTarget); |
| 169 | txCallout["Priority"] = iv_priority.getUserDataString(); |
| 170 | io_sd.addCallout(txCallout); |
| 171 | |
| 172 | // Guard the TX endpoint. |
| 173 | Guard txGuard = |
| 174 | io_sd.addGuard(util::pdbg::getPhysDevPath(txTarget), iv_guard); |
| 175 | |
| 176 | // Add the callout FFDC to the service data. |
| 177 | nlohmann::json ffdc; |
| 178 | ffdc["Callout Type"] = "Connected Callout"; |
| 179 | ffdc["Bus Type"] = iv_busType.getString(); |
| 180 | ffdc["Target"] = util::pdbg::getPhysDevPath(txTarget); |
| 181 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 182 | ffdc["Guard Type"] = txGuard.getString(); |
| 183 | io_sd.addCalloutFFDC(ffdc); |
| 184 | } |
| 185 | |
| 186 | //------------------------------------------------------------------------------ |
| 187 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 188 | void BusCalloutResolution::resolve(ServiceData& io_sd) const |
| 189 | { |
| 190 | // Get the chip target from the root cause signature. |
| 191 | auto chipTarget = __getRootCauseChipTarget(io_sd); |
| 192 | |
| 193 | // Get the endpoint target for the receiving side of the bus. |
| 194 | auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath); |
| 195 | |
| 196 | // Get the endpoint target for the transfer side of the bus. |
| 197 | auto txTarget = __getConnectedTarget(rxTarget, iv_busType); |
| 198 | |
| 199 | // Callout the RX endpoint. |
| 200 | nlohmann::json rxCallout; |
| 201 | rxCallout["LocationCode"] = util::pdbg::getLocationCode(rxTarget); |
| 202 | rxCallout["Priority"] = iv_priority.getUserDataString(); |
| 203 | io_sd.addCallout(rxCallout); |
| 204 | |
| 205 | // Callout the TX endpoint. |
| 206 | nlohmann::json txCallout; |
| 207 | txCallout["LocationCode"] = util::pdbg::getLocationCode(txTarget); |
| 208 | txCallout["Priority"] = iv_priority.getUserDataString(); |
| 209 | io_sd.addCallout(txCallout); |
| 210 | |
| 211 | // Callout everything else in between. |
| 212 | // TODO: For P10 (OMI bus and XBUS), the callout is simply the backplane. |
| 213 | // There isn't a devtree object for this, yet. So will need to |
| 214 | // hardcode the location code for now. In the future, we will need a |
| 215 | // mechanism to make this data driven. |
| 216 | nlohmann::json bpCallout; |
| 217 | bpCallout["LocationCode"] = "P0"; |
| 218 | bpCallout["Priority"] = iv_priority.getUserDataString(); |
| 219 | io_sd.addCallout(bpCallout); |
| 220 | |
| 221 | // Guard the RX endpoint. |
| 222 | Guard guard = |
| 223 | io_sd.addGuard(util::pdbg::getPhysDevPath(rxTarget), iv_guard); |
| 224 | |
| 225 | // Guard the TX endpoint. |
| 226 | // No need to check return because it is the same as RX target. |
| 227 | io_sd.addGuard(util::pdbg::getPhysDevPath(txTarget), iv_guard); |
| 228 | |
| 229 | // TODO: Currently no guard for "everything else in between". |
| 230 | |
| 231 | // Add the callout FFDC to the service data. |
| 232 | nlohmann::json ffdc; |
| 233 | ffdc["Callout Type"] = "Bus Callout"; |
| 234 | ffdc["Bus Type"] = iv_busType.getString(); |
| 235 | ffdc["RX Target"] = util::pdbg::getPhysDevPath(rxTarget); |
| 236 | ffdc["TX Target"] = util::pdbg::getPhysDevPath(txTarget); |
| 237 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 238 | ffdc["Guard Type"] = guard.getString(); |
| 239 | io_sd.addCalloutFFDC(ffdc); |
| 240 | } |
| 241 | |
| 242 | //------------------------------------------------------------------------------ |
| 243 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 244 | void ClockCalloutResolution::resolve(ServiceData& io_sd) const |
| 245 | { |
| 246 | // Add the callout to the service data. |
| 247 | // TODO: For P10, the callout is simply the backplane. There isn't a devtree |
| 248 | // object for this, yet. So will need to hardcode the location code |
| 249 | // for now. In the future, we will need a mechanism to make this data |
| 250 | // driven. |
| 251 | nlohmann::json callout; |
| 252 | callout["LocationCode"] = "P0"; |
| 253 | callout["Priority"] = iv_priority.getUserDataString(); |
| 254 | io_sd.addCallout(callout); |
| 255 | |
| 256 | // Add the guard info to the service data. |
| 257 | // TODO: Still waiting for clock targets to be defined in the device tree. |
| 258 | // For get the processor path for the FFDC. |
| 259 | // static const std::map<callout::ClockType, std::string> m = { |
| 260 | // {callout::ClockType::OSC_REF_CLOCK_0, ""}, |
| 261 | // {callout::ClockType::OSC_REF_CLOCK_1, ""}, |
| 262 | // }; |
| 263 | // auto target = std::string{util::pdbg::getPath(m.at(iv_clockType))}; |
| 264 | // auto guardPath = util::pdbg::getPhysDevPath(target); |
| 265 | // Guard guard = io_sd.addGuard(guardPath, iv_guard); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 266 | auto target = __getRootCauseChipTarget(io_sd); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 267 | auto guardPath = util::pdbg::getPhysDevPath(target); |
| 268 | |
| 269 | // Add the callout FFDC to the service data. |
| 270 | nlohmann::json ffdc; |
| 271 | ffdc["Callout Type"] = "Clock Callout"; |
| 272 | ffdc["Clock Type"] = iv_clockType.getString(); |
| 273 | ffdc["Target"] = guardPath; |
| 274 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 275 | ffdc["Guard Type"] = ""; // TODO: guard.getString(); |
| 276 | io_sd.addCalloutFFDC(ffdc); |
| 277 | } |
| 278 | |
| 279 | //------------------------------------------------------------------------------ |
| 280 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 281 | void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const |
| 282 | { |
| 283 | // Add the actual callout to the service data. |
| 284 | nlohmann::json callout; |
| 285 | callout["Procedure"] = iv_procedure.getString(); |
| 286 | callout["Priority"] = iv_priority.getUserDataString(); |
| 287 | io_sd.addCallout(callout); |
Zane Shelley | 2d11432 | 2021-08-25 17:06:12 -0500 | [diff] [blame] | 288 | |
| 289 | // Add the callout FFDC to the service data. |
| 290 | nlohmann::json ffdc; |
| 291 | ffdc["Callout Type"] = "Procedure Callout"; |
| 292 | ffdc["Procedure"] = iv_procedure.getString(); |
| 293 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 294 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | //------------------------------------------------------------------------------ |
| 298 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 299 | } // namespace analyzer |