blob: 8e186a007383a3bbbf2e00380349e6d02b8dae80 [file] [log] [blame]
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12
13/* Maximum size for request */
14#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
15/* Response lengths are inclusive of completion code */
16#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
17
Sampa Misra7fcfb662019-05-08 13:13:53 -050018#define PLDM_GET_PDR_REQ_BYTES 13
19/* Minimum response length */
20#define PLDM_GET_PDR_MIN_RESP_BYTES 12
21
Sampa Misra0db1dfa2019-03-19 00:15:31 -050022enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
23
24enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
25
26enum pldm_platform_commands {
27 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -050028 PLDM_GET_PDR = 0x51,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050029};
30
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050031/** @brief PLDM PDR types
32 */
33enum pldm_pdr_types {
34 PLDM_STATE_EFFECTER_PDR = 11,
35};
36
37/** @brief PLDM effecter initialization schemes
38 */
39enum pldm_effecter_init {
40 PLDM_NO_INIT,
41 PLDM_USE_INIT_PDR,
42 PLDM_ENABLE_EFFECTER,
43 PLDM_DISABLE_EFECTER
44};
45
Deepak Kodihalli557dfb02019-05-12 13:11:17 +053046/** @brief PLDM Platform M&C completion codes
47 */
48enum pldm_platform_completion_codes {
49 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
50};
51
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050052/** @struct pldm_pdr_hdr
53 *
54 * Structure representing PLDM common PDR header
55 */
56struct pldm_pdr_hdr {
57 uint32_t record_handle;
58 uint8_t version;
59 uint8_t type;
60 uint16_t record_change_num;
61 uint16_t length;
62} __attribute__((packed));
63
64/** @struct pldm_state_effecter_pdr
65 *
66 * Structure representing PLDM state effecter PDR
67 */
68struct pldm_state_effecter_pdr {
69 struct pldm_pdr_hdr hdr;
70 uint16_t terminus_handle;
71 uint16_t effecter_id;
72 uint16_t entity_type;
73 uint16_t entity_instance;
74 uint16_t container_id;
75 uint16_t effecter_semantic_id;
76 uint8_t effecter_init;
77 bool8_t has_description_pdr;
78 uint8_t composite_effecter_count;
79 uint8_t possible_states[1];
80} __attribute__((packed));
81
82/** @struct state_effecter_possible_states
83 *
84 * Structure representing state enums for state effecter
85 */
86struct state_effecter_possible_states {
87 uint16_t state_set_id;
88 uint8_t possible_states_size;
89 bitfield8_t states[1];
90} __attribute__((packed));
91
Sampa Misra0db1dfa2019-03-19 00:15:31 -050092/** @struct set_effecter_state_field
93 *
94 * Structure representing a stateField in SetStateEffecterStates command */
95
96typedef struct state_field_for_state_effecter_set {
97 uint8_t set_request; //!< Whether to change the state
98 uint8_t effecter_state; //!< Expected state of the effecter
99} __attribute__((packed)) set_effecter_state_field;
100
Priyanga7257fdf2019-06-10 01:59:45 -0500101/** @struct PLDM_SetStateEffecterStates_Request
102 *
103 * Structure representing PLDM set state effecter states request.
104 */
105struct pldm_set_state_effecter_states_req {
106 uint16_t effecter_id;
107 uint8_t comp_effecter_count;
108 set_effecter_state_field field[8];
109} __attribute__((packed));
110
Sampa Misra7fcfb662019-05-08 13:13:53 -0500111/** @struct pldm_get_pdr_resp
112 *
113 * structure representing GetPDR response packet
114 * transfer CRC is not part of the structure and will be
115 * added at the end of last packet in multipart transfer
116 */
117struct pldm_get_pdr_resp {
118 uint8_t completion_code;
119 uint32_t next_record_handle;
120 uint32_t next_data_transfer_handle;
121 uint8_t transfer_flag;
122 uint16_t response_count;
123 uint8_t record_data[1];
124} __attribute__((packed));
125
126/** @struct pldm_get_pdr_req
127 *
128 * structure representing GetPDR request packet
129 */
130struct pldm_get_pdr_req {
131 uint32_t record_handle;
132 uint32_t data_transfer_handle;
133 uint8_t transfer_op_flag;
134 uint16_t request_count;
135 uint16_t record_change_number;
136} __attribute__((packed));
137
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500138/* Responder */
139
140/* SetStateEffecterStates */
141
142/** @brief Create a PLDM response message for SetStateEffecterStates
143 *
144 * @param[in] instance_id - Message's instance id
145 * @param[in] completion_code - PLDM completion code
146 * @param[out] msg - Message will be written to this
147 * @return pldm_completion_codes
148 * @note Caller is responsible for memory alloc and dealloc of param
149 * 'msg.body.payload'
150 */
151
152int encode_set_state_effecter_states_resp(uint8_t instance_id,
153 uint8_t completion_code,
154 struct pldm_msg *msg);
155
156/** @brief Decode SetStateEffecterStates request data
157 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500158 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500159 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500160 * @param[out] effecter_id - used to identify and access the effecter
161 * @param[out] comp_effecter_count - number of individual sets of effecter
162 * information. Upto eight sets of state effecter info can be accessed
163 * for a given effecter.
164 * @param[out] field - each unit is an instance of the stateFileld structure
165 * that is used to set the requested state for a particular effecter
166 * within the state effecter. This field holds the starting address of
167 * the stateField values. The user is responsible to allocate the
168 * memory prior to calling this command. Since the state field count is
169 * not known in advance, the user should allocate the maximum size
170 * always, which is 8 in number.
171 * @return pldm_completion_codes
172 */
vkaverapa6575b82019-04-03 05:33:52 -0500173
Zahed Hossain223a73d2019-07-04 12:46:18 -0500174int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500175 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500176 uint16_t *effecter_id,
177 uint8_t *comp_effecter_count,
178 set_effecter_state_field *field);
179
Sampa Misra7fcfb662019-05-08 13:13:53 -0500180/* GetPDR */
181
182/** @brief Create a PLDM response message for GetPDR
183 *
184 * @param[in] instance_id - Message's instance id
185 * @param[in] completion_code - PLDM completion code
186 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
187 * the PDR Repository
188 * @param[in] next_data_transfer_hndl - A handle that identifies the next
189 * portion of the PDR data to be transferred, if any
190 * @param[in] transfer_flag - Indicates the portion of PDR data being
191 * transferred
192 * @param[in] resp_cnt - The number of recordData bytes returned in this
193 * response
194 * @param[in] record_data - PDR data bytes of length resp_cnt
195 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
196 * in the last part of a PDR being transferred
197 * @param[out] msg - Message will be written to this
198 * @return pldm_completion_codes
199 * @note Caller is responsible for memory alloc and dealloc of param
200 * 'msg.payload'
201 */
202int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
203 uint32_t next_record_hndl,
204 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
205 uint16_t resp_cnt, const uint8_t *record_data,
206 uint8_t transfer_crc, struct pldm_msg *msg);
207
208/** @brief Decode GetPDR request data
209 *
210 * @param[in] msg - Request message
211 * @param[in] payload_length - Length of request message payload
212 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
213 * @param[out] data_transfer_hndl - Handle used to identify a particular
214 * multipart PDR data transfer operation
215 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
216 * portion of transfer
217 * @param[out] request_cnt - The maximum number of record bytes requested
218 * @param[out] record_chg_num - Used to determine whether the PDR has changed
219 * while PDR transfer is going on
220 * @return pldm_completion_codes
221 */
222
223int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
224 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
225 uint8_t *transfer_op_flag, uint16_t *request_cnt,
226 uint16_t *record_chg_num);
227
228/* Requester */
229
230/* SetStateEffecterStates */
231
vkaverap98a2c192019-04-03 05:33:52 -0500232/** @brief Create a PLDM request message for SetStateEffecterStates
233 *
234 * @param[in] instance_id - Message's instance id
235 * @param[in] effecter_id - used to identify and access the effecter
236 * @param[in] comp_effecter_count - number of individual sets of effecter
237 * information. Upto eight sets of state effecter info can be accessed
238 * for a given effecter.
239 * @param[in] field - each unit is an instance of the stateField structure
240 * that is used to set the requested state for a particular effecter
241 * within the state effecter. This field holds the starting address of
242 * the stateField values. The user is responsible to allocate the
243 * memory prior to calling this command. The user has to allocate the
244 * field parameter as sizeof(set_effecter_state_field) *
245 * comp_effecter_count
246 * @param[out] msg - Message will be written to this
247 * @return pldm_completion_codes
248 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500249 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500250 */
251
252int encode_set_state_effecter_states_req(uint8_t instance_id,
253 uint16_t effecter_id,
254 uint8_t comp_effecter_count,
255 set_effecter_state_field *field,
256 struct pldm_msg *msg);
257
258/** @brief Decode SetStateEffecterStates response data
Zahed Hossain223a73d2019-07-04 12:46:18 -0500259 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500260 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500261 * @param[out] completion_code - PLDM completion code
262 * @return pldm_completion_codes
263 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500264int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500265 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500266 uint8_t *completion_code);
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500267#ifdef __cplusplus
268}
269#endif
270
271#endif /* PLATFORM_H */