blob: 3fc8ab3973c49308b00be4c318ab4f71ba67fa8c [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
Jolie Kuf798c8f2020-04-14 11:18:06 +080018#define PLDM_GET_SENSOR_READING_REQ_BYTES 4
Sampa Misra0db1dfa2019-03-19 00:15:31 -050019/* Response lengths are inclusive of completion code */
20#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080021#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050022
George Liu30b859f2020-01-07 15:03:22 +080023#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
24#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
25
Sampa Misra7fcfb662019-05-08 13:13:53 -050026#define PLDM_GET_PDR_REQ_BYTES 13
27/* Minimum response length */
28#define PLDM_GET_PDR_MIN_RESP_BYTES 12
Jolie Ku6787f172020-03-19 11:15:53 +080029#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
Jolie Kuf798c8f2020-04-14 11:18:06 +080030#define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8
Sampa Misra7fcfb662019-05-08 13:13:53 -050031
Zahed Hossaind4abab12020-02-06 03:36:43 -060032/* Minimum length for PLDM PlatformEventMessage request */
33#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
34#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
Tom Joseph56e45c52020-03-16 10:01:45 +053035#define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2
Zahed Hossaind4abab12020-02-06 03:36:43 -060036
Zahed Hossain1c861712020-03-04 08:55:19 -060037/* Minumum length of senson event data */
38#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
39#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
40#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
41#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
42#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
43#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
44#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
45#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
46
Zahed Hossain9be087c2020-04-02 02:26:41 -050047/* Minimum length of data for pldmPDRRepositoryChgEvent */
48#define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2
49#define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2
50
George Liu30b859f2020-01-07 15:03:22 +080051enum pldm_effecter_data_size {
52 PLDM_EFFECTER_DATA_SIZE_UINT8,
53 PLDM_EFFECTER_DATA_SIZE_SINT8,
54 PLDM_EFFECTER_DATA_SIZE_UINT16,
55 PLDM_EFFECTER_DATA_SIZE_SINT16,
56 PLDM_EFFECTER_DATA_SIZE_UINT32,
57 PLDM_EFFECTER_DATA_SIZE_SINT32
58};
59
Sampa Misra0db1dfa2019-03-19 00:15:31 -050060enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
61
62enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
63
Jolie Ku3557bad2020-03-02 16:22:57 +080064enum sensor_operational_state {
65 ENABLED = 0x00,
66 DISABLED = 0x01,
67 UNAVAILABLE = 0x02,
68 STATUSUNKNOWN = 0x03,
69 FAILED = 0x04,
70 INITIALIZING = 0x05,
71 SHUTTINGDOWN = 0x06,
72 INTEST = 0x07
73};
74
75enum present_state {
76 UNKNOWN = 0x0,
77 NORMAL = 0x01,
78 WARNING = 0x02,
79 CRITICAL = 0x03,
80 FATAL = 0x04,
81 LOWERWARNING = 0x05,
82 LOWERCRITICAL = 0x06,
83 LOWERFATAL = 0x07,
84 UPPERWARNING = 0x08,
85 UPPERCRITICAL = 0x09,
86 UPPERFATAL = 0x0a
87};
88
Jolie Kuf798c8f2020-04-14 11:18:06 +080089enum pldm_sensor_event_message_enable {
90 PLDM_NO_EVENT_GENERATION,
91 PLDM_EVENTS_DISABLED,
92 PLDM_EVENTS_ENABLED,
93 PLDM_OP_EVENTS_ONLY_ENABLED,
94 PLDM_STATE_EVENTS_ONLY_ENABLED
95};
96
Jolie Ku6787f172020-03-19 11:15:53 +080097enum pldm_effecter_oper_state {
98 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
99 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
100 EFFECTER_OPER_STATE_DISABLED,
101 EFFECTER_OPER_STATE_UNAVAILABLE,
102 EFFECTER_OPER_STATE_STATUSUNKNOWN,
103 EFFECTER_OPER_STATE_FAILED,
104 EFFECTER_OPER_STATE_INITIALIZING,
105 EFFECTER_OPER_STATE_SHUTTINGDOWN,
106 EFFECTER_OPER_STATE_INTEST
107};
108
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500109enum pldm_platform_commands {
Jolie Kuf798c8f2020-04-14 11:18:06 +0800110 PLDM_GET_SENSOR_READING = 0x11,
Jolie Ku3557bad2020-03-02 16:22:57 +0800111 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +0800112 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +0800113 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500114 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -0500115 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600116 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500117};
118
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500119/** @brief PLDM PDR types
120 */
121enum pldm_pdr_types {
122 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500123 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600124 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500125};
126
127/** @brief PLDM effecter initialization schemes
128 */
129enum pldm_effecter_init {
130 PLDM_NO_INIT,
131 PLDM_USE_INIT_PDR,
132 PLDM_ENABLE_EFFECTER,
133 PLDM_DISABLE_EFECTER
134};
135
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530136/** @brief PLDM Platform M&C completion codes
137 */
138enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500139 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
140 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500141
142 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
143 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530144 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500145 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
146 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
147
Sampa Misraa2fa0702019-05-31 01:28:55 -0500148 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530149};
150
Zahed Hossaind4abab12020-02-06 03:36:43 -0600151/** @brief PLDM Event types
152 */
153enum pldm_event_types {
154 PLDM_SENSOR_EVENT = 0x00,
155 PLDM_EFFECTER_EVENT = 0x01,
156 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
157 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
158 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
159 PLDM_MESSAGE_POLL_EVENT = 0x05,
160 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
161};
162
163/** @brief PLDM sensorEventClass states
164 */
165enum sensor_event_class_states {
166 PLDM_SENSOR_OP_STATE,
167 PLDM_STATE_SENSOR_STATE,
168 PLDM_NUMERIC_SENSOR_STATE
169};
170
171/** @brief PLDM sensor supported states
172 */
173enum pldm_sensor_operational_state {
174 PLDM_SENSOR_ENABLED,
175 PLDM_SENSOR_DISABLED,
176 PLDM_SENSOR_UNAVAILABLE,
177 PLDM_SENSOR_STATUSUNKOWN,
178 PLDM_SENSOR_FAILED,
179 PLDM_SENSOR_INITIALIZING,
180 PLDM_SENSOR_SHUTTINGDOWN,
181 PLDM_SENSOR_INTEST
182};
183
184/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
185 */
186enum pldm_pdr_repository_chg_event_data_format {
187 REFRESH_ENTIRE_REPOSITORY,
188 FORMAT_IS_PDR_TYPES,
189 FORMAT_IS_PDR_HANDLES
190};
191
Zahed Hossain9be087c2020-04-02 02:26:41 -0500192/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
193 * eventDataOperation
194 */
195enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
196 PLDM_REFRESH_ALL_RECORDS,
197 PLDM_RECORDS_DELETED,
198 PLDM_RECORDS_ADDED,
199 PLDM_RECORDS_MODIFIED
200};
201
Zahed Hossain1c861712020-03-04 08:55:19 -0600202/** @brief PLDM NumericSensorStatePresentReading data type
203 */
204enum pldm_sensor_readings_data_type {
205 PLDM_SENSOR_DATA_SIZE_UINT8,
206 PLDM_SENSOR_DATA_SIZE_SINT8,
207 PLDM_SENSOR_DATA_SIZE_UINT16,
208 PLDM_SENSOR_DATA_SIZE_SINT16,
209 PLDM_SENSOR_DATA_SIZE_UINT32,
210 PLDM_SENSOR_DATA_SIZE_SINT32
211};
212
Tom Joseph56e45c52020-03-16 10:01:45 +0530213/** @brief PLDM PlatformEventMessage response status
214 */
215enum pldm_platform_event_status {
216 PLDM_EVENT_NO_LOGGING = 0x00,
217 PLDM_EVENT_LOGGING_DISABLED = 0x01,
218 PLDM_EVENT_LOG_FULL = 0x02,
219 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
220 PLDM_EVENT_LOGGED = 0x04,
221 PLDM_EVENT_LOGGING_REJECTED = 0x05
222};
223
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500224/** @struct pldm_pdr_hdr
225 *
226 * Structure representing PLDM common PDR header
227 */
228struct pldm_pdr_hdr {
229 uint32_t record_handle;
230 uint8_t version;
231 uint8_t type;
232 uint16_t record_change_num;
233 uint16_t length;
234} __attribute__((packed));
235
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500236/** @struct pldm_pdr_entity_association
237 *
238 * Structure representing PLDM Entity Association PDR
239 */
240struct pldm_pdr_entity_association {
241 uint16_t container_id;
242 uint8_t association_type;
243 pldm_entity container;
244 uint8_t num_children;
245 pldm_entity children[1];
246} __attribute__((packed));
247
Deepak Kodihallidb914672020-02-07 02:47:45 -0600248/** @struct pldm_pdr_fru_record_set
249 *
250 * Structure representing PLDM FRU record set PDR
251 */
252struct pldm_pdr_fru_record_set {
253 uint16_t terminus_handle;
254 uint16_t fru_rsi;
255 uint16_t entity_type;
256 uint16_t entity_instance_num;
257 uint16_t container_id;
258} __attribute__((packed));
259
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500260/** @struct pldm_state_effecter_pdr
261 *
262 * Structure representing PLDM state effecter PDR
263 */
264struct pldm_state_effecter_pdr {
265 struct pldm_pdr_hdr hdr;
266 uint16_t terminus_handle;
267 uint16_t effecter_id;
268 uint16_t entity_type;
269 uint16_t entity_instance;
270 uint16_t container_id;
271 uint16_t effecter_semantic_id;
272 uint8_t effecter_init;
273 bool8_t has_description_pdr;
274 uint8_t composite_effecter_count;
275 uint8_t possible_states[1];
276} __attribute__((packed));
277
278/** @struct state_effecter_possible_states
279 *
280 * Structure representing state enums for state effecter
281 */
282struct state_effecter_possible_states {
283 uint16_t state_set_id;
284 uint8_t possible_states_size;
285 bitfield8_t states[1];
286} __attribute__((packed));
287
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500288/** @struct set_effecter_state_field
289 *
290 * Structure representing a stateField in SetStateEffecterStates command */
291
292typedef struct state_field_for_state_effecter_set {
293 uint8_t set_request; //!< Whether to change the state
294 uint8_t effecter_state; //!< Expected state of the effecter
295} __attribute__((packed)) set_effecter_state_field;
296
Jolie Ku3557bad2020-03-02 16:22:57 +0800297/** @struct get_sensor_readings_field
298 *
299 * Structure representing a stateField in GetStateSensorReadings command */
300
301typedef struct state_field_for_get_state_sensor_readings {
302 uint8_t sensor_op_state; //!< The state of the sensor itself
303 uint8_t present_state; //!< Return a state value
304 uint8_t previous_state; //!< The state that the presentState was entered
305 //! from. This must be different from the
306 //! present state
307 uint8_t event_state; //!< Return a state value from a PLDM State Set
308 //! that is associated with the sensor
309} __attribute__((packed)) get_sensor_state_field;
310
Priyanga7257fdf2019-06-10 01:59:45 -0500311/** @struct PLDM_SetStateEffecterStates_Request
312 *
313 * Structure representing PLDM set state effecter states request.
314 */
315struct pldm_set_state_effecter_states_req {
316 uint16_t effecter_id;
317 uint8_t comp_effecter_count;
318 set_effecter_state_field field[8];
319} __attribute__((packed));
320
Sampa Misra7fcfb662019-05-08 13:13:53 -0500321/** @struct pldm_get_pdr_resp
322 *
323 * structure representing GetPDR response packet
324 * transfer CRC is not part of the structure and will be
325 * added at the end of last packet in multipart transfer
326 */
327struct pldm_get_pdr_resp {
328 uint8_t completion_code;
329 uint32_t next_record_handle;
330 uint32_t next_data_transfer_handle;
331 uint8_t transfer_flag;
332 uint16_t response_count;
333 uint8_t record_data[1];
334} __attribute__((packed));
335
336/** @struct pldm_get_pdr_req
337 *
338 * structure representing GetPDR request packet
339 */
340struct pldm_get_pdr_req {
341 uint32_t record_handle;
342 uint32_t data_transfer_handle;
343 uint8_t transfer_op_flag;
344 uint16_t request_count;
345 uint16_t record_change_number;
346} __attribute__((packed));
347
George Liu30b859f2020-01-07 15:03:22 +0800348/** @struct pldm_set_numeric_effecter_value_req
349 *
350 * structure representing SetNumericEffecterValue request packet
351 */
352struct pldm_set_numeric_effecter_value_req {
353 uint16_t effecter_id;
354 uint8_t effecter_data_size;
355 uint8_t effecter_value[1];
356} __attribute__((packed));
357
Jolie Ku3557bad2020-03-02 16:22:57 +0800358/** @struct pldm_get_state_sensor_readings_req
359 *
360 * Structure representing PLDM get state sensor readings request.
361 */
362struct pldm_get_state_sensor_readings_req {
363 uint16_t sensor_id;
364 bitfield8_t sensor_rearm;
365 uint8_t reserved;
366} __attribute__((packed));
367
368/** @struct pldm_get_state_sensor_readings_resp
369 *
370 * Structure representing PLDM get state sensor readings response.
371 */
372struct pldm_get_state_sensor_readings_resp {
373 uint8_t completion_code;
374 uint8_t comp_sensor_count;
375 get_sensor_state_field field[1];
376} __attribute__((packed));
377
Zahed Hossaind4abab12020-02-06 03:36:43 -0600378/** @struct pldm_sensor_event
379 *
380 * structure representing sensorEventClass
381 */
382struct pldm_sensor_event_data {
383 uint16_t sensor_id;
384 uint8_t sensor_event_class_type;
385 uint8_t event_class[1];
386} __attribute__((packed));
387
388/** @struct pldm_state_sensor_state
389 *
390 * structure representing sensorEventClass for stateSensorState
391 */
392struct pldm_sensor_event_state_sensor_state {
393 uint8_t sensor_offset;
394 uint8_t event_state;
395 uint8_t previous_event_state;
396} __attribute__((packed));
397
398/** @struct pldm_sensor_event_numeric_sensor_state
399 *
400 * structure representing sensorEventClass for stateSensorState
401 */
402struct pldm_sensor_event_numeric_sensor_state {
403 uint8_t event_state;
404 uint8_t previous_event_state;
405 uint8_t sensor_data_size;
406 uint8_t present_reading[1];
407} __attribute__((packed));
408
409/** @struct pldm_sensor_event_sensor_op_state
410 *
411 * structure representing sensorEventClass for SensorOpState
412 */
413struct pldm_sensor_event_sensor_op_state {
414 uint8_t present_op_state;
415 uint8_t previous_op_state;
416} __attribute__((packed));
417
418/** @struct pldm_platform_event_message_req
419 *
420 * structure representing PlatformEventMessage command request data
421 */
422struct pldm_platform_event_message_req {
423 uint8_t format_version;
424 uint8_t tid;
425 uint8_t event_class;
426 uint8_t event_data[1];
427} __attribute__((packed));
428
429/** @struct pldm_platform_event_message_response
430 *
431 * structure representing PlatformEventMessage command response data
432 */
433struct pldm_platform_event_message_resp {
434 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500435 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600436} __attribute__((packed));
437
438/** @struct pldm_pdr_repository_chg_event_data
439 *
440 * structure representing pldmPDRRepositoryChgEvent class eventData
441 */
442struct pldm_pdr_repository_chg_event_data {
443 uint8_t event_data_format;
444 uint8_t number_of_change_records;
445 uint8_t change_records[1];
446} __attribute__((packed));
447
448/** @struct pldm_pdr_repository_chg_event_change_record_data
449 *
450 * structure representing pldmPDRRepositoryChgEvent class eventData's change
451 * record data
452 */
453struct pldm_pdr_repository_change_record_data {
454 uint8_t event_data_operation;
455 uint8_t number_of_change_entries;
456 uint32_t change_entry[1];
457} __attribute__((packed));
458
Jolie Ku6787f172020-03-19 11:15:53 +0800459/** @struct pldm_get_numeric_effecter_value_req
460 *
461 * structure representing GetNumericEffecterValue request packet
462 */
463struct pldm_get_numeric_effecter_value_req {
464 uint16_t effecter_id;
465} __attribute__((packed));
466
467/** @struct pldm_get_numeric_effecter_value_resp
468 *
469 * structure representing GetNumericEffecterValue response packet
470 */
471struct pldm_get_numeric_effecter_value_resp {
472 uint8_t completion_code;
473 uint8_t effecter_data_size;
474 uint8_t effecter_oper_state;
475 uint8_t pending_and_present_values[1];
476} __attribute__((packed));
477
Jolie Kuf798c8f2020-04-14 11:18:06 +0800478/** @struct pldm_get_sensor_reading_req
479 *
480 * Structure representing PLDM get sensor reading request
481 */
482struct pldm_get_sensor_reading_req {
483 uint16_t sensor_id;
484 bool8_t rearm_event_state;
485} __attribute__((packed));
486
487/** @struct pldm_get_sensor_reading_resp
488 *
489 * Structure representing PLDM get sensor reading response
490 */
491struct pldm_get_sensor_reading_resp {
492 uint8_t completion_code;
493 uint8_t sensor_data_size;
494 uint8_t sensor_operational_state;
495 uint8_t sensor_event_message_enable;
496 uint8_t present_state;
497 uint8_t previous_state;
498 uint8_t event_state;
499 uint8_t present_reading[1];
500} __attribute__((packed));
501
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500502/* Responder */
503
George Liu30b859f2020-01-07 15:03:22 +0800504/* SetNumericEffecterValue */
505
506/** @brief Decode SetNumericEffecterValue request data
507 *
508 * @param[in] msg - Request message
509 * @param[in] payload_length - Length of request message payload
510 * @param[out] effecter_id - used to identify and access the effecter
511 * @param[out] effecter_data_size - The bit width and format of the setting
512 * value for the effecter.
513 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
514 * @param[out] effecter_value - The setting value of numeric effecter being
515 * requested.
516 * @return pldm_completion_codes
517 */
518int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
519 size_t payload_length,
520 uint16_t *effecter_id,
521 uint8_t *effecter_data_size,
522 uint8_t *effecter_value);
523
524/** @brief Create a PLDM response message for SetNumericEffecterValue
525 *
526 * @param[in] instance_id - Message's instance id
527 * @param[in] completion_code - PLDM completion code
528 * @param[out] msg - Message will be written to this
529 * @param[in] payload_length - Length of request message payload
530 * @return pldm_completion_codes
531 * @note Caller is responsible for memory alloc and dealloc of param
532 * 'msg.body.payload'
533 */
534int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
535 uint8_t completion_code,
536 struct pldm_msg *msg,
537 size_t payload_length);
538
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500539/* SetStateEffecterStates */
540
541/** @brief Create a PLDM response message for SetStateEffecterStates
542 *
543 * @param[in] instance_id - Message's instance id
544 * @param[in] completion_code - PLDM completion code
545 * @param[out] msg - Message will be written to this
546 * @return pldm_completion_codes
547 * @note Caller is responsible for memory alloc and dealloc of param
548 * 'msg.body.payload'
549 */
550
551int encode_set_state_effecter_states_resp(uint8_t instance_id,
552 uint8_t completion_code,
553 struct pldm_msg *msg);
554
555/** @brief Decode SetStateEffecterStates request data
556 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500557 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500558 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500559 * @param[out] effecter_id - used to identify and access the effecter
560 * @param[out] comp_effecter_count - number of individual sets of effecter
561 * information. Upto eight sets of state effecter info can be accessed
562 * for a given effecter.
563 * @param[out] field - each unit is an instance of the stateFileld structure
564 * that is used to set the requested state for a particular effecter
565 * within the state effecter. This field holds the starting address of
566 * the stateField values. The user is responsible to allocate the
567 * memory prior to calling this command. Since the state field count is
568 * not known in advance, the user should allocate the maximum size
569 * always, which is 8 in number.
570 * @return pldm_completion_codes
571 */
vkaverapa6575b82019-04-03 05:33:52 -0500572
Zahed Hossain223a73d2019-07-04 12:46:18 -0500573int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500574 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500575 uint16_t *effecter_id,
576 uint8_t *comp_effecter_count,
577 set_effecter_state_field *field);
578
Sampa Misra7fcfb662019-05-08 13:13:53 -0500579/* GetPDR */
580
581/** @brief Create a PLDM response message for GetPDR
582 *
583 * @param[in] instance_id - Message's instance id
584 * @param[in] completion_code - PLDM completion code
585 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
586 * the PDR Repository
587 * @param[in] next_data_transfer_hndl - A handle that identifies the next
588 * portion of the PDR data to be transferred, if any
589 * @param[in] transfer_flag - Indicates the portion of PDR data being
590 * transferred
591 * @param[in] resp_cnt - The number of recordData bytes returned in this
592 * response
593 * @param[in] record_data - PDR data bytes of length resp_cnt
594 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
595 * in the last part of a PDR being transferred
596 * @param[out] msg - Message will be written to this
597 * @return pldm_completion_codes
598 * @note Caller is responsible for memory alloc and dealloc of param
599 * 'msg.payload'
600 */
601int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
602 uint32_t next_record_hndl,
603 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
604 uint16_t resp_cnt, const uint8_t *record_data,
605 uint8_t transfer_crc, struct pldm_msg *msg);
606
607/** @brief Decode GetPDR request data
608 *
609 * @param[in] msg - Request message
610 * @param[in] payload_length - Length of request message payload
611 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
612 * @param[out] data_transfer_hndl - Handle used to identify a particular
613 * multipart PDR data transfer operation
614 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
615 * portion of transfer
616 * @param[out] request_cnt - The maximum number of record bytes requested
617 * @param[out] record_chg_num - Used to determine whether the PDR has changed
618 * while PDR transfer is going on
619 * @return pldm_completion_codes
620 */
621
622int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
623 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
624 uint8_t *transfer_op_flag, uint16_t *request_cnt,
625 uint16_t *record_chg_num);
626
Jolie Ku3557bad2020-03-02 16:22:57 +0800627/* GetStateSensorReadings */
628
629/** @brief Decode GetStateSensorReadings request data
630 *
631 * @param[in] msg - Request message
632 * @param[in] payload_length - Length of request message payload
633 * @param[out] sensor_id - used to identify and access the simple or composite
634 * sensor
635 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
636 * particular sensor within the state sensor, where bit [0] corresponds
637 * to the first state sensor (sensor offset 0) and bit [7] corresponds
638 * to the eighth sensor (sensor offset 7), sequentially.
639 * @param[out] reserved - value: 0x00
640 * @return pldm_completion_codes
641 */
642
643int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
644 size_t payload_length,
645 uint16_t *sensor_id,
646 bitfield8_t *sensor_rearm,
647 uint8_t *reserved);
648
649/** @brief Encode GetStateSensorReadings response data
650 *
651 * @param[in] instance_id - Message's instance id
652 * @param[in] completion_code - PLDM completion code
653 * @param[out] comp_sensor_count - The number of individual sets of sensor
654 * information that this command accesses
655 * @param[out] field - Each stateField is an instance of a stateField structure
656 * that is used to return the present operational state setting and the
657 * present state and event state for a particular set of sensor
658 * information contained within the state sensor
659 * @param[out] msg - Message will be written to this
660 * @return pldm_completion_codes
661 */
662
663int encode_get_state_sensor_readings_resp(uint8_t instance_id,
664 uint8_t completion_code,
665 uint8_t comp_sensor_count,
666 get_sensor_state_field *field,
667 struct pldm_msg *msg);
668
Jolie Ku6787f172020-03-19 11:15:53 +0800669/* GetNumericEffecterValue */
670
671/** @brief Decode GetNumericEffecterValue request data
672 *
673 * @param[in] msg - Request message
674 * @param[in] payload_length - Length of request message payload
675 * @param[out] effecter_id - used to identify and access the effecter
676 * @return pldm_completion_codes
677 */
678int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
679 size_t payload_length,
680 uint16_t *effecter_id);
681
682/** @brief Create a PLDM response message for GetNumericEffecterValue
683 *
684 * @param[in] instance_id - Message's instance id
685 * @param[in] completion_code - PLDM completion code
686 * @param[in] effecter_data_size - The bit width and format of the setting
687 * value for the effecter.
688 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
689 * @param[in] effecter_oper_state - The state of the effecter itself
690 * @param[in] pending_value - The pending numeric value setting of the
691 * effecter. The effecterDataSize field indicates the number of
692 * bits used for this field
693 * @param[in] present_value - The present numeric value setting of the
694 * effecter. The effecterDataSize indicates the number of bits
695 * used for this field
696 * @param[out] msg - Message will be written to this
697 * @param[in] payload_length - Length of request message payload
698 * @return pldm_completion_codes
699 * @note Caller is responsible for memory alloc and dealloc of param
700 * 'msg.payload'
701 */
702int encode_get_numeric_effecter_value_resp(
703 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
704 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
705 struct pldm_msg *msg, size_t payload_length);
706
Jolie Kuf798c8f2020-04-14 11:18:06 +0800707/* GetSensorReading */
708
709/** @brief Decode GetSensorReading request data
710 *
711 * @param[in] msg - Request message
712 * @param[in] payload_length - Length of request message payload
713 * @param[out] sensor_id - A handle that is used to identify and access
714 * the sensor
715 * @param[out] rearm_event_state - true = manually re-arm EventState after
716 * responding to this request, false = no manual re-arm
717 * @return pldm_completion_codes
718 */
719
720int decode_get_sensor_reading_req(const struct pldm_msg *msg,
721 size_t payload_length, uint16_t *sensor_id,
722 bool8_t *rearm_event_state);
723
724/** @brief Encode GetSensorReading response data
725 *
726 * @param[in] instance_id - Message's instance id
727 * @param[in] completion_code - PLDM completion code
728 * @param[out] sensor_data_size - The bit width and format of reading and
729 * threshold values
730 * @param[out] sensor_operational_state - The state of the sensor itself
731 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
732 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
733 * stateEventsOnlyEnabled }
734 * @param[out] present_state - The most recently assessed state value monitored
735 * by the sensor
736 * @param[out] previous_state - The state that the presentState was entered
737 * from
738 * @param[out] event_state - Indicates which threshold crossing assertion
739 * events have been detected
740 * @param[out] present_reading - The present value indicated by the sensor
741 * @param[out] msg - Message will be written to this
742 * @param[in] payload_length - Length of request message payload
743 * @return pldm_completion_codes
744 */
745
746int encode_get_sensor_reading_resp(
747 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
748 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
749 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
750 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
751
Sampa Misra7fcfb662019-05-08 13:13:53 -0500752/* Requester */
753
George Liu820a9a52019-11-26 14:43:59 +0800754/* GetPDR */
755
756/** @brief Create a PLDM request message for GetPDR
757 *
758 * @param[in] instance_id - Message's instance id
759 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
760 * @param[in] data_transfer_hndl - Handle used to identify a particular
761 * multipart PDR data transfer operation
762 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
763 * portion of transfer
764 * @param[in] request_cnt - The maximum number of record bytes requested
765 * @param[in] record_chg_num - Used to determine whether the PDR has changed
766 * while PDR transfer is going on
767 * @param[out] msg - Message will be written to this
768 * @param[in] payload_length - Length of request message payload
769 * @return pldm_completion_codes
770 * @note Caller is responsible for memory alloc and dealloc of param
771 * 'msg.payload'
772 */
773int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
774 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
775 uint16_t request_cnt, uint16_t record_chg_num,
776 struct pldm_msg *msg, size_t payload_length);
777
778/** @brief Decode GetPDR response data
779 *
George Liu684a7162019-12-06 15:10:52 +0800780 * Note:
781 * * If the return value is not PLDM_SUCCESS, it represents a
782 * transport layer error.
783 * * If the completion_code value is not PLDM_SUCCESS, it represents a
784 * protocol layer error and all the out-parameters are invalid.
785 *
George Liu820a9a52019-11-26 14:43:59 +0800786 * @param[in] msg - Request message
787 * @param[in] payload_length - Length of request message payload
788 * @param[out] completion_code - PLDM completion code
789 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
790 * the PDR Repository
791 * @param[out] next_data_transfer_hndl - A handle that identifies the next
792 * portion of the PDR data to be transferred, if any
793 * @param[out] transfer_flag - Indicates the portion of PDR data being
794 * transferred
795 * @param[out] resp_cnt - The number of recordData bytes returned in this
796 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500797 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
798 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800799 * @param[in] record_data_length - Length of record_data
800 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
801 * in the last part of a PDR being transferred
802 * @return pldm_completion_codes
803 */
804int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
805 uint8_t *completion_code, uint32_t *next_record_hndl,
806 uint32_t *next_data_transfer_hndl,
807 uint8_t *transfer_flag, uint16_t *resp_cnt,
808 uint8_t *record_data, size_t record_data_length,
809 uint8_t *transfer_crc);
810
Sampa Misra7fcfb662019-05-08 13:13:53 -0500811/* SetStateEffecterStates */
812
vkaverap98a2c192019-04-03 05:33:52 -0500813/** @brief Create a PLDM request message for SetStateEffecterStates
814 *
815 * @param[in] instance_id - Message's instance id
816 * @param[in] effecter_id - used to identify and access the effecter
817 * @param[in] comp_effecter_count - number of individual sets of effecter
818 * information. Upto eight sets of state effecter info can be accessed
819 * for a given effecter.
820 * @param[in] field - each unit is an instance of the stateField structure
821 * that is used to set the requested state for a particular effecter
822 * within the state effecter. This field holds the starting address of
823 * the stateField values. The user is responsible to allocate the
824 * memory prior to calling this command. The user has to allocate the
825 * field parameter as sizeof(set_effecter_state_field) *
826 * comp_effecter_count
827 * @param[out] msg - Message will be written to this
828 * @return pldm_completion_codes
829 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500830 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500831 */
832
833int encode_set_state_effecter_states_req(uint8_t instance_id,
834 uint16_t effecter_id,
835 uint8_t comp_effecter_count,
836 set_effecter_state_field *field,
837 struct pldm_msg *msg);
838
839/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800840 *
841 * Note:
842 * * If the return value is not PLDM_SUCCESS, it represents a
843 * transport layer error.
844 * * If the completion_code value is not PLDM_SUCCESS, it represents a
845 * protocol layer error and all the out-parameters are invalid.
846 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500847 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500848 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500849 * @param[out] completion_code - PLDM completion code
850 * @return pldm_completion_codes
851 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500852int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500853 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500854 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800855
856/* SetNumericEffecterValue */
857
858/** @brief Create a PLDM request message for SetNumericEffecterValue
859 *
860 * @param[in] instance_id - Message's instance id
861 * @param[in] effecter_id - used to identify and access the effecter
862 * @param[in] effecter_data_size - The bit width and format of the setting
863 * value for the effecter.
864 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
865 * @param[in] effecter_value - The setting value of numeric effecter being
866 * requested.
867 * @param[in] payload_length - Length of request message payload
868 * @param[out] msg - Message will be written to this
869 * @return pldm_completion_codes
870 * @note Caller is responsible for memory alloc and dealloc of param
871 * 'msg.payload'
872 */
873int encode_set_numeric_effecter_value_req(
874 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
875 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
876
877/** @brief Decode SetNumericEffecterValue response data
878 * @param[in] msg - Request message
879 * @param[in] payload_length - Length of response message payload
880 * @param[out] completion_code - PLDM completion code
881 * @return pldm_completion_codes
882 */
883int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
884 size_t payload_length,
885 uint8_t *completion_code);
886
Jolie Ku3557bad2020-03-02 16:22:57 +0800887/** @brief Create a PLDM request message for GetStateSensorReadings
888 *
889 * @param[in] instance_id - Message's instance id
890 * @param[in] sensor_id - used to identify and access the simple or composite
891 * sensor
892 * @param[in] sensorRearm - Each bit location in this field corresponds to a
893 * particular sensor within the state sensor, where bit [0] corresponds
894 * to the first state sensor (sensor offset 0) and bit [7] corresponds
895 * to the eighth sensor (sensor offset 7), sequentially
896 * @param[in] reserved - value: 0x00
897 * @param[out] msg - Message will be written to this
898 * @return pldm_completion_codes
899 * @note Caller is responsible for memory alloc and dealloc of param
900 * 'msg.payload'
901 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800902int encode_get_state_sensor_readings_req(uint8_t instance_id,
903 uint16_t sensor_id,
904 bitfield8_t sensor_rearm,
905 uint8_t reserved,
906 struct pldm_msg *msg);
907
908/** @brief Decode GetStateSensorReadings response data
909 *
910 * @param[in] msg - Request message
911 * @param[in] payload_length - Length of response message payload
912 * @param[out] completion_code - PLDM completion code
913 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
914 * information that this command accesses
915 * @param[out] field - Each stateField is an instance of a stateField structure
916 * that is used to return the present operational state setting and the
917 * present state and event state for a particular set of sensor
918 * information contained within the state sensor
919 * @return pldm_completion_codes
920 */
921
922int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
923 size_t payload_length,
924 uint8_t *completion_code,
925 uint8_t *comp_sensor_count,
926 get_sensor_state_field *field);
927
Zahed Hossaind4abab12020-02-06 03:36:43 -0600928/* PlatformEventMessage */
929
930/** @brief Decode PlatformEventMessage request data
931 * @param[in] msg - Request message
932 * @param[in] payload_length - Length of response message payload
933 * @param[out] format_version - Version of the event format
934 * @param[out] tid - Terminus ID for the terminus that originated the event
935 * message
936 * @param[out] event_class - The class of event being sent
937 * @param[out] event_data_offset - Offset where the event data should be read
938 * from pldm msg
939 * @return pldm_completion_codes
940 */
941int decode_platform_event_message_req(const struct pldm_msg *msg,
942 size_t payload_length,
943 uint8_t *format_version, uint8_t *tid,
944 uint8_t *event_class,
945 size_t *event_data_offset);
946
947/** @brief Encode PlatformEventMessage response data
948 * @param[in] instance_id - Message's instance id
949 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500950 * @param[in] platform_event_status - Response status of the event message
951 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -0600952 * @param[out] msg - Message will be written to this
953 * @return pldm_completion_codes
954 * @note Caller is responsible for memory alloc and dealloc of param
955 * 'msg.payload'
956 */
957int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500958 uint8_t completion_code,
959 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600960 struct pldm_msg *msg);
961
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -0500962/** @brief Encode PlatformEventMessage request data
963 * @param[in] instance_id - Message's instance id
964 * @param[in] format_version - Version of the event format
965 * @param[in] tid - Terminus ID for the terminus that originated the event
966 * message
967 * @param[in] event_class - The class of event being sent
968 * @param[in] event_data - the event data should be read from pldm msg
969 * @param[in] event_data_length - Length of the event data
970 * @param[out] msg - Request message
971 * @return pldm_completion_codes
972 * @note Caller is responsible for memory alloc and dealloc of param
973 * 'msg.payload'
974 */
975int encode_platform_event_message_req(uint8_t instance_id,
976 uint8_t format_version, uint8_t tid,
977 uint8_t event_class,
978 const uint8_t *event_data,
979 size_t event_data_length,
980 struct pldm_msg *msg);
981
982/** @brief Decode PlatformEventMessage response data
983 * @param[in] msg - Request message
984 * @param[in] payload_length - Length of Response message payload
985 * @param[out] completion_code - PLDM completion code
986 * @param[out] platform_event_status - Response status of the event message
987 * command
988 * @return pldm_completion_codes
989 */
990int decode_platform_event_message_resp(const struct pldm_msg *msg,
991 size_t payload_length,
992 uint8_t *completion_code,
993 uint8_t *platform_event_status);
994
Zahed Hossain1c861712020-03-04 08:55:19 -0600995/** @brief Decode sensorEventData response data
996 *
997 * @param[in] event_data - event data from the response message
998 * @param[in] event_data_length - length of the event data
999 * @param[out] sensor_id - sensorID value of the sensor
1000 * @param[out] sensor_event_class_type - Type of sensor event class
1001 * @param[out] event_class_data_offset - Offset where the event class data
1002 * should be read from event data
1003 * @return pldm_completion_codes
1004 * @note Caller is responsible for memory alloc and dealloc of param
1005 * 'event_data'
1006 */
1007int decode_sensor_event_data(const uint8_t *event_data,
1008 size_t event_data_length, uint16_t *sensor_id,
1009 uint8_t *sensor_event_class_type,
1010 size_t *event_class_data_offset);
1011
1012/** @brief Decode sensorOpState response data
1013 *
1014 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1015 * @param[in] sensor_data_length - Length of sensor_data
1016 * @param[out] present_op_state - The sensorOperationalState value from the
1017 * state change that triggered the event message
1018 * @param[out] previous_op_state - The sensorOperationalState value for the
1019 * state from which the present state was entered
1020 * @return pldm_completion_codes
1021 * @note Caller is responsible for memory alloc and dealloc of param
1022 * 'sensor_data'
1023 */
1024int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1025 uint8_t *present_op_state,
1026 uint8_t *previous_op_state);
1027
1028/** @brief Decode stateSensorState response data
1029 *
1030 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1031 * @param[in] sensor_data_length - Length of sensor_data
1032 * @param[out] sensor_offset - Identifies which state sensor within a composite
1033 * state sensor the event is being returned for
1034 * @param[out] event_state - The event state value from the state change that
1035 * triggered the event message
1036 * @param[out] previous_event_state - The event state value for the state from
1037 * which the present event state was entered
1038 * @return pldm_completion_codes
1039 * @note Caller is responsible for memory alloc and dealloc of param
1040 * 'sensor_data'
1041 */
1042int decode_state_sensor_data(const uint8_t *sensor_data,
1043 size_t sensor_data_length, uint8_t *sensor_offset,
1044 uint8_t *event_state,
1045 uint8_t *previous_event_state);
1046
1047/** @brief Decode numericSensorState response data
1048 *
1049 * @param[in] sensor_data - sensor_data for sensorEventClass =
1050 * numericSensorState
1051 * @param[in] sensor_data_length - Length of sensor_data
1052 * @param[out] event_state - The eventState value from the state change that
1053 * triggered the event message
1054 * @param[out] previous_event_state - The eventState value for the state from
1055 * which the present state was entered
1056 * @param[out] sensor_data_size - The bit width and format of reading and
1057 * threshold values that the sensor returns
1058 * @param[out] present_reading - The present value indicated by the sensor
1059 * @return pldm_completion_codes
1060 * @note Caller is responsible for memory alloc and dealloc of param
1061 * 'sensor_data'
1062 */
1063int decode_numeric_sensor_data(const uint8_t *sensor_data,
1064 size_t sensor_data_length, uint8_t *event_state,
1065 uint8_t *previous_event_state,
1066 uint8_t *sensor_data_size,
1067 uint32_t *present_reading);
1068
Jolie Ku6787f172020-03-19 11:15:53 +08001069/* GetNumericEffecterValue */
1070
1071/** @brief Create a PLDM request message for GetNumericEffecterValue
1072 *
1073 * @param[in] instance_id - Message's instance id
1074 * @param[in] effecter_id - used to identify and access the effecter
1075 * @param[out] msg - Message will be written to this
1076 * @return pldm_completion_codes
1077 * @note Caller is responsible for memory alloc and dealloc of param
1078 * 'msg.payload'
1079 */
1080int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1081 uint16_t effecter_id,
1082 struct pldm_msg *msg);
1083
1084/** @brief Create a PLDM response message for GetNumericEffecterValue
1085 *
1086 * @param[in] msg - Request message
1087 * @param[in] payload_length - Length of request message payload
1088 * @param[out] completion_code - PLDM completion code
1089 * @param[out] effecter_data_size - The bit width and format of the setting
1090 * value for the effecter.
1091 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1092 * @param[out] effecter_oper_state - The state of the effecter itself
1093 * @param[out] pending_value - The pending numeric value setting of the
1094 * effecter. The effecterDataSize field indicates the number of
1095 * bits used for this field
1096 * @param[out] present_value - The present numeric value setting of the
1097 * effecter. The effecterDataSize indicates the number of bits
1098 * used for this field
1099 * @return pldm_completion_codes
1100 */
1101int decode_get_numeric_effecter_value_resp(
1102 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1103 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1104 uint8_t *pending_value, uint8_t *present_value);
1105
Zahed Hossain9be087c2020-04-02 02:26:41 -05001106/** @brief Decode pldmPDRRepositoryChgEvent response data
1107 *
1108 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1109 * @param[in] event_data_size - Length of event_data
1110 * @param[out] event_data_format - This field indicates if the changedRecords
1111 * are of PDR Types or PDR Record Handles
1112 * @param[out] number_of_change_records - The number of changeRecords following
1113 * this field
1114 * @param[out] change_record_data_offset - Identifies where changeRecord data
1115 * is located within event_data
1116 * @return pldm_completion_codes
1117 * @note Caller is responsible for memory alloc and dealloc of param
1118 * 'event_data'
1119 */
1120int decode_pldm_pdr_repository_chg_event_data(
1121 const uint8_t *event_data, size_t event_data_size,
1122 uint8_t *event_data_format, uint8_t *number_of_change_records,
1123 size_t *change_record_data_offset);
1124
1125/** @brief Decode PldmPDRRepositoryChangeRecord response data
1126 *
1127 * @param[in] change_record_data - changeRecordData for
1128 * pldmPDRRepositoryChgEvent
1129 * @param[in] change_record_data_size - Length of change_record_data
1130 * @param[out] event_data_operation - This field indicates the changeEntries
1131 * operation types
1132 * @param[out] number_of_change_entries - The number of changeEntries following
1133 * this field
1134 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1135 * is located within change_record_data
1136 * @return pldm_completion_codes
1137 * @note Caller is responsible for memory alloc and dealloc of param
1138 * 'change_record_data'
1139 */
1140int decode_pldm_pdr_repository_change_record_data(
1141 const uint8_t *change_record_data, size_t change_record_data_size,
1142 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1143 size_t *change_entry_data_offset);
1144
Jolie Kuf798c8f2020-04-14 11:18:06 +08001145/* GetSensorReading */
1146
1147/** @brief Encode GetSensorReading request data
1148 *
1149 * @param[in] instance_id - Message's instance id
1150 * @param[in] sensor_id - A handle that is used to identify and access the
1151 * sensor
1152 * @param[in] rearm_event_state - true = manually re-arm EventState after
1153 * responding to this request, false = no manual re-arm
1154 * @param[out] msg - Message will be written to this
1155 * @return pldm_completion_codes
1156 * @note Caller is responsible for memory alloc and dealloc of param
1157 * 'msg.payload'
1158 */
1159int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1160 bool8_t rearm_event_state,
1161 struct pldm_msg *msg);
1162
1163/** @brief Decode GetSensorReading response data
1164 *
1165 * @param[in] msg - Request message
1166 * @param[in] payload_length - Length of response message payload
1167 * @param[out] completion_code - PLDM completion code
1168 * @param[out] sensor_data_size - The bit width and format of reading and
1169 * threshold values
1170 * @param[out] sensor_operational_state - The state of the sensor itself
1171 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1172 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1173 * stateEventsOnlyEnabled }
1174 * @param[out] present_state - The most recently assessed state value monitored
1175 * by the sensor
1176 * @param[out] previous_state - The state that the presentState was entered
1177 * from
1178 * @param[out] event_state - Indicates which threshold crossing assertion
1179 * events have been detected
1180 * @param[out] present_reading - The present value indicated by the sensor
1181 * @return pldm_completion_codes
1182 */
1183
1184int decode_get_sensor_reading_resp(
1185 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1186 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1187 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1188 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1189
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001190#ifdef __cplusplus
1191}
1192#endif
1193
1194#endif /* PLATFORM_H */