summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2/test/fapi2DdimmGetEfdTest.H
blob: 43a359381fbfefbc42696b4aa7c80ba09a252276 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/fapi2/test/fapi2DdimmGetEfdTest.H $                   */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2019                        */
/* [+] 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                                                     */

#ifndef __FAPI2_DDIMM_GET_EFD_TEST_H
#define __FAPI2_DDIMM_GET_EFD_TEST_H

#include <cxxtest/TestSuite.H>
#include <ddimm_get_efd.H>

//******************************************************************************
// class fapi2DdimmGetEfdTest
//
// @brief This tests the HWP call ddimm_get_efd/ddr4_get_efd
//
//******************************************************************************
class fapi2DdimmGetEfdTest : public CxxTest::TestSuite
{
public:

//******************************************************************************
//                                 Public API
//******************************************************************************

//******************************************************************************
// fapi2DdimmGetEfdTest ctor
//******************************************************************************
fapi2DdimmGetEfdTest();

//******************************************************************************
// testDdimmGetEfdHwpCall
//
// @brief A wrapper around the actual test procedures.
//
//******************************************************************************
void testDdimmGetEfdHwpCall();

private:

//******************************************************************************
// Private Test Cases
//******************************************************************************

//******************************************************************************
// sanityCheckTest
//
// @brief The setup creates a perfect scenario to get a match from the get go.
//        If this fails, then setup is broken/corrupt, design has changed, etc.
//        Either way, no point in continuing until fixed.
//
// @return true if a match was found (which signifies that the test suite has
//         been initialized correctly), false if no match found (which
//         signifies that the test suite has NOT been initialized correctly)
//
//******************************************************************************
bool sanityCheckTest();

//******************************************************************************
// sizeMisMatchTest
//
// @brief Do negative testing on the sizes of the different elements - SPD
//        buffer, EFD memory space size, etc.
//
//******************************************************************************
void sizeMisMatchTest();

//******************************************************************************
// dmbDataTest
//
// @brief Do negative testing on the DMB manufacturer ID and the DMB revision.
//        Test for incorrect values.
//
//******************************************************************************
void dmbDataTest();

//******************************************************************************
// vpdInfoInputTest
//
// @brief Do negative testing on the frequency and master rank data passed in
//        via the VPDInfo struct. Test for incorrect values.
//
//******************************************************************************
void vpdInfoInputTest();

//******************************************************************************
// findMatchTest
//
// @brief Do positive testing on finding/not finding a match for given
//        frequency and rank.
//
//******************************************************************************
void findMatchTest();



//******************************************************************************
//
// Private utilities to facilitate the testing.  These utilities help
// to manipulate buffers for easy testing.
//
//******************************************************************************

/*
 * @brief Initialize the SPD buffer to a good state - one that has no issues
 *        finding an EFD to match the criteria in the VPDInfo struct.
 */
void initializeSpdBuffer();

/*
 * @brief Create the buffer for the SPD with given parameters.
 *
 * @param[out] o_spdBufferPtr, pointer to a newly created SPD buffer
 * @param[in]  i_spdBufferSize, size to make the SPD buffer
 */
void createSpdBuffer(      uint8_t* &o_spdBufferPtr,
                     const size_t    i_spdBufferSize);

/*
 * @brief Set the DDIMM type of SPD buffer at the proper location
 *        within the SPD buffer.
 *
 * @param[in] i_spdDdimmType, DDIMM type to set within the SPD buffe
 */
void setSpdDdimmType(const uint8_t i_spdDdimmType);

/*
 * @brief Set the EFD memory space location at the proper location
 *        within the SPD buffer.
 *
 * @param[in] i_efdMemorySpaceLocation, the EFD memory space location
 */
void setEfdMemorySpaceLocation(const uint64_t i_efdMemorySpaceLocation);

/*
 * @brief Set the EFD memory space size at the proper location
 *        within the SPD buffer.
 *
 * @param[in] i_efdMemorySpaceSize, the EFD memory space size
 */
void setEfdMemorySpaceSize(const uint8_t   i_efdMemorySpaceSize);

/*
 * @brief Set the number of EFDs, for this buffer, at the proper location
 *        within the SPD buffer.
 *
 * @param[in] i_efdCount, the number of EFDs
 */
void setEfdCount(const uint16_t i_efdCount);

/*
 * @brief Set the DMB manufacturer ID at the proper location
 *        within the SPD buffer.
 *
 * @param[in] i_spdDmbMfgId, the DMB manufacturer ID
 */
void setSpdDmbMfgId(const uint16_t i_spdDmbMfgId);

/*
 * @brief Set the DMB revision at the proper location within the SPD buffer.
 *
 * @param[in]  i_spdDmbMfgId, the DMB revision
 */
void setSpdDmbRevision(const uint8_t i_spdDmbRevision);

/*
 * @brief Set individual EFD data block ending offset within the EFD meta data
 *
 * @param[in] i_efdMetaDataN, the individual EFD meta data to modify, 0 based
 * @param[in] i_efdDataBlockEnd, the corresponding EFD data block end
 *                                for the given EFD meta data
 */
void setEfdMetaDataNEfdDataBlockEnd(const size_t  i_efdMetaDataN,
                                    const uint8_t i_efdDataBlockEnd);
/*
 * @brief Set all the EFD data block sizes within the EFD meta datas
 *
 * @param[in] i_efdDataBlockSize, size of the EFD data block
 */
void setAllEfdMetaDatasEfdDataBlockSize(const uint8_t i_efdDataBlockSize);

/*
 * @brief Set an individual EFD meta data's extended function type
 *
 * @param[in] i_efdMetaDataN, the individual EFD meta data to modify, 0 based
 * @param[in] i_extendedFunctionType, the extended function type value
 */
void setEfdMetaDataExtendedFunctionType(const size_t  i_efdMetaDataN,
                                        const uint8_t i_extendedFunctionType);

