blob: 2b5dd9fa492fb3f4c2703f111d7e829b98ebbbe1 [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,
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053023};
24
Tom Joseph93d68712020-01-07 10:24:41 +053025/** @brief FRU record types
26 */
27enum 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 */
34enum 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 */
45enum 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 Thomas8e92c6c2019-08-06 12:22:34 +053063/** @struct pldm_get_fru_record_table_metadata_resp
64 *
65 * Structure representing PLDM get FRU table metadata response.
66 */
67struct 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
PriyangaRamasamy497665a2019-07-30 12:48:25 +053082/** @struct pldm_get_fru_record_table_req
83 *
84 * Structure representing PLDM get FRU record table request.
85 */
86struct 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 */
95struct 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 Joseph93d68712020-01-07 10:24:41 +0530102/** @struct pldm_fru_record_tlv
103 *
104 * Structure representing each FRU field entry (type, length, value)
105 */
106struct 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 */
116struct 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 Thomas8e92c6c2019-08-06 12:22:34 +0530124/* 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 */
136int encode_get_fru_record_table_metadata_req(uint8_t instance_id,
137 struct pldm_msg *msg);
138
139/** @brief Decode GetFruRecordTable response data
140 *
141 * @param[in] msg - Response message
142 * @param[in] payload_length - Length of response message payload
143 * @param[out] completion_code - Pointer to response msg's PLDM completion code
144 * @param[out] fru_data_major_version - Major version of the FRU Record
145 * @param[out] fru_data_minor_version - Minor version of the FRU Record
146 * @param[out] fru_table_maximum_size - Size of the largest FRU Record data
147 * @param[out] fru_table_length - Total length of the FRU Record Table
148 * @param[out] total_Record_Set_Identifiers - Total number of FRU Record Data
149 * structures
150 * @param[out] total_table_records - Total number of records in the table
151 * @param[out] checksum - integrity checksum on the FRU Record Table data
152 * @return pldm_completion_codes
153 */
154int decode_get_fru_record_table_metadata_resp(
155 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
156 uint8_t *fru_data_major_version, uint8_t *fru_data_minor_version,
157 uint32_t *fru_table_maximum_size, uint32_t *fru_table_length,
158 uint16_t *total_record_set_identifiers, uint16_t *total_table_records,
159 uint32_t *checksum);
160
161/* Responder */
162
163/* GetFRURecordTableMetadata */
164
165/** @brief Create a PLDM response message for GetFRURecordTableMetadata
166 *
167 * @param[in] instance_id - Message's instance id
168 * @param[in] completion_code - PLDM completion code
169 * @param[in] fru_data_major_version - Major version of the FRU Record
170 * @param[in] fru_data_minor_version - Minor version of the FRU Record
171 * @param[in] fru_table_maximum_size - Size of the largest FRU Record data
172 * @param[in] fru_table_length - Total length of the FRU Record Table
173 * @param[in] total_Record_Set_Identifiers - Total number of FRU Record Data
174 * structures
175 * @param[in] total_table_records - Total number of records in the table
176 * @param[in] checksum - integrity checksum on the FRU Record Table data
177 * @param[in,out] msg - Message will be written to this
178 * @return pldm_completion_codes
179 * @note Caller is responsible for memory alloc and dealloc of param
180 * 'msg.payload'
181 */
182
183int encode_get_fru_record_table_metadata_resp(
184 uint8_t instance_id, uint8_t completion_code,
185 uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
186 uint32_t fru_table_maximum_size, uint32_t fru_table_length,
187 uint16_t total_record_set_identifiers, uint16_t total_table_records,
188 uint32_t checksum, struct pldm_msg *msg);
189
PriyangaRamasamy497665a2019-07-30 12:48:25 +0530190/* GetFruRecordTable */
191
192/** @brief Decode GetFruRecordTable request data
193 *
194 * @param[in] msg - PLDM request message payload
195 * @param[in] payload_length - Length of request payload
196 * @param[out] data_transfer_handle - A handle, used to identify a FRU Record
197 * Table data transfer
198 * @param[out] transfer_operation_flag - A flag that indicates whether this is
199 * the start of the transfer
200 * @return pldm_completion_codes
201 */
202int decode_get_fru_record_table_req(const struct pldm_msg *msg,
203 size_t payload_length,
204 uint32_t *data_transfer_handle,
205 uint8_t *transfer_operation_flag);
206
207/** @brief Create a PLDM response message for GetFruRecordTable
208 *
209 * @param[in] instance_id - Message's instance id
210 * @param[in] completion_code - PLDM completion code
211 * @param[in] next_data_transfer_handle - A handle that is used to identify the
212 * next portion of the transfer
213 * @param[in] transfer_flag - The transfer flag that indicates what part of the
214 * transfer this response represents
215 * @param[in,out] msg - Message will be written to this
216 * @return pldm_completion_codes
217 * @note Caller is responsible for memory alloc and dealloc of param 'msg',
218 * and for appending the FRU table to the msg.
219 */
220int encode_get_fru_record_table_resp(uint8_t instance_id,
221 uint8_t completion_code,
222 uint32_t next_data_transfer_handle,
223 uint8_t transfer_flag,
224 struct pldm_msg *msg);
225
Tom Joseph93d68712020-01-07 10:24:41 +0530226/** @brief Encode the FRU record in the FRU table
227 *
228 * @param[in/out] fru_table - Pointer to the FRU table
229 * @param[in] total_size - The size of the table,including the size of FRU
230 * record to be added to the table.
231 * @param[in/out] curr_size - The size of the table, excluding the size of FRU
232 * record to be added to the table.
233 * @param[in] record_set_id - FRU record set identifier
234 * @param[in] record_type - FRU record type
235 * @param[in] num_frus - Number of FRU fields
236 * @param[in] encoding - Encoding type for FRU fields
237 * @param[in] tlvs - Pointer to the buffer with all the FRU fields
238 * @param[in] tlvs_size - Size of the buffer with all the FRU fields
239 *
240 * @return pldm_completion_codes
241 */
242int encode_fru_record(uint8_t *fru_table, size_t total_size, size_t *curr_size,
243 uint16_t record_set_id, uint8_t record_type,
244 uint8_t num_frus, uint8_t encoding, uint8_t *tlvs,
245 size_t tlvs_size);
246
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530247#ifdef __cplusplus
248}
249#endif
250
251#endif