summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/ecc/ecc.H
blob: 610d204893281e9c72869d7e0debb5c35c899b12 (plain)
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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/generic/memory/lib/ecc/ecc.H $                     */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2019,2020                        */
/* [+] 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 ecc.H
/// @brief Top level API for MSS ECC
///
// *HWP HWP Owner: Matt Hickman <Matthew.Hickman@ibm.com>
// *HWP HWP Backup: Stephen Glancy <sglancy@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: FSP:HB

#ifndef _MSS_ECC_H_
#define _MSS_ECC_H_

#include <fapi2.H>
#include <generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H>
#include <generic/memory/lib/utils/shared/mss_generic_consts.H>
#include <generic/memory/lib/utils/mcbist/gen_mss_mcbist.H>
#include <generic/memory/lib/ecc/ecc_traits.H>
#include <generic/memory/lib/ecc/galois.H>
#include <generic/memory/lib/ecc/hw_mark_store.H>
#include <generic/memory/lib/ecc/fw_mark_store.H>
#include <generic/memory/lib/ecc/mainline_nce_trap.H>
#include <generic/memory/lib/ecc/mainline_rce_trap.H>
#include <generic/memory/lib/ecc/mainline_mpe_trap.H>
#include <generic/memory/lib/ecc/mainline_ue_trap.H>
#include <generic/memory/lib/ecc/mainline_aue_trap.H>
#include <generic/memory/lib/ecc/mbs_error_vector_trap.H>
#include <generic/memory/lib/ecc/maint_current_trap.H>
#include <generic/memory/lib/ecc/read_error_count_regs.H>
#include <generic/memory/lib/ecc/modal_symbol_count.H>
#include <generic/memory/lib/ecc/mark_shadow_reg.H>

namespace mss
{

namespace ecc
{

///
/// @brief Get Hardware Mark Store
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[in] i_rank the desired rank
/// @param[out] o_galois the Galois code of the mark
/// @param[out] o_confirmed true if the mark is a chipmark
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_hwms( const fapi2::Target<T>& i_target,
                                   const uint64_t i_rank,
                                   uint64_t& o_galois,
                                   mss::states& o_confirmed )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::hwms::read(i_target, i_rank, l_buffer) );
    mss::ecc::hwms::get_chipmark(l_buffer, o_galois);
    mss::ecc::hwms::get_confirmed(l_buffer, o_confirmed);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Set Hardware Mark Store
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[in] i_rank the desired rank
/// @param[in] i_galois the Galois code of the mark, or set to 0 to clear mark
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode set_hwms( const fapi2::Target<T>& i_target,
                                   const uint64_t i_rank,
                                   const uint64_t i_galois )
{
    fapi2::buffer<uint64_t> l_buffer;
    uint8_t l_symbol = 0;

    // galois value of 0 means to clear the mark so only fill in fields if non-zero
    if (i_galois != 0)
    {
        // check for valid Galois code
        FAPI_TRY( mss::ecc::galois_to_symbol( (uint8_t)i_galois, l_symbol) );

        mss::ecc::hwms::set_chipmark(l_buffer, i_galois);
        mss::ecc::hwms::set_confirmed(l_buffer, mss::YES);
        mss::ecc::hwms::set_exit_1(l_buffer, mss::YES);
    }

    FAPI_TRY( mss::ecc::hwms::write(i_target, i_rank, l_buffer) );

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Firmware Mark Store
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[in] i_rank the desired rank
/// @param[out] o_galois the Galois code of the mark
/// @param[out] o_type the type code of the mark
/// @param[out] o_region the region code of the mark
/// @param[out] o_address the starting address of the mark
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_fwms( const fapi2::Target<T>& i_target,
                                   const uint64_t i_rank,
                                   uint64_t& o_galois,
                                   mss::ecc::fwms::mark_type& o_type,
                                   mss::ecc::fwms::mark_region& o_region,
                                   mss::mcbist::address& o_address )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::fwms::read(i_target, i_rank, l_buffer) );
    mss::ecc::fwms::get_mark(l_buffer, o_galois);
    mss::ecc::fwms::get_type(l_buffer, o_type);
    mss::ecc::fwms::get_region(l_buffer, o_region);
    mss::ecc::fwms::get_address(l_buffer, o_address);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Set Firmware Mark Store
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[in] i_rank the desired rank
/// @param[in] i_galois the Galois code of the mark, or set to 0 to clear mark
/// @param[in] i_type the type code of the mark
/// @param[in] i_region the region code of the mark
/// @param[in] i_address the starting address of the mark
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode set_fwms( const fapi2::Target<T>& i_target,
                                   const uint64_t i_rank,
                                   const uint64_t i_galois,
                                   const mss::ecc::fwms::mark_type i_type,
                                   const mss::ecc::fwms::mark_region i_region,
                                   const mss::mcbist::address i_address )
{
    fapi2::buffer<uint64_t> l_buffer = 0;
    uint8_t l_symbol = 0;

    // galois value of 0 means to clear the mark so only fill in fields if non-zero
    if (i_galois != 0)
    {
        // check for valid Galois code
        FAPI_TRY( mss::ecc::galois_to_symbol( (uint8_t)i_galois, l_symbol) );

        mss::ecc::fwms::set_mark(l_buffer, i_galois);
        mss::ecc::fwms::set_type(l_buffer, i_type);
        mss::ecc::fwms::set_region(l_buffer, i_region);
        mss::ecc::fwms::set_address(l_buffer, i_address);
        mss::ecc::fwms::set_exit_1(l_buffer, mss::YES);
    }

    FAPI_TRY( mss::ecc::fwms::write(i_target, i_rank, l_buffer) );

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Query Hardware Marks
/// @tparam T the fapi2::TargetType - derived
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_target the fapi2 target
/// @param[out] o_marks vector of Galois codes of any marks set
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
/// @note no rank information is returned
///
template< fapi2::TargetType T, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline fapi2::ReturnCode get_hw_marks( const fapi2::Target<T>& i_target,
                                       std::vector<uint64_t>& o_marks )
{
    fapi2::buffer<uint64_t> l_buffer;
    uint64_t l_galois = 0;
    auto l_confirmed = mss::states::NO;

    o_marks.clear();

    for (uint64_t l_rank = 0; l_rank < TT::ECC_MAX_MRANK_PER_PORT; ++l_rank)
    {
        FAPI_TRY( get_hwms(i_target, l_rank, l_galois, l_confirmed) );

        if (l_confirmed == mss::states::YES)
        {
            o_marks.push_back(l_galois);
        }
    }

    return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Query Firmware Marks
/// @tparam T the fapi2::TargetType - derived
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_target the fapi2 target
/// @param[out] o_marks vector of Galois codes of any marks set
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
/// @note no rank information is returned
///
template< fapi2::TargetType T, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline fapi2::ReturnCode get_fw_marks( const fapi2::Target<T>& i_target,
                                       std::vector<uint64_t>& o_marks )
{
    fapi2::buffer<uint64_t> l_buffer;
    uint64_t l_galois = 0;
    auto l_type = mss::ecc::fwms::mark_type::CHIP;
    auto l_region = mss::ecc::fwms::mark_region::UNIVERSAL;
    mss::mcbist::address l_address;

    o_marks.clear();

    for (uint64_t l_rank = 0; l_rank < TT::ECC_MAX_MRANK_PER_PORT; ++l_rank)
    {
        FAPI_TRY( get_fwms(i_target, l_rank, l_galois, l_type, l_region, l_address) );

        if (l_region != mss::ecc::fwms::mark_region::DISABLED)
        {
            o_marks.push_back(l_galois);
        }
    }

    return fapi2::FAPI2_RC_SUCCESS;

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline NCE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline nce
/// @param[out] o_on_rce mss::YES if nce is part of an rce
/// @param[out] o_is_tce mss::YES if nce is a tce
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_nce_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address,
        mss::states& o_on_rce,
        mss::states& o_is_tce )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_nce_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_nce_trap::get_address(l_buffer, o_address);
    mss::ecc::mainline_nce_trap::get_nce_on_rce(l_buffer, o_on_rce);
    mss::ecc::mainline_nce_trap::get_nce_is_tce(l_buffer, o_is_tce);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline NCE error vector traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_galois the Galois code
/// @param[out] o_magnitude the magnitude of the error
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_nce_error_vector_trap( const fapi2::Target<T>& i_target,
        uint64_t& o_galois,
        uint64_t& o_magnitude )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mbs_error_vector_trap::read(i_target, l_buffer) );
    mss::ecc::mbs_error_vector_trap::get_nce_galois(i_target, l_buffer, o_galois);
    mss::ecc::mbs_error_vector_trap::get_nce_magnitude(i_target, l_buffer, o_magnitude);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline TCE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline nce
/// @param[out] o_on_rce mss::YES if nce is part of an rce
/// @param[out] o_is_tce mss::YES if nce is a tce
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_tce_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address,
        mss::states& o_on_rce,
        mss::states& o_is_tce )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_nce_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_nce_trap::get_address(l_buffer, o_address);
    mss::ecc::mainline_nce_trap::get_nce_on_rce(l_buffer, o_on_rce);
    mss::ecc::mainline_nce_trap::get_nce_is_tce(l_buffer, o_is_tce);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline TCE error vector traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_nce_galois the Galois code
/// @param[out] o_nce_magnitude the magnitude of the error
/// @param[out] o_tce_galois the Galois code
/// @param[out] o_tce_magnitude the magnitude of the error
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_tce_error_vector_trap( const fapi2::Target<T>& i_target,
        uint64_t& o_nce_galois,
        uint64_t& o_nce_magnitude,
        uint64_t& o_tce_galois,
        uint64_t& o_tce_magnitude )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mbs_error_vector_trap::read(i_target, l_buffer) );
    mss::ecc::mbs_error_vector_trap::get_nce_galois(i_target, l_buffer, o_nce_galois);
    mss::ecc::mbs_error_vector_trap::get_nce_magnitude(i_target, l_buffer, o_nce_magnitude);
    mss::ecc::mbs_error_vector_trap::get_tce_galois(i_target, l_buffer, o_tce_galois);
    mss::ecc::mbs_error_vector_trap::get_tce_magnitude(i_target, l_buffer, o_tce_magnitude);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline MPE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline mpe
/// @param[out] o_on_rce mss::YES if mpe is part of an rce
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_mpe_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address,
        mss::states& o_on_rce )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_mpe_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_mpe_trap::get_address(l_buffer, o_address);
    mss::ecc::mainline_mpe_trap::get_mpe_on_rce(l_buffer, o_on_rce);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline RCE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline rce
/// @param[out] o_nce_on_rce mss::YES if nce is part of an rce
/// @param[out] o_tce_on_rce mss::YES if tce is part of an rce
/// @param[out] o_mpe_on_rce mss::YES if mpe is part of an rce
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_rce_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address,
        mss::states& o_nce_on_rce,
        mss::states& o_tce_on_rce,
        mss::states& o_mpe_on_rce )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_rce_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_rce_trap::get_address(l_buffer, o_address);

    FAPI_TRY( mss::ecc::mainline_nce_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_nce_trap::get_nce_on_rce(l_buffer, o_nce_on_rce);
    mss::ecc::mainline_nce_trap::get_nce_is_tce(l_buffer, o_tce_on_rce);

    FAPI_TRY( mss::ecc::mainline_mpe_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_mpe_trap::get_mpe_on_rce(l_buffer, o_mpe_on_rce);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline UE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline ue
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_ue_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_ue_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_ue_trap::get_address(l_buffer, o_address);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Mainline AUE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the trap address of the last mainline aue
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_aue_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mainline_aue_trap::read(i_target, l_buffer) );
    mss::ecc::mainline_aue_trap::get_address(l_buffer, o_address);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get IMPE address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_chipmark the mark location (Galois code) of the last mark placed
/// @param[out] o_rank the rank of the last mark placed
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_impe_addr_trap( const fapi2::Target<T>& i_target,
        uint64_t& o_chipmark,
        uint64_t& o_rank )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mark_shadow_reg::read(i_target, l_buffer) );
    mss::ecc::mark_shadow_reg::get_chipmark(l_buffer, o_chipmark);
    mss::ecc::mark_shadow_reg::get_rank(l_buffer, o_rank);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Maint Current address traps
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_address the last address executed
/// @param[out] o_port_trap port value if MCBCFGQ_cfg_current_addr_trap_update_dis == 0
/// @param[out] o_dimm_trap dimm value if MCBCFGQ_cfg_current_addr_trap_update_dis == 0
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_maint_current_addr_trap( const fapi2::Target<T>& i_target,
        mss::mcbist::address& o_address,
        uint64_t& o_port_trap,
        uint64_t& o_dimm_trap )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::maint_current_trap::read(i_target, l_buffer) );
    mss::ecc::maint_current_trap::get_address(l_buffer, o_address);
    mss::ecc::maint_current_trap::get_port(l_buffer, o_port_trap);
    mss::ecc::maint_current_trap::get_dimm(l_buffer, o_dimm_trap);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Per Symbol Error Counts
/// @tparam T the fapi2::TargetType - derived
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_target the fapi2 target
/// @param[out] o_error_counts vector of symbol error counts
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline fapi2::ReturnCode get_per_symbol_error_counts( const fapi2::Target<T>& i_target,
        std::vector<uint64_t>& o_error_counts )
{
    fapi2::buffer<uint64_t> l_buffer;
    uint64_t l_count = 0;
    o_error_counts.clear();

    for (uint64_t l_index = 0; l_index < TT::NUM_MBSSYM_REGS; ++l_index)
    {
        FAPI_TRY( mss::ecc::modal_symbol_count::read(i_target, l_index, l_buffer) );

        for (uint64_t l_symbol = 0; l_symbol < TT::MODAL_SYMBOL_COUNTERS_PER_REG; ++l_symbol)
        {
            l_count = 0;
            mss::ecc::modal_symbol_count::get_count(l_buffer, l_symbol, l_count);
            o_error_counts.push_back(l_count);
        }
    }

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Intermittent NCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of intermittent NCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_intermittent_nce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg0::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg0::get_intermittent_ce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Soft NCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of soft NCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_soft_nce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg0::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg0::get_soft_ce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Hard NCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of hard NCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_hard_nce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg0::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg0::get_hard_ce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Intermittent MCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of intermittent MCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_intermittent_mce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg0::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg0::get_intermittent_mce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Soft MCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of soft MCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_soft_mce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg0::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg0::get_soft_mce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get Hard MCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of hard MCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_hard_mce_count( const fapi2::Target<T>& i_target,
        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg1::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg1::get_hard_mce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get ICE (IMPE) error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of ICE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_ice_count( const fapi2::Target<T>& i_target,
                                        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg1::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg1::get_ice_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get UE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of UE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_ue_count( const fapi2::Target<T>& i_target,
                                       uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg1::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg1::get_ue_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get AUE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of AUE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_aue_count( const fapi2::Target<T>& i_target,
                                        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg1::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg1::get_aue_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get RCE error count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_count count of RCE events
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_rce_count( const fapi2::Target<T>& i_target,
                                        uint64_t& o_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::read_error_count_reg1::read(i_target, l_buffer) );
    mss::ecc::read_error_count_reg1::get_rce_count(l_buffer, o_count);

fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Get MCE symbol count
/// @tparam T the fapi2::TargetType - derived
/// @param[in] i_target the fapi2 target
/// @param[out] o_symbol0_count count of symbol 0 errors
/// @param[out] o_symbol1_count count of symbol 1 errors
/// @param[out] o_symbol2_count count of symbol 2 errors
/// @param[out] o_symbol3_count count of symbol 3 errors
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode get_mce_symbol_count( const fapi2::Target<T>& i_target,
        uint64_t& o_symbol0_count,
        uint64_t& o_symbol1_count,
        uint64_t& o_symbol2_count,
        uint64_t& o_symbol3_count )
{
    fapi2::buffer<uint64_t> l_buffer;

    FAPI_TRY( mss::ecc::mark_symbol_count_reg::read(i_target, l_buffer) );
    mss::ecc::mark_symbol_count_reg::get_symbol0_count(l_buffer, o_symbol0_count);
    mss::ecc::mark_symbol_count_reg::get_symbol1_count(l_buffer, o_symbol1_count);
    mss::ecc::mark_symbol_count_reg::get_symbol2_count(l_buffer, o_symbol2_count);
    mss::ecc::mark_symbol_count_reg::get_symbol3_count(l_buffer, o_symbol3_count);

fapi_try_exit:
    return fapi2::current_err;
}

} // close namespace ecc

} // close namespace mss

#endif
OpenPOWER on IntegriCloud