blob: 24f8c5642bdf8ce536d9c7cb563941e9bda1b0e4 [file] [log] [blame]
gokulsanker138ceba2021-04-05 13:25:25 +05301#ifndef FW_UPDATE_H
2#define FW_UPDATE_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7#include "base.h"
gokulsanker22fbb342021-04-05 15:55:06 +05308#include "utils.h"
gokulsanker138ceba2021-04-05 13:25:25 +05309
Tom Joseph568e4702021-06-07 22:15:49 -070010#define PLDM_FWUP_COMPONENT_BITMAP_MULTIPLE 8
Tom Joseph58cc1722021-06-09 07:15:49 -070011#define PLDM_FWUP_INVALID_COMPONENT_COMPARISON_TIMESTAMP 0xFFFFFFFF
gokulsanker138ceba2021-04-05 13:25:25 +053012#define PLDM_QUERY_DEVICE_IDENTIFIERS_REQ_BYTES 0
gokulsankereca3e192021-04-05 14:57:41 +053013/** @brief Minimum length of device descriptor, 2 bytes for descriptor type,
14 * 2 bytes for descriptor length and atleast 1 byte of descriptor data
15 */
16#define PLDM_FWUP_DEVICE_DESCRIPTOR_MIN_LEN 5
gokulsanker981fbfb2021-04-05 15:17:25 +053017#define PLDM_GET_FIRMWARE_PARAMETERS_REQ_BYTES 0
gokulsankerd434edc2021-04-05 16:36:04 +053018#define PLDM_FWUP_BASELINE_TRANSFER_SIZE 32
19#define PLDM_FWUP_MIN_OUTSTANDING_REQ 1
gokulsanker138ceba2021-04-05 13:25:25 +053020
21/** @brief PLDM Firmware update commands
22 */
gokulsanker981fbfb2021-04-05 15:17:25 +053023enum pldm_firmware_update_commands {
24 PLDM_QUERY_DEVICE_IDENTIFIERS = 0x01,
gokulsankerd434edc2021-04-05 16:36:04 +053025 PLDM_GET_FIRMWARE_PARAMETERS = 0x02,
gokulsanker1b909d82021-04-05 17:26:02 +053026 PLDM_REQUEST_UPDATE = 0x10,
gokulsankeraa3a5cd2021-04-22 11:06:42 +053027 PLDM_PASS_COMPONENT_TABLE = 0x13,
gokulsanker9c440d02021-06-03 09:54:02 +053028 PLDM_UPDATE_COMPONENT = 0x14,
29 PLDM_REQUEST_FIRMWARE_DATA = 0x15
gokulsanker981fbfb2021-04-05 15:17:25 +053030};
gokulsanker138ceba2021-04-05 13:25:25 +053031
gokulsanker611238c2021-04-05 16:50:44 +053032/** @brief PLDM Firmware update completion codes
33 */
34enum pldm_firmware_update_completion_codes {
35 PLDM_FWUP_NOT_IN_UPDATE_MODE = 0x80,
36 PLDM_FWUP_ALREADY_IN_UPDATE_MODE = 0x81,
37 PLDM_FWUP_DATA_OUT_OF_RANGE = 0x82,
38 PLDM_FWUP_INVALID_TRANSFER_LENGTH = 0x83,
39 PLDM_FWUP_INVALID_STATE_FOR_COMMAND = 0x84,
40 PLDM_FWUP_INCOMPLETE_UPDATE = 0x85,
41 PLDM_FWUP_BUSY_IN_BACKGROUND = 0x86,
42 PLDM_FWUP_CANCEL_PENDING = 0x87,
43 PLDM_FWUP_COMMAND_NOT_EXPECTED = 0x87,
44 PLDM_FWUP_RETRY_REQUEST_FW_DATA = 0x89,
45 PLDM_FWUP_UNABLE_TO_INITIATE_UPDATE = 0x8A,
46 PLDM_FWUP_ACTIVATION_NOT_REQUIRED = 0x8B,
47 PLDM_FWUP_SELF_CONTAINED_ACTIVATION_NOT_PERMITTED = 0x8C,
48 PLDM_FWUP_NO_DEVICE_METADATA = 0x8D,
49 PLDM_FWUP_RETRY_REQUEST_UPDATE = 0x8E,
50 PLDM_FWUP_NO_PACKAGE_DATA = 0x8F,
51 PLDM_FWUP_INVALID_TRANSFER_HANDLE = 0x90,
52 PLDM_FWUP_INVALID_TRANSFER_OPERATION_FLAG = 0x91,
53 PLDM_FWUP_ACTIVATE_PENDING_IMAGE_NOT_PERMITTED = 0x92,
54 PLDM_FWUP_PACKAGE_DATA_ERROR = 0x93
55};
56
Tom Joseph763b51e2021-06-05 04:50:47 -070057/** @brief String type values defined in the PLDM firmware update specification
58 */
59enum pldm_firmware_update_string_type {
60 PLDM_STR_TYPE_UNKNOWN = 0,
61 PLDM_STR_TYPE_ASCII = 1,
62 PLDM_STR_TYPE_UTF_8 = 2,
63 PLDM_STR_TYPE_UTF_16 = 3,
64 PLDM_STR_TYPE_UTF_16LE = 4,
65 PLDM_STR_TYPE_UTF_16BE = 5
66};
67
68/** @brief Descriptor types defined in PLDM firmware update specification
69 */
70enum pldm_firmware_update_descriptor_types {
71 PLDM_FWUP_PCI_VENDOR_ID = 0x0000,
72 PLDM_FWUP_IANA_ENTERPRISE_ID = 0x0001,
73 PLDM_FWUP_UUID = 0x0002,
74 PLDM_FWUP_PNP_VENDOR_ID = 0x0003,
75 PLDM_FWUP_ACPI_VENDOR_ID = 0x0004,
76 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID = 0x0005,
77 PLDM_FWUP_SCSI_VENDOR_ID = 0x0006,
78 PLDM_FWUP_PCI_DEVICE_ID = 0x0100,
79 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID = 0x0101,
80 PLDM_FWUP_PCI_SUBSYSTEM_ID = 0x0102,
81 PLDM_FWUP_PCI_REVISION_ID = 0x0103,
82 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER = 0x0104,
83 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER = 0x0105,
84 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING = 0x0106,
85 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING = 0x0107,
86 PLDM_FWUP_SCSI_PRODUCT_ID = 0x0108,
87 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE = 0x0109,
88 PLDM_FWUP_VENDOR_DEFINED = 0xFFFF
89};
90
91/** @brief Descriptor types length defined in PLDM firmware update specification
92 */
93enum pldm_firmware_update_descriptor_types_length {
94 PLDM_FWUP_PCI_VENDOR_ID_LENGTH = 2,
95 PLDM_FWUP_IANA_ENTERPRISE_ID_LENGTH = 4,
96 PLDM_FWUP_UUID_LENGTH = 16,
97 PLDM_FWUP_PNP_VENDOR_ID_LENGTH = 3,
98 PLDM_FWUP_ACPI_VENDOR_ID_LENGTH = 4,
99 PLDM_FWUP_IEEE_ASSIGNED_COMPANY_ID_LENGTH = 3,
100 PLDM_FWUP_SCSI_VENDOR_ID_LENGTH = 8,
101 PLDM_FWUP_PCI_DEVICE_ID_LENGTH = 2,
102 PLDM_FWUP_PCI_SUBSYSTEM_VENDOR_ID_LENGTH = 2,
103 PLDM_FWUP_PCI_SUBSYSTEM_ID_LENGTH = 2,
104 PLDM_FWUP_PCI_REVISION_ID_LENGTH = 1,
105 PLDM_FWUP_PNP_PRODUCT_IDENTIFIER_LENGTH = 4,
106 PLDM_FWUP_ACPI_PRODUCT_IDENTIFIER_LENGTH = 4,
107 PLDM_FWUP_ASCII_MODEL_NUMBER_LONG_STRING_LENGTH = 40,
108 PLDM_FWUP_ASCII_MODEL_NUMBER_SHORT_STRING_LENGTH = 10,
109 PLDM_FWUP_SCSI_PRODUCT_ID_LENGTH = 16,
110 PLDM_FWUP_UBM_CONTROLLER_DEVICE_CODE_LENGTH = 4
111};
112
gokulsanker1b909d82021-04-05 17:26:02 +0530113/** @brief ComponentClassification values defined in firmware update
114 * specification
115 */
116enum pldm_component_classification_values {
117 PLDM_COMP_UNKNOWN = 0x0000,
118 PLDM_COMP_OTHER = 0x0001,
119 PLDM_COMP_DRIVER = 0x0002,
120 PLDM_COMP_CONFIGURATION_SOFTWARE = 0x0003,
121 PLDM_COMP_APPLICATION_SOFTWARE = 0x0004,
122 PLDM_COMP_INSTRUMENTATION = 0x0005,
123 PLDM_COMP_FIRMWARE_OR_BIOS = 0x0006,
124 PLDM_COMP_DIAGNOSTIC_SOFTWARE = 0x0007,
125 PLDM_COMP_OPERATING_SYSTEM = 0x0008,
126 PLDM_COMP_MIDDLEWARE = 0x0009,
127 PLDM_COMP_FIRMWARE = 0x000A,
128 PLDM_COMP_BIOS_OR_FCODE = 0x000B,
129 PLDM_COMP_SUPPORT_OR_SERVICEPACK = 0x000C,
130 PLDM_COMP_SOFTWARE_BUNDLE = 0x000D,
131 PLDM_COMP_DOWNSTREAM_DEVICE = 0xFFFF
132};
133
gokulsanker566784b2021-04-05 17:47:04 +0530134/** @brief ComponentResponse values in the response of PassComponentTable
135 */
136enum pldm_component_responses {
137 PLDM_CR_COMP_CAN_BE_UPDATED = 0,
138 PLDM_CR_COMP_MAY_BE_UPDATEABLE = 1
139};
140
141/** @brief ComponentResponseCode values in the response of PassComponentTable
142 */
143enum pldm_component_response_codes {
144 PLDM_CRC_COMP_CAN_BE_UPDATED = 0x00,
145 PLDM_CRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
146 PLDM_CRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
147 PLDM_CRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
148 PLDM_CRC_COMP_CONFLICT = 0x04,
149 PLDM_CRC_COMP_PREREQUISITES_NOT_MET = 0x05,
150 PLDM_CRC_COMP_NOT_SUPPORTED = 0x06,
151 PLDM_CRC_COMP_SECURITY_RESTRICTIONS = 0x07,
152 PLDM_CRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
153 PLDM_CRC_ACTIVE_IMAGE_NOT_UPDATEABLE_SUBSEQUENTLY = 0x09,
154 PLDM_CRC_COMP_VER_STR_IDENTICAL = 0x0A,
155 PLDM_CRC_COMP_VER_STR_LOWER = 0x0B,
156 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
157 PLDM_CRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
158};
159
gokulsanker4b533f22021-04-22 12:53:00 +0530160/** @brief ComponentCompatibilityResponse values in the response of
161 * UpdateComponent
162 */
163enum pldm_component_compatability_responses {
164 PLDM_CCR_COMP_CAN_BE_UPDATED = 0,
165 PLDM_CCR_COMP_CANNOT_BE_UPDATED = 1
166};
167
168/** @brief ComponentCompatibilityResponse Code values in the response of
169 * UpdateComponent
170 */
171enum pldm_component_compatability_response_codes {
172 PLDM_CCRC_NO_RESPONSE_CODE = 0x00,
173 PLDM_CCRC_COMP_COMPARISON_STAMP_IDENTICAL = 0x01,
174 PLDM_CCRC_COMP_COMPARISON_STAMP_LOWER = 0x02,
175 PLDM_CCRC_INVALID_COMP_COMPARISON_STAMP = 0x03,
176 PLDM_CCRC_COMP_CONFLICT = 0x04,
177 PLDM_CCRC_COMP_PREREQUISITES_NOT_MET = 0x05,
178 PLDM_CCRC_COMP_NOT_SUPPORTED = 0x06,
179 PLDM_CCRC_COMP_SECURITY_RESTRICTIONS = 0x07,
180 PLDM_CCRC_INCOMPLETE_COMP_IMAGE_SET = 0x08,
181 PLDM_CCRC_COMP_INFO_NO_MATCH = 0x09,
182 PLDM_CCRC_COMP_VER_STR_IDENTICAL = 0x0A,
183 PLDM_CCRC_COMP_VER_STR_LOWER = 0x0B,
184 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MIN = 0xD0,
185 PLDM_CCRC_VENDOR_COMP_RESP_CODE_RANGE_MAX = 0xEF
186};
187
Tom Joseph568e4702021-06-07 22:15:49 -0700188/** @struct pldm_package_header_information
189 *
190 * Structure representing fixed part of package header information
191 */
192struct pldm_package_header_information {
193 uint8_t uuid[PLDM_FWUP_UUID_LENGTH];
194 uint8_t package_header_format_version;
195 uint16_t package_header_size;
196 uint8_t timestamp104[PLDM_TIMESTAMP104_SIZE];
197 uint16_t component_bitmap_bit_length;
198 uint8_t package_version_string_type;
199 uint8_t package_version_string_length;
200} __attribute__((packed));
201
Tom Joseph64af3452021-06-08 04:05:28 -0700202/** @struct pldm_firmware_device_id_record
203 *
204 * Structure representing firmware device ID record
205 */
206struct pldm_firmware_device_id_record {
207 uint16_t record_length;
208 uint8_t descriptor_count;
209 bitfield32_t device_update_option_flags;
210 uint8_t comp_image_set_version_string_type;
211 uint8_t comp_image_set_version_string_length;
212 uint16_t fw_device_pkg_data_length;
213} __attribute__((packed));
214
Tom Joseph763b51e2021-06-05 04:50:47 -0700215/** @struct pldm_descriptor_tlv
216 *
217 * Structure representing descriptor type, length and value
218 */
219struct pldm_descriptor_tlv {
220 uint16_t descriptor_type;
221 uint16_t descriptor_length;
222 uint8_t descriptor_data[1];
223} __attribute__((packed));
224
225/** @struct pldm_vendor_defined_descriptor_title_data
226 *
227 * Structure representing vendor defined descriptor title sections
228 */
229struct pldm_vendor_defined_descriptor_title_data {
230 uint8_t vendor_defined_descriptor_title_str_type;
231 uint8_t vendor_defined_descriptor_title_str_len;
232 uint8_t vendor_defined_descriptor_title_str[1];
233} __attribute__((packed));
234
Tom Joseph58cc1722021-06-09 07:15:49 -0700235/** @struct pldm_component_image_information
236 *
237 * Structure representing fixed part of individual component information in
238 * PLDM firmware update package
239 */
240struct pldm_component_image_information {
241 uint16_t comp_classification;
242 uint16_t comp_identifier;
243 uint32_t comp_comparison_stamp;
244 bitfield16_t comp_options;
245 bitfield16_t requested_comp_activation_method;
246 uint32_t comp_location_offset;
247 uint32_t comp_size;
248 uint8_t comp_version_string_type;
249 uint8_t comp_version_string_length;
250} __attribute__((packed));
251
gokulsankereca3e192021-04-05 14:57:41 +0530252/** @struct pldm_query_device_identifiers_resp
253 *
254 * Structure representing query device identifiers response.
255 */
256struct pldm_query_device_identifiers_resp {
257 uint8_t completion_code;
258 uint32_t device_identifiers_len;
259 uint8_t descriptor_count;
260} __attribute__((packed));
261
gokulsanker22fbb342021-04-05 15:55:06 +0530262/** @struct pldm_get_firmware_parameters_resp
263 *
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700264 * Structure representing the fixed part of GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530265 */
266struct pldm_get_firmware_parameters_resp {
267 uint8_t completion_code;
268 bitfield32_t capabilities_during_update;
269 uint16_t comp_count;
270 uint8_t active_comp_image_set_ver_str_type;
271 uint8_t active_comp_image_set_ver_str_len;
272 uint8_t pending_comp_image_set_ver_str_type;
273 uint8_t pending_comp_image_set_ver_str_len;
274} __attribute__((packed));
275
gokulsankere1fb7a82021-04-05 16:09:29 +0530276/** @struct pldm_component_parameter_entry
277 *
278 * Structure representing component parameter table entry.
279 */
280struct pldm_component_parameter_entry {
281 uint16_t comp_classification;
282 uint16_t comp_identifier;
283 uint8_t comp_classification_index;
284 uint32_t active_comp_comparison_stamp;
285 uint8_t active_comp_ver_str_type;
286 uint8_t active_comp_ver_str_len;
287 uint8_t active_comp_release_date[8];
288 uint32_t pending_comp_comparison_stamp;
289 uint8_t pending_comp_ver_str_type;
290 uint8_t pending_comp_ver_str_len;
291 uint8_t pending_comp_release_date[8];
292 bitfield16_t comp_activation_methods;
293 bitfield32_t capabilities_during_update;
294} __attribute__((packed));
295
gokulsankerd434edc2021-04-05 16:36:04 +0530296/** @struct pldm_request_update_req
297 *
298 * Structure representing fixed part of Request Update request
299 */
300struct pldm_request_update_req {
301 uint32_t max_transfer_size;
302 uint16_t num_of_comp;
303 uint8_t max_outstanding_transfer_req;
304 uint16_t pkg_data_len;
305 uint8_t comp_image_set_ver_str_type;
306 uint8_t comp_image_set_ver_str_len;
307} __attribute__((packed));
308
gokulsanker611238c2021-04-05 16:50:44 +0530309/** @struct pldm_request_update_resp
310 *
311 * Structure representing Request Update response
312 */
313struct pldm_request_update_resp {
314 uint8_t completion_code;
315 uint16_t fd_meta_data_len;
316 uint8_t fd_will_send_pkg_data;
317} __attribute__((packed));
318
gokulsanker1b909d82021-04-05 17:26:02 +0530319/** @struct pldm_pass_component_table_req
320 *
321 * Structure representing PassComponentTable request
322 */
323struct pldm_pass_component_table_req {
324 uint8_t transfer_flag;
325 uint16_t comp_classification;
326 uint16_t comp_identifier;
327 uint8_t comp_classification_index;
328 uint32_t comp_comparison_stamp;
329 uint8_t comp_ver_str_type;
330 uint8_t comp_ver_str_len;
331} __attribute__((packed));
332
gokulsanker566784b2021-04-05 17:47:04 +0530333/** @struct pldm_pass_component_table_resp
334 *
335 * Structure representing PassComponentTable response
336 */
337struct pldm_pass_component_table_resp {
338 uint8_t completion_code;
339 uint8_t comp_resp;
340 uint8_t comp_resp_code;
341} __attribute__((packed));
342
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530343/** @struct pldm_update_component_req
344 *
345 * Structure representing UpdateComponent request
346 */
347struct pldm_update_component_req {
348 uint16_t comp_classification;
349 uint16_t comp_identifier;
350 uint8_t comp_classification_index;
351 uint32_t comp_comparison_stamp;
352 uint32_t comp_image_size;
353 bitfield32_t update_option_flags;
354 uint8_t comp_ver_str_type;
355 uint8_t comp_ver_str_len;
356} __attribute__((packed));
357
gokulsanker4b533f22021-04-22 12:53:00 +0530358/** @struct pldm_update_component_resp
359 *
360 * Structure representing UpdateComponent response
361 */
362struct pldm_update_component_resp {
363 uint8_t completion_code;
364 uint8_t comp_compatability_resp;
365 uint8_t comp_compatability_resp_code;
366 bitfield32_t update_option_flags_enabled;
367 uint16_t time_before_req_fw_data;
368} __attribute__((packed));
369
gokulsankera4e6b292021-06-02 16:35:39 +0530370/** @struct pldm_request_firmware_data_req
371 *
372 * Structure representing RequestFirmwareData request.
373 */
374struct pldm_request_firmware_data_req {
375 uint32_t offset;
376 uint32_t length;
377} __attribute__((packed));
378
Tom Joseph568e4702021-06-07 22:15:49 -0700379/** @brief Decode the PLDM package header information
380 *
381 * @param[in] data - pointer to package header information
382 * @param[in] length - available length in the firmware update package
383 * @param[out] package_header_info - pointer to fixed part of PLDM package
384 * header information
385 * @param[out] package_version_str - pointer to package version string
386 *
387 * @return pldm_completion_codes
388 */
389int decode_pldm_package_header_info(
390 const uint8_t *data, size_t length,
391 struct pldm_package_header_information *package_header_info,
392 struct variable_field *package_version_str);
393
Tom Joseph64af3452021-06-08 04:05:28 -0700394/** @brief Decode individual firmware device ID record
395 *
396 * @param[in] data - pointer to firmware device ID record
397 * @param[in] length - available length in the firmware update package
398 * @param[in] component_bitmap_bit_length - ComponentBitmapBitLengthfield
399 * parsed from the package header info
400 * @param[out] fw_device_id_record - pointer to fixed part of firmware device
401 * id record
402 * @param[out] applicable_components - pointer to ApplicableComponents
403 * @param[out] comp_image_set_version_str - pointer to
404 * ComponentImageSetVersionString
405 * @param[out] record_descriptors - pointer to RecordDescriptors
406 * @param[out] fw_device_pkg_data - pointer to FirmwareDevicePackageData
407 *
408 * @return pldm_completion_codes
409 */
410int decode_firmware_device_id_record(
411 const uint8_t *data, size_t length, uint16_t component_bitmap_bit_length,
412 struct pldm_firmware_device_id_record *fw_device_id_record,
413 struct variable_field *applicable_components,
414 struct variable_field *comp_image_set_version_str,
415 struct variable_field *record_descriptors,
416 struct variable_field *fw_device_pkg_data);
417
Tom Joseph763b51e2021-06-05 04:50:47 -0700418/** @brief Decode the record descriptor entries in the firmware update package
419 * and the Descriptors in the QueryDeviceIDentifiers command
420 *
421 * @param[in] data - pointer to descriptor entry
422 * @param[in] length - remaining length of the descriptor data
423 * @param[out] descriptor_type - pointer to descriptor type
424 * @param[out] descriptor_data - pointer to descriptor data
425 *
426 * @return pldm_completion_codes
427 */
428int decode_descriptor_type_length_value(const uint8_t *data, size_t length,
429 uint16_t *descriptor_type,
430 struct variable_field *descriptor_data);
431
432/** @brief Decode the vendor defined descriptor value
433 *
434 * @param[in] data - pointer to vendor defined descriptor value
435 * @param[in] length - length of the vendor defined descriptor value
436 * @param[out] descriptor_title_str_type - pointer to vendor defined descriptor
437 * title string type
438 * @param[out] descriptor_title_str - pointer to vendor defined descriptor
439 * title string
440 * @param[out] descriptor_data - pointer to vendor defined descriptor data
441 *
442 * @return pldm_completion_codes
443 */
444int decode_vendor_defined_descriptor_value(
445 const uint8_t *data, size_t length, uint8_t *descriptor_title_str_type,
446 struct variable_field *descriptor_title_str,
447 struct variable_field *descriptor_data);
448
Tom Joseph58cc1722021-06-09 07:15:49 -0700449/** @brief Decode individual component image information
450 *
451 * @param[in] data - pointer to component image information
452 * @param[in] length - available length in the firmware update package
453 * @param[out] pldm_comp_image_info - pointer to fixed part of component image
454 * information
455 * @param[out] comp_version_str - pointer to component version string
456 *
457 * @return pldm_completion_codes
458 */
459int decode_pldm_comp_image_info(
460 const uint8_t *data, size_t length,
461 struct pldm_component_image_information *pldm_comp_image_info,
462 struct variable_field *comp_version_str);
463
gokulsanker138ceba2021-04-05 13:25:25 +0530464/** @brief Create a PLDM request message for QueryDeviceIdentifiers
465 *
466 * @param[in] instance_id - Message's instance id
467 * @param[in] payload_length - Length of the request message payload
468 * @param[in,out] msg - Message will be written to this
469 *
470 * @return pldm_completion_codes
471 *
472 * @note Caller is responsible for memory alloc and dealloc of param
473 * 'msg.payload'
474 */
475int encode_query_device_identifiers_req(uint8_t instance_id,
476 size_t payload_length,
477 struct pldm_msg *msg);
gokulsankereca3e192021-04-05 14:57:41 +0530478
479/** @brief Decode QueryDeviceIdentifiers response message
480 *
481 * @param[in] msg - Response message
482 * @param[in] payload_length - Length of response message payload
483 * @param[out] completion_code - Pointer to response msg's PLDM completion code
484 * @param[out] device_identifiers_len - Pointer to device identifiers length
485 * @param[out] descriptor_count - Pointer to descriptor count
486 * @param[out] descriptor_data - Pointer to descriptor data
487 *
488 * @return pldm_completion_codes
489 */
490int decode_query_device_identifiers_resp(const struct pldm_msg *msg,
491 size_t payload_length,
492 uint8_t *completion_code,
493 uint32_t *device_identifiers_len,
494 uint8_t *descriptor_count,
495 uint8_t **descriptor_data);
gokulsanker981fbfb2021-04-05 15:17:25 +0530496
497/** @brief Create a PLDM request message for GetFirmwareParameters
498 *
499 * @param[in] instance_id - Message's instance id
500 * @param[in] payload_length - Length of the request message payload
501 * @param[in,out] msg - Message will be written to this
502 *
503 * @return pldm_completion_codes
504 *
505 * @note Caller is responsible for memory alloc and dealloc of param
506 * 'msg.payload'
507 */
508int encode_get_firmware_parameters_req(uint8_t instance_id,
509 size_t payload_length,
510 struct pldm_msg *msg);
gokulsanker22fbb342021-04-05 15:55:06 +0530511
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700512/** @brief Decode GetFirmwareParameters response
gokulsanker22fbb342021-04-05 15:55:06 +0530513 *
514 * @param[in] msg - Response message
515 * @param[in] payload_length - Length of response message payload
516 * @param[out] resp_data - Pointer to get firmware parameters response
517 * @param[out] active_comp_image_set_ver_str - Pointer to active component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700518 * image set version string
gokulsanker22fbb342021-04-05 15:55:06 +0530519 * @param[out] pending_comp_image_set_ver_str - Pointer to pending component
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700520 * image set version string
521 * @param[out] comp_parameter_table - Pointer to component parameter table
gokulsanker22fbb342021-04-05 15:55:06 +0530522 *
523 * @return pldm_completion_codes
524 */
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700525int decode_get_firmware_parameters_resp(
gokulsanker22fbb342021-04-05 15:55:06 +0530526 const struct pldm_msg *msg, size_t payload_length,
527 struct pldm_get_firmware_parameters_resp *resp_data,
528 struct variable_field *active_comp_image_set_ver_str,
Tom Joseph3fd3eb82021-06-18 04:13:29 -0700529 struct variable_field *pending_comp_image_set_ver_str,
530 struct variable_field *comp_parameter_table);
gokulsanker22fbb342021-04-05 15:55:06 +0530531
gokulsankere1fb7a82021-04-05 16:09:29 +0530532/** @brief Decode component entries in the component parameter table which is
533 * part of the response of GetFirmwareParameters command
534 *
535 * @param[in] data - Component entry
536 * @param[in] length - Length of component entry
537 * @param[out] component_data - Pointer to component parameter table
538 * @param[out] active_comp_ver_str - Pointer to active component version string
539 * @param[out] pending_comp_ver_str - Pointer to pending component version
540 * string
541 *
542 * @return pldm_completion_codes
543 */
544int decode_get_firmware_parameters_resp_comp_entry(
545 const uint8_t *data, size_t length,
546 struct pldm_component_parameter_entry *component_data,
547 struct variable_field *active_comp_ver_str,
548 struct variable_field *pending_comp_ver_str);
549
gokulsankerd434edc2021-04-05 16:36:04 +0530550/** @brief Create PLDM request message for RequestUpdate
551 *
552 * @param[in] instance_id - Message's instance id
553 * @param[in] max_transfer_size - Maximum size of the variable payload allowed
554 * to be requested via RequestFirmwareData
555 * command
556 * @param[in] num_of_comp - Total number of components that will be passed to
557 * the FD during the update
558 * @param[in] max_outstanding_transfer_req - Total number of outstanding
559 * RequestFirmwareData
560 * commands that can be sent by the FD
561 * @param[in] pkg_data_len - Value of the FirmwareDevicePackageDataLength field
562 * present in firmware package header
563 * @param[in] comp_image_set_ver_str_type - StringType of
564 * ComponentImageSetVersionString
565 * @param[in] comp_image_set_ver_str_len - The length of the
566 * ComponentImageSetVersionString
567 * @param[in] comp_img_set_ver_str - Component Image Set version information
568 * @param[in,out] msg - Message will be written to this
569 * @param[in] payload_length - Length of request message payload
570 *
571 * @return pldm_completion_codes
572 *
573 * @note Caller is responsible for memory alloc and dealloc of param
574 * 'msg.payload'
575 */
576int encode_request_update_req(uint8_t instance_id, uint32_t max_transfer_size,
577 uint16_t num_of_comp,
578 uint8_t max_outstanding_transfer_req,
579 uint16_t pkg_data_len,
580 uint8_t comp_image_set_ver_str_type,
581 uint8_t comp_image_set_ver_str_len,
582 const struct variable_field *comp_img_set_ver_str,
583 struct pldm_msg *msg, size_t payload_length);
gokulsanker611238c2021-04-05 16:50:44 +0530584
585/** @brief Decode a RequestUpdate response message
586 *
587 * @param[in] msg - Response message
588 * @param[in] payload_length - Length of response message payload
589 * @param[out] completion_code - Pointer to hold the completion code
590 * @param[out] fd_meta_data_len - Pointer to hold the length of FD metadata
591 * @param[out] fd_will_send_pkg_data - Pointer to hold information whether FD
592 * will send GetPackageData command
593 * @return pldm_completion_codes
594 */
595int decode_request_update_resp(const struct pldm_msg *msg,
596 size_t payload_length, uint8_t *completion_code,
597 uint16_t *fd_meta_data_len,
598 uint8_t *fd_will_send_pkg_data);
599
gokulsanker1b909d82021-04-05 17:26:02 +0530600/** @brief Create PLDM request message for PassComponentTable
601 *
602 * @param[in] instance_id - Message's instance id
603 * @param[in] transfer_flag - TransferFlag
604 * @param[in] comp_classification - ComponentClassification
605 * @param[in] comp_identifier - ComponentIdentifier
606 * @param[in] comp_classification_index - ComponentClassificationIndex
607 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
608 * @param[in] comp_ver_str_type - ComponentVersionStringType
609 * @param[in] comp_ver_str_len - ComponentVersionStringLength
610 * @param[in] comp_ver_str - ComponentVersionString
611 * @param[in,out] msg - Message will be written to this
612 * @param[in] payload_length - Length of request message payload
613 * information
614 *
615 * @return pldm_completion_codes
616 *
617 * @note Caller is responsible for memory alloc and dealloc of param
618 * 'msg.payload'
619 */
620int encode_pass_component_table_req(
621 uint8_t instance_id, uint8_t transfer_flag, uint16_t comp_classification,
622 uint16_t comp_identifier, uint8_t comp_classification_index,
623 uint32_t comp_comparison_stamp, uint8_t comp_ver_str_type,
624 uint8_t comp_ver_str_len, const struct variable_field *comp_ver_str,
625 struct pldm_msg *msg, size_t payload_length);
626
gokulsanker566784b2021-04-05 17:47:04 +0530627/** @brief Decode PassComponentTable response message
628 *
629 * @param[in] msg - Response message
630 * @param[in] payload_length - Length of response message payload
631 * @param[out] completion_code - Pointer to hold completion code
632 * @param[out] comp_resp - Pointer to hold component response
633 * @param[out] comp_resp_code - Pointer to hold component response code
634 *
635 * @return pldm_completion_codes
636 */
637int decode_pass_component_table_resp(const struct pldm_msg *msg,
638 size_t payload_length,
639 uint8_t *completion_code,
640 uint8_t *comp_resp,
641 uint8_t *comp_resp_code);
642
gokulsankeraa3a5cd2021-04-22 11:06:42 +0530643/** @brief Create PLDM request message for UpdateComponent
644 *
645 * @param[in] instance_id - Message's instance id
646 * @param[in] comp_classification - ComponentClassification
647 * @param[in] comp_identifier - ComponentIdentifier
648 * @param[in] comp_classification_index - ComponentClassificationIndex
649 * @param[in] comp_comparison_stamp - ComponentComparisonStamp
650 * @param[in] comp_image_size - ComponentImageSize
651 * @param[in] update_option_flags - UpdateOptionFlags
652 * @param[in] comp_ver_str_type - ComponentVersionStringType
653 * @param[in] comp_ver_str_len - ComponentVersionStringLength
654 * @param[in] comp_ver_str - ComponentVersionString
655 * @param[in,out] msg - Message will be written to this
656 * @param[in] payload_length - Length of request message payload
657 * information
658 *
659 * @return pldm_completion_codes
660 *
661 * @note Caller is responsible for memory alloc and dealloc of param
662 * 'msg.payload'
663 */
664int encode_update_component_req(
665 uint8_t instance_id, uint16_t comp_classification, uint16_t comp_identifier,
666 uint8_t comp_classification_index, uint32_t comp_comparison_stamp,
667 uint32_t comp_image_size, bitfield32_t update_option_flags,
668 uint8_t comp_ver_str_type, uint8_t comp_ver_str_len,
669 const struct variable_field *comp_ver_str, struct pldm_msg *msg,
670 size_t payload_length);
671
gokulsanker4b533f22021-04-22 12:53:00 +0530672/** @brief Decode UpdateComponent response message
673 *
674 * @param[in] msg - Response message
675 * @param[in] payload_length - Length of response message payload
676 * @param[out] completion_code - Pointer to hold completion code
677 * @param[out] comp_compatability_resp - Pointer to hold component
678 * compatibility response
679 * @param[out] comp_compatability_resp_code - Pointer to hold component
680 * compatibility response code
681 * @param[out] update_option_flags_enabled - Pointer to hold
682 * UpdateOptionsFlagEnabled
683 * @param[out] time_before_req_fw_data - Pointer to hold the estimated time
684 * before sending RequestFirmwareData
685 *
686 * @return pldm_completion_codes
687 */
688int decode_update_component_resp(const struct pldm_msg *msg,
689 size_t payload_length,
690 uint8_t *completion_code,
691 uint8_t *comp_compatability_resp,
692 uint8_t *comp_compatability_resp_code,
693 bitfield32_t *update_option_flags_enabled,
694 uint16_t *time_before_req_fw_data);
gokulsankera4e6b292021-06-02 16:35:39 +0530695
696/** @brief Decode RequestFirmwareData request message
697 *
698 * @param[in] msg - Request message
699 * @param[in] payload_length - Length of request message payload
700 * @param[out] offset - Pointer to hold offset
701 * @param[out] length - Pointer to hold the size of the component image
702 * segment requested by the FD/FDP
703 *
704 * @return pldm_completion_codes
705 */
706int decode_request_firmware_data_req(const struct pldm_msg *msg,
707 size_t payload_length, uint32_t *offset,
708 uint32_t *length);
gokulsanker9c440d02021-06-03 09:54:02 +0530709
710/** @brief Create PLDM response message for RequestFirmwareData
711 *
712 * The ComponentImagePortion is not encoded in the PLDM response message
713 * by encode_request_firmware_data_resp to avoid an additional copy. Populating
714 * ComponentImagePortion in the PLDM response message is handled by the user
715 * of this API. The payload_length validation considers only the
716 * CompletionCode.
717 *
718 * @param[in] instance_id - Message's instance id
719 * @param[in] completion_code - CompletionCode
720 * @param[in,out] msg - Message will be written to this
721 * @param[in] payload_length - Length of response message payload
722 *
723 * @return pldm_completion_codes
724 *
725 * @note Caller is responsible for memory alloc and dealloc of param
726 * 'msg.payload'
727 */
728int encode_request_firmware_data_resp(uint8_t instance_id,
729 uint8_t completion_code,
730 struct pldm_msg *msg,
731 size_t payload_length);
732
gokulsanker138ceba2021-04-05 13:25:25 +0530733#ifdef __cplusplus
734}
735#endif
736
737#endif // End of FW_UPDATE_H