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

/** @file prdfLineDelete.H
 * Contains the definitions needed for the line delete algorithms and the CE
 * table.
 */

#ifndef __PRDFLINEDELETE_H
#define __PRDFLINEDELETE_H

#include <UtilSMap.H>
#include <prdfThresholdResolutions.H>
#include <iipstep.h>
#include <iipCaptureData.h>

namespace PRDF
{

/** @namespace LineDelete
 *  Namespace to encapsulate all of the LineDelete specific classes and enums.
 */
namespace LineDelete
{

    /** @enum CacheType
     *  Used to express where a cache error occured.
     */
    enum CacheType
    {
        L3 = 0,
        L3_DIR = 1,
        L2 = 2,
        L2_DIR = 4,
        CACHE_MASK = L3 | L3_DIR | L2 | L2_DIR,

        SLICE_A = 8,
        SLICE_B = 16,
        SLICE_MASK = SLICE_A | SLICE_B
    };

    /** @enum CacheErrorType
     *  Used to express the types of cache errors that can occur.
     */
    enum CacheErrorType
    {
        UE, CE
    };

    /** @typedef PrdfCacheAddress
     *        Used to index cache error hits in the CE table.
     */
    typedef uint32_t PrdfCacheAddress;

    /** @typedef PrdfCacheAddressTable
     *  Maps Cache Addresses to hit counts.
     */
    typedef UtilSMap<PrdfCacheAddress, uint32_t> PrdfCacheAddressTable;

    /** @class PrdfCacheCETable
     *  Used to store and threshold cache CE errors.
     *
     *  Takes a threshold policy (such as "2 per day") and allows that many hits
     *  per address before signalling "at threshold".  (the 2nd occurance would
     *  be the at threshold).
     *
     *  @note This is now being used for eRepair as well as cache CEs.
     */
    class PrdfCacheCETable
    {
      public:

        /** Default constructor */
        PrdfCacheCETable() {}

        /**
         * @brief Constructor from ThresholdPolicy struct.
         * @param i_thPolicy A pointer to a ThresholdPolicy struct.
         */
        explicit PrdfCacheCETable(
                    const ThresholdResolution::ThresholdPolicy i_thPolicy ) :
            iv_thPolicy(i_thPolicy), cv_flushTimerInited(false), cv_total(0)
        {}

        // NOTE: iv_thPolicy should never be deleted in this class so the
        // default destructor will be sufficient.

            /** @fn addAddress
             *  Insert an address into the CE table.
             *
             *  @param The CE address.
             *  @param The Service Data Collector to get the current time.
             *
             *  @return true - if the threshold policy has been reached.
             *  @return false - if the threshold policy has not been reached.
             */
            bool addAddress(PrdfCacheAddress, STEP_CODE_DATA_STRUCT &);

        /**
         * @brief  Checks if the threshold had been reached for the given
         *         address.
         * @param  i_addr The CE address.
         * @param  i_sdc  The Service Data Collector.
         * @return TRUE if threshold has been reached and time interval has not
         *         elapsed, FALSE otherwise.
         */
        bool addrThReached( PrdfCacheAddress i_addr,
                            STEP_CODE_DATA_STRUCT & i_sdc );

            /** @fn PrdfCacheCETable::isIntervalElapsed()
             *  @param STEP_CODE_DATA_STRUCT & i_sdc
             *  @return TRUE if the interval time has elapsed.
             */
            bool isIntervalElapsed( STEP_CODE_DATA_STRUCT & i_sdc );

            /** @fn flushTable
             *  Clear all CE hits from the table and reset timer to 0.
             */
            void flushTable();

            /** @fn getTotalCount
             *  Returns the total amount of CE hits in a table
             *
             *  @return uint32_t - the total CE hits in a table
             */
            uint32_t getTotalCount();        //zs01

            /** @fn addToCaptureData
             *  Adds CE table to the capture data.
             *
             *        @param The chip Handle.
             *        @param The scom id.
                *  @param The Service Data Collector.
             */
            void addToCaptureData(TARGETING::TargetHandle_t i_pchipHandle, int32_t, CaptureData &); // zs02

            /** @fn getLargestEntry
             *  @brief Will search the PrdfCacheCETable for the address with the
             *         largest count.
             *  @param The count of the highest entry (default = NULL).
             *  @return Address with the largest count.
             */
            PrdfCacheAddress getLargestEntry( uint32_t * o_count = NULL );

            /** @fn PrdfCacheCETable::getTableSize
             *  @return uint32_t - The total number of entries in the table
             */
            uint32_t getTableSize(); //zs04

             //mp26 a
            /** @fn getCRCAnalysisEntries
             *  @brief Will search the PrdfCacheCETable for the different count
             *         values..
             *  @param Output the highest count..
             *  @param Output the second highest count..
             *  @param Output the lowest count..
             *  @return Address with the largest count.
             */
            PrdfCacheAddress getCRCAnalysisEntries(
                                             uint32_t & o_countHigh,
                                             uint32_t & o_count2ndHigh,
                                             uint32_t & o_countLow);

      private:

        ThresholdResolution::ThresholdPolicy iv_thPolicy;
        PrdfCacheAddressTable cv_ceTable;
        Timer cv_flushTimer;
        bool cv_flushTimerInited;
        uint32_t cv_total;        //zs01

    };

};

} // end namespace PRDF

#endif

OpenPOWER on IntegriCloud