summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2HwpTest.H
blob: 620325b3bbaefb3cb073200d388212302d18d907 (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/fapi2HwpTest.H $                           */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,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                                                     */

#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <fapi2.H>
#include <hwpf_fapi2_reasoncodes.H>
#include <fapi2TestUtils.H>
#include <p9_sample_procedure.H>
#include <plat_hwp_invoker.H>



using namespace fapi2;


class Fapi2HwpTest : public CxxTest::TestSuite
{
public:
//******************************************************************************
// test_fapi2Hwp
//******************************************************************************
void test_fapi2Hwp()
{
    int numTests = 0;
    int numFails = 0;
    errlHndl_t l_errl = NULL;

    do
    {
        // Create a vector of TARGETING::Target pointers
        TARGETING::TargetHandleList l_chipList;

        // Get a list of all of the proc chips
        TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, false);

        TARGETING::Target * l_nimbusProc = NULL;

        //Take the first NIMBUS proc and use it
        for(uint32_t i = 0; i < l_chipList.size(); i++)
        {
            if(TARGETING::MODEL_NIMBUS ==
            l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
            {
              l_nimbusProc = l_chipList[i];
              break;
            }
        }
        numTests++;
        if(l_nimbusProc == NULL)
        {
            // Send an errorlog because we cannot find any NIMBUS procs.
            FAPI_ERR("FAPI2_GETPARENT:: could not find Nimbus proc, skipping tests");
            numFails++;
            /*@
            * @errortype    ERRORLOG::ERRL_SEV_UNRECOVERABLE
            * @moduleid     fapi2::MOD_FAPI2_PLAT_HWP_TEST
            * @reasoncode   fapi2::RC_NO_PROCS_FOUND
            * @userdata1    Model Type we looked for
            * @userdata2    Unused
            * @devdesc      Could not find NIMBUS procs in system model
            */
            l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                            fapi2::MOD_FAPI2_PLAT_HWP_TEST,
                                            fapi2::RC_NO_PROCS_FOUND,
                                            TARGETING::MODEL_NIMBUS,
                                            NULL,
                                            true/*SW Error*/);
            errlCommit(l_errl,HWPF_COMP_ID);
            break;
        }

        TARGETING::Target* targeting_targets[NUM_TARGETS];
        generateTargets(l_nimbusProc, targeting_targets);

        for( uint64_t x = 0; x < NUM_TARGETS; x++ )
        {
            if(targeting_targets[x] == NULL)
            {
              FAPI_ERR("Unable to find target for item %d in targeting_targets", x);

              /*@
              * @errortype    ERRORLOG::ERRL_SEV_UNRECOVERABLE
              * @moduleid     fapi2::MOD_FAPI2_PLAT_HWP_TEST
              * @reasoncode   fapi2::RC_NO_PATH_TO_TARGET_FOUND
              * @userdata1    Index of target in array of objects
              * @userdata2    Unused
              * @devdesc      Could not find a path to the target of that type
              */
              l_errl = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                              fapi2::MOD_FAPI2_PLAT_HWP_TEST,
                                              fapi2::RC_NO_PATH_TO_TARGET_FOUND,
                                              x,
                                              NULL,
                                              true/*SW Error*/);
              errlCommit(l_errl,HWPF_COMP_ID);
            }
        }

        fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_nimbusProc);
        fapi2::Target<fapi2::TARGET_TYPE_EQ> fapi2_eqTarget(targeting_targets[MY_EQ]);
        fapi2::Target<fapi2::TARGET_TYPE_EX> fapi2_exTarget(targeting_targets[MY_EX]);
        fapi2::Target<fapi2::TARGET_TYPE_CORE> fapi2_coreTarget(
                targeting_targets[MY_CORE]);
        fapi2::Target<fapi2::TARGET_TYPE_MCS> fapi2_mcsTarget(targeting_targets[MY_MCS]);
        fapi2::Target<fapi2::TARGET_TYPE_MCA> fapi2_mcaTarget(targeting_targets[MY_MCA]);
        fapi2::Target<fapi2::TARGET_TYPE_MCBIST> fapi2_mcbistTarget(
                                                    targeting_targets[MY_MCBIST]);
        fapi2::Target<fapi2::TARGET_TYPE_PEC> fapi2_pecTarget(targeting_targets[MY_PEC]);
        fapi2::Target<fapi2::TARGET_TYPE_PHB> fapi2_phbTarget(targeting_targets[MY_PHB]);
        fapi2::Target<fapi2::TARGET_TYPE_XBUS> fapi2_xbusTarget(
                targeting_targets[MY_XBUS]);
        fapi2::Target<fapi2::TARGET_TYPE_OBUS> fapi2_obusTarget(
                targeting_targets[MY_OBUS]);
        fapi2::Target<fapi2::TARGET_TYPE_NV> fapi2_nvTarget(
                targeting_targets[MY_NV]);
        fapi2::Target<fapi2::TARGET_TYPE_PPE> fapi2_ppeTarget(targeting_targets[MY_PPE]);
        fapi2::Target<fapi2::TARGET_TYPE_PERV> fapi2_pervTarget(
                targeting_targets[MY_PERV]);
        fapi2::Target<fapi2::TARGET_TYPE_SBE> fapi2_sbeTarget(targeting_targets[MY_SBE]);
        fapi2::Target<fapi2::TARGET_TYPE_CAPP> fapi2_cappTarget(
                                      targeting_targets[MY_CAPP]);


        int scratchWriteValue = 5;

        //Get/Set Attr for all of the targets
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_proc, fapi2_procTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_proc !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_eq, fapi2_eqTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_eq !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_ex, fapi2_exTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_ex !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_core, fapi2_coreTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_core !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcs, fapi2_mcsTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_mcs !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mca, fapi2_mcaTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_mca !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcbist, fapi2_mcbistTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_mcbist !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_pec, fapi2_pecTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_pec !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_phb, fapi2_phbTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_phb !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_xbus, fapi2_xbusTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_xbus !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_obus, fapi2_obusTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_obus !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_nv, fapi2_nvTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_nv !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_ppe, fapi2_ppeTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_ppe !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_perv, fapi2_pervTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_perv !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_sbe, fapi2_sbeTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_sbe !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_capp, fapi2_cappTarget, scratchWriteValue);
        if(l_errl != NULL)
        {
          delete l_errl;
          l_errl = NULL;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_capp !!");
        }
    }while(0);
    FAPI_INF("test_fapiHWP:: Test Complete. %d/%d fails",  numFails,numTests);
}

};
OpenPOWER on IntegriCloud