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