blob: 8e8af2521fa818058295a61c5e2a1ca1e2e2080c [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
25/** @struct pldm_get_fru_record_table_metadata_resp
26 *
27 * Structure representing PLDM get FRU table metadata response.
28 */
29struct pldm_get_fru_record_table_metadata_resp {
30 uint8_t completion_code; //!< completion code
31 uint8_t fru_data_major_version; //!< The major version of the FRU Record
32 uint8_t fru_data_minor_version; //!< The minor version of the FRU Record
33 uint32_t
34 fru_table_maximum_size; //!< The size of the largest FRU Record data
35 uint32_t fru_table_length; //!< The total length of the FRU Record Table
36 uint16_t total_record_set_identifiers; //!< The total number of FRU
37 //!< Record Data structures
38 uint16_t
39 total_table_records; //!< The total number of records in the table
40 uint32_t
41 checksum; //!< The integrity checksum on the FRU Record Table data
42} __attribute__((packed));
43
PriyangaRamasamy497665a2019-07-30 12:48:25 +053044/** @struct pldm_get_fru_record_table_req
45 *
46 * Structure representing PLDM get FRU record table request.
47 */
48struct pldm_get_fru_record_table_req {
49 uint32_t data_transfer_handle;
50 uint8_t transfer_operation_flag;
51} __attribute__((packed));
52
53/** @struct pldm_get_fru_record_table_resp
54 *
55 * Structure representing PLDM get FRU record table response.
56 */
57struct pldm_get_fru_record_table_resp {
58 uint8_t completion_code;
59 uint32_t next_data_transfer_handle;
60 uint8_t transfer_flag;
61 uint8_t fru_record_table_data[1];
62} __attribute__((packed));
63
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +053064/* Requester */
65
66/* GetFRURecordTableMetadata */
67
68/** @brief Create a PLDM request message for GetFRURecordTableMetadata
69 *
70 * @param[in] instance_id - Message's instance id
71 * @param[in,out] msg - Message will be written to this
72 * @return pldm_completion_codes
73 * @note Caller is responsible for memory alloc and dealloc of param
74 * 'msg.payload'
75 */
76int encode_get_fru_record_table_metadata_req(uint8_t instance_id,
77 struct pldm_msg *msg);
78
79/** @brief Decode GetFruRecordTable response data
80 *
81 * @param[in] msg - Response message
82 * @param[in] payload_length - Length of response message payload
83 * @param[out] completion_code - Pointer to response msg's PLDM completion code
84 * @param[out] fru_data_major_version - Major version of the FRU Record
85 * @param[out] fru_data_minor_version - Minor version of the FRU Record
86 * @param[out] fru_table_maximum_size - Size of the largest FRU Record data
87 * @param[out] fru_table_length - Total length of the FRU Record Table
88 * @param[out] total_Record_Set_Identifiers - Total number of FRU Record Data
89 * structures
90 * @param[out] total_table_records - Total number of records in the table
91 * @param[out] checksum - integrity checksum on the FRU Record Table data
92 * @return pldm_completion_codes
93 */
94int decode_get_fru_record_table_metadata_resp(
95 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
96 uint8_t *fru_data_major_version, uint8_t *fru_data_minor_version,
97 uint32_t *fru_table_maximum_size, uint32_t *fru_table_length,
98 uint16_t *total_record_set_identifiers, uint16_t *total_table_records,
99 uint32_t *checksum);
100
101/* Responder */
102
103/* GetFRURecordTableMetadata */
104
105/** @brief Create a PLDM response message for GetFRURecordTableMetadata
106 *
107 * @param[in] instance_id - Message's instance id
108 * @param[in] completion_code - PLDM completion code
109 * @param[in] fru_data_major_version - Major version of the FRU Record
110 * @param[in] fru_data_minor_version - Minor version of the FRU Record
111 * @param[in] fru_table_maximum_size - Size of the largest FRU Record data
112 * @param[in] fru_table_length - Total length of the FRU Record Table
113 * @param[in] total_Record_Set_Identifiers - Total number of FRU Record Data
114 * structures
115 * @param[in] total_table_records - Total number of records in the table
116 * @param[in] checksum - integrity checksum on the FRU Record Table data
117 * @param[in,out] msg - Message will be written to this
118 * @return pldm_completion_codes
119 * @note Caller is responsible for memory alloc and dealloc of param
120 * 'msg.payload'
121 */
122
123int encode_get_fru_record_table_metadata_resp(
124 uint8_t instance_id, uint8_t completion_code,
125 uint8_t fru_data_major_version, uint8_t fru_data_minor_version,
126 uint32_t fru_table_maximum_size, uint32_t fru_table_length,
127 uint16_t total_record_set_identifiers, uint16_t total_table_records,
128 uint32_t checksum, struct pldm_msg *msg);
129
PriyangaRamasamy497665a2019-07-30 12:48:25 +0530130/* GetFruRecordTable */
131
132/** @brief Decode GetFruRecordTable request data
133 *
134 * @param[in] msg - PLDM request message payload
135 * @param[in] payload_length - Length of request payload
136 * @param[out] data_transfer_handle - A handle, used to identify a FRU Record
137 * Table data transfer
138 * @param[out] transfer_operation_flag - A flag that indicates whether this is
139 * the start of the transfer
140 * @return pldm_completion_codes
141 */
142int decode_get_fru_record_table_req(const struct pldm_msg *msg,
143 size_t payload_length,
144 uint32_t *data_transfer_handle,
145 uint8_t *transfer_operation_flag);
146
147/** @brief Create a PLDM response message for GetFruRecordTable
148 *
149 * @param[in] instance_id - Message's instance id
150 * @param[in] completion_code - PLDM completion code
151 * @param[in] next_data_transfer_handle - A handle that is used to identify the
152 * next portion of the transfer
153 * @param[in] transfer_flag - The transfer flag that indicates what part of the
154 * transfer this response represents
155 * @param[in,out] msg - Message will be written to this
156 * @return pldm_completion_codes
157 * @note Caller is responsible for memory alloc and dealloc of param 'msg',
158 * and for appending the FRU table to the msg.
159 */
160int encode_get_fru_record_table_resp(uint8_t instance_id,
161 uint8_t completion_code,
162 uint32_t next_data_transfer_handle,
163 uint8_t transfer_flag,
164 struct pldm_msg *msg);
165
Jinu Joy Thomas8e92c6c2019-08-06 12:22:34 +0530166#ifdef __cplusplus
167}
168#endif
169
170#endif