summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/p9/prdfLineDelete.C
blob: f8099ceb06eaeb4e006d8a3dca4a05b7e0f7b989 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/p9/prdfLineDelete.C $           */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2005,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 prdfLineDelete.C
 * Contains the definitions needed for the line delete algorithms and the CE
 * table.
 */


#include <prdfLineDelete.H>
#include <iipServiceDataCollector.h>
#include <prdfBitString.H>

namespace PRDF
{

// See prdfLineDelete.H for full function documentation.
namespace LineDelete
{

    /* PrdfCacheCETable::addAddress
     * Insert address into CE table.
     */
    bool PrdfCacheCETable::addAddress( PrdfCacheAddress i_addr,
                                       STEP_CODE_DATA_STRUCT & i_sdc )
    {
        // Get the time of the current error.
        Timer timeOfError = i_sdc.service_data->GetTOE();

        // Check if time interval has elapsed. If so, flush the table.
        if ( (timeOfError > cv_flushTimer) || !cv_flushTimerInited )
        {
            this->flushTable();
            cv_flushTimer = timeOfError + iv_thPolicy.interval;
            cv_flushTimerInited = true;
        }

        // Increment address hit count.
        uint32_t count = ++cv_ceTable[i_addr];

        // Return whether the address threshold has been reached or not.
        return ( iv_thPolicy.threshold <= count );
    }

    /* PrdfCacheCETable::isIntervalElapsed()
     */
    bool PrdfCacheCETable::isIntervalElapsed( STEP_CODE_DATA_STRUCT & i_sdc )
    {
        bool o_rc = false;
        if ( cv_flushTimerInited )
            o_rc = ( i_sdc.service_data->GetTOE() > cv_flushTimer );
        return o_rc;
    }

    /* PrdfCacheCETable::flushTable()
     * Clear all entries from CE table.
     */
    void PrdfCacheCETable::flushTable()
    {
        // wipe interval timer and clear all hits.
        cv_flushTimerInited = false;
        cv_ceTable.clear();
    }

};

} // end namespace PRDF

OpenPOWER on IntegriCloud