This repository has been archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fru.h
481 lines (431 loc) · 17.6 KB
/
fru.h
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
#ifndef FRU_H
#define FRU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <asm/byteorder.h>
#include <stddef.h>
#include <stdint.h>
#include "base.h"
#include "utils.h"
#define PLDM_GET_FRU_RECORD_TABLE_METADATA_REQ_BYTES 0
#define PLDM_GET_FRU_RECORD_TABLE_METADATA_RESP_BYTES 19
#define PLDM_GET_FRU_RECORD_TABLE_REQ_BYTES 5
#define PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES 6
#define PLDM_GET_FRU_RECORD_BY_OPTION_MIN_RESP_BYTES 6
#define FRU_TABLE_CHECKSUM_SIZE 4
enum pldm_fru_completion_codes {
PLDM_FRU_DATA_STRUCTURE_TABLE_UNAVAILABLE = 0x85,
};
/** @brief PLDM FRU commands
*/
enum pldm_fru_commands {
PLDM_GET_FRU_RECORD_TABLE_METADATA = 0X01,
PLDM_GET_FRU_RECORD_TABLE = 0X02,
PLDM_SET_FRU_RECORD_TABLE = 0X03,
PLDM_GET_FRU_RECORD_BY_OPTION = 0X04
};
/** @brief FRU record types
*/
enum pldm_fru_record_type {
PLDM_FRU_RECORD_TYPE_GENERAL = 0X01,
PLDM_FRU_RECORD_TYPE_OEM = 0XFE,
};
/** @brief Encoding type for FRU fields
*/
enum pldm_fru_field_encoding {
PLDM_FRU_ENCODING_UNSPECIFIED = 0X00,
PLDM_FRU_ENCODING_ASCII = 0X01,
PLDM_FRU_ENCODING_UTF8 = 0X02,
PLDM_FRU_ENCODING_UTF16 = 0X03,
PLDM_FRU_ENCODING_UTF16LE = 0X04,
PLDM_FRU_ENCODING_UTF16BE = 0X05,
};
/** @brief FRU field types
*/
enum pldm_fru_field_type {
PLDM_FRU_FIELD_TYPE_CHASSIS = 0X01,
PLDM_FRU_FIELD_TYPE_MODEL = 0X02,
PLDM_FRU_FIELD_TYPE_PN = 0X03,
PLDM_FRU_FIELD_TYPE_SN = 0X04,
PLDM_FRU_FIELD_TYPE_MANUFAC = 0X05,
PLDM_FRU_FIELD_TYPE_MANUFAC_DATE = 0X06,
PLDM_FRU_FIELD_TYPE_VENDOR = 0X07,
PLDM_FRU_FIELD_TYPE_NAME = 0X08,
PLDM_FRU_FIELD_TYPE_SKU = 0X09,
PLDM_FRU_FIELD_TYPE_VERSION = 0X0A,
PLDM_FRU_FIELD_TYPE_ASSET_TAG = 0X0B,
PLDM_FRU_FIELD_TYPE_DESC = 0X0C,
PLDM_FRU_FIELD_TYPE_EC_LVL = 0X0D,
PLDM_FRU_FIELD_TYPE_OTHER = 0X0E,
PLDM_FRU_FIELD_TYPE_IANA = 0X0F,
};
/** @struct pldm_get_fru_record_table_metadata_resp
*
* Structure representing PLDM get FRU table metadata response.
*/
struct pldm_get_fru_record_table_metadata_resp {
uint8_t completion_code; //!< completion code
uint8_t fru_data_major_version; //!< The major version of the FRU Record
uint8_t fru_data_minor_version; //!< The minor version of the FRU Record
uint32_t
fru_table_maximum_size; //!< The size of the largest FRU Record data
uint32_t fru_table_length; //!< The total length of the FRU Record Table
uint16_t total_record_set_identifiers; //!< The total number of FRU
//!< Record Data structures
uint16_t
total_table_records; //!< The total number of records in the table
uint32_t
checksum; //!< The integrity checksum on the FRU Record Table data
} __attribute__((packed));
/** @struct pldm_get_fru_record_table_req
*
* Structure representing PLDM get FRU record table request.
*/
struct pldm_get_fru_record_table_req {
uint32_t data_transfer_handle;
uint8_t transfer_operation_flag;
} __attribute__((packed));
/** @struct pldm_get_fru_record_table_resp
*
* Structure representing PLDM get FRU record table response.
*/
struct pldm_get_fru_record_table_resp {
uint8_t completion_code;
uint32_t next_data_transfer_handle;
uint8_t transfer_flag;
uint8_t fru_record_table_data[1];
} __attribute__((packed));
struct pldm_set_fru_record_table_req {
uint32_t data_transfer_handle;
uint8_t transfer_flag;
} __attribute__((packed));
struct pldm_set_fru_record_table_resp {
uint8_t completion_code;
uint32_t next_data_transfer_handle;
} __attribute__((packed));
struct pldm_get_fru_record_by_option_req {
uint32_t data_transfer_handle;
uint16_t fru_table_handle;
uint16_t record_set_identifier;
uint8_t record_type;
uint8_t field_type;
uint8_t transfer_op_flag;
} __attribute__((packed));
struct pldm_get_fru_record_by_option_resp {
uint8_t completion_code;
uint32_t next_data_transfer_handle;
uint8_t transfer_flag;
uint8_t fru_structure_data[1];
} __attribute__((packed));
/** @struct pldm_fru_record_tlv
*
* Structure representing each FRU field entry (type, length, value)
*/
struct pldm_fru_record_tlv {
uint8_t type;
uint8_t length;
uint8_t value[1];
} __attribute__((packed));
/** @struct pldm_fru_record_data_format
*
* Structure representing the FRU record data format
*/
struct pldm_fru_record_data_format {
uint16_t record_set_id;
uint8_t record_type;
uint8_t num_fru_fields;
uint8_t encoding_type;
struct pldm_fru_record_tlv tlvs[1];
} __attribute__((packed));
/* Requester */
/* GetFRURecordTableMetadata */
/** @brief Create a PLDM request message for GetFRURecordTableMetadata
*
* @param[in] instance_id - Message's instance id
* @param[in,out] msg - Message will be written to this
* @param[in] payload_length - Length of the request message payload
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_get_fru_record_table_metadata_req(uint8_t instance_id,
struct pldm_msg *msg,
size_t payload_length);
/** @brief Decode GetFruRecordTable response data
*
* Note:
* * If the return value is not PLDM_SUCCESS, it represents a
* transport layer error.
* * If the completion_code value is not PLDM_SUCCESS, it represents a
* protocol layer error and all the out-parameters are invalid.
*
* @param[in] msg - Response message
* @param[in] payload_length - Length of response message payload
* @param[out] completion_code - Pointer to response msg's PLDM completion code
* @param[out] fru_data_major_version - Major version of the FRU Record
* @param[out] fru_data_minor_version - Minor version of the FRU Record
* @param[out] fru_table_maximum_size - Size of the largest FRU Record data
* @param[out] fru_table_length - Total length of the FRU Record Table
* @param[out] total_Record_Set_Identifiers - Total number of FRU Record Data
* structures
* @param[out] total_table_records - Total number of records in the table
* @param[out] checksum - integrity checksum on the FRU Record Table data
* @return pldm_completion_codes
*/
int decode_get_fru_record_table_metadata_resp(
const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
uint8_t *fru_data_major_version, uint8_t *fru_data_minor_version,
uint32_t *fru_table_maximum_size, uint32_t *fru_table_length,
uint16_t *total_record_set_identifiers, uint16_t *total_table_records,
uint32_t *checksum);
/* Responder */
/* GetFRURecordTableMetadata */
/** @brief Create a PLDM response message for GetFRURecordTableMetadata
*
* @param[in] instance_id - Message's instance id
* @param[in] completion_code - PLDM completion code
* @param[in] fru_data_major_version - Major version of the FRU Record
* @param[in] fru_data_minor_version - Minor version of the FRU Record
* @param[in] fru_table_maximum_size - Size of the largest FRU Record data
* @param[in] fru_table_length - Total length of the FRU Record Table
* @param[in] total_Record_Set_Identifiers - Total number of FRU Record Data
* structures
* @param[in] total_table_records - Total number of records in the table
* @param[in] checksum - integrity checksum on the FRU Record Table data
* @param[in,out] msg - Message will be written to this
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_get_fru_record_table_metadata_resp(
uint8_t instance_id, uint8_t completion_code,
uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
uint32_t fru_table_maximum_size, uint32_t fru_table_length,
uint16_t total_record_set_identifiers, uint16_t total_table_records,
uint32_t checksum, struct pldm_msg *msg);
/* GetFruRecordTable */
/** @brief Decode GetFruRecordTable request data
*
* @param[in] msg - PLDM request message payload
* @param[in] payload_length - Length of request payload
* @param[out] data_transfer_handle - A handle, used to identify a FRU Record
* Table data transfer
* @param[out] transfer_operation_flag - A flag that indicates whether this is
* the start of the transfer
* @return pldm_completion_codes
*/
int decode_get_fru_record_table_req(const struct pldm_msg *msg,
size_t payload_length,
uint32_t *data_transfer_handle,
uint8_t *transfer_operation_flag);
/** @brief Create a PLDM response message for GetFruRecordTable
*
* @param[in] instance_id - Message's instance id
* @param[in] completion_code - PLDM completion code
* @param[in] next_data_transfer_handle - A handle that is used to identify the
* next portion of the transfer
* @param[in] transfer_flag - The transfer flag that indicates what part of the
* transfer this response represents
* @param[in,out] msg - Message will be written to this
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param 'msg',
* and for appending the FRU table to the msg.
*/
int encode_get_fru_record_table_resp(uint8_t instance_id,
uint8_t completion_code,
uint32_t next_data_transfer_handle,
uint8_t transfer_flag,
struct pldm_msg *msg);
/* GetFRURecordByOption */
/** @brief Decode GetFRURecordByOption request data
*
* @param[in] msg - PLDM request message payload
* @param[in] payload_length - Length of request payload
* @param[out] data_transfer_handle - A handle, used to identify a FRU Record
* Table data transfer
* @param[out] fru_table_handle - A handle, used to identify a FRU DATA
* records
* @param[out] record_set_identifier - FRU record set identifier
* @param[out] record_type - FRU record type
* @param[out] field_type - FRU field type
* @param[out] transfer_op_flag - A flag that indicates whether this is
* the start of the transfer
* @return pldm_completion_codes
*/
int decode_get_fru_record_by_option_req(
const struct pldm_msg *msg, size_t payload_length,
uint32_t *data_transfer_handle, uint16_t *fru_table_handle,
uint16_t *record_set_identifier, uint8_t *record_type, uint8_t *field_type,
uint8_t *transfer_op_flag);
/** @brief Encode GetFRURecordByOption response data
*
* @param[in] instance_id - Message's instance id
* @param[in] completion_code - PLDM completion code
* @param[in] next_data_transfer_handle - A handle that is used to identify the
* next portion of the transfer
* @param[in] transfer_flag - The transfer flag that indicates what part of the
* transfer this response represents
* @param[in] fru_structure_data - FRU Structure Data
* @param[in] data_size - Size of FRU Structrue Data
* @param[in,out] msg - Message will be written to this
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param 'msg',
* and for appending the FRU table to the msg.
*/
int encode_get_fru_record_by_option_resp(uint8_t instance_id,
uint8_t completion_code,
uint32_t next_data_transfer_handle,
uint8_t transfer_flag,
const void *fru_structure_data,
size_t data_size, struct pldm_msg *msg,
size_t payload_length);
/* Requester */
/* GetFruRecordTable */
/** @brief Create a PLDM request message for GetFruRecordTable
*
* @param[in] instance_id - Message's instance id
* @param[in] data_transfer_handle - A handle, used to identify a FRU Record
* Table data transfer
* @param[in] transfer_operation_flag - A flag that indicates whether this is
* the start of the transfer
* @param[in,out] msg - Message will be written to this
* @param[in] payload_length - Length of request message payload
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_get_fru_record_table_req(uint8_t instance_id,
uint32_t data_transfer_handle,
uint8_t transfer_operation_flag,
struct pldm_msg *msg,
size_t payload_length);
/** @brief Decode GetFruRecordTable response data
*
* @param[in] msg - Response message
* @param[in] payload_length - Length of response message payload
* @param[out] completion_code - Pointer to response msg's PLDM completion code
* @param[out] next_data_transfer_handle - A handle used to identify the next
* portion of the transfer
* @param[out] transfer_flag - The transfer flag that indicates what part of
* the transfer this response represents
* @param[out] fru_record_table_data - This data is a portion of the overall
* FRU Record Table
* @param[out] fru_record_table_length - Length of the FRU record table data
* @return pldm_completion_codes
*/
int decode_get_fru_record_table_resp(
const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
uint8_t *fru_record_table_data, size_t *fru_record_table_length);
/** @brief Encode the FRU record in the FRU table
*
* @param[in/out] fru_table - Pointer to the FRU table
* @param[in] total_size - The size of the table,including the size of FRU
* record to be added to the table.
* @param[in/out] curr_size - The size of the table, excluding the size of FRU
* record to be added to the table.
* @param[in] record_set_id - FRU record set identifier
* @param[in] record_type - FRU record type
* @param[in] num_frus - Number of FRU fields
* @param[in] encoding - Encoding type for FRU fields
* @param[in] tlvs - Pointer to the buffer with all the FRU fields
* @param[in] tlvs_size - Size of the buffer with all the FRU fields
*
* @return pldm_completion_codes
*/
int encode_fru_record(uint8_t *fru_table, size_t total_size, size_t *curr_size,
uint16_t record_set_id, uint8_t record_type,
uint8_t num_frus, uint8_t encoding, uint8_t *tlvs,
size_t tlvs_size);
/* GetFRURecordByOption */
/** @brief Create a PLDM request message for GetFRURecordByOption
*
* @param[in] instance_id - Message's instance id
* @param[in] data_transfer_handle - A handle, used to identify a FRU Record
* Table data transfer
* @param[in] fru_table_handle - A handle, used to identify a FRU DATA records
* @param[in] record_set_identifier - FRU record set identifier
* @param[in] record_type - FRU record type
* @param[in] field_type - FRU field type
* @param[in] transfer_op_flag - A flag that indicates whether this is
* the start of the transfer
* @param[in,out] msg - Message will be written to this
* @param[in] payload_length - Length of request message payload
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_get_fru_record_by_option_req(
uint8_t instance_id, uint32_t data_transfer_handle,
uint16_t fru_table_handle, uint16_t record_set_identifier,
uint8_t record_type, uint8_t field_type, uint8_t transfer_op_flag,
struct pldm_msg *msg, size_t payload_length);
/** @brief Decode GetFRURecordByOption response data
*
* @param[in] msg - Response message
* @param[in] payload_length - Length of response message payload
* @param[out] completion_code - Pointer to response msg's PLDM completion code
* @param[out] next_data_transfer_handle - A handle used to identify the next
* portion of the transfer
* @param[out] transfer_flag - The transfer flag that indicates what part of
* the transfer this response represents
* @param[out] fru_structure_data - FRU Structure Data
* @return pldm_completion_codes
*/
int decode_get_fru_record_by_option_resp(
const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
uint32_t *next_transfer_handle, uint8_t *transfer_flag,
struct variable_field *fru_structure_data);
/** @brief Get FRU Record Table By Option
* @param[in] table - The source fru record table
* @param[in] table_size - Size of the source fru record table
* @param[out] record_table - Fru table fetched based on the input option
* @param[in/out] record_size - Size of the table fetched by fru record option
* @param[in] rsi - FRU record set identifier
* @param[in] rt - FRU record type
* @param[in] ft - FRU field type
*/
void get_fru_record_by_option(const uint8_t *table, size_t table_size,
uint8_t *record_table, size_t *record_size,
uint16_t rsi, uint8_t rt, uint8_t ft);
/** Requester
*
* SetFruRecordTable
*
* @brief Create a PLDM request message for SetFruRecordTable
*
* @param[in] instance_id - Message's instance id
* @param[in] data_transfer_handle - A handle, used to identify a FRU Record
* Table data transfer
* @param[in] transfer_flag - The transfer flag that indicates what part of
* the transfer this response represents
* @param[in] fru_record_table_data - This data is a portion of the overall
* FRU Record Table
* @param[in,out] msg - Message will be written to this
* @param[in] payload_length - Length of request message payload
* @return pldm_completion_codes
* @note Caller is responsible for memory alloc and dealloc of param
* 'msg.payload'
*/
int encode_set_fru_record_table_req(
const uint8_t instance_id, const uint32_t data_transfer_handle,
const uint8_t transfer_flag, struct variable_field *fru_record_table_data,
struct pldm_msg *msg, const size_t payload_length);
/** @brief Decode SetFruRecordTable response data
*
* @param[in] msg - Response message
* @param[in] payload_length - Length of response message payload
* @param[out] completion_code - Pointer to response msg's PLDM completion code
* @param[out] next_data_transfer_handle - A handle used to identify the next
* portion of the transfer
* @return pldm_completion_codes
*/
int decode_set_fru_record_table_resp(const struct pldm_msg *msg,
const size_t payload_length,
uint8_t *completion_code,
uint32_t *next_data_transfer_handle);
#ifdef __cplusplus
}
#endif
#endif