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