1 #pragma once 2 3 #include <libpldm/pldm.h> 4 #include <libpldm/base.h> 5 #include <libpldm/utils.h> 6 7 enum pldm_control_completion_codes { 8 PLDM_CONTROL_INVALID_DATA_TRANSFER_HANDLE = 0x80, 9 PLDM_CONTROL_INVALID_TRANSFER_OPERATION_FLAG = 0x81, 10 PLDM_CONTROL_INVALID_PLDM_TYPE_IN_REQUEST_DATA = 0x83, 11 PLDM_CONTROL_INVALID_PLDM_VERSION_IN_REQUEST_DATA = 0x84, 12 }; 13 14 // Static storage can be allocated with PLDM_SIZEOF_CONTROL macro */ 15 struct pldm_control; 16 17 /** @brief Handle a PLDM Control message 18 * 19 * @param[in] control 20 * @param[in] req_msg - PLDM incoming request message payload 21 * @param[in] req_len - length of req_msg buffer 22 * @param[out] resp_msg - PLDM outgoing response message payload buffer 23 * @param[inout] resp_len - length of available resp_msg buffer, will be updated 24 * with the length written to resp_msg. 25 * 26 * @return 0 on success, a negative errno value on failure. 27 * 28 * Will provide a response to send when resp_len > 0 and returning 0. 29 */ 30 int pldm_control_handle_msg(struct pldm_control *control, const void *req_msg, 31 size_t req_len, void *resp_msg, size_t *resp_len); 32 33 /** @brief Initialise a struct pldm_control 34 * 35 * @param[in] control 36 * @param[in] pldm_control_size - pass PLDM_SIZEOF_CONTROL 37 * 38 * @return 0 on success, a negative errno value on failure. 39 */ 40 int pldm_control_setup(struct pldm_control *control, size_t pldm_control_size); 41 42 /** @brief Add a PLDM type to report. 43 * 44 * @param[in] control 45 * @param[in] type - PLDM type, enum pldm_supported_types 46 * @param[in] versions - list of versions for GetPLDMVersion response. 47 * This is an array of 32-bit version values, followed by 48 * a CRC32 over the version values. The size of this buffer 49 * is 4*versions_count. The versions buffer must remain 50 * present for the duration of the pldm_control's lifetime. 51 * @param[in] versions_count - number of entries in versions, including the trailing CRC32. 52 * @param[in] commands - pointer to an array of bitfield8_t[8], for GetPLDMCommands 53 * response for this type. The buffer must remain 54 * present for the duration of the pldm_control's lifetime. 55 * 56 * @return 0 on success, a negative errno value on failure. 57 */ 58 int pldm_control_add_type(struct pldm_control *control, uint8_t pldm_type, 59 const void *versions, size_t versions_count, 60 const bitfield8_t *commands); 61