summaryrefslogtreecommitdiffstats
path: root/src/usr/htmgt/test/pstatetest.H
blob: e5d2746953d3fe5fe9727bc0e87b0530a2fc0a0e (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/htmgt/test/pstatetest.H $                             */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014                             */
/* [+] 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 __PSTATETEST_H
#define __PSTATETEST_H

#include <cxxtest/TestSuite.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>

#include <targeting/common/targetservice.H>
#include <targeting/common/attributes.H>
#include <targeting/common/commontargeting.H>
#include <targeting/common/utilFilter.H>
#include <targeting/common/util.H>

#include <fapi.H>
#include <fapiPlatHwpInvoker.H>

#include <vfs/vfs.H>
#include <pstates.h>
#include <proc_get_voltage.H>
#include <mss_bulk_pwr_throttles.H>
#include <mss_util_to_throttle.H>
#include <mss_throttle_to_power.H>

using namespace TARGETING;

class pstateTest: public CxxTest::TestSuite
{
    public:

        // Test function to build pstate table
        // TODO RCT 114284 fix testcase
        // Requires Hostboot functions that are not yet merged. Testcase should
        // eventually call hb function "runP8BuildPstateDataBlock" declaired in
        // freqVoltageSvc.H to build pstate table.
        // p8_build_pstate_datablock reads VPD from all existing cores, not
        // just functional cores.  The current SIMICS standalone model does
        // not support MVDP for all existing cores.
        void DISABLE_test_verifyPstate( void )
        {
            errlHndl_t l_errl = NULL;
            bool pstateLibLoadedLocally = false;

            if(!VFS::module_is_loaded( "libpstates.so" ) )
            {
                l_errl = VFS::module_load( "libpstates.so" );
                if( l_errl )
                {
                    TS_FAIL("Could not load pstate module" );
                    errlCommit(l_errl,HTMGT_COMP_ID);
                }
                else
                {
                    pstateLibLoadedLocally = true;
                }
            }

            PstateSuperStructure pstateData;
            TargetHandleList procChips;
            getAllChips(procChips, TYPE_PROC, true);

            for (TargetHandleList::iterator itr = procChips.begin();
                 itr != procChips.end();
                 ++itr)
            {
                // cast OUR type of target to a FAPI type of target.
                const fapi::Target
                    fapiTarg(fapi::TARGET_TYPE_PROC_CHIP,
                             (const_cast<Target*>(*itr)));


                FAPI_INVOKE_HWP( l_errl,
                                 p8_build_pstate_datablock,
                                 fapiTarg,
                                 &pstateData
                               );

                if( l_errl )
                {
                    errlCommit(l_errl,HTMGT_COMP_ID);
                    TS_FAIL("verifyPstate failed for huid 0x%x",
                            get_huid(*itr));
                }
            }

            if(pstateLibLoadedLocally)
            {
                VFS::module_unload( "libpstates.so" );
            }

        }

        // test to call procedures HTMGT will need
        void test_procedures( void )
        {
            errlHndl_t l_errl = NULL;

            bool mccfgLibLoadedLocally = false;

            if(!VFS::module_is_loaded( "libmc_config.so" ) )
            {
                l_errl = VFS::module_load( "libmc_config.so" );
                if( l_errl )
                {
                    TS_FAIL("Could not load mc_config module" );
                    errlCommit(l_errl,HTMGT_COMP_ID);
                }
                else
                {
                    mccfgLibLoadedLocally = true;
                }
            }

            TARGETING::TargetHandleList l_mbaTargetList;
            getAllChiplets(l_mbaTargetList, TYPE_MBA);

            for (TargetHandleList::const_iterator l_mba_iter = l_mbaTargetList.begin();
                 l_mba_iter != l_mbaTargetList.end(); ++l_mba_iter)

            {
                const TARGETING::Target* l_mba_target = *l_mba_iter;

                const fapi::Target l_fapi_mba_target
                    (fapi::TARGET_TYPE_MBA_CHIPLET,
                     (const_cast<TARGETING::Target*>(l_mba_target)));

                FAPI_INVOKE_HWP( l_errl,
                                 mss_bulk_pwr_throttles,
                                 l_fapi_mba_target);
                if( l_errl )
                {
                    errlCommit(l_errl, HTMGT_COMP_ID);
                    TS_FAIL("Call to mss_bulk_pwr_throttles failed");
                }

                FAPI_INVOKE_HWP( l_errl,
                                 mss_util_to_throttle,
                                 l_fapi_mba_target);
                if( l_errl )
                {
                    errlCommit(l_errl, HTMGT_COMP_ID);
                    TS_FAIL("Call to mss_util_to_throttle failed");
                }


                FAPI_INVOKE_HWP( l_errl,
                                 mss_throttle_to_power,
                                 l_fapi_mba_target);
                if( l_errl )
                {
                    errlCommit(l_errl, HTMGT_COMP_ID);
                    TS_FAIL("Call to mss_throttle_to_power failed");
                }
            }

            if(mccfgLibLoadedLocally)
            {
                VFS::module_unload( "libmc_config.so" );
            }
        }
};

#endif
OpenPOWER on IntegriCloud