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, |
| 101 | const callout::Priority& i_priority, bool i_guard) |
| 102 | { |
| 103 | nlohmann::json callout; |
| 104 | callout["LocationCode"] = i_locCode; |
| 105 | callout["Priority"] = i_priority.getUserDataString(); |
| 106 | callout["Deconfigured"] = false; |
| 107 | callout["Guarded"] = i_guard; |
| 108 | io_sd.addCallout(callout); |
| 109 | } |
| 110 | |
| 111 | //------------------------------------------------------------------------------ |
| 112 | |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 113 | void __calloutBackplane(ServiceData& io_sd, const callout::Priority& i_priority) |
| 114 | { |
| 115 | // TODO: There isn't a device tree object for this. So will need to hardcode |
| 116 | // the location code for now. In the future, we will need a mechanism |
| 117 | // to make this data driven. |
| 118 | |
| 119 | nlohmann::json callout; |
| 120 | callout["LocationCode"] = "P0"; |
| 121 | callout["Priority"] = i_priority.getUserDataString(); |
| 122 | callout["Deconfigured"] = false; |
| 123 | callout["Guarded"] = false; |
| 124 | io_sd.addCallout(callout); |
| 125 | } |
| 126 | |
| 127 | //------------------------------------------------------------------------------ |
| 128 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 129 | void HardwareCalloutResolution::resolve(ServiceData& io_sd) const |
| 130 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 131 | // Get the location code and entity path for this target. |
| 132 | auto locCode = __getRootCauseChipPath(io_sd); |
| 133 | auto entityPath = __getUnitPath(locCode, iv_unitPath); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 134 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 135 | // Add the actual callout to the service data. |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 136 | __calloutTarget(io_sd, locCode, iv_priority, iv_guard); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 137 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 138 | // Add the callout FFDC to the service data. |
| 139 | nlohmann::json ffdc; |
| 140 | ffdc["Callout Type"] = "Hardware Callout"; |
| 141 | ffdc["Target"] = entityPath; |
| 142 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 143 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 144 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 145 | } |
| 146 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 147 | //------------------------------------------------------------------------------ |
| 148 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 149 | void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const |
| 150 | { |
| 151 | // Get the chip target path from the root cause signature. |
| 152 | auto chipPath = __getRootCauseChipPath(io_sd); |
| 153 | |
| 154 | // Get the endpoint target path for the receiving side of the bus. |
| 155 | auto rxPath = __getUnitPath(chipPath, iv_unitPath); |
| 156 | |
| 157 | // Get the endpoint target path for the transfer side of the bus. |
| 158 | auto txPath = __getConnectedPath(rxPath, iv_busType); |
| 159 | |
| 160 | // Callout the TX endpoint. |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 161 | __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard); |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 162 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 163 | // Add the callout FFDC to the service data. |
| 164 | nlohmann::json ffdc; |
| 165 | ffdc["Callout Type"] = "Connected Callout"; |
| 166 | ffdc["Bus Type"] = iv_busType.getString(); |
| 167 | ffdc["Target"] = std::get<0>(txPath); |
| 168 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 169 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 170 | io_sd.addCalloutFFDC(ffdc); |
| 171 | } |
| 172 | |
| 173 | //------------------------------------------------------------------------------ |
| 174 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 175 | void BusCalloutResolution::resolve(ServiceData& io_sd) const |
| 176 | { |
| 177 | // Get the chip target path from the root cause signature. |
| 178 | auto chipPath = __getRootCauseChipPath(io_sd); |
| 179 | |
| 180 | // Get the endpoint target path for the receiving side of the bus. |
| 181 | auto rxPath = __getUnitPath(chipPath, iv_unitPath); |
| 182 | |
| 183 | // Get the endpoint target path for the transfer side of the bus. |
| 184 | auto txPath = __getConnectedPath(rxPath, iv_busType); |
| 185 | |
| 186 | // Callout the RX endpoint. |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 187 | __calloutTarget(io_sd, chipPath, iv_priority, iv_guard); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 188 | |
| 189 | // Callout the TX endpoint. |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 190 | __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 191 | |
| 192 | // Callout everything else in between. |
| 193 | // 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] | 194 | __calloutBackplane(io_sd, iv_priority); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 195 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 196 | // Add the callout FFDC to the service data. |
| 197 | nlohmann::json ffdc; |
| 198 | ffdc["Callout Type"] = "Bus Callout"; |
| 199 | ffdc["Bus Type"] = iv_busType.getString(); |
| 200 | ffdc["RX Target"] = rxPath; |
| 201 | ffdc["TX Target"] = std::get<0>(txPath); |
| 202 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 203 | ffdc["Guard"] = iv_guard; |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 204 | io_sd.addCalloutFFDC(ffdc); |
| 205 | } |
| 206 | |
| 207 | //------------------------------------------------------------------------------ |
| 208 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 209 | void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const |
| 210 | { |
| 211 | // Add the actual callout to the service data. |
| 212 | nlohmann::json callout; |
| 213 | callout["Procedure"] = iv_procedure.getString(); |
| 214 | callout["Priority"] = iv_priority.getUserDataString(); |
| 215 | io_sd.addCallout(callout); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 216 | |
| 217 | // Add the callout FFDC to the service data. |
| 218 | nlohmann::json ffdc; |
| 219 | ffdc["Callout Type"] = "Procedure Callout"; |
| 220 | ffdc["Procedure"] = iv_procedure.getString(); |
| 221 | ffdc["Priority"] = iv_priority.getRegistryString(); |
| 222 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 223 | } |
| 224 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 225 | //------------------------------------------------------------------------------ |
| 226 | |
| 227 | void ClockCalloutResolution::resolve(ServiceData& io_sd) const |
| 228 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 229 | // Callout the clock target. |
| 230 | // TODO: For P10, the callout is simply the backplane. Also, there are no |
| 231 | // clock targets in the device tree. So at the moment there is no |
| 232 | // guard support for clock targets. |
| 233 | __calloutBackplane(io_sd, iv_priority); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 234 | |
| 235 | // Add the callout FFDC to the service data. |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 236 | // TODO: Add the target and guard type if guard is ever supported. |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 237 | nlohmann::json ffdc; |
| 238 | ffdc["Callout Type"] = "Clock Callout"; |
| 239 | ffdc["Clock Type"] = iv_clockType.getString(); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 240 | ffdc["Priority"] = iv_priority.getRegistryString(); |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 241 | io_sd.addCalloutFFDC(ffdc); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | //------------------------------------------------------------------------------ |
| 245 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 246 | } // namespace analyzer |
| 247 | |
| 248 | using namespace analyzer; |
| 249 | |
| 250 | TEST(Resolution, TestSet1) |
| 251 | { |
| 252 | // Create a few resolutions |
| 253 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 254 | proc_str, callout::Priority::HIGH, false); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 255 | |
| 256 | auto c2 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 257 | omi_str, callout::Priority::MED_A, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 258 | |
| 259 | auto c3 = std::make_shared<HardwareCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 260 | core_str, callout::Priority::MED, true); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 261 | |
| 262 | auto c4 = std::make_shared<ProcedureCalloutResolution>( |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 263 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 264 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 265 | auto c5 = std::make_shared<ClockCalloutResolution>( |
| 266 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false); |
| 267 | |
| 268 | // l1 = (c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 269 | auto l1 = std::make_shared<ResolutionList>(); |
| 270 | l1->push(c1); |
| 271 | l1->push(c2); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 272 | l1->push(c5); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 273 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 274 | // l2 = (c4, c3, c1, c2, c5) |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 275 | auto l2 = std::make_shared<ResolutionList>(); |
| 276 | l2->push(c4); |
| 277 | l2->push(c3); |
| 278 | l2->push(l1); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 279 | |
| 280 | // Get some ServiceData objects |
| 281 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 282 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
Zane Shelley | ca49619 | 2021-08-09 12:05:52 -0500 | [diff] [blame] | 283 | ServiceData sd1{sig, true}; |
| 284 | ServiceData sd2{sig, false}; |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 285 | |
| 286 | // Resolve |
Zane Shelley | 723fa23 | 2021-08-09 12:02:06 -0500 | [diff] [blame] | 287 | l1->resolve(sd1); |
| 288 | l2->resolve(sd2); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 289 | |
| 290 | // Start verifying |
| 291 | nlohmann::json j{}; |
| 292 | std::string s{}; |
| 293 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 294 | j = sd1.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 295 | s = R"([ |
| 296 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 297 | "Deconfigured": false, |
| 298 | "Guarded": false, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 299 | "LocationCode": "/proc0", |
| 300 | "Priority": "H" |
| 301 | }, |
| 302 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 303 | "Deconfigured": false, |
| 304 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 305 | "LocationCode": "P0", |
| 306 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 307 | } |
| 308 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 309 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 310 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 311 | j = sd2.getCalloutList(); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 312 | s = R"([ |
| 313 | { |
| 314 | "Priority": "L", |
| 315 | "Procedure": "NEXTLVL" |
| 316 | }, |
| 317 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 318 | "Deconfigured": false, |
| 319 | "Guarded": true, |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 320 | "LocationCode": "/proc0", |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 321 | "Priority": "H" |
| 322 | }, |
| 323 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 324 | "Deconfigured": false, |
| 325 | "Guarded": false, |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 326 | "LocationCode": "P0", |
| 327 | "Priority": "L" |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 328 | } |
| 329 | ])"; |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 330 | EXPECT_EQ(s, j.dump(4)); |
| 331 | } |
| 332 | |
| 333 | TEST(Resolution, HardwareCallout) |
| 334 | { |
| 335 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 336 | omi_str, callout::Priority::MED_A, true); |
| 337 | |
| 338 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 339 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 340 | ServiceData sd{sig, true}; |
| 341 | |
| 342 | c1->resolve(sd); |
| 343 | |
| 344 | nlohmann::json j{}; |
| 345 | std::string s{}; |
| 346 | |
| 347 | // Callout list |
| 348 | j = sd.getCalloutList(); |
| 349 | s = R"([ |
| 350 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 351 | "Deconfigured": false, |
| 352 | "Guarded": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 353 | "LocationCode": "/proc0", |
| 354 | "Priority": "A" |
| 355 | } |
| 356 | ])"; |
| 357 | EXPECT_EQ(s, j.dump(4)); |
| 358 | |
| 359 | // Callout FFDC |
| 360 | j = sd.getCalloutFFDC(); |
| 361 | s = R"([ |
| 362 | { |
| 363 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 364 | "Guard": true, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 365 | "Priority": "medium_group_A", |
| 366 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 367 | } |
| 368 | ])"; |
| 369 | EXPECT_EQ(s, j.dump(4)); |
| 370 | } |
| 371 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 372 | TEST(Resolution, ConnectedCallout) |
| 373 | { |
| 374 | auto c1 = std::make_shared<ConnectedCalloutResolution>( |
| 375 | callout::BusType::SMP_BUS, iolink_str, callout::Priority::MED_A, true); |
| 376 | |
| 377 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 378 | callout::BusType::OMI_BUS, ocmb_str, callout::Priority::MED_B, true); |
| 379 | |
| 380 | auto c3 = std::make_shared<ConnectedCalloutResolution>( |
| 381 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_C, true); |
| 382 | |
| 383 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 384 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 385 | ServiceData sd{sig, true}; |
| 386 | |
| 387 | nlohmann::json j{}; |
| 388 | std::string s{}; |
| 389 | |
| 390 | c1->resolve(sd); |
| 391 | c2->resolve(sd); |
| 392 | c3->resolve(sd); |
| 393 | |
| 394 | // Callout list |
| 395 | j = sd.getCalloutList(); |
| 396 | s = R"([ |
| 397 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 398 | "Deconfigured": false, |
| 399 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 400 | "LocationCode": "/proc1", |
| 401 | "Priority": "A" |
| 402 | }, |
| 403 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 404 | "Deconfigured": false, |
| 405 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 406 | "LocationCode": "/proc0", |
| 407 | "Priority": "B" |
| 408 | }, |
| 409 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 410 | "Deconfigured": false, |
| 411 | "Guarded": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 412 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 413 | "Priority": "C" |
| 414 | } |
| 415 | ])"; |
| 416 | EXPECT_EQ(s, j.dump(4)); |
| 417 | |
| 418 | // Callout FFDC |
| 419 | j = sd.getCalloutFFDC(); |
| 420 | s = R"([ |
| 421 | { |
| 422 | "Bus Type": "SMP_BUS", |
| 423 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 424 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 425 | "Priority": "medium_group_A", |
| 426 | "Target": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0" |
| 427 | }, |
| 428 | { |
| 429 | "Bus Type": "OMI_BUS", |
| 430 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 431 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 432 | "Priority": "medium_group_B", |
| 433 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 434 | }, |
| 435 | { |
| 436 | "Bus Type": "OMI_BUS", |
| 437 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 438 | "Guard": true, |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 439 | "Priority": "medium_group_C", |
| 440 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 441 | } |
| 442 | ])"; |
| 443 | EXPECT_EQ(s, j.dump(4)); |
| 444 | } |
| 445 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 446 | TEST(Resolution, BusCallout) |
| 447 | { |
| 448 | auto c1 = std::make_shared<HardwareCalloutResolution>( |
| 449 | omi_str, callout::Priority::MED_A, true); |
| 450 | |
| 451 | auto c2 = std::make_shared<ConnectedCalloutResolution>( |
| 452 | callout::BusType::OMI_BUS, omi_str, callout::Priority::MED_A, true); |
| 453 | |
| 454 | auto c3 = std::make_shared<BusCalloutResolution>( |
| 455 | callout::BusType::OMI_BUS, omi_str, callout::Priority::LOW, false); |
| 456 | |
| 457 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 458 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 459 | ServiceData sd{sig, true}; |
| 460 | |
| 461 | nlohmann::json j{}; |
| 462 | std::string s{}; |
| 463 | |
| 464 | c1->resolve(sd); |
| 465 | c2->resolve(sd); |
| 466 | c3->resolve(sd); |
| 467 | |
| 468 | // Callout list |
| 469 | j = sd.getCalloutList(); |
| 470 | s = R"([ |
| 471 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 472 | "Deconfigured": false, |
| 473 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 474 | "LocationCode": "/proc0", |
| 475 | "Priority": "A" |
| 476 | }, |
| 477 | { |
Zane Shelley | 9a738f7 | 2021-11-03 20:45:30 -0500 | [diff] [blame] | 478 | "Deconfigured": false, |
| 479 | "Guarded": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 480 | "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0", |
| 481 | "Priority": "A" |
| 482 | }, |
| 483 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 484 | "Deconfigured": false, |
| 485 | "Guarded": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 486 | "LocationCode": "P0", |
| 487 | "Priority": "L" |
| 488 | } |
| 489 | ])"; |
| 490 | EXPECT_EQ(s, j.dump(4)); |
| 491 | |
| 492 | // Callout FFDC |
| 493 | j = sd.getCalloutFFDC(); |
| 494 | s = R"([ |
| 495 | { |
| 496 | "Callout Type": "Hardware Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 497 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 498 | "Priority": "medium_group_A", |
| 499 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0" |
| 500 | }, |
| 501 | { |
| 502 | "Bus Type": "OMI_BUS", |
| 503 | "Callout Type": "Connected Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 504 | "Guard": true, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 505 | "Priority": "medium_group_A", |
| 506 | "Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 507 | }, |
| 508 | { |
| 509 | "Bus Type": "OMI_BUS", |
| 510 | "Callout Type": "Bus Callout", |
Zane Shelley | a00426f | 2021-11-04 10:50:50 -0500 | [diff] [blame] | 511 | "Guard": false, |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 512 | "Priority": "low", |
| 513 | "RX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0", |
| 514 | "TX Target": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0" |
| 515 | } |
| 516 | ])"; |
| 517 | EXPECT_EQ(s, j.dump(4)); |
| 518 | } |
| 519 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 520 | TEST(Resolution, ClockCallout) |
| 521 | { |
| 522 | auto c1 = std::make_shared<ClockCalloutResolution>( |
| 523 | callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::HIGH, false); |
| 524 | |
| 525 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 526 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 527 | ServiceData sd{sig, true}; |
| 528 | |
| 529 | c1->resolve(sd); |
| 530 | |
| 531 | nlohmann::json j{}; |
| 532 | std::string s{}; |
| 533 | |
| 534 | // Callout list |
| 535 | j = sd.getCalloutList(); |
| 536 | s = R"([ |
| 537 | { |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 538 | "Deconfigured": false, |
| 539 | "Guarded": false, |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 540 | "LocationCode": "P0", |
| 541 | "Priority": "H" |
| 542 | } |
| 543 | ])"; |
| 544 | EXPECT_EQ(s, j.dump(4)); |
| 545 | |
| 546 | // Callout FFDC |
| 547 | j = sd.getCalloutFFDC(); |
| 548 | s = R"([ |
| 549 | { |
| 550 | "Callout Type": "Clock Callout", |
| 551 | "Clock Type": "OSC_REF_CLOCK_1", |
Zane Shelley | 1eff945 | 2021-11-03 13:59:54 -0500 | [diff] [blame] | 552 | "Priority": "high" |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 553 | } |
| 554 | ])"; |
| 555 | EXPECT_EQ(s, j.dump(4)); |
| 556 | } |
| 557 | |
| 558 | TEST(Resolution, ProcedureCallout) |
| 559 | { |
| 560 | auto c1 = std::make_shared<ProcedureCalloutResolution>( |
| 561 | callout::Procedure::NEXTLVL, callout::Priority::LOW); |
| 562 | |
| 563 | libhei::Chip chip{chip_str, 0xdeadbeef}; |
| 564 | libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP}; |
| 565 | ServiceData sd{sig, true}; |
| 566 | |
| 567 | c1->resolve(sd); |
| 568 | |
| 569 | nlohmann::json j{}; |
| 570 | std::string s{}; |
| 571 | |
| 572 | // Callout list |
| 573 | j = sd.getCalloutList(); |
| 574 | s = R"([ |
| 575 | { |
| 576 | "Priority": "L", |
| 577 | "Procedure": "NEXTLVL" |
| 578 | } |
| 579 | ])"; |
| 580 | EXPECT_EQ(s, j.dump(4)); |
| 581 | |
| 582 | // Callout FFDC |
| 583 | j = sd.getCalloutFFDC(); |
| 584 | s = R"([ |
| 585 | { |
| 586 | "Callout Type": "Procedure Callout", |
| 587 | "Priority": "low", |
| 588 | "Procedure": "NEXTLVL" |
| 589 | } |
| 590 | ])"; |
| 591 | EXPECT_EQ(s, j.dump(4)); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 592 | } |