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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/runtime/test/runtimeattrstest.H $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2012,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 */
#ifndef __TEST_RUNTIMEATTRSTEST_H
#define __TEST_RUNTIMEATTRSTEST_H
/**
* @file runtimeattrstest.H
*
*/
#include <cxxtest/TestSuite.H>
#include <fapi.H>
#include <fapiAttributeIds.H>
#include <targeting/common/target.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <arch/ppc.H> //for MAGIC
#include <attributeenums.H>
#include <errl/errlmanager.H>
#include <hwpf/plat/fapiPlatHwpInvoker.H>
#include "../common/hsvc_attribute_structs.H"
extern trace_desc_t* g_trac_runtime;
using namespace fapi;
class RuntimeAttrsTest: public CxxTest::TestSuite
{
public:
void testVerifySystemAttributes(void)
{
TRACFCOMP( g_trac_runtime, "testVerifySystemAttributes> start" );
hsvc_system_data_t* sysdata = getSysPtr();
//Look for a valid node number
if( sysdata->nodePresent != 0x8000000000000000 )
{
TRACFCOMP( g_trac_runtime, "nodePresent=%.16X", sysdata->nodePresent );
TS_FAIL("testVerifySystemAttributes> nodePresent is invalid");
}
//Make sure we have some attributes out there
if( sysdata->numAttr == 0 )
{
TS_FAIL("testVerifySystemAttributes> numAttr is zero");
}
//Make sure that the offset is what we expect
if( sysdata->offset != 24 ) //3 words from the start
{
TRACFCOMP( g_trac_runtime, "offset=%.16X", sysdata->offset );
TS_FAIL("testVerifySystemAttributes> offset is invalid");
}
char* beginning = reinterpret_cast<char*>(sysdata);
hsvc_attr_header_t* headers = reinterpret_cast<hsvc_attr_header_t*>
((beginning+sysdata->offset));
//Grab a couple of arbitrary attributes
ReturnCode l_rc;
fapi::ATTR_FREQ_PB_Type freq = 0;
l_rc = FAPI_ATTR_GET(ATTR_FREQ_PB,NULL,freq);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_FREQ_PB");
}
bool freq_found = false;
fapi::ATTR_PROC_R_LOADLINE_Type loadline = 0;
l_rc = FAPI_ATTR_GET(ATTR_PROC_R_LOADLINE,NULL,loadline);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_PROC_R_LOADLINE");
}
bool loadline_found = false;
uint64_t attr = 0;
while( headers[attr].id != hsvc_attr_header_t::NO_ATTRIBUTE )
{
if( headers[attr].id == fapi::ATTR_FREQ_PB )
{
freq_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_FREQ_PB_Type) )
{
TRACFCOMP( g_trac_runtime, "size=%.16X", headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_FREQ_PB data is wrong");
}
else
{
fapi::ATTR_FREQ_PB_Type* freq_act =
reinterpret_cast<fapi::ATTR_FREQ_PB_Type*>
(beginning+headers[attr].offset);
if( *freq_act != freq )
{
TRACFCOMP( g_trac_runtime, "Expected=%X, Actual=%X", freq, *freq_act );
TS_FAIL("fapi::ATTR_FREQ_PB data is wrong");
}
}
}
else if( headers[attr].id == fapi::ATTR_PROC_R_LOADLINE )
{
loadline_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_PROC_R_LOADLINE_Type) )
{
TRACFCOMP( g_trac_runtime, "size=%.16X", headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_PROC_R_LOADLINE data is wrong");
}
else
{
fapi::ATTR_PROC_R_LOADLINE_Type* loadline_act =
reinterpret_cast<fapi::ATTR_PROC_R_LOADLINE_Type*>
(beginning+headers[attr].offset);
if( *loadline_act != loadline )
{
TRACFCOMP( g_trac_runtime, "Expected=%X, Actual=%X", loadline, *loadline_act );
TS_FAIL("fapi::ATTR_PROC_R_LOADLINE data is wrong");
}
}
}
attr++;
}
if( attr != sysdata->numAttr )
{
TRACFCOMP( g_trac_runtime, "numAttr=%d, found attr=%d", sysdata->numAttr, attr );
TS_FAIL("testVerifySystemAttributes> Number of attributes found doesn't match expected value");
}
if( !freq_found )
{
TS_FAIL("Never found FREQ_PB in system attributes");
}
if( !loadline_found )
{
TS_FAIL("Never found ATTR_PROC_R_LOADLINE in system attributes");
}
TRACFCOMP( g_trac_runtime, "testVerifySystemAttributes> finish" );
}
void testVerifyNodeAttributes(void)
{
TRACFCOMP( g_trac_runtime, "testVerifyNodeAttributes> start" );
hsvc_node_data_t* nodedata = getNodePtr();
//Make sure we have some targets out there (at least 1 proc and 1 ex)
if( nodedata->numTargets < 2 )
{
TS_FAIL("testVerifyNodeAttributes> numTargets is zero");
}
//Make sure that the offsets are reasonable
if( nodedata->procOffset == 0 )
{
TS_FAIL("testVerifyNodeAttributes> procOffset is invalid");
}
if( nodedata->exOffset == 0 )
{
TS_FAIL("testVerifyNodeAttributes> exOffset is invalid");
}
if( nodedata->procOffset == nodedata->exOffset )
{
TS_FAIL("testVerifyNodeAttributes> offsets are equal - that is bad");
}
char* beginning = reinterpret_cast<char*>(nodedata);
//Look at the procs
hsvc_proc_header_t* procs = reinterpret_cast<hsvc_proc_header_t*>
((beginning+nodedata->procOffset));
//Verify the header data is okay
hsvc_proc_header_t* curproc = procs;
TRACDCOMP( g_trac_runtime, "procs=%p", procs );
while( curproc->procid != hsvc_proc_header_t::NO_PROC )
{
//Verify we have some attributes
if( curproc->numAttr == 0 )
{
TRACFCOMP(g_trac_runtime,"Proc %d has zero attributes",curproc->procid);
TS_FAIL("testVerifyNodeAttributes> no attributes for proc");
}
//Find a target to match this one
fapi::Target* proc = getProcTarget( curproc->procid );
TRACDCOMP( g_trac_runtime, "procid = %d", curproc->procid );
//Grab a couple of arbitrary attributes
hsvc_attr_header_t* headers = reinterpret_cast<hsvc_attr_header_t*>
((beginning+curproc->offset));
ReturnCode l_rc;
fapi::ATTR_CHIP_ID_Type tmp1 = 0;
l_rc = FAPI_ATTR_GET(ATTR_CHIP_ID,proc,tmp1);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_CHIP_ID");
}
bool tmp1_found = false;
fapi::ATTR_PM_PVSAFE_PSTATE_Type tmp2 = 0;
l_rc = FAPI_ATTR_GET(ATTR_PM_PVSAFE_PSTATE,proc,tmp2);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_PM_PVSAFE_PSTATE");
}
bool tmp2_found = false;
uint64_t attr = 0;
while( headers[attr].id != hsvc_attr_header_t::NO_ATTRIBUTE )
{
if( headers[attr].id == fapi::ATTR_CHIP_ID )
{
tmp1_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_CHIP_ID_Type) )
{
TRACFCOMP( g_trac_runtime, "procid=%d: size=%.16X", curproc->procid, headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_CHIP_ID data is wrong");
}
else
{
fapi::ATTR_CHIP_ID_Type* tmp1_act =
reinterpret_cast<fapi::ATTR_CHIP_ID_Type*>
(beginning+headers[attr].offset);
if( *tmp1_act != tmp1 )
{
TRACFCOMP( g_trac_runtime, "procid=%d: Expected=%X, Actual=%X", curproc->procid, tmp1, *tmp1_act );
TS_FAIL("fapi::ATTR_CHIP_ID data is wrong");
}
}
}
else if( headers[attr].id == fapi::ATTR_PM_PVSAFE_PSTATE )
{
tmp2_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_PM_PVSAFE_PSTATE_Type) )
{
TRACFCOMP( g_trac_runtime, "size=%.16X", headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_PM_PVSAFE_PSTATE data is wrong");
}
else
{
fapi::ATTR_PM_PVSAFE_PSTATE_Type* tmp2_act =
reinterpret_cast<fapi::ATTR_PM_PVSAFE_PSTATE_Type*>
(beginning+headers[attr].offset);
if( *tmp2_act != tmp2 )
{
TRACFCOMP( g_trac_runtime, "procid=%d: Expected=%X, Actual=%X", curproc->procid, tmp2, *tmp2_act );
TS_FAIL("fapi::ATTR_PM_PVSAFE_PSTATE data is wrong");
}
}
}
attr++;
}
if( attr != curproc->numAttr )
{
TRACFCOMP( g_trac_runtime, "procid=%d: numAttr=%d, found attr=%d", curproc->procid, curproc->numAttr, attr );
TS_FAIL("testVerifyNodeAttributes> Number of attributes found doesn't match expected value");
}
if( !tmp1_found )
{
TS_FAIL("Never found ATTR_PM_PVSAFE_PSTATE for procid=%d",curproc->procid);
}
if( !tmp2_found )
{
TS_FAIL("Never found ATTR_PM_PVSAFE_PSTATE for procid=%d",curproc->procid);
}
delete proc;
curproc++;
}
//Look at the EXs
hsvc_ex_header_t* exs = reinterpret_cast<hsvc_ex_header_t*>
((beginning+nodedata->exOffset));
//Verify the header data is okay
hsvc_ex_header_t* curex = exs;
while( curex->parent_procid != hsvc_proc_header_t::NO_PROC )
{
//Verify we have some attributes
if( curex->numAttr == 0 )
{
TRACFCOMP(g_trac_runtime,"Proc %d has zero attributes",curproc->procid);
TS_FAIL("testVerifyNodeAttributes> no attributes for proc");
}
//Find a target to match this one
fapi::Target* ex = getExTarget( curex->parent_procid,
curex->chiplet );
TRACDCOMP( g_trac_runtime, "procid = %d, chiplet = %d", curex->parent_procid, curex->chiplet );
//Grab a couple of arbitrary attributes
hsvc_attr_header_t* headers = reinterpret_cast<hsvc_attr_header_t*>
((beginning+curex->offset));
ReturnCode l_rc;
fapi::ATTR_CHIP_UNIT_POS_Type tmp1 = 0;
l_rc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS,ex,tmp1);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_CHIP_UNIT_POS");
errlHndl_t errhdl = fapiRcToErrl(l_rc);
errlCommit(errhdl,RUNTIME_COMP_ID);
}
bool tmp1_found = false;
fapi::ATTR_FUNCTIONAL_Type tmp2 = 0;
l_rc = FAPI_ATTR_GET(ATTR_FUNCTIONAL,ex,tmp2);
if( l_rc )
{
TS_FAIL("Error getting fapi::ATTR_FUNCTIONAL");
errlHndl_t errhdl = fapiRcToErrl(l_rc);
errlCommit(errhdl,RUNTIME_COMP_ID);
}
bool tmp2_found = false;
uint64_t attr = 0;
while( headers[attr].id != hsvc_attr_header_t::NO_ATTRIBUTE )
{
if( headers[attr].id == fapi::ATTR_CHIP_UNIT_POS )
{
tmp1_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_CHIP_UNIT_POS_Type) )
{
TRACFCOMP( g_trac_runtime, "size=%.16X", headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_CHIP_UNIT_POS data is wrong");
}
else
{
fapi::ATTR_CHIP_UNIT_POS_Type* tmp1_act =
reinterpret_cast<fapi::ATTR_CHIP_UNIT_POS_Type*>
(beginning+headers[attr].offset);
if( *tmp1_act != tmp1 )
{
TRACFCOMP( g_trac_runtime, "procid=%d: Expected=%X, Actual=%X", curproc->procid, tmp1, *tmp1_act );
TS_FAIL("fapi::ATTR_CHIP_UNIT_POS data is wrong");
}
}
}
else if( headers[attr].id == fapi::ATTR_FUNCTIONAL )
{
tmp2_found = true;
if( headers[attr].sizeBytes !=
sizeof(fapi::ATTR_FUNCTIONAL_Type) )
{
TRACFCOMP( g_trac_runtime, "size=%.16X", headers[attr].sizeBytes );
TS_FAIL("Size of fapi::ATTR_FUNCTIONAL data is wrong");
}
else
{
fapi::ATTR_FUNCTIONAL_Type* tmp2_act =
reinterpret_cast<fapi::ATTR_FUNCTIONAL_Type*>
(beginning+headers[attr].offset);
if( *tmp2_act != tmp2 )
{
TRACFCOMP( g_trac_runtime, "procid=%d: Expected=%X, Actual=%X", curproc->procid, tmp2, *tmp2_act );
TS_FAIL("fapi::ATTR_FUNCTIONAL data is wrong");
}
}
}
attr++;
}
if( attr != curex->numAttr )
{
TRACFCOMP( g_trac_runtime, "procid=%d: numAttr=%d, found attr=%d", curproc->procid, curex->numAttr, attr );
TS_FAIL("Number of attributes found doesn't match expected value");
}
if( !tmp1_found )
{
TS_FAIL("Never found ATTR_CHIP_UNIT_POS for procid=%d, ex=%d",
curproc->procid,curex->chiplet);
}
if( !tmp2_found )
{
TS_FAIL("Never found ATTR_FUNCTIONAL for procid=%d, ex=%d",
curproc->procid,curex->chiplet);
}
delete ex;
curex++;
}
TRACFCOMP( g_trac_runtime, "testVerifyNodeAttributes> finish" );
}
private:
hsvc_system_data_t* getSysPtr(void)
{
errlHndl_t errhdl = NULL;
uint64_t sys_data_addr = 0;
size_t sys_data_size = 0;
errhdl = RUNTIME::get_host_data_section(RUNTIME::HSVC_SYSTEM_DATA,
0,
sys_data_addr,
sys_data_size );
return( (hsvc_system_data_t*)(sys_data_addr) );
};
hsvc_node_data_t* getNodePtr(void)
{
errlHndl_t errhdl = NULL;
uint64_t node_data_addr = 0;
size_t node_data_size = 0;
errhdl = RUNTIME::get_host_data_section(RUNTIME::HSVC_NODE_DATA,
0,
node_data_addr,
node_data_size );
return( (hsvc_node_data_t*)(node_data_addr) );
};
//utility to fetch a proc target based on a procid
TARGETING::Target* _getProcTarget( uint64_t i_procid )
{
// Grab a system object to work with
TARGETING::Target* sys = NULL;
TARGETING::targetService().getTopLevelTarget(sys);
// Loop through all of the procs
TARGETING::TargetHandleList all_procs;
TARGETING::getAllChips( all_procs, TARGETING::TYPE_PROC, false );
if( all_procs.empty() )
{
TRACDCOMP( g_trac_runtime, "all_procs is empty!!, type=%d", TARGETING::TYPE_PROC );
TARGETING::PredicateCTM predProc(TARGETING::CLASS_CHIP, TARGETING::TYPE_PROC);
TARGETING::PredicatePostfixExpr checkExpr;
checkExpr.push(&predProc);
TARGETING::targetService().getAssociated( all_procs, sys,
TARGETING::TargetService::CHILD,
TARGETING::TargetService::ALL, &checkExpr );
}
TARGETING::Target* proc_target = NULL;
for( size_t p = 0; p < all_procs.size(); p++ )
{
uint64_t node_id =
all_procs[p]->getAttr<TARGETING::ATTR_FABRIC_NODE_ID>();
uint64_t CHIP_UNIT_POS =
all_procs[p]->getAttr<TARGETING::ATTR_FABRIC_CHIP_ID>();
uint32_t procid = (node_id << 3) | (CHIP_UNIT_POS); //NNNCCC
if( procid == i_procid )
{
proc_target = all_procs[p];
break;
}
}
return proc_target;
}
//utility to fetch a proc target based on a procid
fapi::Target* getProcTarget( uint64_t i_procid )
{
TARGETING::Target* proc = _getProcTarget(i_procid);
if( proc != NULL )
{
return( new fapi::Target( fapi::TARGET_TYPE_PROC_CHIP,
reinterpret_cast<void *>
(const_cast<TARGETING::Target*>(proc)) ) );
}
return NULL;
};
//utility to fetch an ex target based on a procid and chiplet number
fapi::Target* getExTarget( uint64_t i_procid, uint64_t i_chiplet )
{
TARGETING::Target* proc = _getProcTarget(i_procid);
TARGETING::TargetHandleList all_ex;
TARGETING::getChildChiplets( all_ex, proc,
TARGETING::TYPE_EX, false );
for( size_t e = 0; e < all_ex.size(); e++ )
{
uint32_t chiplet = all_ex[e]->getAttr<TARGETING::ATTR_CHIP_UNIT>();
if( chiplet == i_chiplet )
{
return( new fapi::Target(
fapi::TARGET_TYPE_PROC_CHIP,
reinterpret_cast<void *>
(const_cast<TARGETING::Target*>(all_ex[e])) ) );
}
}
return NULL;
}
};
#endif
|