summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaThresholds_common.C
blob: b1734715054ee41683b2d23742951b81cca014db (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaThresholds_common.C $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/** @file  prdfCenMbaThresholds_common.C
 *  @brief Utility functions used to get specific Centaur thresholds.
 */

// Framework includes
#include <prdfExtensibleChip.H>
#include <prdfMfgThresholds.H>
#include <prdfMfgThresholdMgr.H>
#include <prdfPlatServices.H>

// Pegasus includes
#include <prdfCenMbaThresholds.H>
#include <prdfCenMemUtils.H>

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

// MNFG RCE threshold
static uint32_t MBA_RCE_NON_MNFG_TH = 8;

//-----------------------------------------------------------------------------

ThresholdResolution::ThresholdPolicy getRceThreshold()
{
    uint32_t th = MBA_RCE_NON_MNFG_TH;
    if ( mfgMode() )
    {
        th =  MfgThresholdMgr::getInstance()->
                    getThreshold( PRDF_CEN_MBA_RT_RCE_PER_RANK );

        if( th > MBA_RCE_NON_MNFG_TH ) th = MBA_RCE_NON_MNFG_TH;
    }
    return ThresholdResolution::ThresholdPolicy( th,
                                            ThresholdResolution::ONE_DAY);
}

//-----------------------------------------------------------------------------
int32_t getMnfgMemCeTh( ExtensibleChip * i_mbaChip, const CenRank & i_rank,
                        uint16_t & o_cePerDram, uint16_t & o_cePerHalfRank,
                        uint16_t & o_cePerDimm )
{
    #define PRDF_FUNC "[getMnfgMemCeTh] "

    int32_t o_rc = SUCCESS;

    do
    {
        // Get base threshold ( 2GB ).
        uint8_t baseTh = getMnfgCeTh();

        // A base threhold of 0 indicates there should be no thresholding.
        if ( 0 == baseTh )
        {
            o_cePerDram = o_cePerHalfRank = o_cePerDimm =
                                    MfgThresholdFileCommon::INFINITE_LIMIT_THR;
            break;
        }

        // Get DRAM size
        uint8_t size = 0;
        o_rc = MemUtils::getDramSize( i_mbaChip, size );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "MemUtils::getDramSize() failed" );
            break;
        }

        // Get number of ranks per DIMM select.
        uint8_t rankCount = getRanksPerDimm( i_mbaChip->GetChipHandle(),
                                             i_rank.getDimmSlct() );
        if ( 0 == rankCount )
        {
            PRDF_ERR( PRDF_FUNC "PlatServices::getRanksPerDimm() failed" );
            o_rc = FAIL; break;
        }

        // Get number of allowed CEs.
        uint8_t baseAllowed = baseTh - 1;

        // Calculate CEs per DRAM.
        //   The DRAM size is in MBAXCR[6:7], where 0 = 2Gb, 1 = 4Gb, 2 = 8Gb,
        //   and 3 = 16 Gb. So the allowed CEs per DRAM can be calculated with
        //   the following:
        //         perDram = base * 2^(MBAXCR[6:7]+1) * (9/16)
        //     or, perDram = (base << MBAXCR[6:7]+1)  * (9/16)
        uint32_t computeBase = (baseAllowed << (size+1)) * 9;
        o_cePerDram = (computeBase + 8) / 16;

        // Calculate CEs per DIMM.
        o_cePerDimm = ((computeBase * (2 + rankCount)) + 8) / 16;

        // Calculate CEs per half-rank.
        // Same as perDimm where rankCount is 1;
        o_cePerHalfRank = ((computeBase * (2 + 1)) + 8) / 16;

    } while (0);

    return o_rc;

    #undef PRDF_FUNC
}

} // end namespace PRDF

OpenPOWER on IntegriCloud