Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 3 | #include <analyzer/analyzer_main.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 4 | #include <analyzer/resolution.hpp> |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 5 | #include <util/trace.hpp> |
| 6 | |
| 7 | #include <regex> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 8 | |
| 9 | #include "gtest/gtest.h" |
| 10 | |
| 11 | // Chip string |
| 12 | constexpr auto chip_str = "/proc0"; |
| 13 | |
| 14 | // Unit paths |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 15 | constexpr auto proc_str = ""; |
| 16 | constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0"; |
| 17 | constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0"; |
| 18 | constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0"; |
| 19 | constexpr auto core_str = "pib/perv39/eq7/fc1/core1"; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 20 | |
| 21 | // Local implementation of this function. |
| 22 | namespace analyzer |
| 23 | { |
| 24 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 25 | //------------------------------------------------------------------------------ |
| 26 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 27 | // Helper function to get the root cause chip target path from the service data. |
| 28 | std::string __getRootCauseChipPath(const ServiceData& i_sd) |
| 29 | { |
| 30 | return std::string{(const char*)i_sd.getRootCause().getChip().getChip()}; |
| 31 | } |
| 32 | |
| 33 | //------------------------------------------------------------------------------ |
| 34 | |
| 35 | // Helper function to get a unit target path from the given unit path, which is |
| 36 | // a devtree path relative the the containing chip. An empty string indicates |
| 37 | // the chip target path should be returned. |
| 38 | std::string __getUnitPath(const std::string& i_chipPath, |
| 39 | const std::string& i_unitPath) |
| 40 | { |
| 41 | auto path = i_chipPath; // default, if i_unitPath is empty |
| 42 | |
| 43 | if (!i_unitPath.empty()) |
| 44 | { |
| 45 | path += "/" + i_unitPath; |
| 46 | } |
| 47 | |
| 48 | return path; |
| 49 | } |
| 50 | |
| 51 | //------------------------------------------------------------------------------ |
| 52 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 53 | // Helper function to get the connected target Path on the other side of the |
| 54 | // given bus. |
| 55 | std::tuple<std::string, std::string> |
| 56 | __getConnectedPath(const std::string& i_rxPath, |
| 57 | const callout::BusType& i_busType) |
| 58 | { |
| 59 | std::string txUnitPath{}; |
| 60 | std::string txChipPath{}; |
| 61 | |
| 62 | // Need to get the target type from the RX path. |
| 63 | const std::regex re{"(/proc0)(.*)/([a-z]+)([0-9]+)"}; |
| 64 | std::smatch match; |
| 65 | std::regex_match(i_rxPath, match, re); |
| 66 | assert(5 == match.size()); |
| 67 | std::string rxType = match[3].str(); |
| 68 | |
| 69 | if (callout::BusType::SMP_BUS == i_busType && "smpgroup" == rxType) |
| 70 | { |
| 71 | // Use the RX unit path on a different processor. |
| 72 | txUnitPath = "/proc1" + match[2].str() + "/" + rxType + match[4].str(); |
| 73 | txChipPath = "/proc1"; |
| 74 | } |
| 75 | else if (callout::BusType::OMI_BUS == i_busType && "omi" == rxType) |
| 76 | { |
| 77 | // Append the OCMB to the RX path. |
| 78 | txUnitPath = i_rxPath + "/ocmb0"; |
| 79 | txChipPath = txUnitPath; |
| 80 | } |
| 81 | else if (callout::BusType::OMI_BUS == i_busType && "ocmb" == rxType) |
| 82 | { |
| 83 | // Strip the OCMB off of the RX path. |
| 84 | txUnitPath = match[1].str() + match[2].str(); |
| 85 | txChipPath = "/proc0"; |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | // This would be a code bug. |
| 90 | throw std::logic_error("Unsupported config: i_rxTarget=" + i_rxPath + |
| 91 | " i_busType=" + i_busType.getString()); |
| 92 | } |
| 93 | |
| 94 | assert(!txUnitPath.empty()); // just in case we missed something above |
| 95 | |
| 96 | return std::make_tuple(txUnitPath, txChipPath); |
| 97 | } |
| 98 | |
| 99 | //------------------------------------------------------------------------------ |
| 100 | |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 101 | void __calloutTarget(ServiceData& io_sd, const std::string& i_locCode, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 102 | const callout::Priority& i_priority, bool i_guard, |
| 103 | const std::string& i_guardPath) |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 104 | { |
| 105 | nlohmann::json callout; |
| 106 | callout["LocationCode"] = i_locCode; |
| 107 | callout["Priority"] = i_priority.getUserDataString(); |
| 108 | callout["Deconfigured"] = false; |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 109 | callout["Guarded"] = false; // default |
| 110 | |
| 111 | // Check if guard info should be added. |
| 112 | if (i_guard) |
| 113 | { |
| 114 | auto guardType = io_sd.queryGuardPolicy(); |
| 115 | |
| 116 | if (!(callout::GuardType::NONE == guardType)) |
| 117 | { |
| 118 | callout["Guarded"] = true; |
| 119 | callout["Guard Path"] = i_guardPath; |
| 120 | callout["Guard Type"] = guardType.getString(); |
| 121 | } |
| 122 | } |
| 123 | |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 124 | io_sd.addCallout(callout); |
| 125 | } |
| 126 | |
| 127 | //------------------------------------------------------------------------------ |
| 128 | |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 129 | void __calloutBackplane(ServiceData& io_sd, const callout::Priority& i_priority) |
| 130 | { |
| 131 | // TODO: There isn't a device tree object for this. So will need to hardcode |
| 132 | // the location code for now. In the future, we will need a mechanism |
| 133 | // to make this data driven. |
| 134 | |
| 135 | nlohmann::json callout; |
| 136 | callout["LocationCode"] = "P0"; |
| 137 | callout["Priority"] = i_priority.getUserDataString(); |
| 138 | callout["Deconfigured"] = false; |
| 139 | callout["Guarded"] = false; |
| 140 | io_sd.addCallout(callout); |
| 141 | } |
| 142 | |
| 143 | //------------------------------------------------------------------------------ |
| 144 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 145 | void HardwareCalloutResolution::resolve(ServiceData& io_sd) const |
| 146 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 147 | // Get the location code and entity path for this target. |
| 148 | auto locCode = __getRootCauseChipPath(io_sd); |
| 149 | auto entityPath = __getUnitPath(locCode, iv_unitPath); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 150 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 151 | // Add the actual callout to the service data. |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 152 | __calloutTarget(io_sd, locCode, iv_priority, iv_guard, entityPath); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 153 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 154 | // Add the callout FFDC to the service data. |
| 155 | nlohmann::json ffdc; |
| 156 | ffdc["Callout Type"] = "Hardware Callout"; |
| 157 | ffdc["Target"] = entityPath; |
| 158 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 159 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 160 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 161 | } |
| 162 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 163 | //------------------------------------------------------------------------------ |
| 164 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 165 | void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const |
| 166 | { |
| 167 | // Get the chip target path from the root cause signature. |
| 168 | auto chipPath = __getRootCauseChipPath(io_sd); |
| 169 | |
| 170 | // Get the endpoint target path for the receiving side of the bus. |
| 171 | auto rxPath = __getUnitPath(chipPath, iv_unitPath); |
| 172 | |
| 173 | // Get the endpoint target path for the transfer side of the bus. |
| 174 | auto txPath = __getConnectedPath(rxPath, iv_busType); |
| 175 | |
| 176 | // Callout the TX endpoint. |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 177 | __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard, |
| 178 | std::get<0>(txPath)); |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 179 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 180 | // Add the callout FFDC to the service data. |
| 181 | nlohmann::json ffdc; |
| 182 | ffdc["Callout Type"] = "Connected Callout"; |
| 183 | ffdc["Bus Type"] = iv_busType.getString(); |
| 184 | ffdc["Target"] = std::get<0>(txPath); |
| 185 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 186 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 187 | io_sd.addCalloutFFDC(ffdc); |
| 188 | } |
| 189 | |
| 190 | //------------------------------------------------------------------------------ |
| 191 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 192 | void BusCalloutResolution::resolve(ServiceData& io_sd) const |
| 193 | { |
| 194 | // Get the chip target path from the root cause signature. |
| 195 | auto chipPath = __getRootCauseChipPath(io_sd); |
| 196 | |
| 197 | // Get the endpoint target path for the receiving side of the bus. |
| 198 | auto rxPath = __getUnitPath(chipPath, iv_unitPath); |
| 199 | |
| 200 | // Get the endpoint target path for the transfer side of the bus. |
| 201 | auto txPath = __getConnectedPath(rxPath, iv_busType); |
| 202 | |
| 203 | // Callout the RX endpoint. |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 204 | __calloutTarget(io_sd, chipPath, iv_priority, iv_guard, rxPath); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 205 | |
| 206 | // Callout the TX endpoint. |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 207 | __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard, |
| 208 | std::get<0>(txPath)); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 209 | |
| 210 | // Callout everything else in between. |
| 211 | // TODO: For P10 (OMI bus and XBUS), the callout is simply the backplane. |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 212 | __calloutBackplane(io_sd, iv_priority); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 213 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 214 | // Add the callout FFDC to the service data. |
| 215 | nlohmann::json ffdc; |
| 216 | ffdc["Callout Type"] = "Bus Callout"; |
| 217 | ffdc["Bus Type"] = iv_busType.getString(); |
| 218 | ffdc["RX Target"] = rxPath; |
| 219 | ffdc["TX Target"] = std::get<0>(txPath); |
| 220 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 221 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 222 | io_sd.addCalloutFFDC(ffdc); |
| 223 | } |
| 224 | |
| 225 | //------------------------------------------------------------------------------ |
| 226 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 227 | void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const |
| 228 | { |
| 229 | // Add the actual callout to the service data. |
| 230 | nlohmann::json callout; |
| 231 | callout["Procedure"] = iv_procedure.getString(); |
| 232 | callout["Priority"] = iv_priority.getUserDataString(); |
| 233 | io_sd.addCallout(callout); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 234 | |
| 235 | // Add the callout FFDC to the service data. |
| 236 | nlohmann::json ffdc; |
| 237 | ffdc["Callout Type"] = "Procedure Callout"; |
| 238 | ffdc["Procedure"] = iv_procedure.getString(); |
| 239 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 240 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 241 | } |
| 242 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 243 | //------------------------------------------------------------------------------ |
| 244 | |
| 245 | void ClockCalloutResolution::resolve(ServiceData& io_sd) const |
| 246 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 247 | // Callout the clock target. |
| 248 | // TODO: For P10, the callout is simply the backplane. Also, there are no |
| 249 | // clock targets in the device tree. So at the moment there is no |
| 250 | // guard support for clock targets. |
| 251 | __calloutBackplane(io_sd, iv_priority); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 252 | |
| 253 | // Add the callout FFDC to the service data. |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 254 | // TODO: Add the target and guard type if guard is ever supported. |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 255 | nlohmann::json ffdc; |
| 256 | ffdc["Callout Type"] = "Clock Callout"; |
| 257 | ffdc["Clock Type"] = iv_clockType.getString(); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 258 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 259 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | //------------------------------------------------------------------------------ |
| 263 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 264 | } // namespace analyzer |
| 265 | |
| 266 | using namespace analyzer; |
| 267 | |
| 268 | TEST(Resolution, TestSet1) |
| 269 | { |
| 270 | // Create a few resolutions |
| 271 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 272 | proc_str, callout::Priority::HIGH, false); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 273 | |
| 274 | auto c2 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 275 | omi_str, callout::Priority::MED_A, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 276 | |
| 277 | auto c3 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 278 | core_str, callout::Priority::MED, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 279 | |
| 280 | auto c4 = std::make_shared<ProcedureCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 281 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 282 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 283 | auto c5 = std::make_shared<ClockCalloutResolution>( |
| 284 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false); |
| 285 | |
| 286 | // l1 = (c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 287 | auto l1 = std::make_shared<ResolutionList>(); |
| 288 | l1->push(c1); |
| 289 | l1->push(c2); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 290 | l1->push(c5); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 291 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 292 | // l2 = (c4, c3, c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 293 | auto l2 = std::make_shared<ResolutionList>(); |
| 294 | l2->push(c4); |
| 295 | l2->push(c3); |
| 296 | l2->push(l1); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 297 | |
| 298 | // Get some ServiceData objects |
| 299 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 300 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 301 | ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
| 302 | ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 303 | |
| 304 | // Resolve |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 305 | l1->resolve(sd1); |
| 306 | l2->resolve(sd2); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 307 | |
| 308 | // Start verifying |
| 309 | nlohmann::json j{}; |
| 310 | std::string s{}; |
| 311 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 312 | j = sd1.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 313 | s = R"([ |
| 314 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 315 | "Deconfigured": false, |
| 316 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 317 | "LocationCode": "/proc0", |
| 318 | "Priority": "H" |
| 319 | }, |
| 320 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 321 | "Deconfigured": false, |
| 322 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 323 | "LocationCode": "P0", |
| 324 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 325 | } |
| 326 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 327 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 328 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 329 | j = sd2.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 330 | s = R"([ |
| 331 | { |
| 332 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 333 | "Procedure": "next_level_support" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 334 | }, |
| 335 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 336 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 337 | "Guard Path": "/proc0/pib/perv39/eq7/fc1/core1", |
| 338 | "Guard Type": "GARD_Predictive", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 339 | "Guarded": true, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 340 | "LocationCode": "/proc0", |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 341 | "Priority": "H" |
| 342 | }, |
| 343 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 344 | "Deconfigured": false, |
| 345 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 346 | "LocationCode": "P0", |
| 347 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 348 | } |
| 349 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 350 | EXPECT_EQ(s, j.dump(4)); |
| 351 | } |
| 352 | |
| 353 | TEST(Resolution, HardwareCallout) |
| 354 | { |
| 355 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 356 | omi_str, callout::Priority::MED_A, true); |
| 357 | |
| 358 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 359 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 360 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 361 | |
| 362 | c1->resolve(sd); |
| 363 | |
| 364 | nlohmann::json j{}; |
| 365 | std::string s{}; |
| 366 | |
| 367 | // Callout list |
| 368 | j = sd.getCalloutList(); |
| 369 | s = R"([ |
| 370 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 371 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 372 | "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 373 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 374 | "Guarded": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 375 | "LocationCode": "/proc0", |
| 376 | "Priority": "A" |
| 377 | } |
| 378 | ])"; |
| 379 | EXPECT_EQ(s, j.dump(4)); |
| 380 | |
| 381 | // Callout FFDC |
| 382 | j = sd.getCalloutFFDC(); |
| 383 | s = R"([ |
| 384 | { |
| 385 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 386 | "Guard": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 387 | "Priority": "medium_group_A", |
| 388 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 389 | } |
| 390 | ])"; |
| 391 | EXPECT_EQ(s, j.dump(4)); |
| 392 | } |
| 393 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 394 | TEST(Resolution, ConnectedCallout) |
| 395 | { |
| 396 | auto c1 = std::make_shared<ConnectedCalloutResolution>( |
| 397 | callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true); |
| 398 | |
| 399 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 400 | callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true); |
| 401 | |
| 402 | auto c3 = std::make_shared<ConnectedCalloutResolution>( |
| 403 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true); |
| 404 | |
| 405 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 406 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 407 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 408 | |
| 409 | nlohmann::json j{}; |
| 410 | std::string s{}; |
| 411 | |
| 412 | c1->resolve(sd); |
| 413 | c2->resolve(sd); |
| 414 | c3->resolve(sd); |
| 415 | |
| 416 | // Callout list |
| 417 | j = sd.getCalloutList(); |
| 418 | s = R"([ |
| 419 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 420 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 421 | "Guard Path": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0", |
| 422 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 423 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 424 | "LocationCode": "/proc1", |
| 425 | "Priority": "A" |
| 426 | }, |
| 427 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 428 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 429 | "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 430 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 431 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 432 | "LocationCode": "/proc0", |
| 433 | "Priority": "B" |
| 434 | }, |
| 435 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 436 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 437 | "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 438 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 439 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 440 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 441 | "Priority": "C" |
| 442 | } |
| 443 | ])"; |
| 444 | EXPECT_EQ(s, j.dump(4)); |
| 445 | |
| 446 | // Callout FFDC |
| 447 | j = sd.getCalloutFFDC(); |
| 448 | s = R"([ |
| 449 | { |
| 450 | "Bus Type": "SMP_BUS", |
| 451 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 452 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 453 | "Priority": "medium_group_A", |
| 454 | "Target": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0" |
| 455 | }, |
| 456 | { |
| 457 | "Bus Type": "OMI_BUS", |
| 458 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 459 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 460 | "Priority": "medium_group_B", |
| 461 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 462 | }, |
| 463 | { |
| 464 | "Bus Type": "OMI_BUS", |
| 465 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 466 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 467 | "Priority": "medium_group_C", |
| 468 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 469 | } |
| 470 | ])"; |
| 471 | EXPECT_EQ(s, j.dump(4)); |
| 472 | } |
| 473 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 474 | TEST(Resolution, BusCallout) |
| 475 | { |
| 476 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 477 | omi_str, callout::Priority::MED_A, true); |
| 478 | |
| 479 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 480 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 481 | |
| 482 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 483 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 484 | |
| 485 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 486 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 487 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 488 | |
| 489 | nlohmann::json j{}; |
| 490 | std::string s{}; |
| 491 | |
| 492 | c1->resolve(sd); |
| 493 | c2->resolve(sd); |
| 494 | c3->resolve(sd); |
| 495 | |
| 496 | // Callout list |
| 497 | j = sd.getCalloutList(); |
| 498 | s = R"([ |
| 499 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 500 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 501 | "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 502 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 503 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 504 | "LocationCode": "/proc0", |
| 505 | "Priority": "A" |
| 506 | }, |
| 507 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 508 | "Deconfigured": false, |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 509 | "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 510 | "Guard Type": "GARD_Unrecoverable", |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 511 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 512 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 513 | "Priority": "A" |
| 514 | }, |
| 515 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 516 | "Deconfigured": false, |
| 517 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 518 | "LocationCode": "P0", |
| 519 | "Priority": "L" |
| 520 | } |
| 521 | ])"; |
| 522 | EXPECT_EQ(s, j.dump(4)); |
| 523 | |
| 524 | // Callout FFDC |
| 525 | j = sd.getCalloutFFDC(); |
| 526 | s = R"([ |
| 527 | { |
| 528 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 529 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 530 | "Priority": "medium_group_A", |
| 531 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 532 | }, |
| 533 | { |
| 534 | "Bus Type": "OMI_BUS", |
| 535 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 536 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 537 | "Priority": "medium_group_A", |
| 538 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 539 | }, |
| 540 | { |
| 541 | "Bus Type": "OMI_BUS", |
| 542 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 543 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 544 | "Priority": "low", |
| 545 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 546 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 547 | } |
| 548 | ])"; |
| 549 | EXPECT_EQ(s, j.dump(4)); |
| 550 | } |
| 551 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 552 | TEST(Resolution, ClockCallout) |
| 553 | { |
| 554 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 555 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 556 | |
| 557 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 558 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 559 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 560 | |
| 561 | c1->resolve(sd); |
| 562 | |
| 563 | nlohmann::json j{}; |
| 564 | std::string s{}; |
| 565 | |
| 566 | // Callout list |
| 567 | j = sd.getCalloutList(); |
| 568 | s = R"([ |
| 569 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 570 | "Deconfigured": false, |
| 571 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 572 | "LocationCode": "P0", |
| 573 | "Priority": "H" |
| 574 | } |
| 575 | ])"; |
| 576 | EXPECT_EQ(s, j.dump(4)); |
| 577 | |
| 578 | // Callout FFDC |
| 579 | j = sd.getCalloutFFDC(); |
| 580 | s = R"([ |
| 581 | { |
| 582 | "Callout Type": "Clock Callout", |
| 583 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 584 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 585 | } |
| 586 | ])"; |
| 587 | EXPECT_EQ(s, j.dump(4)); |
| 588 | } |
| 589 | |
| 590 | TEST(Resolution, ProcedureCallout) |
| 591 | { |
| 592 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 593 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 594 | |
| 595 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 596 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | 82be3ab | 2021-12-07 10:36:08 -0600 | [diff] [blame] | 597 | ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP}; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 598 | |
| 599 | c1->resolve(sd); |
| 600 | |
| 601 | nlohmann::json j{}; |
| 602 | std::string s{}; |
| 603 | |
| 604 | // Callout list |
| 605 | j = sd.getCalloutList(); |
| 606 | s = R"([ |
| 607 | { |
| 608 | "Priority": "L", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 609 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 610 | } |
| 611 | ])"; |
| 612 | EXPECT_EQ(s, j.dump(4)); |
| 613 | |
| 614 | // Callout FFDC |
| 615 | j = sd.getCalloutFFDC(); |
| 616 | s = R"([ |
| 617 | { |
| 618 | "Callout Type": "Procedure Callout", |
| 619 | "Priority": "low", |
Zane Shelley | 86ccc45 | 2021-11-16 13:10:52 -0600 | [diff] [blame] | 620 | "Procedure": "next_level_support" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 621 | } |
| 622 | ])"; |
| 623 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 624 | } |