-
Notifications
You must be signed in to change notification settings - Fork 97
/
hwas.C
4301 lines (3836 loc) · 166 KB
/
hwas.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/hwas/common/hwas.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2019 */
/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
/**
* @file hwas.C
*
* HardWare Availability Service functions.
* See hwas.H for doxygen documentation tags.
*
*/
/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <algorithm>
#include <map>
#include <stdio.h> // sprintf
#ifdef __HOSTBOOT_MODULE
#include <config.h>
#include <initservice/initserviceif.H>
#endif
#include <targeting/common/commontargeting.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/util.H>
#include <hwas/common/hwas.H>
#include <hwas/common/hwasCommon.H>
#include <hwas/common/hwasError.H>
#include <hwas/common/pgLogic.H>
#include <hwas/common/deconfigGard.H>
#include <hwas/common/hwas_reasoncodes.H>
namespace HWAS
{
using namespace TARGETING;
using namespace HWAS::COMMON;
// trace setup; used by HWAS_DBG and HWAS_ERR macros
HWAS_TD_t g_trac_dbg_hwas = NULL; // debug - fast
HWAS_TD_t g_trac_imp_hwas = NULL; // important - slow
#ifdef __HOSTBOOT_MODULE
TRAC_INIT(&g_trac_dbg_hwas, "HWAS", KILOBYTE );
TRAC_INIT(&g_trac_imp_hwas, "HWAS_I", KILOBYTE );
#else
TRAC_INIT(&g_trac_dbg_hwas, "HWAS", 1024 );
TRAC_INIT(&g_trac_imp_hwas, "HWAS_I", 1024 );
#endif
// SORT functions that we'll use for PR keyword processing
bool compareProcGroup(procRestrict_t t1, procRestrict_t t2)
{
if (t1.group == t2.group)
{
return (t1.target->getAttr<ATTR_HUID>() <
t2.target->getAttr<ATTR_HUID>());
}
return (t1.group < t2.group);
}
bool compareAffinity(const TargetInfo t1, const TargetInfo t2)
{
return t1.affinityPath < t2.affinityPath;
}
/*
* @brief This function takes in proc target and returns group/chip id
* in the following bit format: GGGG CCC
* where G = Group Id and C = Chip Id
*
* @param[in] i_proc: proc target
* @retval: chip info including group and chip id
*/
uint64_t getGroupChipIdInfo (TargetHandle_t i_proc)
{
auto l_grp_id = i_proc->getAttr<ATTR_FABRIC_GROUP_ID>();
auto l_chip_id = i_proc->getAttr<ATTR_FABRIC_CHIP_ID>();
//Chip ID is three bits long, therefore, shift group id
//by 3 and OR it with chip id
return ((l_grp_id << 3) | l_chip_id);
}
/*
* @brief This function takes in the value of ATTR_PROC_MEM_TO_USE
* and extract out group and chip id
* in the following bit format: GGGG CCC
* where G = Group Id and C = Chip Id
*
* @param[in] i_proc_mem_to_use: Value of ATTR_PROC_MEM_TO_USE
* @param[out] o_grp_id: groupd id
* @param[out] o_chip_id: chip id
*/
void parseProcMemToUseIntoGrpChipId (uint8_t i_proc_mem_to_use,
uint8_t & o_grp_id,
uint8_t & o_chip_id)
{
o_grp_id = (i_proc_mem_to_use >> 3) & 0x0F;
o_chip_id = i_proc_mem_to_use & 0x07;
}
/**
* @brief simple helper fn to get and set hwas state to poweredOn,
* present, functional
*
* @param[in] i_target pointer to target that we're looking at
* @param[in] i_present boolean indicating present or not
* @param[in] i_functional boolean indicating functional or not
* @param[in] i_errlEid erreid that caused change to non-funcational;
* 0 if not associated with an error or if
* functional is true
*
* @return none
*
*/
void enableHwasState(Target *i_target,
bool i_present, bool i_functional,
uint32_t i_errlEid)
{
HwasState hwasState = i_target->getAttr<ATTR_HWAS_STATE>();
if (i_functional == false)
{ // record the EID as a reason that we're marking non-functional
hwasState.deconfiguredByEid = i_errlEid;
}
hwasState.poweredOn = true;
hwasState.present = i_present;
hwasState.functional = i_functional;
i_target->setAttr<ATTR_HWAS_STATE>( hwasState );
}
/**
* @brief disable obuses in wrap config.
* Due to fabric limitations, we can only have 2 parallel OBUS
* connections at a time in wrap config.So, deconfigure appropriate
* OBUSes using the following rule. If the value of
* MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE (on the system target) does
* not match with the value of MFG_WRAP_TEST_ABUS_LINKS_SET (on the
* OBUS target), then deconfigure the OBUSes.
* @return errlHndl_t
*
*/
errlHndl_t disableOBUSes()
{
errlHndl_t l_err = nullptr;
do
{
//get system target and figure out which links to enable
Target* pSys;
targetService().getTopLevelTarget(pSys);
auto l_links_set_enable =
pSys->getAttr<ATTR_MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE>();
//get all OBUS chiplets
TargetHandleList l_obusList;
getAllChiplets(l_obusList, TYPE_OBUS);
for (const auto & l_obus : l_obusList)
{
//It fails to compile if you compare two different enum types
//That's why, typecasting here. The underlying enum value
//should be the same.
ATTR_MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE_type l_link_set =
(ATTR_MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE_type)
l_obus->getAttr<ATTR_MFG_WRAP_TEST_ABUS_LINKS_SET>();
if (l_links_set_enable != l_link_set)
{
//deconfigure
l_err = HWAS::theDeconfigGard().deconfigureTarget(
*l_obus,
HWAS::DeconfigGard::DECONFIGURED_BY_NO_MATCHING_LINK_SET);
if (l_err)
{
HWAS_ERR("disableOBUSes: Unable to deconfigure %x OBUS",
get_huid(l_obus));
break;
}
}
}
if (l_err)
{
break;
}
//Sanity Check to make sure each proc only has a max of 2 OBUSes
//only if MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE was overidden
//because that means we are trying to run in wrap mode.
//Otherwise, it will be defaulted to SET_NONE
if (l_links_set_enable)
{
TargetHandleList l_procList;
getAllChips(l_procList, TYPE_PROC);
for (const auto & l_proc : l_procList)
{
getChildChiplets(l_obusList, l_proc, TYPE_OBUS, true);
if (l_obusList.size() > 2)
{
HWAS_ERR("disableOBUSes: Only 2 BUSes should be functional"
" under %x, found %d",
get_huid(l_proc), l_obusList.size());
/*@
* @errortype
* @severity ERRL_SEV_UNRECOVERABLE
* @moduleid MOD_DISABLE_OBUS
* @reasoncode RC_ONLY_TWO_OBUS_SHOULD_BE_CONFIGURED
* @devdesc Due to fabric limitations, only 2
* OBUSes should be configured, we found
* too many
* @custdesc A problem occurred during the IPL of
* the system: Found too many obus links
* @userdata1 HUID of proc
* @userdata2 number of functional OBUSes
*/
l_err = hwasError(ERRL_SEV_UNRECOVERABLE,
MOD_DISABLE_OBUS,
RC_ONLY_TWO_OBUS_SHOULD_BE_CONFIGURED,
get_huid(l_proc), l_obusList.size());
break;
}
}
}
} while (0);
return l_err;
}
errlHndl_t update_proc_mem_to_use (const Target* i_node)
{
errlHndl_t l_errl {nullptr};
TargetHandle_t l_masterProcTarget {nullptr};
do
{
//Get master proc
l_errl =
targetService().queryMasterProcChipTargetHandle(l_masterProcTarget,
i_node);
if (l_errl)
{
HWAS_ERR("update_proc_mem_to_use: unable to get master proc");
break;
}
//Check if this processor has missing memory
//If yes, then get the HRMOR of the proc we want to use the mem of
uint8_t l_proc_mem_to_use = l_masterProcTarget->getAttr
<ATTR_PROC_MEM_TO_USE>();
uint8_t l_proc_mem_to_use_save = l_proc_mem_to_use;
bool l_found_missing_mem = false;
l_errl = check_for_missing_memory(i_node, l_proc_mem_to_use,
l_found_missing_mem);
if (l_errl)
{
HWAS_ERR("update_proc_mem_to_use: unable to check for missing mem");
break;
}
//We found missing memory behind master proc, but
//check_for_missing_memory didn't update proc_mem_to_use
//probably because there are no other procs with memory,
//create an error.
if (l_found_missing_mem && (l_proc_mem_to_use==l_proc_mem_to_use_save))
{
HWAS_ERR("update_proc_mem_to_use: ATTR_PROC_MEM_TO_USE didn't get"
" updated even though we were missing mem behind master proc");
/*@
* @errortype
* @severity ERRL_SEV_UNRECOVERABLE
* @moduleid MOD_UPDATE_PROC_MEM_TO_USE
* @reasoncode RC_NO_UPDATE_WHEN_MEM_MISSING
* @devdesc No procs found with valid memory
* @custdesc A problem occurred during the IPL of
* the system: No memory found
* @userdata1 Saved value of ATTR_PROC_MEM_TO_USE
* @userdata2 Updated value of ATTR_PROC_MEM_TO_USE
*/
l_errl = hwasError(ERRL_SEV_UNRECOVERABLE,
MOD_UPDATE_PROC_MEM_TO_USE,
RC_NO_UPDATE_WHEN_MEM_MISSING,
l_proc_mem_to_use_save,
l_proc_mem_to_use);
hwasErrorAddProcedureCallout(l_errl,
EPUB_PRC_FIND_DECONFIGURED_PART,
SRCI_PRIORITY_HIGH);
break;
}
//set PROC_MEM_TO_USE to the group/chip id of the proc we want to
//use the mem of
//get all procs behind the input node
TargetHandleList l_procs;
getChildAffinityTargetsByState( l_procs,
i_node,
CLASS_CHIP,
TYPE_PROC,
UTIL_FILTER_ALL);
for (auto & l_proc : l_procs)
{
l_proc->setAttr<ATTR_PROC_MEM_TO_USE>(l_proc_mem_to_use);
}
} while (0);
return l_errl;
}
errlHndl_t check_for_missing_memory (const Target* i_node,
uint8_t & io_proc_mem_to_use,
bool & o_found_missing_mem)
{
errlHndl_t l_errl {nullptr};
o_found_missing_mem = true;
do
{
/////////////////////////////////////////////////////////////
//Step 1 -- Figure out the lowest group/chip id proc that has
// memory
/////////////////////////////////////////////////////////////
//get all procs behind the input node
TargetHandleList l_procs;
getChildAffinityTargetsByState( l_procs,
i_node,
CLASS_CHIP,
TYPE_PROC,
UTIL_FILTER_FUNCTIONAL);
//sort based on group/chip id. So, we can deterministically
//pick the processor with memory. This will also help guarantee
//that we will attempt to use master (or altmaster) proc's memory
//first before using slave proc's memory.
std::sort(l_procs.begin(), l_procs.end(),
[] (TargetHandle_t a, TargetHandle_t b)
{
return getGroupChipIdInfo(a) < getGroupChipIdInfo(b);
});
uint8_t l_temp_proc_mem_to_use = io_proc_mem_to_use;
//find a processor that has dimms
for (auto & l_proc : l_procs)
{
TargetHandleList l_funcDimms;
getChildAffinityTargetsByState( l_funcDimms,
l_proc,
CLASS_LOGICAL_CARD,
TYPE_DIMM,
UTIL_FILTER_FUNCTIONAL);
//Pick the first proc we find with dimms
if (l_funcDimms.size() > 0)
{
l_temp_proc_mem_to_use = getGroupChipIdInfo(l_proc);
break;
}
}
/////////////////////////////////////////////////////////////
//Step 2 -- Get the proc we are currently using the memory of
// and check if it has memory
/////////////////////////////////////////////////////////////
//get the proc pointed by PROC_MEM_TO_USE and check
//if there is memory behind that proc. We rely on the current
//value of PROC_MEM_TO_USE, so, we don't change our answer
//unnecessarily (in cases when both master proc and altmaster
//have memory)
uint8_t l_grp = 0;
uint8_t l_chip = 0;
parseProcMemToUseIntoGrpChipId(io_proc_mem_to_use, l_grp, l_chip);
PredicateAttrVal<ATTR_FABRIC_GROUP_ID> l_predGrp (l_grp);
PredicateAttrVal<ATTR_FABRIC_CHIP_ID> l_predChip (l_chip);
PredicateCTM l_predProc (CLASS_CHIP, TYPE_PROC);
PredicateIsFunctional l_isFunctional;
PredicatePostfixExpr l_procCheckExpr;
l_procCheckExpr.push(&l_predProc).push(&l_isFunctional).
push(&l_predGrp).push(&l_predChip).And().And().And();
TargetHandleList l_procMemUsedCurrently;
targetService().getAssociated(l_procMemUsedCurrently,
i_node,
TargetService::CHILD_BY_AFFINITY,
TargetService::IMMEDIATE,
&l_procCheckExpr);
HWAS_INF("check_for_missing_memory: looking for a proc with "
"grp=0x%x chip=0x%x, found %d procs",
l_grp, l_chip, l_procMemUsedCurrently.size());
if (l_procMemUsedCurrently.size() >= 1)
{
//found proc
//Check if proc whose memory we are currently using has dimms
TargetHandleList l_funcDimms;
getChildAffinityTargetsByState( l_funcDimms,
l_procMemUsedCurrently[0],
CLASS_LOGICAL_CARD,
TYPE_DIMM,
UTIL_FILTER_FUNCTIONAL);
if (l_funcDimms.size() > 0)
{
//we found dimms behind the proc we are currently using
o_found_missing_mem = false;
}
}
/////////////////////////////////////////////////////////////
//Step 3-- If proc picked in Step1 has lower group/chip id
// than current proc_mem_to_use value or
// there is no memory behind the currently used proc,
// then we update the proc_mem_to_use
//NOTE: This ensures that if someone replaces the dimm on a lowered
// number proc, then we can fall back to that lowered number
// proc. Also, it makes sure that we are updating only when
// current proc_mem_to_use doesn't have memory or it's not
// pointing to a valid proc.
/////////////////////////////////////////////////////////////
if ((l_temp_proc_mem_to_use < io_proc_mem_to_use)
|| (o_found_missing_mem))
{
HWAS_INF("check_for_missing_memory: found a need to switch"
" PROC_MEM_TO_USE from 0x%x to 0x%x",
io_proc_mem_to_use, l_temp_proc_mem_to_use);
io_proc_mem_to_use = l_temp_proc_mem_to_use;
}
else
{
HWAS_INF("check_for_missing_memory: kept PROC_MEM_TO_USE same"
" 0x%x", io_proc_mem_to_use);
}
} while (0);
return l_errl;
}
errlHndl_t check_current_proc_mem_to_use_is_still_valid (bool o_match)
{
errlHndl_t l_err {nullptr};
o_match = true;
do
{
//Get the master proc to get the current value of PROC_MEM_TO_USE
TargetHandle_t l_mProc;
l_err = targetService().queryMasterProcChipTargetHandle(l_mProc);
if (l_err)
{
HWAS_ERR("ERROR: getting master proc");
break;
}
auto l_proc_mem_to_use = l_mProc->getAttr<ATTR_PROC_MEM_TO_USE>();
//Get the node target to pass to check_for_missing_memory
TargetHandleList l_nodes;
getEncResources(l_nodes, TYPE_NODE, UTIL_FILTER_FUNCTIONAL);
HWAS_ASSERT((l_nodes.size() == 1), "Only expecting 1 functional node");
auto l_curr_proc_mem_to_use = l_proc_mem_to_use;
bool l_found_missing_mem {false};
l_err = HWAS::check_for_missing_memory(l_nodes[0],
l_proc_mem_to_use,
l_found_missing_mem);
if (l_err)
{
HWAS_ERR("ERROR: check_for_missing_memory");
break;
}
HWAS_INF("PROC_MEM_TO_USE currentVal=0x%x reComputedVal=0x%x",
l_curr_proc_mem_to_use, l_proc_mem_to_use);
if (l_curr_proc_mem_to_use != l_proc_mem_to_use)
{
HWAS_INF("check_current_proc_mem_to_use_is_still_valid: "
"currentVal and reComputerVal don't match");
o_match = false;
}
} while (0);
return l_err;
}
/**
* @brief Do presence detect on only MUX targets and enable HWAS state
*
* @param[in] i_sysTarget the top level target (CLASS_SYS)
* @return errlHndl_t return nullptr if no error,
* else return a handle to an error entry
*
*/
errlHndl_t discoverMuxTargetsAndEnable(const Target &i_sysTarget)
{
HWAS_DBG(ENTER_MRK"discoverMuxTargetsAndEnable");
errlHndl_t l_err{nullptr};
do
{
// Only get MUX targets
const PredicateCTM l_muxPred(CLASS_CHIP, TYPE_I2C_MUX);
TARGETING::PredicatePostfixExpr l_muxPredExpr;
l_muxPredExpr.push(&l_muxPred);
TargetHandleList l_pMuxCheckPres;
targetService().getAssociated( l_pMuxCheckPres, (&i_sysTarget),
TargetService::CHILD, TargetService::ALL, &l_muxPredExpr);
// Do the presence detect on only MUX targets
l_err = platPresenceDetect(l_pMuxCheckPres);
// If an issue with platPresenceDetect, then exit, returning
// error back to caller
if (nullptr != l_err)
{
break;
}
// Enable the HWAS State for the MUXes
const bool l_present(true);
const bool l_functional(true);
const uint32_t l_errlEid(0);
for (TargetHandle_t pTarget : l_pMuxCheckPres)
{
// set HWAS state to show MUX is present and functional
enableHwasState(pTarget, l_present, l_functional, l_errlEid);
}
} while (0);
HWAS_DBG(EXIT_MRK"discoverMuxTargetsAndEnable exit with %s",
(nullptr == l_err ? "no error" : "error"));
return l_err;
}
errlHndl_t discoverTargets()
{
HWAS_DBG("discoverTargets entry");
errlHndl_t errl = NULL;
// loop through all the targets and set HWAS_STATE to a known default
for (TargetIterator target = targetService().begin();
target != targetService().end();
++target)
{
// TODO:RTC:151617 Need to find a better way
// to initialize the target
TARGETING::ATTR_INIT_TO_AVAILABLE_type initToAvailable = false;
if( (target->tryGetAttr<TARGETING::ATTR_INIT_TO_AVAILABLE>(
initToAvailable))
&& (initToAvailable))
{
HwasState hwasState = target->getAttr<ATTR_HWAS_STATE>();
hwasState.deconfiguredByEid = 0;
hwasState.poweredOn = true;
hwasState.present = true;
hwasState.functional = true;
hwasState.dumpfunctional = false;
target->setAttr<ATTR_HWAS_STATE>(hwasState);
}
else
{
HwasState hwasState = target->getAttr<ATTR_HWAS_STATE>();
hwasState.deconfiguredByEid = 0;
hwasState.poweredOn = false;
hwasState.present = false;
hwasState.functional = false;
hwasState.dumpfunctional = false;
target->setAttr<ATTR_HWAS_STATE>(hwasState);
}
}
// Assumptions and actions:
// CLASS_SYS (exactly 1) - mark as present
// CLASS_ENC, TYPE_PROC, TYPE_MCS, TYPE_MEMBUF, TYPE_DIMM
// (ALL require hardware query) - call platPresenceDetect
// \->children: CLASS_* (NONE require hardware query) - mark as present
do
{
// find CLASS_SYS (the top level target)
Target* pSys;
targetService().getTopLevelTarget(pSys);
HWAS_ASSERT(pSys,
"HWAS discoverTargets: no CLASS_SYS TopLevelTarget found");
// mark this as present
enableHwasState(pSys, true, true, 0);
HWAS_DBG("pSys %.8X - marked present",
pSys->getAttr<ATTR_HUID>());
// Certain targets have dependencies on the MUX, so it is best to
// presence detect and enable the MUX before moving on to these targets.
// Please take this into consideration if code needs to be rearranged
// in the future.
errl = discoverMuxTargetsAndEnable(*pSys);
if (errl != NULL)
{
break; // break out of the do/while so that we can return
}
PredicateCTM predEnc(CLASS_ENC);
PredicateCTM predChip(CLASS_CHIP);
PredicateCTM predDimm(CLASS_LOGICAL_CARD, TYPE_DIMM);
PredicateCTM predMcs(CLASS_UNIT, TYPE_MCS);
PredicateCTM predPmic(CLASS_ASIC, TYPE_PMIC);
// We can ignore chips of TYPE_I2C_MUX because they
// were already detected above in discoverMuxTargetsAndEnable
PredicateCTM predMux(CLASS_CHIP, TYPE_I2C_MUX);
PredicatePostfixExpr checkExpr;
checkExpr.push(&predChip).push(&predDimm).Or().push(&predEnc).Or().
push(&predMcs).Or().push(&predPmic).Or().
push(&predMux).Not().And();
TargetHandleList pCheckPres;
targetService().getAssociated( pCheckPres, pSys,
TargetService::CHILD, TargetService::ALL, &checkExpr );
// pass this list to the hwas platform-specific api where
// pCheckPres will be modified to only have present targets
HWAS_DBG("pCheckPres size: %d", pCheckPres.size());
errl = platPresenceDetect(pCheckPres);
HWAS_DBG("pCheckPres size: %d", pCheckPres.size());
if (errl != NULL)
{
break; // break out of the do/while so that we can return
}
// for each, read their ID/EC level. if that works,
// mark them and their descendants as present
// read the partialGood vector to determine if any are not functional
// and read and store values from the PR keyword
// list of procs and data that we'll need to look at when potentially
// reducing the list of valid ECs later
procRestrict_t l_procEntry;
std::vector <procRestrict_t> l_procRestrictList;
// sort the list by ATTR_HUID to ensure that we
// start at the same place each time
std::sort(pCheckPres.begin(), pCheckPres.end(),
compareTargetHuid);
for (TargetHandleList::const_iterator pTarget_it = pCheckPres.begin();
pTarget_it != pCheckPres.end();
++pTarget_it
)
{
TargetHandle_t pTarget = *pTarget_it;
// if CLASS_ENC is still in this list, mark as present
if (pTarget->getAttr<ATTR_CLASS>() == CLASS_ENC)
{
enableHwasState(pTarget, true, true, 0);
HWAS_DBG("pTarget %.8X - CLASS_ENC marked present",
pTarget->getAttr<ATTR_HUID>());
// on to the next target
continue;
}
bool chipPresent = true;
bool chipFunctional = true;
bool createInfoLog = false;
uint32_t errlEid = 0;
uint16_t pgData[VPD_CP00_PG_DATA_ENTRIES];
bzero(pgData, sizeof(pgData));
// Cache the target type
auto l_targetType = pTarget->getAttr<ATTR_TYPE>();
// This error is created preemptively to capture any targets that
// were deemed non-functional for partial good reasons. If there are
// no issues, then this error log is deleted.
/*@
* @errortype
* @severity ERRL_SEV_INFORMATIONAL
* @moduleid MOD_DISCOVER_TARGETS
* @reasoncode RC_PARTIAL_GOOD_INFORMATION
* @devdesc Partial Good (PG) issues are present within the
* system and this error log contains information
* about which targets, procs, and entries in the
* PG vector are problematic.
* @custdesc An issue occured during IPL of the system:
* Internal Firmware Error
* @userdata1 None
* @userdata2 None
*/
errlHndl_t infoErrl = hwasError(ERRL_SEV_INFORMATIONAL,
MOD_DISCOVER_TARGETS,
RC_PARTIAL_GOOD_INFORMATION);
if( (pTarget->getAttr<ATTR_CLASS>() == CLASS_CHIP)
&& (l_targetType != TYPE_TPM)
&& (l_targetType != TYPE_SP)
&& (l_targetType != TYPE_BMC)
&& (l_targetType != TYPE_I2C_MUX))
{
// read Chip ID/EC data from these physical chips
errl = platReadIDEC(pTarget);
if (errl)
{
// read of ID/EC failed even tho we THOUGHT we were present.
HWAS_INF("pTarget 0x%.8X - read IDEC failed "
"(eid 0x%X) - bad",
get_huid(pTarget), errl->eid());
// chip NOT present and NOT functional, so that FSP doesn't
// include this for HB to process
chipPresent = false;
chipFunctional = false;
errlEid = errl->eid();
// commit the error but keep going
errlCommit(errl, HWAS_COMP_ID);
// errl is now NULL
}
else if (l_targetType == TYPE_PROC)
{
// read partialGood vector from these as well.
errl = platReadPartialGood(pTarget, pgData);
if (errl)
{ // read of PG failed even tho we were present..
HWAS_INF("pTarget 0x%.8X - read PG failed "
"(eid 0x%X) - bad",
get_huid(pTarget), errl->eid());
chipFunctional = false;
errlEid = errl->eid();
// commit the error but keep going
errlCommit(errl, HWAS_COMP_ID);
// errl is now NULL
}
else
{
// look at the 'nest' logic to override the
// functionality of this proc
chipFunctional =
isChipFunctional(pTarget,
pgData);
if(!chipFunctional)
{
// Add this proc to the informational error log.
platHwasErrorAddHWCallout(infoErrl,
pTarget,
SRCI_PRIORITY_HIGH,
NO_DECONFIG,
GARD_NULL);
createInfoLog = true;
}
// Fill in a dummy restrict list
l_procEntry.target = pTarget;
// every proc is uniquely counted
l_procEntry.group = pTarget->getAttr<ATTR_HUID>();
// just 1 proc per group
l_procEntry.procs = 1;
// indicates we should use all available ECs
l_procEntry.maxECs = UINT32_MAX;
l_procRestrictList.push_back(l_procEntry);
}
} // TYPE_PROC
} // CLASS_CHIP
HWAS_DBG("pTarget %.8X - detected present, %sfunctional",
pTarget->getAttr<ATTR_HUID>(),
chipFunctional ? "" : "NOT ");
// Now determine if the descendants of this target are
// present and/or functional
checkPartialGoodForDescendants(pTarget,
pgData,
chipFunctional,
errlEid,
infoErrl,
createInfoLog);
// set HWAS state to show CHIP is present, functional per above
enableHwasState(pTarget, chipPresent, chipFunctional, errlEid);
// If there were partial good issues with the chip or its
// descendents then create an info error log. Otherwise, delete
// and move on.
if (createInfoLog)
{
TargetHandle_t l_masterProc = nullptr;
//Get master proc
errl =
targetService()
.queryMasterProcChipTargetHandle(l_masterProc);
if (errl)
{
HWAS_ERR("discoverTargets: unable to get master proc");
errlCommit(errl, HWAS_COMP_ID);
errlCommit(infoErrl, HWAS_COMP_ID);
break;
}
auto l_model = l_masterProc->getAttr<ATTR_MODEL>();
// Setup model dependent all good data
uint16_t l_modelPgData[MODEL_PG_DATA_ENTRIES] = {0};
l_modelPgData[0] = (MODEL_NIMBUS == l_model)
? (VPD_CP00_PG_XBUS_GOOD_NIMBUS
| VPD_CP00_PG_XBUS_IOX[0])
: VPD_CP00_PG_XBUS_GOOD_CUMULUS;
l_modelPgData[1] = (TARGETING::MODEL_NIMBUS == l_model)
? VPD_CP00_PG_RESERVED_GOOD
: VPD_CP00_PG_OBUS_GOOD;
hwasErrorAddPartialGoodFFDC(infoErrl, l_modelPgData, pgData);
errlCommit(infoErrl, HWAS_COMP_ID);
}
else
{
delete infoErrl;
infoErrl = nullptr;
}
} // for pTarget_it
// Check for non-present Procs and if found, trigger
// DeconfigGard::_invokeDeconfigureAssocProc() to run by setting
// setXAOBusEndpointDeconfigured to true
PredicateCTM predProc(CLASS_CHIP, TYPE_PROC);
TargetHandleList l_procs;
targetService().getAssociated(l_procs,
pSys,
TargetService::CHILD,
TargetService::ALL,
&predProc);
for (TargetHandleList::const_iterator
l_procsIter = l_procs.begin();
l_procsIter != l_procs.end();
++l_procsIter)
{
if ( !(*l_procsIter)->getAttr<ATTR_HWAS_STATE>().present )
{
HWAS_INF("discoverTargets: Proc %.8X not present",
(*l_procsIter)->getAttr<ATTR_HUID>());
HWAS::theDeconfigGard().setXAOBusEndpointDeconfigured(true);
}
}
//Check all of the slave processor's EC levels to ensure they match master
//processor's EC level.
//function will return error log pointing to all error logs created
//by this function as this function could detect multiple procs w/
//bad ECs and will make a log for each
errl = validateProcessorEcLevels();
if (errl)
{
HWAS_ERR("discoverTargets: validateProcessorEcLevels failed");
break;
}
// Potentially reduce the number of ec/core units that are present
// based on fused mode
// marking bad units as present=false;
// deconfigReason = 0 because present is false so this is not a
// deconfigured event.
errl = restrictECunits(l_procRestrictList, false, 0);
if (errl)
{
HWAS_ERR("discoverTargets: restrictECunits failed");
break;
}
// Mark any MCA units that are present but have a disabled port
// as non-functional
errl = markDisabledMcas();
if (errl)
{
HWAS_ERR("discoverTargets: markDisabledMcas failed");
break;
}
// call invokePresentByAssoc() to obtain functional MCSs, MEMBUFs, and
// DIMMs for non-direct memory or MCSs, MCAs, and DIMMs for direct
// memory. Call algorithm function presentByAssoc() to determine
// targets that need to be deconfigured
invokePresentByAssoc();
#ifdef __HOSTBOOT_MODULE
if (INITSERVICE::isSMPWrapConfig())
{
//Due to fabric limitations, we can only have 2 parallel OBUS
//connections at a time in wrap config. So, deconfigure appropriate
//OBUSes using the following rule. If the value of
//MFG_WRAP_TEST_ABUS_LINKS_SET_ENABLE (on the system target) does
//not match with the value of MFG_WRAP_TEST_ABUS_LINKS_SET (on the
//OBUS target), then deconfigure the OBUSes.
errl = disableOBUSes();
if (errl)
{
HWAS_ERR ("discoverTargets:: disableOBUSes failed");
break;
}
}
#endif
} while (0);
if (errl)
{
HWAS_INF("discoverTargets failed (plid 0x%X)", errl->plid());
}
else
{
HWAS_INF("discoverTargets completed successfully");
}
return errl;
} // discoverTargets
bool isChipFunctional(const TARGETING::TargetHandle_t &i_target,
const uint16_t i_pgData[])
{
bool l_chipFunctional = true;
ATTR_MODEL_type l_model = i_target->getAttr<ATTR_MODEL>();
uint16_t l_xbus = (l_model == MODEL_NIMBUS) ?
VPD_CP00_PG_XBUS_GOOD_NIMBUS : VPD_CP00_PG_XBUS_GOOD_CUMULUS;
uint16_t l_perv = (l_model == MODEL_AXONE) ?
VPD_CP00_PG_PERVASIVE_GOOD_AXONE : VPD_CP00_PG_PERVASIVE_GOOD;
uint16_t l_n2 = (l_model == MODEL_AXONE) ?
VPD_CP00_PG_N2_GOOD_AXONE : VPD_CP00_PG_N2_GOOD;
// Check all bits in FSI entry
if (i_pgData[VPD_CP00_PG_FSI_INDEX] !=
VPD_CP00_PG_FSI_GOOD)
{
HWAS_INF("pTarget %.8X - FSI pgData[%d]: "
"actual 0x%04X, expected 0x%04X - bad",
i_target->getAttr<ATTR_HUID>(),
VPD_CP00_PG_FSI_INDEX,
i_pgData[VPD_CP00_PG_FSI_INDEX],
VPD_CP00_PG_FSI_GOOD);
l_chipFunctional = false;
}
else
// Check all bits in PRV entry
if (i_pgData[VPD_CP00_PG_PERVASIVE_INDEX] !=
l_perv)
{
HWAS_INF("pTarget %.8X - Pervasive pgData[%d]: "
"actual 0x%04X, expected 0x%04X - bad",
i_target->getAttr<ATTR_HUID>(),
VPD_CP00_PG_PERVASIVE_INDEX,