summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenMemUtils.H
blob: 2b62aafa4c68ad5d37d81511f6202c413fc5e2b6 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenMemUtils.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 prdfCenMemUtils_H
#define prdfCenMemUtils_H

/** @file  prdfCenMemUtils.H
 *  @brief General utility functions for Centaur
 */

//------------------------------------------------------------------------------
//  Includes
//------------------------------------------------------------------------------

#include <vector>
#include <prdfCenSymbol.H>
#include <prdfParserEnums.H>

namespace PRDF
{

class ExtensibleChip;
struct STEP_CODE_DATA_STRUCT;

namespace MemUtils
{

//==============================================================================
//  Constants and Enums
//==============================================================================

/**
 * @brief Lists all possible sizes for a DRAM.
 * @note  These values must match the defintion of MBAXCR[6:7]. They are
 *        important for calculations.
 */
enum DramSize
{
    SIZE_2GB  = 0,
    SIZE_4GB  = 1,
    SIZE_8GB  = 2,
    SIZE_16GB = 3,
};

//==============================================================================
//  Maintenance statistics
//==============================================================================

/**
 * @brief Collects CE symbol data.
 */
struct SymbolData
{
    CenSymbol symbol;
    uint8_t count;
    SymbolData() : count(0) {}
};

typedef std::vector<SymbolData> MaintSymbols;

/** Functor for MaintSymbols to sort by count. */
inline bool sortSymDataCount( const SymbolData & i, const SymbolData & j )
{
    return i.count < j.count;
}

/** Functor for MaintSymbols to match a DRAM. */
class MatchSymDataDram
{
  public:
    explicit MatchSymDataDram( const CenSymbol & i_d ) : iv_d(i_d.getDram()) {}

    bool operator() ( const SymbolData & i_data ) const
    { return ( iv_d == i_data.symbol.getDram() ); }

  private:
    uint8_t iv_d;
};

/** Functor for MaintSymbols to match a symbol. */
class MatchSymDataSymbol
{
  public:
    explicit MatchSymDataSymbol( const CenSymbol & i_s ) : iv_s(i_s) {}

    bool operator() ( const SymbolData & i_data ) const
    { return ( iv_s == i_data.symbol ); }

  private:
    CenSymbol iv_s;
};

/**
 * @brief  Queries the per symbol counters and returns a sorted list of symbols
 *         with a count greater than or equal to the given threshold.
 * @note   The returned list will be sorted from lowest count to highest count.
 * @param  i_mbaChip     Target MBA chip.
 * @param  i_rank        Target rank.
 * @param  o_maintStats  Returns the list of symbols and counts.
 * @param  o_chipMark    This represents the DRAM in which a chip mark should be
 *                       placed, if necessary, based on the following:
 *                         - In x4 mode, this represents the DRAM with the
 *                           highest total per symbol count with at least 1
 *                           symbol that has exceeded threshold.
 *                         - In x8 mode, this represents the DRAM with the
 *                           highest total per symbol count with at least 2
 *                           symbols that have exceeded threshold.
 *                       It is possible that there will be symbols returned in
 *                       o_maintStats that do not meet the criteria stated
 *                       above. Therefore, the user must check if o_chipMark is
 *                       valid before using it.
 * @param  i_thr         The count threshold. Each symbol count must be greater
 *                       than or equal to this value to be added to the list.
 *                       The default is 1, which means all non-zero counts will
 *                       be added to the list. A value of 0 will result in a bad
 *                       return code.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 */
int32_t collectCeStats( ExtensibleChip * i_mbaChip, const CenRank & i_rank,
                        MaintSymbols & o_maintStats, CenSymbol & o_chipMark,
                        uint8_t i_thr = 1 );

/**
 * @brief  Clears the per symbol CE counters on a target MBA (via MEMBUF and MBA
 *         position number).
 * @param  i_membChip MEMBUF chip.
 * @param  i_mbaPos   MBA positions number (0-1).
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 */
int32_t clearPerSymbolCounters( ExtensibleChip * i_membChip,
                                uint32_t i_mbaPos );

/**
 * @brief  Gets DRAM size for an MBA.
 * @param  i_mbaChip   MBA chip.
 * @param  o_size  size for a DRAM.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 */
int32_t getDramSize( ExtensibleChip * i_mbaChip, uint8_t & o_size );

/**
 * @brief  Cleanup for channel CS on Centaur.
 * @param  i_mbChip   Membuf chip.
 * @param  i_sc  Service Data Collector.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 */
int32_t chnlCsCleanup( ExtensibleChip *i_mbChip,
                       STEP_CODE_DATA_STRUCT & i_sc );

/**
 * @brief  determines the type of Centaur based raw card  associated with MBA.
 * @param  i_mba    mba target
 * @param  o_type   raw card type.
 * @return Non-SUCCESS if an internal function fails, SUCCESS otherwise.
 * @note   Function is not intended for IS DIMM.
 */
int32_t getRawCardType( TARGETING::TargetHandle_t i_mba,
                        CEN_SYMBOL::WiringType & o_type );
} // end namespace MemUtils

} // end namespace PRDF

#endif
OpenPOWER on IntegriCloud