summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/plat/pegasus/prdfCenMbaIplCeStats.H
blob: b873eec9e23d7944dff85bd9b5b83245a09ff4b6 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/plat/pegasus/prdfCenMbaIplCeStats.H $       */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* 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                                                     */

#ifndef PRDF_CEN_MBA_IPL_CE_STATS_H
#define PRDF_CEN_MBA_IPL_CE_STATS_H

/** @file  prdfCenMbaIplCeStats.H */

//------------------------------------------------------------------------------
#include <prdfExtensibleChip.H>
#include <prdfCenAddress.H>
#include <prdfCenSymbol.H>
#include <prdfCenAddress.H>
#include <map>

namespace PRDF
{
class ExtensibleChip;
class MemoryMru;
//------------------------------------------------------------------------------

/**
 * This class is used for storing the CE statistics that are gathered during a
 * manufacturing mode IPL for MDIA analysis. Only one instance of this object is
 * meant to be used for each MBA and is stored in its data bundle.
 * It is expected that when the IPL memory diagnostics is complete, MDIA will
 * call the appropriate function to tell this object to analyze all statistics
 * that were collected during the IPL.
 */
class CenMbaIplCeStats
{
  public:

    /**
     * @brief Constructor
     * @param i_mbaChip The MBA chip.
     */
    explicit CenMbaIplCeStats( ExtensibleChip * i_mbaChip )
            :iv_mbaChip(i_mbaChip) {}

    /**
     * @brief Destructor
     */
    ~CenMbaIplCeStats() {}

    /**
     * @brief Bans analysis of the given rank.
     * @param i_rank The rank to ban.
     */
    void banAnalysis( const CenRank & i_rank );

    /**
     * @brief  Bans analysis of the given half rank.
     * @param  i_rank        The rank.
     * @param  i_portSlct The port select.
     * @return Non-SUCCESS if the parameters are invalid, SUCCESS otherwise.
     */
    int32_t banAnalysis( const CenRank & i_rank, uint8_t i_portSlct );

    /**
     * @brief  Will collect all the maintenance statistics and store them for
     *         analysis. Will also clear the scrub statistics counters when
     *         collection is complete.
     * @param  i_rank The rank the maintenance command stopped on.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     */
    int32_t collectStats( const CenRank & i_rank );

    /**
     * @brief  Analyzes the maintenance statistics that were gathered, making
     *         the appropriate callouts.
     * @param  o_callOutsDone TRUE if PRD made a hardware callout, FALSE
     *         otherwise.
     * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
     */
    int32_t analyzeStats ( bool & o_callOutsDone );

    /** @brief  Calls out all symbols with hard CEs.
     *  @param  i_stopRank The rank the maintenance command stopped on.
     */
    int32_t calloutHardCes( const CenRank & i_stopRank );

  private: // enums, structs, typedefs

    /** @brief The key type for each entry in iv_symMap. */
    struct SymbolKey
    {
        CenSymbol symbol; ///< The failing symbol

        /** @brief Overrides the '==' operator. */
        bool operator==( const SymbolKey & i ) const
        { return ( symbol == i.symbol ); }

        /** @brief Overrides the '<' operator. */
        bool operator<( const SymbolKey & i ) const
        { return  (symbol < i.symbol ); }
    };


    /** @brief The key to identify half rank.
     *   This key will be used to ban analysis, rank and dimm
     *   threshold analysis
     */
    struct HalfRankKey
    {
        CenRank rank;     ///< The rank
        uint8_t portSlct; ///< The port select

        /** @brief Overrides the '==' operator. */
        bool operator==( const HalfRankKey & i ) const
        { return ( (rank == i.rank) && (portSlct == i.portSlct) ); }

        /** @brief Overrides the '<' operator. */
        bool operator<( const HalfRankKey & i ) const
        {
            return ( (rank < i.rank) ||
                 ((rank == i.rank) && (portSlct < i.portSlct)) );
        }
    };

    /** @brief The key type for each entry in iv_dramMap. */
    struct DramKey
    {
        CenRank rank;     ///< The rank
        uint8_t dram;     ///< The DRAM (x8:0-17 x4:0-35)
        uint8_t portSlct; ///< The port select (0-1)

        // Techinally, the port select can be derived from the DRAM value,
        // however, it simplifies things to just store the port select here.
        // Therefore, the port select does not need to be used in operator==()
        // or operators<().

        /** @brief Overrides the '==' operator. */
        bool operator==( const DramKey & i ) const
        { return ( (rank == i.rank) && (dram == i.dram) ); }

        /** @brief Overrides the '<' operator. */
        bool operator<( const DramKey & i ) const
        { return ( (rank < i.rank) || ((rank == i.rank) && (dram < i.dram)) ); }
    };

    // data type to collect all symbol statistics
    typedef std::vector<SymbolKey> CESymbols;

    // data type to collect dimm specific statitics. While
    // filling up data for this data type, we should ignore rank select
    // and only consider dimm slct.
    typedef std::map<HalfRankKey,   uint32_t>  CePerHalfDsMap;
    // data type to collect all symbol statistics for a rank.
    typedef std::map<HalfRankKey, uint32_t>  CePerHalfRankMap;
    // data type to store banned half ranks on which analysis is not required.
    typedef std::map<HalfRankKey, bool> BannedAnalysisMap;
    // data type to collect all symbol statistics for a dram.
    typedef std::map<DramKey,     uint32_t>  CePerDramMap;

  private: // functions

    /** @brief  Calls out all symbols on a dram that has exceeded threshold.
     *  @param  o_callOutsMade TRUE if a callout was made, FALSE othewise.
     *  @return Non-SUCCESS if an internal function fails, SUCCESS othewise.
     */
    int32_t calloutCePerDram( bool & o_callOutsMade );

    /** @brief  Calls out all symbols on a rank that has exceeded threshold.
     *  @param  o_callOutsMade TRUE if a callout was made, FALSE othewise.
     *  @return Non-SUCCESS if an internal function fails, SUCCESS othewise.
     */
    int32_t calloutCePerRank( bool & o_callOutsMade );

    /** @brief  Calls out all symbols on a dimm select that has exceeded
     *          threshold.
     *  @param  o_callOutsMade TRUE if a callout was made, FALSE othewise.
     *  @return Non-SUCCESS if an internal function fails, SUCCESS othewise.
     */
    int32_t calloutCePerDs( bool & o_callOutsMade );

    /**
     * @brief Add MemoryMru callout to error log and commit it.
     * @param i_memmru Memory MRU.
     * @param i_errl   Error log.
     */
    void addMruAndCommitErrl( const MemoryMru & i_memmru, errlHndl_t i_errl );

  private: // instance variables

    /** The MBA chip. */
    ExtensibleChip * iv_mbaChip;

    /** A map to keep track of which half ranks have all ready been called out.
     *  This helps reduce excessive callouts for the same hardware. */
    BannedAnalysisMap iv_bannedAnalysis;

    /** A vector containing all data for every failing symbol. */
    CESymbols iv_ceSymbols;

    /** A map containing count for every failing dimm select. */
    CePerHalfDsMap iv_dsMap;

    /** A map containing count for every failing rank. */
    CePerHalfRankMap iv_rankMap;

    /** A map containing count for every failing DRAM. */
    CePerDramMap iv_dramMap;
};

} //end namespace PRDF
#endif /* PRDF_CEN_MBA_IPL_CE_STATS_H */
OpenPOWER on IntegriCloud