blob: dd99633451b1bddef48f059b894b0fe1b3dccff8 [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"
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -050012#include "pdr.h"
Sampa Misra0db1dfa2019-03-19 00:15:31 -050013
14/* Maximum size for request */
15#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
Jolie Ku3557bad2020-03-02 16:22:57 +080016#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
Jolie Ku6787f172020-03-19 11:15:53 +080017#define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
Sampa Misra0db1dfa2019-03-19 00:15:31 -050018/* Response lengths are inclusive of completion code */
19#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080020#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050021
George Liu30b859f2020-01-07 15:03:22 +080022#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
23#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
24
Sampa Misra7fcfb662019-05-08 13:13:53 -050025#define PLDM_GET_PDR_REQ_BYTES 13
26/* Minimum response length */
27#define PLDM_GET_PDR_MIN_RESP_BYTES 12
Jolie Ku6787f172020-03-19 11:15:53 +080028#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
Sampa Misra7fcfb662019-05-08 13:13:53 -050029
Zahed Hossaind4abab12020-02-06 03:36:43 -060030/* Minimum length for PLDM PlatformEventMessage request */
31#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
32#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
Tom Joseph56e45c52020-03-16 10:01:45 +053033#define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2
Zahed Hossaind4abab12020-02-06 03:36:43 -060034
Zahed Hossain1c861712020-03-04 08:55:19 -060035/* Minumum length of senson event data */
36#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
37#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
38#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
39#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
40#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
41#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
42#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
43#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
44
George Liu30b859f2020-01-07 15:03:22 +080045enum pldm_effecter_data_size {
46 PLDM_EFFECTER_DATA_SIZE_UINT8,
47 PLDM_EFFECTER_DATA_SIZE_SINT8,
48 PLDM_EFFECTER_DATA_SIZE_UINT16,
49 PLDM_EFFECTER_DATA_SIZE_SINT16,
50 PLDM_EFFECTER_DATA_SIZE_UINT32,
51 PLDM_EFFECTER_DATA_SIZE_SINT32
52};
53
Sampa Misra0db1dfa2019-03-19 00:15:31 -050054enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
55
56enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
57
Jolie Ku3557bad2020-03-02 16:22:57 +080058enum sensor_operational_state {
59 ENABLED = 0x00,
60 DISABLED = 0x01,
61 UNAVAILABLE = 0x02,
62 STATUSUNKNOWN = 0x03,
63 FAILED = 0x04,
64 INITIALIZING = 0x05,
65 SHUTTINGDOWN = 0x06,
66 INTEST = 0x07
67};
68
69enum present_state {
70 UNKNOWN = 0x0,
71 NORMAL = 0x01,
72 WARNING = 0x02,
73 CRITICAL = 0x03,
74 FATAL = 0x04,
75 LOWERWARNING = 0x05,
76 LOWERCRITICAL = 0x06,
77 LOWERFATAL = 0x07,
78 UPPERWARNING = 0x08,
79 UPPERCRITICAL = 0x09,
80 UPPERFATAL = 0x0a
81};
82
Jolie Ku6787f172020-03-19 11:15:53 +080083enum pldm_effecter_oper_state {
84 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
85 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
86 EFFECTER_OPER_STATE_DISABLED,
87 EFFECTER_OPER_STATE_UNAVAILABLE,
88 EFFECTER_OPER_STATE_STATUSUNKNOWN,
89 EFFECTER_OPER_STATE_FAILED,
90 EFFECTER_OPER_STATE_INITIALIZING,
91 EFFECTER_OPER_STATE_SHUTTINGDOWN,
92 EFFECTER_OPER_STATE_INTEST
93};
94
Sampa Misra0db1dfa2019-03-19 00:15:31 -050095enum pldm_platform_commands {
Jolie Ku3557bad2020-03-02 16:22:57 +080096 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +080097 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +080098 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050099 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -0500100 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600101 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500102};
103
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500104/** @brief PLDM PDR types
105 */
106enum pldm_pdr_types {
107 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500108 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600109 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500110};
111
112/** @brief PLDM effecter initialization schemes
113 */
114enum pldm_effecter_init {
115 PLDM_NO_INIT,
116 PLDM_USE_INIT_PDR,
117 PLDM_ENABLE_EFFECTER,
118 PLDM_DISABLE_EFECTER
119};
120
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530121/** @brief PLDM Platform M&C completion codes
122 */
123enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500124 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
125 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500126
127 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
128 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530129 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500130 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
131 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
132
Sampa Misraa2fa0702019-05-31 01:28:55 -0500133 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530134};
135
Zahed Hossaind4abab12020-02-06 03:36:43 -0600136/** @brief PLDM Event types
137 */
138enum pldm_event_types {
139 PLDM_SENSOR_EVENT = 0x00,
140 PLDM_EFFECTER_EVENT = 0x01,
141 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
142 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
143 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
144 PLDM_MESSAGE_POLL_EVENT = 0x05,
145 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
146};
147
148/** @brief PLDM sensorEventClass states
149 */
150enum sensor_event_class_states {
151 PLDM_SENSOR_OP_STATE,
152 PLDM_STATE_SENSOR_STATE,
153 PLDM_NUMERIC_SENSOR_STATE
154};
155
156/** @brief PLDM sensor supported states
157 */
158enum pldm_sensor_operational_state {
159 PLDM_SENSOR_ENABLED,
160 PLDM_SENSOR_DISABLED,
161 PLDM_SENSOR_UNAVAILABLE,
162 PLDM_SENSOR_STATUSUNKOWN,
163 PLDM_SENSOR_FAILED,
164 PLDM_SENSOR_INITIALIZING,
165 PLDM_SENSOR_SHUTTINGDOWN,
166 PLDM_SENSOR_INTEST
167};
168
169/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
170 */
171enum pldm_pdr_repository_chg_event_data_format {
172 REFRESH_ENTIRE_REPOSITORY,
173 FORMAT_IS_PDR_TYPES,
174 FORMAT_IS_PDR_HANDLES
175};
176
Zahed Hossain1c861712020-03-04 08:55:19 -0600177/** @brief PLDM NumericSensorStatePresentReading data type
178 */
179enum pldm_sensor_readings_data_type {
180 PLDM_SENSOR_DATA_SIZE_UINT8,
181 PLDM_SENSOR_DATA_SIZE_SINT8,
182 PLDM_SENSOR_DATA_SIZE_UINT16,
183 PLDM_SENSOR_DATA_SIZE_SINT16,
184 PLDM_SENSOR_DATA_SIZE_UINT32,
185 PLDM_SENSOR_DATA_SIZE_SINT32
186};
187
Tom Joseph56e45c52020-03-16 10:01:45 +0530188/** @brief PLDM PlatformEventMessage response status
189 */
190enum pldm_platform_event_status {
191 PLDM_EVENT_NO_LOGGING = 0x00,
192 PLDM_EVENT_LOGGING_DISABLED = 0x01,
193 PLDM_EVENT_LOG_FULL = 0x02,
194 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
195 PLDM_EVENT_LOGGED = 0x04,
196 PLDM_EVENT_LOGGING_REJECTED = 0x05
197};
198
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500199/** @struct pldm_pdr_hdr
200 *
201 * Structure representing PLDM common PDR header
202 */
203struct pldm_pdr_hdr {
204 uint32_t record_handle;
205 uint8_t version;
206 uint8_t type;
207 uint16_t record_change_num;
208 uint16_t length;
209} __attribute__((packed));
210
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500211/** @struct pldm_pdr_entity_association
212 *
213 * Structure representing PLDM Entity Association PDR
214 */
215struct pldm_pdr_entity_association {
216 uint16_t container_id;
217 uint8_t association_type;
218 pldm_entity container;
219 uint8_t num_children;
220 pldm_entity children[1];
221} __attribute__((packed));
222
Deepak Kodihallidb914672020-02-07 02:47:45 -0600223/** @struct pldm_pdr_fru_record_set
224 *
225 * Structure representing PLDM FRU record set PDR
226 */
227struct pldm_pdr_fru_record_set {
228 uint16_t terminus_handle;
229 uint16_t fru_rsi;
230 uint16_t entity_type;
231 uint16_t entity_instance_num;
232 uint16_t container_id;
233} __attribute__((packed));
234
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500235/** @struct pldm_state_effecter_pdr
236 *
237 * Structure representing PLDM state effecter PDR
238 */
239struct pldm_state_effecter_pdr {
240 struct pldm_pdr_hdr hdr;
241 uint16_t terminus_handle;
242 uint16_t effecter_id;
243 uint16_t entity_type;
244 uint16_t entity_instance;
245 uint16_t container_id;
246 uint16_t effecter_semantic_id;
247 uint8_t effecter_init;
248 bool8_t has_description_pdr;
249 uint8_t composite_effecter_count;
250 uint8_t possible_states[1];
251} __attribute__((packed));
252
253/** @struct state_effecter_possible_states
254 *
255 * Structure representing state enums for state effecter
256 */
257struct state_effecter_possible_states {
258 uint16_t state_set_id;
259 uint8_t possible_states_size;
260 bitfield8_t states[1];
261} __attribute__((packed));
262
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500263/** @struct set_effecter_state_field
264 *
265 * Structure representing a stateField in SetStateEffecterStates command */
266
267typedef struct state_field_for_state_effecter_set {
268 uint8_t set_request; //!< Whether to change the state
269 uint8_t effecter_state; //!< Expected state of the effecter
270} __attribute__((packed)) set_effecter_state_field;
271
Jolie Ku3557bad2020-03-02 16:22:57 +0800272/** @struct get_sensor_readings_field
273 *
274 * Structure representing a stateField in GetStateSensorReadings command */
275
276typedef struct state_field_for_get_state_sensor_readings {
277 uint8_t sensor_op_state; //!< The state of the sensor itself
278 uint8_t present_state; //!< Return a state value
279 uint8_t previous_state; //!< The state that the presentState was entered
280 //! from. This must be different from the
281 //! present state
282 uint8_t event_state; //!< Return a state value from a PLDM State Set
283 //! that is associated with the sensor
284} __attribute__((packed)) get_sensor_state_field;
285
Priyanga7257fdf2019-06-10 01:59:45 -0500286/** @struct PLDM_SetStateEffecterStates_Request
287 *
288 * Structure representing PLDM set state effecter states request.
289 */
290struct pldm_set_state_effecter_states_req {
291 uint16_t effecter_id;
292 uint8_t comp_effecter_count;
293 set_effecter_state_field field[8];
294} __attribute__((packed));
295
Sampa Misra7fcfb662019-05-08 13:13:53 -0500296/** @struct pldm_get_pdr_resp
297 *
298 * structure representing GetPDR response packet
299 * transfer CRC is not part of the structure and will be
300 * added at the end of last packet in multipart transfer
301 */
302struct pldm_get_pdr_resp {
303 uint8_t completion_code;
304 uint32_t next_record_handle;
305 uint32_t next_data_transfer_handle;
306 uint8_t transfer_flag;
307 uint16_t response_count;
308 uint8_t record_data[1];
309} __attribute__((packed));
310
311/** @struct pldm_get_pdr_req
312 *
313 * structure representing GetPDR request packet
314 */
315struct pldm_get_pdr_req {
316 uint32_t record_handle;
317 uint32_t data_transfer_handle;
318 uint8_t transfer_op_flag;
319 uint16_t request_count;
320 uint16_t record_change_number;
321} __attribute__((packed));
322
George Liu30b859f2020-01-07 15:03:22 +0800323/** @struct pldm_set_numeric_effecter_value_req
324 *
325 * structure representing SetNumericEffecterValue request packet
326 */
327struct pldm_set_numeric_effecter_value_req {
328 uint16_t effecter_id;
329 uint8_t effecter_data_size;
330 uint8_t effecter_value[1];
331} __attribute__((packed));
332
Jolie Ku3557bad2020-03-02 16:22:57 +0800333/** @struct pldm_get_state_sensor_readings_req
334 *
335 * Structure representing PLDM get state sensor readings request.
336 */
337struct pldm_get_state_sensor_readings_req {
338 uint16_t sensor_id;
339 bitfield8_t sensor_rearm;
340 uint8_t reserved;
341} __attribute__((packed));
342
343/** @struct pldm_get_state_sensor_readings_resp
344 *
345 * Structure representing PLDM get state sensor readings response.
346 */
347struct pldm_get_state_sensor_readings_resp {
348 uint8_t completion_code;
349 uint8_t comp_sensor_count;
350 get_sensor_state_field field[1];
351} __attribute__((packed));
352
Zahed Hossaind4abab12020-02-06 03:36:43 -0600353/** @struct pldm_sensor_event
354 *
355 * structure representing sensorEventClass
356 */
357struct pldm_sensor_event_data {
358 uint16_t sensor_id;
359 uint8_t sensor_event_class_type;
360 uint8_t event_class[1];
361} __attribute__((packed));
362
363/** @struct pldm_state_sensor_state
364 *
365 * structure representing sensorEventClass for stateSensorState
366 */
367struct pldm_sensor_event_state_sensor_state {
368 uint8_t sensor_offset;
369 uint8_t event_state;
370 uint8_t previous_event_state;
371} __attribute__((packed));
372
373/** @struct pldm_sensor_event_numeric_sensor_state
374 *
375 * structure representing sensorEventClass for stateSensorState
376 */
377struct pldm_sensor_event_numeric_sensor_state {
378 uint8_t event_state;
379 uint8_t previous_event_state;
380 uint8_t sensor_data_size;
381 uint8_t present_reading[1];
382} __attribute__((packed));
383
384/** @struct pldm_sensor_event_sensor_op_state
385 *
386 * structure representing sensorEventClass for SensorOpState
387 */
388struct pldm_sensor_event_sensor_op_state {
389 uint8_t present_op_state;
390 uint8_t previous_op_state;
391} __attribute__((packed));
392
393/** @struct pldm_platform_event_message_req
394 *
395 * structure representing PlatformEventMessage command request data
396 */
397struct pldm_platform_event_message_req {
398 uint8_t format_version;
399 uint8_t tid;
400 uint8_t event_class;
401 uint8_t event_data[1];
402} __attribute__((packed));
403
404/** @struct pldm_platform_event_message_response
405 *
406 * structure representing PlatformEventMessage command response data
407 */
408struct pldm_platform_event_message_resp {
409 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500410 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600411} __attribute__((packed));
412
413/** @struct pldm_pdr_repository_chg_event_data
414 *
415 * structure representing pldmPDRRepositoryChgEvent class eventData
416 */
417struct pldm_pdr_repository_chg_event_data {
418 uint8_t event_data_format;
419 uint8_t number_of_change_records;
420 uint8_t change_records[1];
421} __attribute__((packed));
422
423/** @struct pldm_pdr_repository_chg_event_change_record_data
424 *
425 * structure representing pldmPDRRepositoryChgEvent class eventData's change
426 * record data
427 */
428struct pldm_pdr_repository_change_record_data {
429 uint8_t event_data_operation;
430 uint8_t number_of_change_entries;
431 uint32_t change_entry[1];
432} __attribute__((packed));
433
Jolie Ku6787f172020-03-19 11:15:53 +0800434/** @struct pldm_get_numeric_effecter_value_req
435 *
436 * structure representing GetNumericEffecterValue request packet
437 */
438struct pldm_get_numeric_effecter_value_req {
439 uint16_t effecter_id;
440} __attribute__((packed));
441
442/** @struct pldm_get_numeric_effecter_value_resp
443 *
444 * structure representing GetNumericEffecterValue response packet
445 */
446struct pldm_get_numeric_effecter_value_resp {
447 uint8_t completion_code;
448 uint8_t effecter_data_size;
449 uint8_t effecter_oper_state;
450 uint8_t pending_and_present_values[1];
451} __attribute__((packed));
452
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500453/* Responder */
454
George Liu30b859f2020-01-07 15:03:22 +0800455/* SetNumericEffecterValue */
456
457/** @brief Decode SetNumericEffecterValue request data
458 *
459 * @param[in] msg - Request message
460 * @param[in] payload_length - Length of request message payload
461 * @param[out] effecter_id - used to identify and access the effecter
462 * @param[out] effecter_data_size - The bit width and format of the setting
463 * value for the effecter.
464 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
465 * @param[out] effecter_value - The setting value of numeric effecter being
466 * requested.
467 * @return pldm_completion_codes
468 */
469int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
470 size_t payload_length,
471 uint16_t *effecter_id,
472 uint8_t *effecter_data_size,
473 uint8_t *effecter_value);
474
475/** @brief Create a PLDM response message for SetNumericEffecterValue
476 *
477 * @param[in] instance_id - Message's instance id
478 * @param[in] completion_code - PLDM completion code
479 * @param[out] msg - Message will be written to this
480 * @param[in] payload_length - Length of request message payload
481 * @return pldm_completion_codes
482 * @note Caller is responsible for memory alloc and dealloc of param
483 * 'msg.body.payload'
484 */
485int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
486 uint8_t completion_code,
487 struct pldm_msg *msg,
488 size_t payload_length);
489
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500490/* SetStateEffecterStates */
491
492/** @brief Create a PLDM response message for SetStateEffecterStates
493 *
494 * @param[in] instance_id - Message's instance id
495 * @param[in] completion_code - PLDM completion code
496 * @param[out] msg - Message will be written to this
497 * @return pldm_completion_codes
498 * @note Caller is responsible for memory alloc and dealloc of param
499 * 'msg.body.payload'
500 */
501
502int encode_set_state_effecter_states_resp(uint8_t instance_id,
503 uint8_t completion_code,
504 struct pldm_msg *msg);
505
506/** @brief Decode SetStateEffecterStates request data
507 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500508 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500509 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500510 * @param[out] effecter_id - used to identify and access the effecter
511 * @param[out] comp_effecter_count - number of individual sets of effecter
512 * information. Upto eight sets of state effecter info can be accessed
513 * for a given effecter.
514 * @param[out] field - each unit is an instance of the stateFileld structure
515 * that is used to set the requested state for a particular effecter
516 * within the state effecter. This field holds the starting address of
517 * the stateField values. The user is responsible to allocate the
518 * memory prior to calling this command. Since the state field count is
519 * not known in advance, the user should allocate the maximum size
520 * always, which is 8 in number.
521 * @return pldm_completion_codes
522 */
vkaverapa6575b82019-04-03 05:33:52 -0500523
Zahed Hossain223a73d2019-07-04 12:46:18 -0500524int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500525 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500526 uint16_t *effecter_id,
527 uint8_t *comp_effecter_count,
528 set_effecter_state_field *field);
529
Sampa Misra7fcfb662019-05-08 13:13:53 -0500530/* GetPDR */
531
532/** @brief Create a PLDM response message for GetPDR
533 *
534 * @param[in] instance_id - Message's instance id
535 * @param[in] completion_code - PLDM completion code
536 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
537 * the PDR Repository
538 * @param[in] next_data_transfer_hndl - A handle that identifies the next
539 * portion of the PDR data to be transferred, if any
540 * @param[in] transfer_flag - Indicates the portion of PDR data being
541 * transferred
542 * @param[in] resp_cnt - The number of recordData bytes returned in this
543 * response
544 * @param[in] record_data - PDR data bytes of length resp_cnt
545 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
546 * in the last part of a PDR being transferred
547 * @param[out] msg - Message will be written to this
548 * @return pldm_completion_codes
549 * @note Caller is responsible for memory alloc and dealloc of param
550 * 'msg.payload'
551 */
552int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
553 uint32_t next_record_hndl,
554 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
555 uint16_t resp_cnt, const uint8_t *record_data,
556 uint8_t transfer_crc, struct pldm_msg *msg);
557
558/** @brief Decode GetPDR request data
559 *
560 * @param[in] msg - Request message
561 * @param[in] payload_length - Length of request message payload
562 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
563 * @param[out] data_transfer_hndl - Handle used to identify a particular
564 * multipart PDR data transfer operation
565 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
566 * portion of transfer
567 * @param[out] request_cnt - The maximum number of record bytes requested
568 * @param[out] record_chg_num - Used to determine whether the PDR has changed
569 * while PDR transfer is going on
570 * @return pldm_completion_codes
571 */
572
573int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
574 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
575 uint8_t *transfer_op_flag, uint16_t *request_cnt,
576 uint16_t *record_chg_num);
577
Jolie Ku3557bad2020-03-02 16:22:57 +0800578/* GetStateSensorReadings */
579
580/** @brief Decode GetStateSensorReadings request data
581 *
582 * @param[in] msg - Request message
583 * @param[in] payload_length - Length of request message payload
584 * @param[out] sensor_id - used to identify and access the simple or composite
585 * sensor
586 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
587 * particular sensor within the state sensor, where bit [0] corresponds
588 * to the first state sensor (sensor offset 0) and bit [7] corresponds
589 * to the eighth sensor (sensor offset 7), sequentially.
590 * @param[out] reserved - value: 0x00
591 * @return pldm_completion_codes
592 */
593
594int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
595 size_t payload_length,
596 uint16_t *sensor_id,
597 bitfield8_t *sensor_rearm,
598 uint8_t *reserved);
599
600/** @brief Encode GetStateSensorReadings response data
601 *
602 * @param[in] instance_id - Message's instance id
603 * @param[in] completion_code - PLDM completion code
604 * @param[out] comp_sensor_count - The number of individual sets of sensor
605 * information that this command accesses
606 * @param[out] field - Each stateField is an instance of a stateField structure
607 * that is used to return the present operational state setting and the
608 * present state and event state for a particular set of sensor
609 * information contained within the state sensor
610 * @param[out] msg - Message will be written to this
611 * @return pldm_completion_codes
612 */
613
614int encode_get_state_sensor_readings_resp(uint8_t instance_id,
615 uint8_t completion_code,
616 uint8_t comp_sensor_count,
617 get_sensor_state_field *field,
618 struct pldm_msg *msg);
619
Jolie Ku6787f172020-03-19 11:15:53 +0800620/* GetNumericEffecterValue */
621
622/** @brief Decode GetNumericEffecterValue request data
623 *
624 * @param[in] msg - Request message
625 * @param[in] payload_length - Length of request message payload
626 * @param[out] effecter_id - used to identify and access the effecter
627 * @return pldm_completion_codes
628 */
629int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
630 size_t payload_length,
631 uint16_t *effecter_id);
632
633/** @brief Create a PLDM response message for GetNumericEffecterValue
634 *
635 * @param[in] instance_id - Message's instance id
636 * @param[in] completion_code - PLDM completion code
637 * @param[in] effecter_data_size - The bit width and format of the setting
638 * value for the effecter.
639 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
640 * @param[in] effecter_oper_state - The state of the effecter itself
641 * @param[in] pending_value - The pending numeric value setting of the
642 * effecter. The effecterDataSize field indicates the number of
643 * bits used for this field
644 * @param[in] present_value - The present numeric value setting of the
645 * effecter. The effecterDataSize indicates the number of bits
646 * used for this field
647 * @param[out] msg - Message will be written to this
648 * @param[in] payload_length - Length of request message payload
649 * @return pldm_completion_codes
650 * @note Caller is responsible for memory alloc and dealloc of param
651 * 'msg.payload'
652 */
653int encode_get_numeric_effecter_value_resp(
654 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
655 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
656 struct pldm_msg *msg, size_t payload_length);
657
Sampa Misra7fcfb662019-05-08 13:13:53 -0500658/* Requester */
659
George Liu820a9a52019-11-26 14:43:59 +0800660/* GetPDR */
661
662/** @brief Create a PLDM request message for GetPDR
663 *
664 * @param[in] instance_id - Message's instance id
665 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
666 * @param[in] data_transfer_hndl - Handle used to identify a particular
667 * multipart PDR data transfer operation
668 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
669 * portion of transfer
670 * @param[in] request_cnt - The maximum number of record bytes requested
671 * @param[in] record_chg_num - Used to determine whether the PDR has changed
672 * while PDR transfer is going on
673 * @param[out] msg - Message will be written to this
674 * @param[in] payload_length - Length of request message payload
675 * @return pldm_completion_codes
676 * @note Caller is responsible for memory alloc and dealloc of param
677 * 'msg.payload'
678 */
679int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
680 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
681 uint16_t request_cnt, uint16_t record_chg_num,
682 struct pldm_msg *msg, size_t payload_length);
683
684/** @brief Decode GetPDR response data
685 *
George Liu684a7162019-12-06 15:10:52 +0800686 * Note:
687 * * If the return value is not PLDM_SUCCESS, it represents a
688 * transport layer error.
689 * * If the completion_code value is not PLDM_SUCCESS, it represents a
690 * protocol layer error and all the out-parameters are invalid.
691 *
George Liu820a9a52019-11-26 14:43:59 +0800692 * @param[in] msg - Request message
693 * @param[in] payload_length - Length of request message payload
694 * @param[out] completion_code - PLDM completion code
695 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
696 * the PDR Repository
697 * @param[out] next_data_transfer_hndl - A handle that identifies the next
698 * portion of the PDR data to be transferred, if any
699 * @param[out] transfer_flag - Indicates the portion of PDR data being
700 * transferred
701 * @param[out] resp_cnt - The number of recordData bytes returned in this
702 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500703 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
704 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800705 * @param[in] record_data_length - Length of record_data
706 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
707 * in the last part of a PDR being transferred
708 * @return pldm_completion_codes
709 */
710int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
711 uint8_t *completion_code, uint32_t *next_record_hndl,
712 uint32_t *next_data_transfer_hndl,
713 uint8_t *transfer_flag, uint16_t *resp_cnt,
714 uint8_t *record_data, size_t record_data_length,
715 uint8_t *transfer_crc);
716
Sampa Misra7fcfb662019-05-08 13:13:53 -0500717/* SetStateEffecterStates */
718
vkaverap98a2c192019-04-03 05:33:52 -0500719/** @brief Create a PLDM request message for SetStateEffecterStates
720 *
721 * @param[in] instance_id - Message's instance id
722 * @param[in] effecter_id - used to identify and access the effecter
723 * @param[in] comp_effecter_count - number of individual sets of effecter
724 * information. Upto eight sets of state effecter info can be accessed
725 * for a given effecter.
726 * @param[in] field - each unit is an instance of the stateField structure
727 * that is used to set the requested state for a particular effecter
728 * within the state effecter. This field holds the starting address of
729 * the stateField values. The user is responsible to allocate the
730 * memory prior to calling this command. The user has to allocate the
731 * field parameter as sizeof(set_effecter_state_field) *
732 * comp_effecter_count
733 * @param[out] msg - Message will be written to this
734 * @return pldm_completion_codes
735 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500736 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500737 */
738
739int encode_set_state_effecter_states_req(uint8_t instance_id,
740 uint16_t effecter_id,
741 uint8_t comp_effecter_count,
742 set_effecter_state_field *field,
743 struct pldm_msg *msg);
744
745/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800746 *
747 * Note:
748 * * If the return value is not PLDM_SUCCESS, it represents a
749 * transport layer error.
750 * * If the completion_code value is not PLDM_SUCCESS, it represents a
751 * protocol layer error and all the out-parameters are invalid.
752 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500753 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500754 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500755 * @param[out] completion_code - PLDM completion code
756 * @return pldm_completion_codes
757 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500758int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500759 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500760 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800761
762/* SetNumericEffecterValue */
763
764/** @brief Create a PLDM request message for SetNumericEffecterValue
765 *
766 * @param[in] instance_id - Message's instance id
767 * @param[in] effecter_id - used to identify and access the effecter
768 * @param[in] effecter_data_size - The bit width and format of the setting
769 * value for the effecter.
770 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
771 * @param[in] effecter_value - The setting value of numeric effecter being
772 * requested.
773 * @param[in] payload_length - Length of request message payload
774 * @param[out] msg - Message will be written to this
775 * @return pldm_completion_codes
776 * @note Caller is responsible for memory alloc and dealloc of param
777 * 'msg.payload'
778 */
779int encode_set_numeric_effecter_value_req(
780 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
781 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
782
783/** @brief Decode SetNumericEffecterValue response data
784 * @param[in] msg - Request message
785 * @param[in] payload_length - Length of response message payload
786 * @param[out] completion_code - PLDM completion code
787 * @return pldm_completion_codes
788 */
789int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
790 size_t payload_length,
791 uint8_t *completion_code);
792
Jolie Ku3557bad2020-03-02 16:22:57 +0800793/** @brief Create a PLDM request message for GetStateSensorReadings
794 *
795 * @param[in] instance_id - Message's instance id
796 * @param[in] sensor_id - used to identify and access the simple or composite
797 * sensor
798 * @param[in] sensorRearm - Each bit location in this field corresponds to a
799 * particular sensor within the state sensor, where bit [0] corresponds
800 * to the first state sensor (sensor offset 0) and bit [7] corresponds
801 * to the eighth sensor (sensor offset 7), sequentially
802 * @param[in] reserved - value: 0x00
803 * @param[out] msg - Message will be written to this
804 * @return pldm_completion_codes
805 * @note Caller is responsible for memory alloc and dealloc of param
806 * 'msg.payload'
807 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800808int encode_get_state_sensor_readings_req(uint8_t instance_id,
809 uint16_t sensor_id,
810 bitfield8_t sensor_rearm,
811 uint8_t reserved,
812 struct pldm_msg *msg);
813
814/** @brief Decode GetStateSensorReadings response data
815 *
816 * @param[in] msg - Request message
817 * @param[in] payload_length - Length of response message payload
818 * @param[out] completion_code - PLDM completion code
819 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
820 * information that this command accesses
821 * @param[out] field - Each stateField is an instance of a stateField structure
822 * that is used to return the present operational state setting and the
823 * present state and event state for a particular set of sensor
824 * information contained within the state sensor
825 * @return pldm_completion_codes
826 */
827
828int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
829 size_t payload_length,
830 uint8_t *completion_code,
831 uint8_t *comp_sensor_count,
832 get_sensor_state_field *field);
833
Zahed Hossaind4abab12020-02-06 03:36:43 -0600834/* PlatformEventMessage */
835
836/** @brief Decode PlatformEventMessage request data
837 * @param[in] msg - Request message
838 * @param[in] payload_length - Length of response message payload
839 * @param[out] format_version - Version of the event format
840 * @param[out] tid - Terminus ID for the terminus that originated the event
841 * message
842 * @param[out] event_class - The class of event being sent
843 * @param[out] event_data_offset - Offset where the event data should be read
844 * from pldm msg
845 * @return pldm_completion_codes
846 */
847int decode_platform_event_message_req(const struct pldm_msg *msg,
848 size_t payload_length,
849 uint8_t *format_version, uint8_t *tid,
850 uint8_t *event_class,
851 size_t *event_data_offset);
852
853/** @brief Encode PlatformEventMessage response data
854 * @param[in] instance_id - Message's instance id
855 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500856 * @param[in] platform_event_status - Response status of the event message
857 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -0600858 * @param[out] msg - Message will be written to this
859 * @return pldm_completion_codes
860 * @note Caller is responsible for memory alloc and dealloc of param
861 * 'msg.payload'
862 */
863int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500864 uint8_t completion_code,
865 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600866 struct pldm_msg *msg);
867
Zahed Hossain1c861712020-03-04 08:55:19 -0600868/** @brief Decode sensorEventData response data
869 *
870 * @param[in] event_data - event data from the response message
871 * @param[in] event_data_length - length of the event data
872 * @param[out] sensor_id - sensorID value of the sensor
873 * @param[out] sensor_event_class_type - Type of sensor event class
874 * @param[out] event_class_data_offset - Offset where the event class data
875 * should be read from event data
876 * @return pldm_completion_codes
877 * @note Caller is responsible for memory alloc and dealloc of param
878 * 'event_data'
879 */
880int decode_sensor_event_data(const uint8_t *event_data,
881 size_t event_data_length, uint16_t *sensor_id,
882 uint8_t *sensor_event_class_type,
883 size_t *event_class_data_offset);
884
885/** @brief Decode sensorOpState response data
886 *
887 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
888 * @param[in] sensor_data_length - Length of sensor_data
889 * @param[out] present_op_state - The sensorOperationalState value from the
890 * state change that triggered the event message
891 * @param[out] previous_op_state - The sensorOperationalState value for the
892 * state from which the present state was entered
893 * @return pldm_completion_codes
894 * @note Caller is responsible for memory alloc and dealloc of param
895 * 'sensor_data'
896 */
897int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
898 uint8_t *present_op_state,
899 uint8_t *previous_op_state);
900
901/** @brief Decode stateSensorState response data
902 *
903 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
904 * @param[in] sensor_data_length - Length of sensor_data
905 * @param[out] sensor_offset - Identifies which state sensor within a composite
906 * state sensor the event is being returned for
907 * @param[out] event_state - The event state value from the state change that
908 * triggered the event message
909 * @param[out] previous_event_state - The event state value for the state from
910 * which the present event state was entered
911 * @return pldm_completion_codes
912 * @note Caller is responsible for memory alloc and dealloc of param
913 * 'sensor_data'
914 */
915int decode_state_sensor_data(const uint8_t *sensor_data,
916 size_t sensor_data_length, uint8_t *sensor_offset,
917 uint8_t *event_state,
918 uint8_t *previous_event_state);
919
920/** @brief Decode numericSensorState response data
921 *
922 * @param[in] sensor_data - sensor_data for sensorEventClass =
923 * numericSensorState
924 * @param[in] sensor_data_length - Length of sensor_data
925 * @param[out] event_state - The eventState value from the state change that
926 * triggered the event message
927 * @param[out] previous_event_state - The eventState value for the state from
928 * which the present state was entered
929 * @param[out] sensor_data_size - The bit width and format of reading and
930 * threshold values that the sensor returns
931 * @param[out] present_reading - The present value indicated by the sensor
932 * @return pldm_completion_codes
933 * @note Caller is responsible for memory alloc and dealloc of param
934 * 'sensor_data'
935 */
936int decode_numeric_sensor_data(const uint8_t *sensor_data,
937 size_t sensor_data_length, uint8_t *event_state,
938 uint8_t *previous_event_state,
939 uint8_t *sensor_data_size,
940 uint32_t *present_reading);
941
Jolie Ku6787f172020-03-19 11:15:53 +0800942/* GetNumericEffecterValue */
943
944/** @brief Create a PLDM request message for GetNumericEffecterValue
945 *
946 * @param[in] instance_id - Message's instance id
947 * @param[in] effecter_id - used to identify and access the effecter
948 * @param[out] msg - Message will be written to this
949 * @return pldm_completion_codes
950 * @note Caller is responsible for memory alloc and dealloc of param
951 * 'msg.payload'
952 */
953int encode_get_numeric_effecter_value_req(uint8_t instance_id,
954 uint16_t effecter_id,
955 struct pldm_msg *msg);
956
957/** @brief Create a PLDM response message for GetNumericEffecterValue
958 *
959 * @param[in] msg - Request message
960 * @param[in] payload_length - Length of request message payload
961 * @param[out] completion_code - PLDM completion code
962 * @param[out] effecter_data_size - The bit width and format of the setting
963 * value for the effecter.
964 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
965 * @param[out] effecter_oper_state - The state of the effecter itself
966 * @param[out] pending_value - The pending numeric value setting of the
967 * effecter. The effecterDataSize field indicates the number of
968 * bits used for this field
969 * @param[out] present_value - The present numeric value setting of the
970 * effecter. The effecterDataSize indicates the number of bits
971 * used for this field
972 * @return pldm_completion_codes
973 */
974int decode_get_numeric_effecter_value_resp(
975 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
976 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
977 uint8_t *pending_value, uint8_t *present_value);
978
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500979#ifdef __cplusplus
980}
981#endif
982
983#endif /* PLATFORM_H */