blob: 4a8205ee108c375bbd025a8f6a36ba5713fb00a0 [file] [log] [blame]
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +05301#ifndef FRU_H
2#define FRU_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <asm/byteorder.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "base.h"
13
Christian Geddes3bdb3c22020-05-01 14:55:39 -050014#define PLDM_GET_FRU_RECORD_TABLE_METADATA_REQ_BYTES 0
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053015#define PLDM_GET_FRU_RECORD_TABLE_METADATA_RESP_BYTES 19
PriyangaRamasamy497665a2019-07-30 12:48:25 +053016#define PLDM_GET_FRU_RECORD_TABLE_REQ_BYTES 5
17#define PLDM_GET_FRU_RECORD_TABLE_MIN_RESP_BYTES 6
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053018
Christian Geddes3bdb3c22020-05-01 14:55:39 -050019#define FRU_TABLE_CHECKSUM_SIZE 4
20
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053021/** @brief PLDM FRU commands
22 */
23enum pldm_fru_commands {
24 PLDM_GET_FRU_RECORD_TABLE_METADATA = 0X01,
PriyangaRamasamy497665a2019-07-30 12:48:25 +053025 PLDM_GET_FRU_RECORD_TABLE = 0X02,
PriyangaRamasamyf3295be2019-07-23 12:18:40 +053026 PLDM_SET_FRU_RECORD_TABLE = 0X03,
27 PLDM_GET_FRU_RECORD_BY_OPTION = 0X04
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053028};
29
Tom Joseph93d68712020-01-07 10:24:41 +053030/** @brief FRU record types
31 */
32enum pldm_fru_record_type {
33 PLDM_FRU_RECORD_TYPE_GENERAL = 0X01,
34 PLDM_FRU_RECORD_TYPE_OEM = 0XFE,
35};
36
37/** @brief Encoding type for FRU fields
38 */
39enum pldm_fru_field_encoding {
40 PLDM_FRU_ENCODING_UNSPECIFIED = 0X00,
41 PLDM_FRU_ENCODING_ASCII = 0X01,
42 PLDM_FRU_ENCODING_UTF8 = 0X02,
43 PLDM_FRU_ENCODING_UTF16 = 0X03,
44 PLDM_FRU_ENCODING_UTF16LE = 0X04,
45 PLDM_FRU_ENCODING_UTF16BE = 0X05,
46};
47
48/** @brief FRU field types
49 */
50enum pldm_fru_field_type {
51 PLDM_FRU_FIELD_TYPE_CHASSIS = 0X01,
52 PLDM_FRU_FIELD_TYPE_MODEL = 0X02,
53 PLDM_FRU_FIELD_TYPE_PN = 0X03,
54 PLDM_FRU_FIELD_TYPE_SN = 0X04,
55 PLDM_FRU_FIELD_TYPE_MANUFAC = 0X05,
56 PLDM_FRU_FIELD_TYPE_MANUFAC_DATE = 0X06,
57 PLDM_FRU_FIELD_TYPE_VENDOR = 0X07,
58 PLDM_FRU_FIELD_TYPE_NAME = 0X08,
59 PLDM_FRU_FIELD_TYPE_SKU = 0X09,
60 PLDM_FRU_FIELD_TYPE_VERSION = 0X0A,
61 PLDM_FRU_FIELD_TYPE_ASSET_TAG = 0X0B,
62 PLDM_FRU_FIELD_TYPE_DESC = 0X0C,
63 PLDM_FRU_FIELD_TYPE_EC_LVL = 0X0D,
64 PLDM_FRU_FIELD_TYPE_OTHER = 0X0E,
65 PLDM_FRU_FIELD_TYPE_IANA = 0X0F,
66};
67
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053068/** @struct pldm_get_fru_record_table_metadata_resp
69 *
70 * Structure representing PLDM get FRU table metadata response.
71 */
72struct pldm_get_fru_record_table_metadata_resp {
73 uint8_t completion_code; //!< completion code
74 uint8_t fru_data_major_version; //!< The major version of the FRU Record
75 uint8_t fru_data_minor_version; //!< The minor version of the FRU Record
76 uint32_t
77 fru_table_maximum_size; //!< The size of the largest FRU Record data
78 uint32_t fru_table_length; //!< The total length of the FRU Record Table
79 uint16_t total_record_set_identifiers; //!< The total number of FRU
80 //!< Record Data structures
81 uint16_t
82 total_table_records; //!< The total number of records in the table
83 uint32_t
84 checksum; //!< The integrity checksum on the FRU Record Table data
85} __attribute__((packed));
86
PriyangaRamasamy497665a2019-07-30 12:48:25 +053087/** @struct pldm_get_fru_record_table_req
88 *
89 * Structure representing PLDM get FRU record table request.
90 */
91struct pldm_get_fru_record_table_req {
92 uint32_t data_transfer_handle;
93 uint8_t transfer_operation_flag;
94} __attribute__((packed));
95
96/** @struct pldm_get_fru_record_table_resp
97 *
98 * Structure representing PLDM get FRU record table response.
99 */
100struct pldm_get_fru_record_table_resp {
101 uint8_t completion_code;
102 uint32_t next_data_transfer_handle;
103 uint8_t transfer_flag;
104 uint8_t fru_record_table_data[1];
105} __attribute__((packed));
106
Tom Joseph93d68712020-01-07 10:24:41 +0530107/** @struct pldm_fru_record_tlv
108 *
109 * Structure representing each FRU field entry (type, length, value)
110 */
111struct pldm_fru_record_tlv {
112 uint8_t type;
113 uint8_t length;
114 uint8_t value[1];
115} __attribute__((packed));
116
117/** @struct pldm_fru_record_data_format
118 *
119 * Structure representing the FRU record data format
120 */
121struct pldm_fru_record_data_format {
122 uint16_t record_set_id;
123 uint8_t record_type;
124 uint8_t num_fru_fields;
125 uint8_t encoding_type;
126 struct pldm_fru_record_tlv tlvs[1];
127} __attribute__((packed));
128
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530129/* Requester */
130
131/* GetFRURecordTableMetadata */
132
133/** @brief Create a PLDM request message for GetFRURecordTableMetadata
134 *
135 * @param[in] instance_id - Message's instance id
136 * @param[in,out] msg - Message will be written to this
Christian Geddes3bdb3c22020-05-01 14:55:39 -0500137 * @param[in] payload_length - Length of the request message payload
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530138 * @return pldm_completion_codes
139 * @note Caller is responsible for memory alloc and dealloc of param
140 * 'msg.payload'
141 */
142int encode_get_fru_record_table_metadata_req(uint8_t instance_id,
Christian Geddes3bdb3c22020-05-01 14:55:39 -0500143 struct pldm_msg *msg,
144 size_t payload_length);
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530145
146/** @brief Decode GetFruRecordTable response data
147 *
George Liu684a7162019-12-06 15:10:52 +0800148 * Note:
149 * * If the return value is not PLDM_SUCCESS, it represents a
150 * transport layer error.
151 * * If the completion_code value is not PLDM_SUCCESS, it represents a
152 * protocol layer error and all the out-parameters are invalid.
153 *
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530154 * @param[in] msg - Response message
155 * @param[in] payload_length - Length of response message payload
156 * @param[out] completion_code - Pointer to response msg's PLDM completion code
157 * @param[out] fru_data_major_version - Major version of the FRU Record
158 * @param[out] fru_data_minor_version - Minor version of the FRU Record
159 * @param[out] fru_table_maximum_size - Size of the largest FRU Record data
160 * @param[out] fru_table_length - Total length of the FRU Record Table
161 * @param[out] total_Record_Set_Identifiers - Total number of FRU Record Data
162 * structures
163 * @param[out] total_table_records - Total number of records in the table
164 * @param[out] checksum - integrity checksum on the FRU Record Table data
165 * @return pldm_completion_codes
166 */
167int decode_get_fru_record_table_metadata_resp(
168 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
169 uint8_t *fru_data_major_version, uint8_t *fru_data_minor_version,
170 uint32_t *fru_table_maximum_size, uint32_t *fru_table_length,
171 uint16_t *total_record_set_identifiers, uint16_t *total_table_records,
172 uint32_t *checksum);
173
174/* Responder */
175
176/* GetFRURecordTableMetadata */
177
178/** @brief Create a PLDM response message for GetFRURecordTableMetadata
179 *
180 * @param[in] instance_id - Message's instance id
181 * @param[in] completion_code - PLDM completion code
182 * @param[in] fru_data_major_version - Major version of the FRU Record
183 * @param[in] fru_data_minor_version - Minor version of the FRU Record
184 * @param[in] fru_table_maximum_size - Size of the largest FRU Record data
185 * @param[in] fru_table_length - Total length of the FRU Record Table
186 * @param[in] total_Record_Set_Identifiers - Total number of FRU Record Data
187 * structures
188 * @param[in] total_table_records - Total number of records in the table
189 * @param[in] checksum - integrity checksum on the FRU Record Table data
190 * @param[in,out] msg - Message will be written to this
191 * @return pldm_completion_codes
192 * @note Caller is responsible for memory alloc and dealloc of param
193 * 'msg.payload'
194 */
195
196int encode_get_fru_record_table_metadata_resp(
197 uint8_t instance_id, uint8_t completion_code,
198 uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
199 uint32_t fru_table_maximum_size, uint32_t fru_table_length,
200 uint16_t total_record_set_identifiers, uint16_t total_table_records,
201 uint32_t checksum, struct pldm_msg *msg);
202
PriyangaRamasamy497665a2019-07-30 12:48:25 +0530203/* GetFruRecordTable */
204
205/** @brief Decode GetFruRecordTable request data
206 *
207 * @param[in] msg - PLDM request message payload
208 * @param[in] payload_length - Length of request payload
209 * @param[out] data_transfer_handle - A handle, used to identify a FRU Record
210 * Table data transfer
211 * @param[out] transfer_operation_flag - A flag that indicates whether this is
212 * the start of the transfer
213 * @return pldm_completion_codes
214 */
215int decode_get_fru_record_table_req(const struct pldm_msg *msg,
216 size_t payload_length,
217 uint32_t *data_transfer_handle,
218 uint8_t *transfer_operation_flag);
219
220/** @brief Create a PLDM response message for GetFruRecordTable
221 *
222 * @param[in] instance_id - Message's instance id
223 * @param[in] completion_code - PLDM completion code
224 * @param[in] next_data_transfer_handle - A handle that is used to identify the
225 * next portion of the transfer
226 * @param[in] transfer_flag - The transfer flag that indicates what part of the
227 * transfer this response represents
228 * @param[in,out] msg - Message will be written to this
229 * @return pldm_completion_codes
230 * @note Caller is responsible for memory alloc and dealloc of param 'msg',
231 * and for appending the FRU table to the msg.
232 */
233int encode_get_fru_record_table_resp(uint8_t instance_id,
234 uint8_t completion_code,
235 uint32_t next_data_transfer_handle,
236 uint8_t transfer_flag,
237 struct pldm_msg *msg);
PriyangaRamasamyf3295be2019-07-23 12:18:40 +0530238/* Requester */
239
240/* GetFruRecordTable */
241
242/** @brief Create a PLDM request message for GetFruRecordTable
243 *
244 * @param[in] instance_id - Message's instance id
245 * @param[in] data_transfer_handle - A handle, used to identify a FRU Record
246 * Table data transfer
247 * @param[in] transfer_operation_flag - A flag that indicates whether this is
248 * the start of the transfer
249 * @param[in,out] msg - Message will be written to this
250 * @param[in] payload_length - Length of request message payload
251 * @return pldm_completion_codes
252 * @note Caller is responsible for memory alloc and dealloc of param
253 * 'msg.payload'
254 */
255
256int encode_get_fru_record_table_req(uint8_t instance_id,
257 uint32_t data_transfer_handle,
258 uint8_t transfer_operation_flag,
259 struct pldm_msg *msg,
260 size_t payload_length);
261
262/** @brief Decode GetFruRecordTable response data
263 *
264 * @param[in] msg - Response message
265 * @param[in] payload_length - Length of response message payload
266 * @param[out] completion_code - Pointer to response msg's PLDM completion code
267 * @param[out] next_data_transfer_handle - A handle used to identify the next
268 * portion of the transfer
269 * @param[out] transfer_flag - The transfer flag that indicates what part of
270 * the transfer this response represents
271 * @param[out] fru_record_table_data - This data is a portion of the overall
272 * FRU Record Table
273 * @param[out] fru_record_table_length - Length of the FRU record table data
274 * @return pldm_completion_codes
275 */
276
277int decode_get_fru_record_table_resp(
278 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
279 uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
280 uint8_t *fru_record_table_data, size_t *fru_record_table_length);
PriyangaRamasamy497665a2019-07-30 12:48:25 +0530281
Tom Joseph93d68712020-01-07 10:24:41 +0530282/** @brief Encode the FRU record in the FRU table
283 *
284 * @param[in/out] fru_table - Pointer to the FRU table
285 * @param[in] total_size - The size of the table,including the size of FRU
286 * record to be added to the table.
287 * @param[in/out] curr_size - The size of the table, excluding the size of FRU
288 * record to be added to the table.
289 * @param[in] record_set_id - FRU record set identifier
290 * @param[in] record_type - FRU record type
291 * @param[in] num_frus - Number of FRU fields
292 * @param[in] encoding - Encoding type for FRU fields
293 * @param[in] tlvs - Pointer to the buffer with all the FRU fields
294 * @param[in] tlvs_size - Size of the buffer with all the FRU fields
295 *
296 * @return pldm_completion_codes
297 */
298int encode_fru_record(uint8_t *fru_table, size_t total_size, size_t *curr_size,
299 uint16_t record_set_id, uint8_t record_type,
300 uint8_t num_frus, uint8_t encoding, uint8_t *tlvs,
301 size_t tlvs_size);
302
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530303#ifdef __cplusplus
304}
305#endif
306
307#endif