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