summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/resolution/prdfThresholdResolutions.H
blob: b61699159882b58d43a071206fa20cf3985c413d (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/framework/resolution/prdfThresholdResolutions.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2003,2019                        */
/* [+] 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                                                     */

#ifndef PRDFTHRESHOLDRESOLUTIONS_H
#define PRDFTHRESHOLDRESOLUTIONS_H
/**
   @file prdfThresholdResolutions.H
   @brief MaskResolution, IntervalThresholdResolution, ResetThresholdResolution
*/


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

#include <map>
#include <prdfErrorSignature.H>
#include <iipResolution.h>
#include <time.h>
#include <prdfTimer.H>

namespace PRDF
{

//--------------------------------------------------------------------
//  Forward References
//--------------------------------------------------------------------

/**
 Set mask Resolution
 @author Doug Gilbert
 @par
 @code
 @endcode
 */
class MaskResolution: public Resolution
{
  public:
    /**
     Constructor
     @param Maskid
     */
    MaskResolution(uint32_t maskId) : iv_maskId(maskId) {}

    /**
     Default Ctor - so it can be used in a vector
     */
    MaskResolution(void) : iv_maskId(0) {}

    /**
     Set MaskId into service data collector
     @pre None
     @post
     @return SUCCESS | non-zero
     @note Acts like Threshold Resolution with a threshold of one
     */
    virtual int32_t Resolve(STEP_CODE_DATA_STRUCT & error);

    virtual void ResetCount();          // wl01

    virtual int32_t GetCount();         // wl01

    /**
     operator ==
     */
    bool operator==(const MaskResolution &r) { return (iv_maskId == r.iv_maskId); } //dg02

  private:  // functions
  protected:  // Data
    uint32_t iv_maskId;

};

/**
 Set Mask on Threshold
 */
class ThresholdResolution : public MaskResolution
{
  public:

    enum TimeBase
    {
        ONE_SEC   = 1,
        ONE_MIN   = ONE_SEC  * 60,
        ONE_HOUR  = ONE_MIN  * 60,
        TEN_HOURS = ONE_HOUR * 10,
        ONE_DAY   = ONE_HOUR * 24,

        NONE = 0xffffffff,
    };

    struct ThresholdPolicy
    {
        // Currently we don't need threshold value more then 255. So using
        // uint8_t here to save space.
        uint8_t threshold;
        uint32_t interval;

        ThresholdPolicy( uint8_t l_threshold, uint32_t l_interval ) :
            threshold(l_threshold), interval(l_interval)
        {}

        ThresholdPolicy() :
            threshold(0), interval(0)
        {}

        bool operator==(ThresholdPolicy i_thr) const
        {
            return ( (threshold == i_thr.threshold) &&
                     (interval  == i_thr.interval) );
        }
    };

    /**
     Constructor
     @param maskid
     @param i_threshold
     @param i_interval
     */
    ThresholdResolution(uint32_t maskId, uint8_t i_threshold, uint32_t i_interval);

    /**
     default Ctor - so it can be used in a vector
     */
    ThresholdResolution(void);

    /**
     Constructor
     @param thresholdp Threshold policy.
     */
    ThresholdResolution(uint32_t maskId,
                        const ThresholdPolicy& thresholdp);

    /**
     Set MaskId into service data collector when a threshold as been reached
     @pre None
     @post Increment thresholdCount - Maskid is set in ServiceData when threshold is reached
     @return SUCCESS | non-zero
     @note In mfg mode the threshold is one
     */
    virtual int32_t Resolve(STEP_CODE_DATA_STRUCT & error);

    virtual void ResetCount();          // wl01

    virtual int32_t GetCount();         // wl01

    /**
     operator ==
     @note This should always return false in order for FlyWeight to always create unique objects
     */
    bool operator==(const ThresholdResolution &r) { return false; }

    /**
     *  Clear out all threshold policy objects
     */
    static void reset();

  public:  // Data

    static const ThresholdPolicy cv_fieldDefault;
    static const ThresholdPolicy cv_mnfgDefault;
    static const ThresholdPolicy cv_pllDefault;

  private: // Data

    // Though this is a pointer, we should never free it in destructor
    //We take its value from global flyweight which will be freed in prd uninitialise
    const ThresholdPolicy * iv_policy;
    uint32_t iv_count;
    Timer iv_endTime;

};

/**
 * @class ThresholdSigResolution
 *
 * Similar to the ThresholdResoultion, except it uses the current error
 * signature in the SDC to determine the 'maskid'.  This allows us to use one
 * ThresholdSigResolution class for each policy instead of one
 * ThresholdResolution for each error for each chip.
 */
class ThresholdSigResolution: public Resolution
{
    public:

        /** ctor(ThresholdPolicyEnum policy)
         *         Initializes the policy to the value specified.
         */
        ThresholdSigResolution( uint8_t i_threshold, uint32_t i_interval);

        /** ctor(ThresholdPolicy* policy)
         *         Initializes the policy to the policy specified.
         */
        ThresholdSigResolution(const ThresholdResolution::ThresholdPolicy& policy);

        /** default ctor
         *         Initialize the policy to "Default".
         */
        ThresholdSigResolution();

        /** default dtor
         *        Does nothing special.
         */
        virtual ~ThresholdSigResolution() {};

        /** Resolve
         *        Increments the error count based on the current signature.  If
         *        error count is over the policy limits, sets mask id and
         *        AT_THRESHOLD flag and then resets the error count.
         */
        virtual int32_t Resolve(STEP_CODE_DATA_STRUCT & error);

        /** operator==
         *        Compare two ThresholdSigResolutions by policies.
         */
        bool operator==(const ThresholdSigResolution &r)
        {
            return ( (r.iv_policy->threshold == iv_policy->threshold) &&
                     (r.iv_policy->interval  == iv_policy->interval) );
        }

        /** Flush
         *         Clear out all error counts recorded for all signatures.
         */
        virtual void Flush() { iv_thresholds.empty(); };

    private:

        // Stores a count/timer pair.
        typedef std::pair<uint32_t, Timer> ThresholdCountAndTimer;

        // Policy for this object.
        // Though this is a pointer, we should never free it in destructor
        // We take its value from global flyweight which will be freed in prd uninitialise
        const ThresholdResolution::ThresholdPolicy * iv_policy;

        // Map of ErrorSignatures->(Count,Timer).
        std::map<ErrorSignature, ThresholdCountAndTimer> iv_thresholds;

};

} // end namespace PRDF

#endif /* PRDFTHRESHOLDRESOLUTIONS_H */

OpenPOWER on IntegriCloud