blob: 7738a2714891d36173d43a08b708a9e1b89c2b53 [file] [log] [blame]
Zane Shelley0b8368c2021-03-18 17:33:41 -05001#include <stdio.h>
2
3#include <analyzer/resolution.hpp>
Zane Shelley5d63cef2021-09-17 18:10:17 -05004#include <util/trace.hpp>
5
6#include <regex>
Zane Shelley0b8368c2021-03-18 17:33:41 -05007
8#include "gtest/gtest.h"
9
10// Chip string
11constexpr auto chip_str = "/proc0";
12
13// Unit paths
Zane Shelley5d63cef2021-09-17 18:10:17 -050014constexpr auto proc_str = "";
15constexpr auto iolink_str = "pib/perv24/pauc0/iohs0/smpgroup0";
16constexpr auto omi_str = "pib/perv12/mc0/mi0/mcc0/omi0";
17constexpr auto ocmb_str = "pib/perv12/mc0/mi0/mcc0/omi0/ocmb0";
18constexpr auto core_str = "pib/perv39/eq7/fc1/core1";
Zane Shelley0b8368c2021-03-18 17:33:41 -050019
20// Local implementation of this function.
21namespace analyzer
22{
23
Zane Shelley84721d92021-09-08 13:30:27 -050024//------------------------------------------------------------------------------
25
Zane Shelley96d54862021-09-17 11:16:12 -050026// Helper function to get the root cause chip target path from the service data.
27std::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.
37std::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 Shelley5d63cef2021-09-17 18:10:17 -050052// Helper function to get the connected target Path on the other side of the
53// given bus.
54std::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 Shelley9a738f72021-11-03 20:45:30 -0500100void __calloutTarget(ServiceData& io_sd, const std::string& i_locCode,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600101 const callout::Priority& i_priority, bool i_guard,
102 const std::string& i_guardPath)
Zane Shelley9a738f72021-11-03 20:45:30 -0500103{
104 nlohmann::json callout;
105 callout["LocationCode"] = i_locCode;
106 callout["Priority"] = i_priority.getUserDataString();
107 callout["Deconfigured"] = false;
Zane Shelleybf3326f2021-11-12 13:41:39 -0600108 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 Shelley9a738f72021-11-03 20:45:30 -0500123 io_sd.addCallout(callout);
124}
125
126//------------------------------------------------------------------------------
127
Zane Shelley1eff9452021-11-03 13:59:54 -0500128void __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 Shelley0b8368c2021-03-18 17:33:41 -0500144void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
145{
Zane Shelley96d54862021-09-17 11:16:12 -0500146 // Get the location code and entity path for this target.
147 auto locCode = __getRootCauseChipPath(io_sd);
148 auto entityPath = __getUnitPath(locCode, iv_unitPath);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500149
Zane Shelleyc85716c2021-08-17 10:54:06 -0500150 // Add the actual callout to the service data.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600151 __calloutTarget(io_sd, locCode, iv_priority, iv_guard, entityPath);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500152
Zane Shelley96d54862021-09-17 11:16:12 -0500153 // 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 Shelleya00426f2021-11-04 10:50:50 -0500158 ffdc["Guard"] = iv_guard;
Zane Shelley96d54862021-09-17 11:16:12 -0500159 io_sd.addCalloutFFDC(ffdc);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500160}
161
Zane Shelleyc85716c2021-08-17 10:54:06 -0500162//------------------------------------------------------------------------------
163
Zane Shelley5d63cef2021-09-17 18:10:17 -0500164void 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 Shelleybf3326f2021-11-12 13:41:39 -0600176 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard,
177 std::get<0>(txPath));
Zane Shelley5d63cef2021-09-17 18:10:17 -0500178
Zane Shelley5d63cef2021-09-17 18:10:17 -0500179 // 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 Shelleya00426f2021-11-04 10:50:50 -0500185 ffdc["Guard"] = iv_guard;
Zane Shelley5d63cef2021-09-17 18:10:17 -0500186 io_sd.addCalloutFFDC(ffdc);
187}
188
189//------------------------------------------------------------------------------
190
Zane Shelley4757a7b2021-09-20 22:23:38 -0500191void 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 Shelleybf3326f2021-11-12 13:41:39 -0600203 __calloutTarget(io_sd, chipPath, iv_priority, iv_guard, rxPath);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500204
205 // Callout the TX endpoint.
Zane Shelleybf3326f2021-11-12 13:41:39 -0600206 __calloutTarget(io_sd, std::get<1>(txPath), iv_priority, iv_guard,
207 std::get<0>(txPath));
Zane Shelley4757a7b2021-09-20 22:23:38 -0500208
209 // Callout everything else in between.
210 // TODO: For P10 (OMI bus and XBUS), the callout is simply the backplane.
Zane Shelley1eff9452021-11-03 13:59:54 -0500211 __calloutBackplane(io_sd, iv_priority);
Zane Shelley4757a7b2021-09-20 22:23:38 -0500212
Zane Shelley4757a7b2021-09-20 22:23:38 -0500213 // 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 Shelleya00426f2021-11-04 10:50:50 -0500220 ffdc["Guard"] = iv_guard;
Zane Shelley4757a7b2021-09-20 22:23:38 -0500221 io_sd.addCalloutFFDC(ffdc);
222}
223
224//------------------------------------------------------------------------------
225
Zane Shelleyc85716c2021-08-17 10:54:06 -0500226void 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 Shelley96d54862021-09-17 11:16:12 -0500233
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 Shelleyc85716c2021-08-17 10:54:06 -0500240}
241
Zane Shelley84721d92021-09-08 13:30:27 -0500242//------------------------------------------------------------------------------
243
244void ClockCalloutResolution::resolve(ServiceData& io_sd) const
245{
Zane Shelley1eff9452021-11-03 13:59:54 -0500246 // 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 Shelley96d54862021-09-17 11:16:12 -0500251
252 // Add the callout FFDC to the service data.
Zane Shelley1eff9452021-11-03 13:59:54 -0500253 // TODO: Add the target and guard type if guard is ever supported.
Zane Shelley96d54862021-09-17 11:16:12 -0500254 nlohmann::json ffdc;
255 ffdc["Callout Type"] = "Clock Callout";
256 ffdc["Clock Type"] = iv_clockType.getString();
Zane Shelley96d54862021-09-17 11:16:12 -0500257 ffdc["Priority"] = iv_priority.getRegistryString();
Zane Shelley96d54862021-09-17 11:16:12 -0500258 io_sd.addCalloutFFDC(ffdc);
Zane Shelley84721d92021-09-08 13:30:27 -0500259}
260
261//------------------------------------------------------------------------------
262
Zane Shelley0b8368c2021-03-18 17:33:41 -0500263} // namespace analyzer
264
265using namespace analyzer;
266
267TEST(Resolution, TestSet1)
268{
269 // Create a few resolutions
270 auto c1 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500271 proc_str, callout::Priority::HIGH, false);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500272
273 auto c2 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500274 omi_str, callout::Priority::MED_A, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500275
276 auto c3 = std::make_shared<HardwareCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500277 core_str, callout::Priority::MED, true);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500278
279 auto c4 = std::make_shared<ProcedureCalloutResolution>(
Zane Shelleyc85716c2021-08-17 10:54:06 -0500280 callout::Procedure::NEXTLVL, callout::Priority::LOW);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500281
Zane Shelley84721d92021-09-08 13:30:27 -0500282 auto c5 = std::make_shared<ClockCalloutResolution>(
283 callout::ClockType::OSC_REF_CLOCK_1, callout::Priority::LOW, false);
284
285 // l1 = (c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500286 auto l1 = std::make_shared<ResolutionList>();
287 l1->push(c1);
288 l1->push(c2);
Zane Shelley84721d92021-09-08 13:30:27 -0500289 l1->push(c5);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500290
Zane Shelley84721d92021-09-08 13:30:27 -0500291 // l2 = (c4, c3, c1, c2, c5)
Zane Shelley723fa232021-08-09 12:02:06 -0500292 auto l2 = std::make_shared<ResolutionList>();
293 l2->push(c4);
294 l2->push(c3);
295 l2->push(l1);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500296
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 Shelleyca496192021-08-09 12:05:52 -0500300 ServiceData sd1{sig, true};
301 ServiceData sd2{sig, false};
Zane Shelley0b8368c2021-03-18 17:33:41 -0500302
303 // Resolve
Zane Shelley723fa232021-08-09 12:02:06 -0500304 l1->resolve(sd1);
305 l2->resolve(sd2);
Zane Shelley0b8368c2021-03-18 17:33:41 -0500306
307 // Start verifying
308 nlohmann::json j{};
309 std::string s{};
310
Zane Shelleyc85716c2021-08-17 10:54:06 -0500311 j = sd1.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500312 s = R"([
313 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500314 "Deconfigured": false,
315 "Guarded": false,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500316 "LocationCode": "/proc0",
317 "Priority": "H"
318 },
319 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500320 "Deconfigured": false,
321 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500322 "LocationCode": "P0",
323 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500324 }
325])";
Zane Shelley96d54862021-09-17 11:16:12 -0500326 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500327
Zane Shelleyc85716c2021-08-17 10:54:06 -0500328 j = sd2.getCalloutList();
Zane Shelley0b8368c2021-03-18 17:33:41 -0500329 s = R"([
330 {
331 "Priority": "L",
Zane Shelley86ccc452021-11-16 13:10:52 -0600332 "Procedure": "next_level_support"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500333 },
334 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500335 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600336 "Guard Path": "/proc0/pib/perv39/eq7/fc1/core1",
337 "Guard Type": "GARD_Predictive",
Zane Shelley9a738f72021-11-03 20:45:30 -0500338 "Guarded": true,
Zane Shelley0b8368c2021-03-18 17:33:41 -0500339 "LocationCode": "/proc0",
Zane Shelley0b8368c2021-03-18 17:33:41 -0500340 "Priority": "H"
341 },
342 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500343 "Deconfigured": false,
344 "Guarded": false,
Zane Shelley84721d92021-09-08 13:30:27 -0500345 "LocationCode": "P0",
346 "Priority": "L"
Zane Shelley0b8368c2021-03-18 17:33:41 -0500347 }
348])";
Zane Shelley96d54862021-09-17 11:16:12 -0500349 EXPECT_EQ(s, j.dump(4));
350}
351
352TEST(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 Shelley9a738f72021-11-03 20:45:30 -0500370 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600371 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
372 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500373 "Guarded": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500374 "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 Shelleya00426f2021-11-04 10:50:50 -0500385 "Guard": true,
Zane Shelley96d54862021-09-17 11:16:12 -0500386 "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 Shelley5d63cef2021-09-17 18:10:17 -0500393TEST(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 Shelley9a738f72021-11-03 20:45:30 -0500419 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600420 "Guard Path": "/proc1/pib/perv24/pauc0/iohs0/smpgroup0",
421 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500422 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500423 "LocationCode": "/proc1",
424 "Priority": "A"
425 },
426 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500427 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600428 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
429 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500430 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500431 "LocationCode": "/proc0",
432 "Priority": "B"
433 },
434 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500435 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600436 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
437 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500438 "Guarded": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500439 "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 Shelleya00426f2021-11-04 10:50:50 -0500451 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500452 "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 Shelleya00426f2021-11-04 10:50:50 -0500458 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500459 "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 Shelleya00426f2021-11-04 10:50:50 -0500465 "Guard": true,
Zane Shelley5d63cef2021-09-17 18:10:17 -0500466 "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 Shelley4757a7b2021-09-20 22:23:38 -0500473TEST(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 Shelley9a738f72021-11-03 20:45:30 -0500499 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600500 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0",
501 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500502 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500503 "LocationCode": "/proc0",
504 "Priority": "A"
505 },
506 {
Zane Shelley9a738f72021-11-03 20:45:30 -0500507 "Deconfigured": false,
Zane Shelleybf3326f2021-11-12 13:41:39 -0600508 "Guard Path": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
509 "Guard Type": "GARD_Unrecoverable",
Zane Shelley9a738f72021-11-03 20:45:30 -0500510 "Guarded": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500511 "LocationCode": "/proc0/pib/perv12/mc0/mi0/mcc0/omi0/ocmb0",
512 "Priority": "A"
513 },
514 {
Zane Shelley1eff9452021-11-03 13:59:54 -0500515 "Deconfigured": false,
516 "Guarded": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500517 "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 Shelleya00426f2021-11-04 10:50:50 -0500528 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500529 "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 Shelleya00426f2021-11-04 10:50:50 -0500535 "Guard": true,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500536 "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 Shelleya00426f2021-11-04 10:50:50 -0500542 "Guard": false,
Zane Shelley4757a7b2021-09-20 22:23:38 -0500543 "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 Shelley96d54862021-09-17 11:16:12 -0500551TEST(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 Shelley1eff9452021-11-03 13:59:54 -0500569 "Deconfigured": false,
570 "Guarded": false,
Zane Shelley96d54862021-09-17 11:16:12 -0500571 "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 Shelley1eff9452021-11-03 13:59:54 -0500583 "Priority": "high"
Zane Shelley96d54862021-09-17 11:16:12 -0500584 }
585])";
586 EXPECT_EQ(s, j.dump(4));
587}
588
589TEST(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 Shelley86ccc452021-11-16 13:10:52 -0600608 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500609 }
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 Shelley86ccc452021-11-16 13:10:52 -0600619 "Procedure": "next_level_support"
Zane Shelley96d54862021-09-17 11:16:12 -0500620 }
621])";
622 EXPECT_EQ(s, j.dump(4));
Zane Shelley0b8368c2021-03-18 17:33:41 -0500623}