summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2HwpTest.H
blob: 167e4f31374989ad190de7797a864ca896a5b3fb (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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* 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,2018                        */
/* [+] 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 = nullptr;

    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 = nullptr;
        TARGETING::Target * l_cumulusProc = nullptr;
        TARGETING::Target * l_proc = nullptr;

        //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;
            }
            if(TARGETING::MODEL_CUMULUS ==
            l_chipList[i]->getAttr<TARGETING::ATTR_MODEL>())
            {
              l_cumulusProc = l_chipList[i];
              break;
            }
        }
        numTests++;

        if (l_nimbusProc != nullptr)
        {
            l_proc = l_nimbusProc;
        }
        else if (l_cumulusProc != nullptr)
        {
            l_proc = l_cumulusProc;
        }
        else //both are nullptr
        {
            // Send an errorlog because we cannot find any NIMBUS procs.
            FAPI_ERR("FAPI2_GETPARENT:: could not find a 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    Other Model Type we looked for
            * @devdesc      Could not find 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,
                                            TARGETING::MODEL_CUMULUS,
                                            true/*SW Error*/);
            errlCommit(l_errl,HWPF_COMP_ID);
            break;
        }

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

        for( uint64_t x = 0; x < NUM_TARGETS; x++ )
        {
            //Skip tests where the HW unit to test isn't valid for the proc type
            if (!isHwValid(l_proc, x))
            {
                continue;
            }
            else if(targeting_targets[x] == nullptr)
            {
              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_proc);
        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_OBUS_BRICK> fapi2_oBrickTarget(
                targeting_targets[MY_OBUS_BRICK]);
        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]);
        fapi2::Target<fapi2::TARGET_TYPE_MC> fapi2_mcTarget(targeting_targets[MY_MC]);
        fapi2::Target<fapi2::TARGET_TYPE_MI> fapi2_miTarget(targeting_targets[MY_MI]);
        fapi2::Target<fapi2::TARGET_TYPE_DMI> fapi2_dmiTarget(targeting_targets[MY_DMI]);

        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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_core !!");
        }
        if (isHwValid(l_proc, MY_MCS))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcs, fapi2_mcsTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              numFails++;
              TS_FAIL("Error occured in p9_sample_procedure_mcs !!");
            }
        }
        if (isHwValid(l_proc, MY_MCA))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mca, fapi2_mcaTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              numFails++;
              TS_FAIL("Error occured in p9_sample_procedure_mca !!");
            }
        }
        if (isHwValid(l_proc, MY_MCBIST))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mcbist, fapi2_mcbistTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_obus !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_obrick, fapi2_oBrickTarget, scratchWriteValue);
        if(l_errl != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_obrick !!");
        }
        numTests++;
        FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_ppe, fapi2_ppeTarget, scratchWriteValue);
        if(l_errl != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          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 != nullptr)
        {
          delete l_errl;
          l_errl = nullptr;
          numFails++;
          TS_FAIL("Error occured in p9_sample_procedure_capp !!");
        }

        if (isHwValid(l_proc, MY_MC))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mc, fapi2_mcTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              numFails++;
              TS_FAIL("Error occured in p9_sample_procedure_mc !!");
            }
        }
        if (isHwValid(l_proc, MY_MI))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_mi, fapi2_miTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              numFails++;
              TS_FAIL("Error occured in p9_sample_procedure_mi !!");
            }
        }
        if (isHwValid(l_proc, MY_DMI))
        {
            numTests++;
            FAPI_INVOKE_HWP(l_errl, p9_sample_procedure_dmi, fapi2_dmiTarget, scratchWriteValue);
            if(l_errl != nullptr)
            {
              delete l_errl;
              l_errl = nullptr;
              numFails++;
              TS_FAIL("Error occured in p9_sample_procedure_dmi !!");
            }
        }

    }while(0);
    FAPI_INF("test_fapiHWP:: Test Complete. %d/%d fails",  numFails,numTests);
}

};
OpenPOWER on IntegriCloud