blob: 746ae4fc775a84f6145edd7f6650064185f8d5d1 [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
46/** @struct pldm_pdr_hdr
47 *
48 * Structure representing PLDM common PDR header
49 */
50struct pldm_pdr_hdr {
51 uint32_t record_handle;
52 uint8_t version;
53 uint8_t type;
54 uint16_t record_change_num;
55 uint16_t length;
56} __attribute__((packed));
57
58/** @struct pldm_state_effecter_pdr
59 *
60 * Structure representing PLDM state effecter PDR
61 */
62struct pldm_state_effecter_pdr {
63 struct pldm_pdr_hdr hdr;
64 uint16_t terminus_handle;
65 uint16_t effecter_id;
66 uint16_t entity_type;
67 uint16_t entity_instance;
68 uint16_t container_id;
69 uint16_t effecter_semantic_id;
70 uint8_t effecter_init;
71 bool8_t has_description_pdr;
72 uint8_t composite_effecter_count;
73 uint8_t possible_states[1];
74} __attribute__((packed));
75
76/** @struct state_effecter_possible_states
77 *
78 * Structure representing state enums for state effecter
79 */
80struct state_effecter_possible_states {
81 uint16_t state_set_id;
82 uint8_t possible_states_size;
83 bitfield8_t states[1];
84} __attribute__((packed));
85
Sampa Misra0db1dfa2019-03-19 00:15:31 -050086/** @struct set_effecter_state_field
87 *
88 * Structure representing a stateField in SetStateEffecterStates command */
89
90typedef struct state_field_for_state_effecter_set {
91 uint8_t set_request; //!< Whether to change the state
92 uint8_t effecter_state; //!< Expected state of the effecter
93} __attribute__((packed)) set_effecter_state_field;
94
Priyanga7257fdf2019-06-10 01:59:45 -050095/** @struct PLDM_SetStateEffecterStates_Request
96 *
97 * Structure representing PLDM set state effecter states request.
98 */
99struct pldm_set_state_effecter_states_req {
100 uint16_t effecter_id;
101 uint8_t comp_effecter_count;
102 set_effecter_state_field field[8];
103} __attribute__((packed));
104
Sampa Misra7fcfb662019-05-08 13:13:53 -0500105/** @struct pldm_get_pdr_resp
106 *
107 * structure representing GetPDR response packet
108 * transfer CRC is not part of the structure and will be
109 * added at the end of last packet in multipart transfer
110 */
111struct pldm_get_pdr_resp {
112 uint8_t completion_code;
113 uint32_t next_record_handle;
114 uint32_t next_data_transfer_handle;
115 uint8_t transfer_flag;
116 uint16_t response_count;
117 uint8_t record_data[1];
118} __attribute__((packed));
119
120/** @struct pldm_get_pdr_req
121 *
122 * structure representing GetPDR request packet
123 */
124struct pldm_get_pdr_req {
125 uint32_t record_handle;
126 uint32_t data_transfer_handle;
127 uint8_t transfer_op_flag;
128 uint16_t request_count;
129 uint16_t record_change_number;
130} __attribute__((packed));
131
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500132/* Responder */
133
134/* SetStateEffecterStates */
135
136/** @brief Create a PLDM response message for SetStateEffecterStates
137 *
138 * @param[in] instance_id - Message's instance id
139 * @param[in] completion_code - PLDM completion code
140 * @param[out] msg - Message will be written to this
141 * @return pldm_completion_codes
142 * @note Caller is responsible for memory alloc and dealloc of param
143 * 'msg.body.payload'
144 */
145
146int encode_set_state_effecter_states_resp(uint8_t instance_id,
147 uint8_t completion_code,
148 struct pldm_msg *msg);
149
150/** @brief Decode SetStateEffecterStates request data
151 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500152 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500153 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500154 * @param[out] effecter_id - used to identify and access the effecter
155 * @param[out] comp_effecter_count - number of individual sets of effecter
156 * information. Upto eight sets of state effecter info can be accessed
157 * for a given effecter.
158 * @param[out] field - each unit is an instance of the stateFileld structure
159 * that is used to set the requested state for a particular effecter
160 * within the state effecter. This field holds the starting address of
161 * the stateField values. The user is responsible to allocate the
162 * memory prior to calling this command. Since the state field count is
163 * not known in advance, the user should allocate the maximum size
164 * always, which is 8 in number.
165 * @return pldm_completion_codes
166 */
vkaverapa6575b82019-04-03 05:33:52 -0500167
Zahed Hossain223a73d2019-07-04 12:46:18 -0500168int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500169 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500170 uint16_t *effecter_id,
171 uint8_t *comp_effecter_count,
172 set_effecter_state_field *field);
173
Sampa Misra7fcfb662019-05-08 13:13:53 -0500174/* GetPDR */
175
176/** @brief Create a PLDM response message for GetPDR
177 *
178 * @param[in] instance_id - Message's instance id
179 * @param[in] completion_code - PLDM completion code
180 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
181 * the PDR Repository
182 * @param[in] next_data_transfer_hndl - A handle that identifies the next
183 * portion of the PDR data to be transferred, if any
184 * @param[in] transfer_flag - Indicates the portion of PDR data being
185 * transferred
186 * @param[in] resp_cnt - The number of recordData bytes returned in this
187 * response
188 * @param[in] record_data - PDR data bytes of length resp_cnt
189 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
190 * in the last part of a PDR being transferred
191 * @param[out] msg - Message will be written to this
192 * @return pldm_completion_codes
193 * @note Caller is responsible for memory alloc and dealloc of param
194 * 'msg.payload'
195 */
196int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
197 uint32_t next_record_hndl,
198 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
199 uint16_t resp_cnt, const uint8_t *record_data,
200 uint8_t transfer_crc, struct pldm_msg *msg);
201
202/** @brief Decode GetPDR request data
203 *
204 * @param[in] msg - Request message
205 * @param[in] payload_length - Length of request message payload
206 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
207 * @param[out] data_transfer_hndl - Handle used to identify a particular
208 * multipart PDR data transfer operation
209 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
210 * portion of transfer
211 * @param[out] request_cnt - The maximum number of record bytes requested
212 * @param[out] record_chg_num - Used to determine whether the PDR has changed
213 * while PDR transfer is going on
214 * @return pldm_completion_codes
215 */
216
217int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
218 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
219 uint8_t *transfer_op_flag, uint16_t *request_cnt,
220 uint16_t *record_chg_num);
221
222/* Requester */
223
224/* SetStateEffecterStates */
225
vkaverap98a2c192019-04-03 05:33:52 -0500226/** @brief Create a PLDM request message for SetStateEffecterStates
227 *
228 * @param[in] instance_id - Message's instance id
229 * @param[in] effecter_id - used to identify and access the effecter
230 * @param[in] comp_effecter_count - number of individual sets of effecter
231 * information. Upto eight sets of state effecter info can be accessed
232 * for a given effecter.
233 * @param[in] field - each unit is an instance of the stateField structure
234 * that is used to set the requested state for a particular effecter
235 * within the state effecter. This field holds the starting address of
236 * the stateField values. The user is responsible to allocate the
237 * memory prior to calling this command. The user has to allocate the
238 * field parameter as sizeof(set_effecter_state_field) *
239 * comp_effecter_count
240 * @param[out] msg - Message will be written to this
241 * @return pldm_completion_codes
242 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500243 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500244 */
245
246int encode_set_state_effecter_states_req(uint8_t instance_id,
247 uint16_t effecter_id,
248 uint8_t comp_effecter_count,
249 set_effecter_state_field *field,
250 struct pldm_msg *msg);
251
252/** @brief Decode SetStateEffecterStates response data
Zahed Hossain223a73d2019-07-04 12:46:18 -0500253 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500254 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500255 * @param[out] completion_code - PLDM completion code
256 * @return pldm_completion_codes
257 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500258int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500259 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500260 uint8_t *completion_code);
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500261#ifdef __cplusplus
262}
263#endif
264
265#endif /* PLATFORM_H */