 /*
 * @brief Set all the EFD meta data's extended function type
 *
 * @param[in] i_extendedFunctionType, the extended function type value
 */
void setAllEfdMetaDatasExtendedFunctionType(
                                          const uint8_t i_extendedFunctionType);
/*
 * @brief Set an individual EFD meta data's implemented state
 *
 * @param[in] i_efdMetaDataN, the individual EFD meta data to modify, 0 based
 * @param[in] i_isImplemented, state of the EFD meta data to be set to
 */
void setEfdMetaDataNisImplemented(const size_t i_efdMetaDataN,
                                  const bool   i_isImplemented);

/*
 * @brief Set all the EFD meta data's implemented state
 *
 * @param[in] i_isImplemented, state of the EFD meta data to be set to
 */
void setAllEfdMetaDatasIsImplemented(const bool i_isImplemented);

 /*
 * @brief Set an individual EFD data block's frequency
 *
 * @param[in] i_frequency, the frequency, in numeric form
 */
uint16_t convertFrequency(const uint16_t i_frequency);

 /*
 * @brief Set an individual EFD data block's frequency
 *
 * @param[in] i_efdDataBlockN, the individual EFD data block to modify, 0 based
 * @param[in] i_frequency, the frequency, in numeric form, to set the
 *            individual EFD data block to
 */
void setEfdDataBlockNFreq(const size_t   i_efdDataBlockN,
                          const uint16_t i_frequency);

 /*
 * @brief Set all the EFD data block's frequency
 *
 * @param[in] i_frequency, the frequency, in numeric form, to set all EFD
 *            data blocks to
 */
void setAllEfdDataBlocksFreq(const uint16_t i_frequency);

 /*
 * @brief Append a frequency to an individual EFD data block
 *
 * @param[in] i_efdDataBlockN, the individual EFD data block to modify, 0 based
 * @param[in] i_frequency, the frequency, in numeric form, to append
 */
void appendToEfdDataBlockNFreq(const size_t   i_efdDataBlockN,
                               const uint16_t i_frequency);

 /*
 * @brief Append a frequency to all EFD data blocks
 *
 * @param[in] i_frequency, the frequency, in numeric form, to append
 */
void appendToAllEfdDataBlocksFreq(const uint16_t i_frequency);

/*
 * @brief Map master rank to bit mask.
 *
 * @param[in]  i_rank, the master rank, in numeric form
 */
uint8_t convertRank(const uint8_t i_rank);

/*
 * @brief Set an individual EFD data block's master rank
 *
 * @param[in] i_efdDataBlockN, the individual EFD data block to modify, 0 based
 * @param[in] i_rank, the master rank, in numeric form, to set the individual
 *            EFD data block to
 */
void setEfdDataBlockNRank(const size_t  i_efdDataBlockN,
                          const uint8_t i_rank);

