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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/ipmi/ipmifruinvprvt.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014,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 */
#ifndef __IPMI_IPMIFRUINVPRVT_H
#define __IPMI_IMPIFRUINVPRVT_H
namespace IPMIFRUINV
{
enum recordFields
{
//Storage Definition Headers will use version 1.2
SPEC_VERSION = 1,
RECORD_UNIT_OF_MEASUREMENT = 8, //size in bytes
CHECKSUM_SIZE = 1, //size in bytes
RECORD_NOT_PRESENT = 0,
ENGLISH_LANGUAGE_CODE = 0,
TYPELENGTH_BYTE_NULL = 0,
TYPELENGTH_BYTE_ASCII = 0xC0,
END_OF_CUSTOM_FIELDS = 0xC1,
COMMON_HEADER_FORMAT_SIZE = 8, //size in bytes
DEFAULT_CHASSIS_TYPE = 0x05,
DEFAULT_FRU_OFFSET = 0,
MAX_ASCII_FIELD_SIZE = 0x3F, //size in bytes
MAX_RECORD_SIZE = 0xFF, //size in bytes
};
};
//Parent Class Contains all common functions to build up, format,
// and send IPMI Fru Inventory Record Data
//The parent Class also defines pure virtual functions so the child
// is responsible to build up the individual record sections
// as the data for those is specific to each child.
class IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
*/
IpmiFruInv(TARGETING::TargetHandle_t i_target);
/**
* @brief Default Destructor
*/
virtual ~IpmiFruInv();
/**
* @brief Factory Pattern Creator function
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
* @param[in] isUpdate, Indicator if the code is updating
* existing data, or setting base data.
*/
static IpmiFruInv *Factory(TARGETING::TargetHandleList i_targets,
bool i_isUpdate);
/**
* @brief Package and send the IPMI FRU Data
*
* @param[in] uint8_t, IPMI Fru Device ID
*/
void sendFruData(uint8_t i_deviceId);
/**
* @brief Gather and Format relevant IPMI Fru Inventory Data
*
* @param[in] void
* @param[out] errlHndl_t, error encountered getting data
*/
errlHndl_t buildFruInvRecord(void);
protected:
//The target to build an IPMI fru inventory record for
TARGETING::TargetHandle_t iv_target;
//The overall IPMI Fru Inventory record to send
std::vector<uint8_t> iv_record_data;
/**
* @brief Format Beginning of Individual IPMI Fru Data Section
*
* @param[in/out] data, Data to be updated with formatting + header
* @param[in] i_setLanguagCode, Indicator to set/not set Language Code
*/
void preFormatProcessing(std::vector<uint8_t>& io_data,
bool i_setLanguageCode);
/**
* @brief Format End of Individual IPMI Fru Data Section
*
* @param[in/out] data, Data container to be updated with formatting
*/
void postFormatProcessing(std::vector<uint8_t>& io_data);
/**
* @brief Complete + Set size of Data Section
*
* @param[in/out] data, Data container with size to be updated
* @param[in] offset, Indicate where to update size of data section
*/
void setAreaSize(std::vector<uint8_t>& io_data, uint8_t i_offset);
/**
* @brief Add inputted data to overall IPMI Fru Record
*
* @param[in] data, Data container to be added to overall record
*/
void addDataToRecord(const std::vector<uint8_t>& i_data);
/**
* @brief Format inpuuted data to hex data that contains build date info
*
* @param[in] mfgDateData, MFG date data container from VPD
* @param[out] mfgDate, MFG date data value in minutes
*/
errlHndl_t formatMfgData(std::vector<uint8_t> i_mfgDateData,
uint32_t& o_mfgDate);
/**
* @brief Add product build date to IPMI fru record
*
* @param[in/out] data, The container to put build date in
* @param[in] mfgDateData, MFG date data container from VPD
*/
void setMfgData(std::vector<uint8_t> &io_data,
std::vector<uint8_t> &i_mfgDateData);
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put intenral use area data in
*/
virtual errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data)=0;
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
virtual errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data)=0;
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
virtual errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data)=0;
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
virtual errlHndl_t buildProductInfoArea(std::vector<uint8_t> &io_data)=0;
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
virtual errlHndl_t buildMultiRecordInfoArea(
std::vector<uint8_t> &io_data)=0;
/**
* @brief Builds a standard data section that is empty
* @param[in] data, The container to put the data in
*/
virtual errlHndl_t buildEmptyArea(std::vector<uint8_t> &i_data);
/**
* @brief Debug function to print data to console
* @param[in] data, The data to be printed
*/
void printRecordDebugData(const std::vector<uint8_t> &i_data);
/**
* @brief Adds ECID attribute data
* @param[in] target, The target to get the Sensor Number from
* @param[in] ecid_info, The ECID attribute data
* @param[in/out] data, The container to put ECID attribute data in
*/
void addEcidData(const TARGETING::TargetHandle_t& i_target,
const TARGETING::ATTR_ECID_type& i_ecidInfo,
std::vector<uint8_t> &io_data);
/**
* @brief Adds EC attribute data
* @param[in] target, The target to get the Sensor Number from
* @param[in] ecInfo, The EC attribute data
* @param[in/out] data, The container to put EC attribute data in
*/
void addECData(const TARGETING::TargetHandle_t& i_target,
const TARGETING::ATTR_EC_type& i_ecInfo,
std::vector<uint8_t> &io_data);
/**
* @brief Adds Ecid and EC attribute data from extra targets as custom data
* @param[in] TargetHandleList, Handle to list of extra
* targets associated with this FRU Record
* @param[in/out] data, The container to put ECID attribute data in
*/
void customData(TARGETING::TargetHandleList i_extraTargets,
std::vector<uint8_t> &io_data);
/**
* @brief Retrieve vpd record keyword and add to IPMI Fru Inventory record
* @param[in/out] data, The container with record data
* @param[in] access, Indicates vpd module to access (MVPD,PVPD,CPVD)
* @param[in] record, Indicates major offset in the VPD to get more data
* @param[in] keyword, Indicates minor offset in the VPD to get more data
* @param[in] ascii, Indicates if VPD field is in ascii format or not
*/
errlHndl_t addCommonVpdData(
const TARGETING::TargetHandle_t& i_target,
std::vector<uint8_t> &io_data,
DeviceFW::AccessType i_accessType,
uint8_t i_record,
uint8_t i_keyword,
bool i_ascii,
bool i_typeLengthByte);
/**
* @brief Add attribute data to IPMI Fru Inventory record
* @param[in/out] data, The container with record data
* @param[in] attrData, Pointer to attribute data
* @param[in] length, Length of data to add
*/
void addCommonAttrData( std::vector<uint8_t> &io_data,
uint8_t * i_pAttrData,
size_t i_length);
// The ATTR_SERIAL_NUMBER and ATTR_PART_NUMBER are 18 bytes but the
// vpd data size is only 16. Only want to add the vpd data, not the pad.
enum vpdSize
{
VPD_SN_PN_VPD_SIZE = 16,
};
// Store number of days in a each month for computation of build date
const uint8_t daysInMonth[12] = {31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
private:
/**
* @brief Compute and Add data checsum to data record
*
* @param[in/out] data, Data to be updated with checsum
*/
void addDataChecksum(std::vector<uint8_t>& io_data);
/**
* @brief Pad data section to proper size
*
* @param[in/out] data, Data to be padded
*/
void padData(std::vector<uint8_t>& io_data);
/**
* @brief Builds a section of the common header
*
* @param[in/out] data, Common Header section data container
* @param[in] section_data, Data from one particular record section
* @param[in/out] cur_offset, Current offset for data in overall record
*/
void buildCommonHeaderSection(std::vector<uint8_t>& io_out_data,
uint32_t i_section_data,
uint32_t &io_cur_offset);
/**
* @brief Sets IPMI Fru Spec Revision Header Format Value
*
* @param[in/out] data, data to add format value to
*/
void addHeaderFormat(std::vector<uint8_t>& io_data);
/**
* @brief Builds the common header data in iv_record
*
* @param[in] internal_use_data, IPMI internal use section data
* @param[in] chassis_data, IPMI chassis section data
* @param[in] board_data, IPMI board section data
* @param[in] product_data, IPMI product section data
* @param[in] multirecord_data, IPMI multirecord section data
* @param[out] void
*/
void buildCommonHeader( const std::vector<uint8_t> &i_internal_use_data,
const std::vector<uint8_t> &i_chassis_data,
const std::vector<uint8_t> &i_board_data,
const std::vector<uint8_t> &i_product_data,
const std::vector<uint8_t> &i_multirecord_data );
/**
* @brief Complete entire record by combining all data parts
*
* @param[in] internal_use_data, IPMI internal use section data
* @param[in] chassis_data, IPMI chassis section data
* @param[in] board_data, IPMI board section data
* @param[in] product_data, IPMI product section data
* @param[in] multirecord_data, IPMI multirecord section data
*/
void completeRecord(const std::vector<uint8_t> &i_internal_use_data,
const std::vector<uint8_t> &i_chassis_data,
const std::vector<uint8_t> &i_board_data,
const std::vector<uint8_t> &i_product_data,
const std::vector<uint8_t> &i_multirecord_data);
};
//Child class for building up ISDimm Fru Inventory Record Data
class isdimmIpmiFruInv : public IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
*/
isdimmIpmiFruInv( TARGETING::TargetHandle_t i_target);
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put internal use area data in
*/
errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
errlHndl_t buildProductInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t> &io_data);
private:
/**
* @brief Adds the specified VPD data to the data to build up a given
* record
* @param[in/out] data, The container with record data
* @param[in] keyword, Indicates where in the VPD to get more data
* @param[in] ascii, Indicates if VPD field is in ascii format or not
*/
errlHndl_t addVpdData(std::vector<uint8_t> &io_data,
uint8_t i_keyword,
bool i_ascii=false);
};
//Child class for building up Processor Fru Inventory Record Data
class procIpmiFruInv : public IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
* @param[in] isUpdate, Indicator if the code is updating
* existing data, or setting base data.
*/
procIpmiFruInv( TARGETING::TargetHandle_t i_target,
bool i_isUpdate );
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put internal use area data in
*/
errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
errlHndl_t buildProductInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t> &io_data);
protected:
//Indicator if a data update is happening.
//True - means we are solely updating certain data
//False - means we are doing the initial 'base' data set
bool iv_isUpdate;
private:
/**
* @brief Adds the specified VPD data to the data to build up a given
* IPMI Fru Inventory record
* @param[in/out] data, The container with record data
* @param[in] record, Indicates major offset in the VPD to get more data
* @param[in] keyword, Indicates minor offset in the VPD to get more data
* @param[in] ascii, Indicates if VPD field is in ascii format or not
* @param[in] typeLengthBtye, Indicates whether type length to be added.
*/
errlHndl_t addVpdData(std::vector<uint8_t> &io_data,
uint8_t i_record,
uint8_t i_keyword,
bool i_ascii=false,
bool i_typeLengthByte=true);
};
//Child class for building up backplane Fru Inventory Record Data
class backplaneIpmiFruInv : public IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
* @param[in] TargetHandleList, Handle to list of extra
* targets associated with this FRU Record
* @param[in] isUpdate, Indicator if the code is updating
* existing data, or setting base data.
*/
backplaneIpmiFruInv( TARGETING::TargetHandle_t i_target,
TARGETING::TargetHandleList i_extraTargets,
bool i_isUpdate );
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put internal use area data in
*/
errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
errlHndl_t buildProductInfoArea(std::vector<uint8_t>& io_data);
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t>& io_data);
protected:
//Indicator if a data update is happening.
//True - means we are solely updating certain data
//False - means we are doing the initial 'base' data set
bool iv_isUpdate;
//The list of Extra Targets if multiple targets are
//associated with one FRU_ID
TARGETING::TargetHandleList iv_extraTargets;
private:
/**
* @brief Adds the specified VPD data to the data to build up a given
* IPMI Fru Inventory record
* @param[in/out] data, The container with record data
* @param[in] record, Indicates major offset in the VPD to get more data
* @param[in] keyword, Indicates minor offset in the VPD to get more data
* @param[in] ascii, Indicates if VPD field is in ascii format or not
* @param[in] typeLengthBtye, Indicates whether type length to be added.
*/
errlHndl_t addVpdData(std::vector<uint8_t> &io_data,
uint8_t i_record,
uint8_t i_keyword,
bool i_ascii=false,
bool i_typeLengthByte=true);
};
//Child class for building up System Firwmare Fru Inventory Record Data
class systemFwIpmiFruInv : public IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
*/
systemFwIpmiFruInv( TARGETING::TargetHandle_t i_target);
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put internal use area data in
*/
errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
errlHndl_t buildProductInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t> &io_data);
};
//Child class for building up membuf Fru Inventory Record Data. For example,
//for a memory riser card Fru.
class membufIpmiFruInv : public IpmiFruInv
{
public:
/**
* @brief Constructor
*
* @param[in] TargetHandle_t, Handle to target for which
* to get relevant IPMI FRU Data from
* @param[in] TargetHandleList, Handle to list of extra
* targets associated with this FRU Record
* @param[in] isUpdate, Indicator if the code is updating
* existing data, or setting base data.
*/
membufIpmiFruInv( TARGETING::TargetHandle_t i_target,
TARGETING::TargetHandleList i_extraTargets,
bool i_isUpdate );
/**
* @brief Builds the Internal Use Area Data Section
* @param[in/out] data, The container to put internal use area data in
*/
errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Chassis Info Area Data Section
* @param[in/out] data, The container to put chassis info area data in
*/
errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Board Info Area Data Section
* @param[in/out] data, The container to put board info area data in
*/
errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
/**
* @brief Builds the Product Info Area Data Section
* @param[in/out] data, The container to put product info area data in
*/
errlHndl_t buildProductInfoArea(std::vector<uint8_t>& io_data);
/**
* @brief Builds the MultiRecord Info Area Data Section
* @param[in/out] data, The container to put multirecord info area data in
*/
errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t>& io_data);
protected:
//Indicator if a data update is happening.
//True - means we are solely updating certain data
//False - means we are doing the initial 'base' data set
bool iv_isUpdate;
//The list of Extra Targets if multiple targets are
//associated with one FRU_ID
TARGETING::TargetHandleList iv_extraTargets;
private:
/**
* @brief Adds the specified VPD data to the data to build up a given
* IPMI Fru Inventory record
* @param[in/out] data, The container with record data
* @param[in] record, Indicates major offset in the VPD to get more data
* @param[in] keyword, Indicates minor offset in the VPD to get more data
* @param[in] ascii, Indicates if VPD field is in ascii format or not
* @param[in] typeLengthBtye, Indicates whether type length to be added.
*/
errlHndl_t addVpdData(std::vector<uint8_t> &io_data,
uint8_t i_record,
uint8_t i_keyword,
bool i_ascii=false,
bool i_typeLengthByte=true);
};
#endif
|