summaryrefslogtreecommitdiffstats
path: root/src/hwpf/include/error_info.H
blob: 9085a4dfa2a43a2b414782092a9e1fb6d9e2c22e (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/hwpf/include/error_info.H $                               */
/*                                                                        */
/* OpenPOWER sbe Project                                                  */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2016                        */
/* [+] 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 error_info.H
/// @brief Defines the Error Information structures and classes
///

#ifndef FAPI2_ERRORINFO_H_
#define FAPI2_ERRORINFO_H_

#include <stdint.h>
#ifndef __PPE__
#include <memory>
#endif
#include <vector>
#include <target.H>
#include <error_info_defs.H>

namespace fapi2
{
#if defined(MINIMUM_FFDC)

// convert generic type to uint64_t
template<typename T>
inline uint64_t convertType( T& i_value )
{
    // for simplicity sake, all FFDC chunks from the SBE
    // are going to be sent as a uint64_t
    return static_cast<uint64_t>(i_value);
};

// convert platform target handle to a uint64_t
template<fapi2::TargetType T, typename V>
inline uint64_t convertType( const fapi2::Target<T, V>& i_value)
{
    // TODO: via RTC 158868 : Update this for multicast targets
    // get the SBE platform target handle
    return static_cast<uint64_t>((static_cast<uint64_t>((static_cast<plat_target_handle_t>(i_value.get()).getFapiTargetType())) << 32) | static_cast<plat_target_handle_t>(i_value.get()).getTargetInstance());
};
#endif

#if !defined(FAPI2_NO_FFDC) && !defined(MINIMUM_FFDC)
// forward fapi2::Assert()
extern void Assert(bool);

///
/// @class ErrorInfoFfdc
///
/// This class contains a copy of some FFDC data
///
class ErrorInfoFfdc
{
    public:
        ///
        /// @brief Constructor
        ///
        /// @param[in] i_ffdcId FFDC Identifier (used to decode FFDC)
        /// @param[in] i_pFfdc  Pointer to the FFDC to copy
        /// @param[in] i_size   Size of the FFDC to copy
        ///
        ErrorInfoFfdc(const uint32_t i_ffdcId,
                      const void*    i_pFfdc,
                      const uint32_t i_size);

        ///
        /// @brief Get a pointer to the FfdcData
        ///
        /// @param[out] o_size Reference to uint32_t that is filled in with
        /// the FFDC size
        ///
        /// @return void *. Pointer to the FFDC
        ///
        inline const void* getData(uint32_t& o_size) const
        {
            o_size = iv_size;
            return iv_pFfdc.get();
        }

        ///
        /// @brief Get a pointer to the FfdcData
        /// @return void *. Pointer to the FFDC
        ///
        inline void* getData(void) const
        {
            return iv_pFfdc.get();
        }

        ///
        /// @brief Get the FFDC Identifier
        ///
        /// @return uint32_t The FFDC Identifier
        ///
        inline uint32_t getFfdcId(void)
        {
            return iv_ffdcId;
        }

#ifdef FAPI_CUSTOM_MALLOC
        ///
        /// @brief Overload new operator to use platform-specific allocator
        ///
        /// @param[in] i_sz  Size of memory to allocate in bytes
        ///
        /// @return  Pointer to allocated memory
        ///
        static void* operator new(size_t i_sz);

        ///
        /// @brief Overload delete operator to use platform-specific deallocator
        ///
        /// @param[in] i_ptr Pointer to memory previously allocated with new
        ///
        static void operator delete(void* i_ptr);
#endif

    private:

        // FFDC Identifier
        uint32_t iv_ffdcId;

        // Pointer to the FFDC
        std::shared_ptr<uint8_t> iv_pFfdc;

        // Size of the FFDC
        uint32_t iv_size;

        // Disabled
        ErrorInfoFfdc(const ErrorInfoFfdc&) = delete;
        ErrorInfoFfdc& operator=(const ErrorInfoFfdc&) = delete;
};

///
/// @struct ErrorInfoHwCallout
///
/// This struct contains hardware to callout
///
struct ErrorInfoHwCallout
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_hw              Hardware to callout
    /// @param[in] i_calloutPriority Priority of callout
    /// @param[in] i_refTarget       Reference to reference target
    ///
    ErrorInfoHwCallout(
        const HwCallouts::HwCallout i_hw,
        const CalloutPriorities::CalloutPriority i_calloutPriority,
        const Target<TARGET_TYPE_ALL>& i_refTarget);

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // The hw to callout
    HwCallouts::HwCallout iv_hw;

    // The callout priority
    CalloutPriorities::CalloutPriority iv_calloutPriority;

    // The reference target (needed for some HW callouts to identify what to
    // callout). The target handle is NULL if there is no reference target.
    Target<TARGET_TYPE_ALL> iv_refTarget;
};

///
/// @struct ErrorInfoProcedureCallout
///
/// This struct contains a procedure to callout
///
struct ErrorInfoProcedureCallout
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_procedure        Procedure to callout
    /// @param[in] i_calloutPriority  Priority of callout
    ///
    ErrorInfoProcedureCallout(
        const ProcedureCallouts::ProcedureCallout i_procedure,
        const CalloutPriorities::CalloutPriority i_calloutPriority);

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // The procedure to callout
    ProcedureCallouts::ProcedureCallout iv_procedure;

    // The callout priority
    CalloutPriorities::CalloutPriority iv_calloutPriority;
};

///
/// @struct ErrorInfoBusCallout
///
/// This struct contains a bus to callout
///
struct ErrorInfoBusCallout
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_target1          Reference to target on one end of the bus
    /// @param[in] i_target2          Reference to target on other end of the bus
    /// @param[in] i_calloutPriority  Priority of callout
    ///
    ErrorInfoBusCallout(
        const Target<TARGET_TYPE_ALL>& i_target1,
        const Target<TARGET_TYPE_ALL>& i_target2,
        const CalloutPriorities::CalloutPriority i_calloutPriority);

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // The targets on each end of the bus to callout
    Target<TARGET_TYPE_ALL> iv_target1;
    Target<TARGET_TYPE_ALL> iv_target2;

    // The callout priority
    CalloutPriorities::CalloutPriority iv_calloutPriority;
};

///
/// @struct ErrorInfoCDG
///
/// This struct contains a target to callout/deconfigure/GARD
///
struct ErrorInfoCDG
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_target      Reference to the target to c/d/g
    /// @param[in] i_callout     True if Target should be called out
    /// @param[in] i_deconfigure True if Target should be deconfigured
    /// @param[in] i_gard        True if Target should be GARDed
    /// @param[in] i_priority    The priority of any callout
    ///
    ErrorInfoCDG(const Target<TARGET_TYPE_ALL>& i_target,
                 const bool i_callout,
                 const bool i_deconfigure,
                 const bool i_gard,
                 const CalloutPriorities::CalloutPriority i_priority);

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // The target to callout/deconfigure/GARD
    Target<TARGET_TYPE_ALL> iv_target;

    // Callout Information
    bool iv_callout;
    CalloutPriorities::CalloutPriority iv_calloutPriority;

    // Deconfigure Information
    bool iv_deconfigure;

    // GARD Information
    bool iv_gard;
};

///
/// @struct ErrorInfoChildrenCDG
///
/// This struct contains children targets to callout/deconfigure/GARD
///
/// Children by containment can be CDG (chiplets belonging to a parent chip)
/// e.g.
/// - PROC_CHIP -> EX_CHIPLET
/// - MEMBUF_CHIP -> MBA_CHIPLET
/// Children by affinity can be CDG.
///   Any from PROC_CHIP->MCS_CHIPLET->MEMBUF_CHIP->MBA_CHIPLET->DIMM e.g.
///   - PROC_CHIP->MEMBUF_CHIP
///   - MEMBUF_CHIP->DIMM
///   - MBA_CHIPLET->DIMM
/// Port and Number criteria can be applied to the child target as
/// detailed in the constructor
///
struct ErrorInfoChildrenCDG
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_parentChip  Reference to the parent target
    /// @param[in] i_childType   Child target type to c/d/g
    /// @param[in] i_callout     True if Target should be called out
    /// @param[in] i_deconfigure True if Target should be deconfigured
    /// @param[in] i_gard        True if Target should be GARDed
    /// @param[in] i_priority    The priority of any callout
    /// @param[in] i_childPort   Child Port
    ///                            For DIMM children, the MBA port number
    /// @param[in] i_childNum    Child Number
    ///                            For DIMM children, the dimm socket number
    ///                            For Chip children, the chip position
    ///                            For Chiplet children, the chiplet unit pos
    ///
    ErrorInfoChildrenCDG(const Target<TARGET_TYPE_ALL>& i_parentChip,
                         const TargetType i_childType,
                         const bool i_callout,
                         const bool i_deconfigure,
                         const bool i_gard,
                         const CalloutPriorities::CalloutPriority i_priority,
                         const uint8_t i_childPort, const uint8_t i_childNum);

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // The parent chip
    Target<TARGET_TYPE_ALL> iv_parent;

    // The child target types to c/d/g
    TargetType iv_childType;

    // Callout Information
    bool iv_callout;
    CalloutPriorities::CalloutPriority iv_calloutPriority;

    // Deconfigure Information
    bool iv_deconfigure;

    // GARD Information
    bool iv_gard;

    // Child Port
    static const uint8_t ALL_CHILD_PORTS = 0xff;
    uint8_t iv_childPort;

    // Child Number
    static const uint8_t ALL_CHILD_NUMBERS = 0xff;
    uint8_t iv_childNumber;
};

///
/// @struct ErrorInfoCollectTrace
///
/// This struct contains trace ID to add to the error log
///
struct ErrorInfoCollectTrace
{
    ///
    /// @brief Constructor.
    ///
    /// @param[in] i_traceId
    ///
    ErrorInfoCollectTrace(CollectTraces::CollectTrace i_traceId);


#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // trace
    CollectTraces::CollectTrace iv_eiTraceId;
};

///
/// @struct ErrorInfo
///
/// This struct defines the error information associated with a fapi2::ffdc
/// Users are allowed to access the data directly
///
struct ErrorInfo
{

#ifdef FAPI_CUSTOM_MALLOC
    ///
    /// @brief Overload new operator to use platform-specific allocator
    ///
    /// @param[in] i_sz  Size of memory to allocate in bytes
    ///
    /// @return  Pointer to allocated memory
    ///
    static void* operator new(size_t i_sz);

    ///
    /// @brief Overload delete operator to use platform-specific deallocator
    ///
    /// @param[in] i_ptr Pointer to memory previously allocated with new
    ///
    static void operator delete(void* i_ptr);
#endif

    // Vector of FFDC Data
    std::vector<std::shared_ptr<ErrorInfoFfdc> > iv_ffdcs;

    // Vector of Hardware to callout
    std::vector<std::shared_ptr<ErrorInfoHwCallout> > iv_hwCallouts;

    // Vector of procedures to callout
    std::vector<std::shared_ptr<ErrorInfoProcedureCallout> >
    iv_procedureCallouts;

    // Vector of buses to callout
    std::vector<std::shared_ptr<ErrorInfoBusCallout> > iv_busCallouts;

    // Vector of targets to callout/deconfigure/GARD
    std::vector<std::shared_ptr<ErrorInfoCDG> > iv_CDGs;

    // Vector of children targets to callout/deconfigure/GARD
    std::vector<std::shared_ptr<ErrorInfoChildrenCDG> > iv_childrenCDGs;

    // Vector of traces to collect
    std::vector<std::shared_ptr<ErrorInfoCollectTrace> > iv_traces;
};
///
/// @brief Structure representing a single ErrorInfo entry.
///
/// An array of these is passed to the addErrorInfo function when a HWP
/// generates an error by calling the FAPI_SET_HWP_ERROR macro
// Why aren't these inherited classes? Saves on allocation overhead.
// We create an array of ErrorInfoEntries as automatics when we start
// FFDC collection. If we did this as inherited classes it would either
// be allocating and deallocating or we'd need to allocate an array of
// the largest and map each struct in to it. That's messy to do without
// unions (that's what they're for) so we do it like this. The inherited
// model would result in a jump table anyway, so we're basically doing
// all of that by hand to avoid the mess.
//
struct ErrorInfoEntryFfdc
{
    uint8_t  iv_ffdcObjIndex;
    uint16_t iv_ffdcSize;
    uint32_t iv_ffdcId;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Structure representing a hardware callout
///
struct ErrorInfoEntryHwCallout
{
    uint8_t iv_hw;
    uint8_t iv_calloutPriority;
    uint8_t iv_refObjIndex;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Structure representing a procedure callout
///
struct ErrorInfoEntryProcCallout
{
    uint8_t iv_procedure;
    uint8_t iv_calloutPriority;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;

    ErrorInfoEntryProcCallout(uint8_t i_procedure, uint8_t i_calloutPriority):
        iv_procedure(i_procedure),
        iv_calloutPriority(i_calloutPriority)
    {}

    ErrorInfoEntryProcCallout(void) = default;
};

///
/// @brief Structure representing a bus callout
///
struct ErrorInfoEntryBusCallout
{
    uint8_t iv_endpoint1ObjIndex;
    uint8_t iv_endpoint2ObjIndex;
    uint8_t iv_calloutPriority;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Structure representing a target callout
///
struct ErrorInfoEntryTargetCDG
{
    uint8_t iv_targetObjIndex;
    uint8_t iv_callout;
    uint8_t iv_deconfigure;
    uint8_t iv_gard;
    uint8_t iv_calloutPriority;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Structure representing a child callout
///
struct ErrorInfoEntryChildrenCDG
{
    uint8_t  iv_parentObjIndex;
    uint8_t  iv_callout;
    uint8_t  iv_deconfigure;
    uint32_t iv_childType;
    uint8_t  iv_childPort;
    uint8_t  iv_childNumber;
    uint8_t  iv_gard;
    uint8_t  iv_calloutPriority;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Structure representing collected trace information
///
struct ErrorInfoEntryCollectTrace
{
    uint32_t  iv_eieTraceId;
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const;
};

///
/// @brief Union of all the error info types
///
struct ErrorInfoEntry
{
    uint8_t iv_type; // Value from ErrorInfoType
    union
    {
        ErrorInfoEntryFfdc ffdc;
        ErrorInfoEntryHwCallout hw_callout;
        ErrorInfoEntryProcCallout proc_callout;
        ErrorInfoEntryBusCallout bus_callout;
        ErrorInfoEntryTargetCDG target_cdg;
        ErrorInfoEntryChildrenCDG children_cdg;
        ErrorInfoEntryCollectTrace collect_trace;
    };

    ///
    /// @brief Add error information to the FFDC object
    /// @param[in] i_info a shared pointer to the error info
    /// @param[in] i_object the list of ffdc objects being collected
    ///
    void addErrorInfo(std::shared_ptr<ErrorInfo> i_info,
                      const void* const* i_object) const
    {
        // "unhandled error info type");
        fapi2::Assert(iv_type < EI_LAST_TYPE);

        switch(iv_type)
        {
            case EI_TYPE_FFDC:
                ffdc.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_HW_CALLOUT:
                hw_callout.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_PROCEDURE_CALLOUT:
                proc_callout.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_BUS_CALLOUT:
                bus_callout.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_CDG:
                target_cdg.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_CHILDREN_CDG:
                children_cdg.addErrorInfo(i_info, i_object);
                break;

            case EI_TYPE_COLLECT_TRACE:
                collect_trace.addErrorInfo(i_info, i_object);
                break;
        };

        return;
    }
};
#endif
}
#endif // FAPI2_ERRORINFO_H_
OpenPOWER on IntegriCloud