 /*
 * @brief Set all the EFD data block's master rank
 *
 * @param[in] i_rank, the master rank, in numeric form, to set all EFD
 *            data blocks to
 *
 */
void setAllEfdDataBlocksRank(const uint8_t i_rank);

/*
 * @brief Create the buffer for the EFD with given parameters.
 *
 * @param[out] o_efdBufferPtr, pointer to a newly created EFD buffer
 * @param[in]  i_efdBufferSize, size to make the EFD buffer
 */
void createEfdBuffer(      uint8_t* &o_efdBufferPtr,
                     const size_t    i_efdBufferSize);

/*
 * @brief Initialize a VPDInfo struct to a known state
 *
 * @param[out] o_vpdInfo, VPDInfo struct to initialize
 */
void initializeVpdInfo(fapi2::VPDInfo<fapi2::TARGET_TYPE_OCMB_CHIP>& o_vpdInfo);

/*
 * @brief Configure an EFD data block to given data
 *
 * @param[in]  i_efdDataBlockN, the individual EFD data block to modify, 0 based
 * @param[in]  i_frequency, the frequency, in numeric form,
 *             to set EFD data block to
 * @param[in]  i_rank, the master rank, in numeric form,
 *             to set EFD data block to
 * @param[in]  i_beginTag, tag to use at the beginning of the EFD data block
 * @param[in]  i_endTag, tag to use at the end of the EFD data block
 */
void configureEfdDataBlockN(const size_t   i_efdDataBlockN,
                            const uint16_t i_frequency,
                            const uint8_t  i_rank,
                            const uint8_t  i_beginTag,
                            const uint8_t  i_endTag);

/*
 * @brief Verify the EFD buffer has the expected value.  It is not enough to
 *        say we found a match.  Must confirm we retrieved the correct EFD
 *        data block.
 *
 * @param[in]  i_frequency, the frequency, in numeric form,
 *             to match in EFD data block
 * @param[in]  i_rank, the master rank, in numeric form,
 *             to match in EFD data block
 * @param[in]  i_beginTag, tag to match at the beginning of the EFD data block
 * @param[in]  i_endTag, tag to match at the end of the EFD data block
 *
 * @return true if the EFD buffer matches data given, else false if no match
 */
bool verifyEfdBuffer(const uint16_t i_frequency,
                     const uint8_t  i_rank,
                     const uint8_t  i_beginTag,
                     const uint8_t  i_endTag);

/*
 * @brief Tag an EFD data block to help identify it when found
 *        Tagging the EFD data block at specific memory places within the EFD
 *        data block, ensures that when a match is found, indeed that block
 *        is returned - the called function cannot spoof the data.  The tags
 *        ensure that the called function is returning the correct EFD data
 *        block in it's entirety.
 *
 * @param[in]  i_efdDataBlockN, the individual EFD data block to modify, 0 based
 * @param[in]  i_beginTag, tag to use at the beginning of the EFD data block
 * @param[in]  i_endTag, tag to use at the end of the EFD data block
 */
void tagEfdDataBlockN(const size_t  i_efdDataBlockN,
                      const uint8_t i_beginTag,
                      const uint8_t i_endTag);

//******************************************************************************
//
// Private data members
//
//******************************************************************************

    uint8_t* iv_efdBufferPtr;
    uint8_t* iv_spdBufferPtr;
    size_t   iv_spdBufferSize;
    uint8_t* iv_efdMetaDataPtr;
    uint8_t* iv_efdBlockDataPtr;
    uint8_t  iv_efdBlockSizeMultiplier;
    size_t   iv_efdBlockSize;
    size_t   iv_efdMemorySpaceLocation;
    size_t   iv_efdMemorySpaceSize;
    uint16_t iv_efdCount;
    uint16_t iv_spdDmbMfgId;
    uint8_t  iv_spdDmbRevision;
    uint8_t  iv_extendedFunctionType;
    uint16_t iv_frequency;
    uint8_t  iv_rank;

    TARGETING::Target * iv_ocmbChipTarget;
    fapi2::ReturnCode iv_rc;
    fapi2::VPDInfo<fapi2::TARGET_TYPE_OCMB_CHIP> iv_vpdInfo;

    size_t iv_numTests;
    size_t iv_numFails;
    TARGETING::MODEL iv_attrModel;
};  // end class fapi2DdimmGetEfdTest

#endif

OpenPOWER on IntegriCloud