summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/p9_hwtests.C
blob: 1f8a713ec2a57f5d6bb0a04a2b9b4cb23148f40d (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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/p9_hwtests.C $                             */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2017                        */
/* [+] 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  p9_hwtests.C
///
/// @brief These procedures test the fapi2 hw_access interfaces.
//-----------------------------------------------------------------------------

#include <cxxtest/TestSuite.H>
#include <fapi2.H>
#include <fapi2_hw_access.H>
#include <errl/errlentry.H>
#include <xscom/piberror.H>
#include <plat_hwp_invoker.H>

fapi2::ReturnCode p9_scomtest_getscom_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint64_t> l_scomdata = 0;

    FAPI_INF("Entering p9_scomtest_getscom_fail...");

    FAPI_INF("Do getscom on proc target");
    FAPI_TRY(fapi2::getScom(i_target,
                            0x11223344,
                            l_scomdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_scomtest_getscom_fail...");

    return fapi2::current_err;

}

fapi2::ReturnCode p9_scomtest_putscom_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint64_t> l_scomdata = 0;

    FAPI_INF("Entering p9_scomtest_putscom_fail...");

    FAPI_INF("Do getscom on proc target");
    FAPI_TRY(fapi2::putScom(i_target,
                            0x22334455,
                            l_scomdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_scomtest_putscom_fail...");

    return fapi2::current_err;

}

fapi2::ReturnCode p9_cfamtest_getcfam_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint32_t> l_cfamdata = 0;

    FAPI_INF("Entering p9_cfamtest_getcfam_fail...");

    FAPI_INF("Do getcfam on proc target");
    FAPI_TRY(fapi2::getCfamRegister(i_target,
                                    0x11223344,
                                    l_cfamdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_cfamtest_getcfam_fail...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_cfamtest_putcfam_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint32_t> l_cfamdata = 0;

    FAPI_INF("Entering p9_cfamtest_putcfam_fail...");

    FAPI_INF("Do getcfam on proc target");
    FAPI_TRY(fapi2::putCfamRegister(i_target,
                                    0x22334455,
                                    l_cfamdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_cfamtest_putcfam_fail...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_scomtest_getscom_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint64_t> l_scomdata = 0;

    FAPI_INF("Entering p9_scomtest_getscom_pass...");

    FAPI_INF("Do getscom on proc target");
    FAPI_TRY(fapi2::getScom(i_target,
                            0x02010803, //CXA FIR Mask Register
                            l_scomdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_scomtest_getscom_pass...");

    return fapi2::current_err;

}

fapi2::ReturnCode p9_scomtest_putscom_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint64_t> l_scomdata = 0;

    FAPI_INF("Entering p9_scomtest_putscom_pass...");

    FAPI_INF("Do getscom on proc target");
    FAPI_TRY(fapi2::putScom(i_target,
                            0x02010803, //CXA FIR Mask Register
                            l_scomdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_scomtest_putscom_pass...");

    return fapi2::current_err;

}

fapi2::ReturnCode p9_cfamtest_getcfam_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint32_t> l_cfamdata = 0;

    FAPI_INF("Entering p9_cfamtest_getcfam_pass...");

    FAPI_INF("Do getcfam on proc target");
    FAPI_TRY(fapi2::getCfamRegister(i_target,
                                    0x1000, //DATA_0 from FSI2PIB
                                    l_cfamdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_cfamtest_getcfam_pass...");

    return fapi2::current_err;

}

fapi2::ReturnCode p9_cfamtest_putcfam_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::buffer<uint32_t> l_cfamdata = 0;

    FAPI_INF("Entering p9_cfamtest_putcfam_pass...");

    FAPI_INF("Do getcfam on proc target");
    FAPI_TRY(fapi2::putCfamRegister(i_target,
                                    0x1000, //DATA_0 from FSI2PIB
                                    l_cfamdata));

 fapi_try_exit:

    FAPI_INF("Exiting p9_cfamtest_putcfam_pass...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_ringtest_getring_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::variable_buffer l_ringdata(64);

    FAPI_INF("Entering p9_ringtest_getring_fail...");

    FAPI_INF("Do getring on proc target");
    FAPI_TRY(fapi2::getRing(i_target,
                            (scanRingId_t)(0x22334455),
                            l_ringdata,
                            fapi2::RING_MODE_HEADER_CHECK));

 fapi_try_exit:

    FAPI_INF("Exiting p9_ringtest_getring_fail...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_ringtest_modring_fail(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::variable_buffer l_ringdata;
    l_ringdata.resize(861);

    FAPI_INF("Entering p9_ringtest_modring_fail...");

    FAPI_INF("Do modifyRing on proc target");
    FAPI_TRY(fapi2::modifyRing(i_target,
                               (scanRingId_t)0x22334455,
                               l_ringdata,
                               fapi2::CHIP_OP_MODIFY_MODE_OR,
                               fapi2::RING_MODE_HEADER_CHECK));

 fapi_try_exit:

    FAPI_INF("Exiting p9_ringtest_modring_fail...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_ringtest_getring_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    fapi2::variable_buffer l_ringdata;
    l_ringdata.resize(861);

    FAPI_INF("Entering p9_ringtest_getring_pass...");

    FAPI_INF("Do getring on proc target");
    FAPI_TRY(fapi2::getRing(i_target,
                            (scanRingId_t)0x00030088,
                            l_ringdata,
                            fapi2::RING_MODE_HEADER_CHECK));

 fapi_try_exit:

    FAPI_INF("Exiting p9_ringtest_getring_pass...");

    return fapi2::current_err;

}


fapi2::ReturnCode p9_ringtest_modring_pass(
               fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    uint32_t bit32_array[861];
    uint32_t length;

    for (length = 0; length < 861; length++)
    {
        bit32_array[length] = length;
    }

    fapi2::variable_buffer l_ringdata(bit32_array, length, 32 * 861);

    FAPI_INF("Entering p9_ringtest_modring_pass...");

    FAPI_INF("Do putring on proc target");
    FAPI_TRY(fapi2::modifyRing(i_target,
                               (scanRingId_t)0x00030088,
                               l_ringdata,
                               fapi2::CHIP_OP_MODIFY_MODE_OR,
                               fapi2::RING_MODE_HEADER_CHECK));

 fapi_try_exit:

    FAPI_INF("Exiting p9_ringtest_modring_pass...");
    return fapi2::current_err;

}

fapi2::ReturnCode p9_platPutRingWRingID_pass()
{
    //every test is displayed this way via FAPI_INF
    FAPI_INF("Entering p9_platPutRingWRingID_pass ...");
    // get the master proc
    TARGETING::Target * l_procTest;
    TARGETING::targetService().masterProcChipTargetHandle( l_procTest);
    fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>
    l_fapi2CpuTarget((l_procTest));

    fapi2::ReturnCode l_status =
            fapi2::putRing(l_fapi2CpuTarget, ob0_fure,
                    fapi2::RING_MODE_SET_PULSE_NO_OPCG_COND);

    if(l_status!= fapi2::FAPI2_RC_SUCCESS)
    {
        TS_FAIL("p9_platPutRingWRingID_pass>> proc test - failed");
    }

    return l_status;
}


fapi2::ReturnCode p9_opmodetest_ignorehwerr(
                fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target,
                uint8_t o_fail)
{
    FAPI_INF("Entering p9_opmodetest_ignorehwerr...");
    //Count the number of scoms we do so we can tell that we ran all of them.
    //Putting in this test so we know opMode isnt getting reset on FAPI_TRY
    uint8_t scomCount = 0;
    const uint8_t EXPECTED_NUMBER_OF_SCOMS = 4;

    do{
        FAPI_INF("Setting opMode to IGNORE_HW_ERROR (0x1)");

        fapi2::setOpMode(fapi2::IGNORE_HW_ERROR);
        fapi2::buffer<uint64_t> l_scomdata1 = 0xFF00FF00;
        fapi2::buffer<uint64_t> l_scomdata2 = 0xFF00FF00;

        fapi2::buffer<uint64_t> l_scomresult1 = 0x0;
        fapi2::buffer<uint64_t> l_scomresult2 = 0x0;


        FAPI_INF("Attempting 1st putScom, this should fail but because of opMode we skip the err");
        FAPI_TRY(fapi2::putScom(i_target,
                                0xDEADBEEF,
                                l_scomdata1));
        scomCount++;

        FAPI_INF("Attempting 2nd putScom this should fail but because of opMode we skip the err");
        FAPI_TRY(fapi2::getScom(i_target,
                                0xCABBABEF,
                                l_scomdata2));
        scomCount++;

        FAPI_INF("Attempting 1st getScom, this should fail but because of opMode we skip the err");
        FAPI_TRY(fapi2::getScom(i_target,
                                0xDEADBEEF,
                                l_scomresult1));
        scomCount++;

        FAPI_INF("Attempting 2nd getScom,  this should fail but because of opMode we skip the err");
        FAPI_TRY(fapi2::getScom(i_target,
                                0xCABBABEF,
                                l_scomresult2));
        scomCount++;

    }while(0);

fapi_try_exit:

    if(scomCount != EXPECTED_NUMBER_OF_SCOMS)
    {
        o_fail = 1;
    }
    FAPI_INF("Exiting p9_opmodetest_ignorehwerr...");

    return fapi2::current_err;
}

fapi2::ReturnCode p9_piberrmask_masktest(
                fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{

    FAPI_INF("Entering p9_piberrmask_masktest...");

    uint8_t completionCheck = 0;

    //Ideally we would like this test case to test errors 1-7 but
    // I am not sure if we can simulate some of the errors

    fapi2::buffer<uint64_t> l_scomdata = 0xFF00FF00;

    //Set the mask to ignore invalid address errors ()
    fapi2::setPIBErrorMask(static_cast<uint8_t>(PIB::PIB_INVALID_ADDRESS));

    //Attempt writing to a bad address
    FAPI_TRY(fapi2::putScom(i_target,
                            0xDEADBEEF,
                            l_scomdata));

    //try another scom, this time a get to make sure that
    // FAPI_TRY does not reset the mask
    FAPI_TRY(fapi2::getScom(i_target,
                            0xDEADBEEF,
                            l_scomdata));

    completionCheck = 1;


 fapi_try_exit:

    if(completionCheck != 1)
    {
        FAPI_ERR("Pib Err Mask is not removing errors and is causing FAPI_TRY to fail");
    }
    FAPI_INF("Exiting p9_piberrmask_masktest...");
    return fapi2::current_err;
}
OpenPOWER on IntegriCloud