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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/scan/test/scantest.H $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,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 __SCANTEST_H
#define __SCANTEST_H
/**
* @file scomtest.H
*
* @brief Test case for scan code
*/
#include <cxxtest/TestSuite.H>
#include <errl/errlmanager.H>
#include <errl/errlentry.H>
#include <devicefw/userif.H>
#include <targeting/common/util.H>
extern trace_desc_t* g_trac_scandd;
class ScanTest: public CxxTest::TestSuite
{
public:
/**
* @brief SCAN test
*
*/
void test_SCANreadWrite_proc(void)
{
TRACFCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> Start" );
uint64_t fails = 0;
uint64_t total = 0;
errlHndl_t l_err = NULL;
// Setup some targets to use
enum {
myPROC0,
memBuf0,
NUM_TARGETS
};
TARGETING::Target* scan_targets[NUM_TARGETS];
for( uint64_t x = 0; x < NUM_TARGETS; x++ )
{
scan_targets[x] = NULL;
}
// Target Proc 0
TARGETING::EntityPath epath(TARGETING::EntityPath::PATH_PHYSICAL);
epath.addLast(TARGETING::TYPE_SYS,0);
epath.addLast(TARGETING::TYPE_NODE,0);
epath.addLast(TARGETING::TYPE_PROC,0);
scan_targets[myPROC0] = TARGETING::targetService().toTarget(epath);
epath.removeLast();
// target membuf 0
epath.addLast(TARGETING::TYPE_MEMBUF,4);
scan_targets[memBuf0] = TARGETING::targetService().toTarget(epath);
//printk("Scan Proc target functional state %X present %X \n",
//scan_targets[myPROC0]->getAttr<TARGETING::ATTR_HWAS_STATE>().functional,scan_targets[myPROC0]->getAttr<TARGETING::ATTR_HWAS_STATE>().present );
TARGETING::HwasState l_hwasState;
l_hwasState = scan_targets[myPROC0]->getAttr<TARGETING::ATTR_HWAS_STATE>();
l_hwasState.functional = true;
scan_targets[myPROC0]->setAttr<TARGETING::ATTR_HWAS_STATE>(l_hwasState);
//printk("Scan Proc target functional state after updating is %X present %X \n",
//scan_targets[myPROC0]->getAttr<TARGETING::ATTR_HWAS_STATE>().functional,scan_targets[myPROC0]->getAttr<TARGETING::ATTR_HWAS_STATE>().present );
for( uint64_t x = 0; x < NUM_TARGETS; x++ )
{
//only run if the target exists
if(scan_targets[x] == NULL)
{
TRACFCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> scan target is null %d", x );
scan_targets[x] = NULL; //remove from our list
continue;
}
else if ((scan_targets[x]->getAttr<TARGETING::ATTR_SCOM_SWITCHES>().useXscom == 0) &&
(scan_targets[x]->getAttr<TARGETING::ATTR_SCOM_SWITCHES>().useFsiScom== 0))
{
TRACFCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> Target %lX cannot use FSI or Xscom", TARGETING::get_huid(scan_targets[x]));
scan_targets[x] = NULL; //remove from our list
}
else if (scan_targets[x]->getAttr<TARGETING::ATTR_HWAS_STATE>().functional != true)
{
TRACFCOMP( g_trac_scandd,"scanTest::test_SCANreadWrite_proc> Target %lX is not functional\n",TARGETING::get_huid(scan_targets[x]) );
scan_targets[x] = NULL; //remove from our list
}
}
// Scan data ..
struct {
TARGETING::Target* target;
uint32_t data[8];
uint64_t ring;
uint64_t length;
uint64_t flag; // used for header check..
} test_data[] = {
{ scan_targets[myPROC0],
{0x12121212, 0x12341234, 0x12341234, 0x12341234, 0x12341234,
0x12341234,0x12341234, 0x00000000}, 0x15030082, 223, 0x0},
{ scan_targets[memBuf0],
{0x34343434, 0xaaaaaaaa, 0xbbbbbbbb, 0xb0000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000}, 0x01034001, 100, 0x2},
};
const uint64_t NUM_ADDRS = sizeof(test_data)/sizeof(test_data[0]);
// allocate space for read data
uint32_t read_data[8];
// write all the test registers
for( uint64_t x = 0; x < NUM_ADDRS; x++ )
{
//only run if the target exists
if(test_data[x].target == NULL)
{
TRACDCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> TARGEt does not exist 2 %d", x );
continue;
}
size_t op_size = test_data[x].length;
//printk("Before a write for TARGET %X\n", TARGETING::get_huid(test_data[x].target));
TRACDCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> Before Device Write 2>>> " );
total++;
l_err = deviceWrite( test_data[x].target,
&(test_data[x].data),
op_size,
DEVICE_SCAN_ADDRESS(test_data[x].ring,
test_data[x].length,
test_data[x].flag) );
if( l_err )
{
TRACFCOMP(g_trac_scandd, "scanTest::test_SCANreadWrite_proc> [%d] Write: Error from device : ring=0x%X, RC=%X", x, test_data[x].ring, l_err->reasonCode() );
TS_FAIL( "scanTest::test_SCANreadWrite_proc> ERROR : Unexpected error log from write1" );
fails++;
errlCommit(l_err,SCAN_COMP_ID);
}
}
// read all the scan data
for( uint64_t x = 0; x < NUM_ADDRS; x++ )
{
for (int j = 0; j<8;j++)
{
read_data[j] = 0;
}
//only run if the target exists
if(test_data[x].target == NULL)
{
continue;
}
size_t op_size = test_data[x].length;
total++;
l_err = deviceRead( test_data[x].target,
&(read_data),
op_size,
DEVICE_SCAN_ADDRESS(test_data[x].ring,
test_data[x].length,
test_data[x].flag) );
if( l_err )
{
TRACFCOMP(g_trac_scandd, "scanTest::SCANreadWrite_proc> [%d] Read: Error from device : ring=0x%X, RC=%X", x, test_data[x].ring, l_err->reasonCode() );
TS_FAIL( "scanTest::test_SCANreadWrite_proc> ERROR : Unexpected error log from write1" );
fails++;
errlCommit(l_err,SCAN_COMP_ID);
}
else // read and verify each word read back from the scan read.
{
// dont need to check the first word.. that is the header.
for (uint64_t y=1;y < (test_data[x].length/32 + 1);y++)
{
//printk("scanTest::test_SCANreadWrite_proc> [%ld] Read: Data : ring=0x%lX, read_data=0x%.8x, //write_data=0x%.8x\n", x, test_data[x].ring, read_data[y], test_data[x].data[y]);
if(read_data[y] != test_data[x].data[y])
{
TRACFCOMP(g_trac_scandd, "scanTest::test_SCANreadWrite_proc> [%d] Read: UNEXPECTED Data miss-match : ring=0x%X, read_data=0x%.8x, write_data=0x%llx", x, test_data[x].ring, read_data[y], test_data[x].data[y]);
TS_FAIL("scanTest::test_SCANreadWrite_proc> ERROR : Data miss-match between read and expected data" );
fails++;
}
}
}
}
TRACFCOMP( g_trac_scandd, "scanTest::test_SCANreadWrite_proc> %d/%d fails", fails, total );
}
};
#endif
|