blob: 649189d2335b1370fcba2058c3a0c895b48a051d [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
George Liu456c9a22020-01-13 11:36:22 +080060enum pldm_range_field_format {
61 PLDM_RANGE_FIELD_FORMAT_UINT8,
62 PLDM_RANGE_FIELD_FORMAT_SINT8,
63 PLDM_RANGE_FIELD_FORMAT_UINT16,
64 PLDM_RANGE_FIELD_FORMAT_SINT16,
65 PLDM_RANGE_FIELD_FORMAT_UINT32,
66 PLDM_RANGE_FIELD_FORMAT_SINT32,
67 PLDM_RANGE_FIELD_FORMAT_REAL32
68};
69
Sampa Misra0db1dfa2019-03-19 00:15:31 -050070enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
71
72enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
73
Jolie Ku3557bad2020-03-02 16:22:57 +080074enum sensor_operational_state {
75 ENABLED = 0x00,
76 DISABLED = 0x01,
77 UNAVAILABLE = 0x02,
78 STATUSUNKNOWN = 0x03,
79 FAILED = 0x04,
80 INITIALIZING = 0x05,
81 SHUTTINGDOWN = 0x06,
82 INTEST = 0x07
83};
84
85enum present_state {
86 UNKNOWN = 0x0,
87 NORMAL = 0x01,
88 WARNING = 0x02,
89 CRITICAL = 0x03,
90 FATAL = 0x04,
91 LOWERWARNING = 0x05,
92 LOWERCRITICAL = 0x06,
93 LOWERFATAL = 0x07,
94 UPPERWARNING = 0x08,
95 UPPERCRITICAL = 0x09,
96 UPPERFATAL = 0x0a
97};
98
Jolie Kuf798c8f2020-04-14 11:18:06 +080099enum pldm_sensor_event_message_enable {
100 PLDM_NO_EVENT_GENERATION,
101 PLDM_EVENTS_DISABLED,
102 PLDM_EVENTS_ENABLED,
103 PLDM_OP_EVENTS_ONLY_ENABLED,
104 PLDM_STATE_EVENTS_ONLY_ENABLED
105};
106
Jolie Ku6787f172020-03-19 11:15:53 +0800107enum pldm_effecter_oper_state {
108 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
109 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
110 EFFECTER_OPER_STATE_DISABLED,
111 EFFECTER_OPER_STATE_UNAVAILABLE,
112 EFFECTER_OPER_STATE_STATUSUNKNOWN,
113 EFFECTER_OPER_STATE_FAILED,
114 EFFECTER_OPER_STATE_INITIALIZING,
115 EFFECTER_OPER_STATE_SHUTTINGDOWN,
116 EFFECTER_OPER_STATE_INTEST
117};
118
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500119enum pldm_platform_commands {
Jolie Kuf798c8f2020-04-14 11:18:06 +0800120 PLDM_GET_SENSOR_READING = 0x11,
Jolie Ku3557bad2020-03-02 16:22:57 +0800121 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +0800122 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +0800123 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500124 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -0500125 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600126 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500127};
128
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500129/** @brief PLDM PDR types
130 */
131enum pldm_pdr_types {
Tom Josephb4268602020-04-17 17:20:45 +0530132 PLDM_STATE_SENSOR_PDR = 4,
George Liu456c9a22020-01-13 11:36:22 +0800133 PLDM_NUMERIC_EFFECTER_PDR = 9,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500134 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500135 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600136 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500137};
138
139/** @brief PLDM effecter initialization schemes
140 */
141enum pldm_effecter_init {
142 PLDM_NO_INIT,
143 PLDM_USE_INIT_PDR,
144 PLDM_ENABLE_EFFECTER,
145 PLDM_DISABLE_EFECTER
146};
147
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530148/** @brief PLDM Platform M&C completion codes
149 */
150enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500151 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
152 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Zach Clark76728752020-03-31 10:44:09 -0500153
154 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
155 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530156 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500157 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
158 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
159
Sampa Misraa2fa0702019-05-31 01:28:55 -0500160 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530161};
162
Zahed Hossaind4abab12020-02-06 03:36:43 -0600163/** @brief PLDM Event types
164 */
165enum pldm_event_types {
166 PLDM_SENSOR_EVENT = 0x00,
167 PLDM_EFFECTER_EVENT = 0x01,
168 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
169 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
170 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
171 PLDM_MESSAGE_POLL_EVENT = 0x05,
172 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
173};
174
175/** @brief PLDM sensorEventClass states
176 */
177enum sensor_event_class_states {
178 PLDM_SENSOR_OP_STATE,
179 PLDM_STATE_SENSOR_STATE,
180 PLDM_NUMERIC_SENSOR_STATE
181};
182
183/** @brief PLDM sensor supported states
184 */
185enum pldm_sensor_operational_state {
186 PLDM_SENSOR_ENABLED,
187 PLDM_SENSOR_DISABLED,
188 PLDM_SENSOR_UNAVAILABLE,
189 PLDM_SENSOR_STATUSUNKOWN,
190 PLDM_SENSOR_FAILED,
191 PLDM_SENSOR_INITIALIZING,
192 PLDM_SENSOR_SHUTTINGDOWN,
193 PLDM_SENSOR_INTEST
194};
195
196/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
197 */
198enum pldm_pdr_repository_chg_event_data_format {
199 REFRESH_ENTIRE_REPOSITORY,
200 FORMAT_IS_PDR_TYPES,
201 FORMAT_IS_PDR_HANDLES
202};
203
Zahed Hossain9be087c2020-04-02 02:26:41 -0500204/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
205 * eventDataOperation
206 */
207enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
208 PLDM_REFRESH_ALL_RECORDS,
209 PLDM_RECORDS_DELETED,
210 PLDM_RECORDS_ADDED,
211 PLDM_RECORDS_MODIFIED
212};
213
Zahed Hossain1c861712020-03-04 08:55:19 -0600214/** @brief PLDM NumericSensorStatePresentReading data type
215 */
216enum pldm_sensor_readings_data_type {
217 PLDM_SENSOR_DATA_SIZE_UINT8,
218 PLDM_SENSOR_DATA_SIZE_SINT8,
219 PLDM_SENSOR_DATA_SIZE_UINT16,
220 PLDM_SENSOR_DATA_SIZE_SINT16,
221 PLDM_SENSOR_DATA_SIZE_UINT32,
222 PLDM_SENSOR_DATA_SIZE_SINT32
223};
224
Tom Joseph56e45c52020-03-16 10:01:45 +0530225/** @brief PLDM PlatformEventMessage response status
226 */
227enum pldm_platform_event_status {
228 PLDM_EVENT_NO_LOGGING = 0x00,
229 PLDM_EVENT_LOGGING_DISABLED = 0x01,
230 PLDM_EVENT_LOG_FULL = 0x02,
231 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
232 PLDM_EVENT_LOGGED = 0x04,
233 PLDM_EVENT_LOGGING_REJECTED = 0x05
234};
235
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500236/** @struct pldm_pdr_hdr
237 *
238 * Structure representing PLDM common PDR header
239 */
240struct pldm_pdr_hdr {
241 uint32_t record_handle;
242 uint8_t version;
243 uint8_t type;
244 uint16_t record_change_num;
245 uint16_t length;
246} __attribute__((packed));
247
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500248/** @struct pldm_pdr_entity_association
249 *
250 * Structure representing PLDM Entity Association PDR
251 */
252struct pldm_pdr_entity_association {
253 uint16_t container_id;
254 uint8_t association_type;
255 pldm_entity container;
256 uint8_t num_children;
257 pldm_entity children[1];
258} __attribute__((packed));
259
Deepak Kodihallidb914672020-02-07 02:47:45 -0600260/** @struct pldm_pdr_fru_record_set
261 *
262 * Structure representing PLDM FRU record set PDR
263 */
264struct pldm_pdr_fru_record_set {
265 uint16_t terminus_handle;
266 uint16_t fru_rsi;
267 uint16_t entity_type;
268 uint16_t entity_instance_num;
269 uint16_t container_id;
270} __attribute__((packed));
271
Tom Josephb4268602020-04-17 17:20:45 +0530272/** @struct pldm_state_sensor_pdr
273 *
274 * Structure representing PLDM state sensor PDR
275 */
276struct pldm_state_sensor_pdr {
277 struct pldm_pdr_hdr hdr;
278 uint16_t terminus_handle;
279 uint16_t sensor_id;
280 uint16_t entity_type;
281 uint16_t entity_instance;
282 uint16_t container_id;
283 uint8_t sensor_init;
284 bool8_t sensor_auxiliary_names_pdr;
285 uint8_t composite_sensor_count;
286 uint8_t possible_states[1];
287} __attribute__((packed));
288
289/** @struct state_sensor_possible_states
290 *
291 * Structure representing state enums for state sensor
292 */
293struct state_sensor_possible_states {
294 uint16_t state_set_id;
295 uint8_t possible_states_size;
296 bitfield8_t states[1];
297} __attribute__((packed));
298
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500299/** @struct pldm_state_effecter_pdr
300 *
301 * Structure representing PLDM state effecter PDR
302 */
303struct pldm_state_effecter_pdr {
304 struct pldm_pdr_hdr hdr;
305 uint16_t terminus_handle;
306 uint16_t effecter_id;
307 uint16_t entity_type;
308 uint16_t entity_instance;
309 uint16_t container_id;
310 uint16_t effecter_semantic_id;
311 uint8_t effecter_init;
312 bool8_t has_description_pdr;
313 uint8_t composite_effecter_count;
314 uint8_t possible_states[1];
315} __attribute__((packed));
316
George Liu456c9a22020-01-13 11:36:22 +0800317/** @union union_effecter_data_size
318 *
319 * The bit width and format of reading and threshold values that the effecter
320 * returns.
321 * Refer to: DSP0248_1.2.0: 28.11 Table 87
322 */
323typedef union {
324 uint8_t value_u8;
325 int8_t value_s8;
326 uint16_t value_u16;
327 int16_t value_s16;
328 uint32_t value_u32;
329 int32_t value_s32;
330} union_effecter_data_size;
331
332/** @union union_range_field_format
333 *
334 * Indicates the format used for the nominalValue, normalMax, and normalMin
335 * fields.
336 * Refer to: DSP0248_1.2.0: 28.11 Table 87
337 */
338typedef union {
339 uint8_t value_u8;
340 int8_t value_s8;
341 uint16_t value_u16;
342 int16_t value_s16;
343 uint32_t value_u32;
344 int32_t value_s32;
345 real32_t value_f32;
346} union_range_field_format;
347
348/** @struct pldm_numeric_effecter_value_pdr
349 *
350 * Structure representing PLDM numeric effecter value PDR
351 */
352struct pldm_numeric_effecter_value_pdr {
353 struct pldm_pdr_hdr hdr;
354 uint16_t terminus_handle;
355 uint16_t effecter_id;
356 uint16_t entity_type;
357 uint16_t entity_instance;
358 uint16_t container_id;
359 uint16_t effecter_semantic_id;
360 uint8_t effecter_init;
361 bool8_t effecter_auxiliary_names;
362 uint8_t base_unit;
363 int8_t unit_modifier;
364 uint8_t rate_unit;
365 uint8_t base_oem_unit_handle;
366 uint8_t aux_unit;
367 int8_t aux_unit_modifier;
368 uint8_t aux_rate_unit;
369 uint8_t aux_oem_unit_handle;
370 bool8_t is_linear;
371 uint8_t effecter_data_size;
372 real32_t resolution;
373 real32_t offset;
374 uint16_t accuracy;
375 uint8_t plus_tolerance;
376 uint8_t minus_tolerance;
377 real32_t state_transition_interval;
378 real32_t transition_interval;
379 union_effecter_data_size max_set_table;
380 union_effecter_data_size min_set_table;
381 uint8_t range_field_format;
382 bitfield8_t range_field_support;
383 union_range_field_format nominal_value;
384 union_range_field_format normal_max;
385 union_range_field_format normal_min;
386 union_range_field_format rated_max;
387 union_range_field_format rated_min;
388} __attribute__((packed));
389
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500390/** @struct state_effecter_possible_states
391 *
392 * Structure representing state enums for state effecter
393 */
394struct state_effecter_possible_states {
395 uint16_t state_set_id;
396 uint8_t possible_states_size;
397 bitfield8_t states[1];
398} __attribute__((packed));
399
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500400/** @struct set_effecter_state_field
401 *
402 * Structure representing a stateField in SetStateEffecterStates command */
403
404typedef struct state_field_for_state_effecter_set {
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500405 uint8_t set_request; //!< Whether to change the state
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500406 uint8_t effecter_state; //!< Expected state of the effecter
407} __attribute__((packed)) set_effecter_state_field;
408
Jolie Ku3557bad2020-03-02 16:22:57 +0800409/** @struct get_sensor_readings_field
410 *
411 * Structure representing a stateField in GetStateSensorReadings command */
412
413typedef struct state_field_for_get_state_sensor_readings {
414 uint8_t sensor_op_state; //!< The state of the sensor itself
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500415 uint8_t present_state; //!< Return a state value
Jolie Ku3557bad2020-03-02 16:22:57 +0800416 uint8_t previous_state; //!< The state that the presentState was entered
417 //! from. This must be different from the
418 //! present state
Deepak Kodihalli826c9d42020-05-26 01:58:06 -0500419 uint8_t event_state; //!< Return a state value from a PLDM State Set
Jolie Ku3557bad2020-03-02 16:22:57 +0800420 //! that is associated with the sensor
421} __attribute__((packed)) get_sensor_state_field;
422
Priyanga7257fdf2019-06-10 01:59:45 -0500423/** @struct PLDM_SetStateEffecterStates_Request
424 *
425 * Structure representing PLDM set state effecter states request.
426 */
427struct pldm_set_state_effecter_states_req {
428 uint16_t effecter_id;
429 uint8_t comp_effecter_count;
430 set_effecter_state_field field[8];
431} __attribute__((packed));
432
Sampa Misra7fcfb662019-05-08 13:13:53 -0500433/** @struct pldm_get_pdr_resp
434 *
435 * structure representing GetPDR response packet
436 * transfer CRC is not part of the structure and will be
437 * added at the end of last packet in multipart transfer
438 */
439struct pldm_get_pdr_resp {
440 uint8_t completion_code;
441 uint32_t next_record_handle;
442 uint32_t next_data_transfer_handle;
443 uint8_t transfer_flag;
444 uint16_t response_count;
445 uint8_t record_data[1];
446} __attribute__((packed));
447
448/** @struct pldm_get_pdr_req
449 *
450 * structure representing GetPDR request packet
451 */
452struct pldm_get_pdr_req {
453 uint32_t record_handle;
454 uint32_t data_transfer_handle;
455 uint8_t transfer_op_flag;
456 uint16_t request_count;
457 uint16_t record_change_number;
458} __attribute__((packed));
459
George Liu30b859f2020-01-07 15:03:22 +0800460/** @struct pldm_set_numeric_effecter_value_req
461 *
462 * structure representing SetNumericEffecterValue request packet
463 */
464struct pldm_set_numeric_effecter_value_req {
465 uint16_t effecter_id;
466 uint8_t effecter_data_size;
467 uint8_t effecter_value[1];
468} __attribute__((packed));
469
Jolie Ku3557bad2020-03-02 16:22:57 +0800470/** @struct pldm_get_state_sensor_readings_req
471 *
472 * Structure representing PLDM get state sensor readings request.
473 */
474struct pldm_get_state_sensor_readings_req {
475 uint16_t sensor_id;
476 bitfield8_t sensor_rearm;
477 uint8_t reserved;
478} __attribute__((packed));
479
480/** @struct pldm_get_state_sensor_readings_resp
481 *
482 * Structure representing PLDM get state sensor readings response.
483 */
484struct pldm_get_state_sensor_readings_resp {
485 uint8_t completion_code;
486 uint8_t comp_sensor_count;
487 get_sensor_state_field field[1];
488} __attribute__((packed));
489
Zahed Hossaind4abab12020-02-06 03:36:43 -0600490/** @struct pldm_sensor_event
491 *
492 * structure representing sensorEventClass
493 */
494struct pldm_sensor_event_data {
495 uint16_t sensor_id;
496 uint8_t sensor_event_class_type;
497 uint8_t event_class[1];
498} __attribute__((packed));
499
500/** @struct pldm_state_sensor_state
501 *
502 * structure representing sensorEventClass for stateSensorState
503 */
504struct pldm_sensor_event_state_sensor_state {
505 uint8_t sensor_offset;
506 uint8_t event_state;
507 uint8_t previous_event_state;
508} __attribute__((packed));
509
510/** @struct pldm_sensor_event_numeric_sensor_state
511 *
512 * structure representing sensorEventClass for stateSensorState
513 */
514struct pldm_sensor_event_numeric_sensor_state {
515 uint8_t event_state;
516 uint8_t previous_event_state;
517 uint8_t sensor_data_size;
518 uint8_t present_reading[1];
519} __attribute__((packed));
520
521/** @struct pldm_sensor_event_sensor_op_state
522 *
523 * structure representing sensorEventClass for SensorOpState
524 */
525struct pldm_sensor_event_sensor_op_state {
526 uint8_t present_op_state;
527 uint8_t previous_op_state;
528} __attribute__((packed));
529
530/** @struct pldm_platform_event_message_req
531 *
532 * structure representing PlatformEventMessage command request data
533 */
534struct pldm_platform_event_message_req {
535 uint8_t format_version;
536 uint8_t tid;
537 uint8_t event_class;
538 uint8_t event_data[1];
539} __attribute__((packed));
540
541/** @struct pldm_platform_event_message_response
542 *
543 * structure representing PlatformEventMessage command response data
544 */
545struct pldm_platform_event_message_resp {
546 uint8_t completion_code;
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -0500547 uint8_t platform_event_status;
Zahed Hossaind4abab12020-02-06 03:36:43 -0600548} __attribute__((packed));
549
550/** @struct pldm_pdr_repository_chg_event_data
551 *
552 * structure representing pldmPDRRepositoryChgEvent class eventData
553 */
554struct pldm_pdr_repository_chg_event_data {
555 uint8_t event_data_format;
556 uint8_t number_of_change_records;
557 uint8_t change_records[1];
558} __attribute__((packed));
559
560/** @struct pldm_pdr_repository_chg_event_change_record_data
561 *
562 * structure representing pldmPDRRepositoryChgEvent class eventData's change
563 * record data
564 */
565struct pldm_pdr_repository_change_record_data {
566 uint8_t event_data_operation;
567 uint8_t number_of_change_entries;
568 uint32_t change_entry[1];
569} __attribute__((packed));
570
Jolie Ku6787f172020-03-19 11:15:53 +0800571/** @struct pldm_get_numeric_effecter_value_req
572 *
573 * structure representing GetNumericEffecterValue request packet
574 */
575struct pldm_get_numeric_effecter_value_req {
576 uint16_t effecter_id;
577} __attribute__((packed));
578
579/** @struct pldm_get_numeric_effecter_value_resp
580 *
581 * structure representing GetNumericEffecterValue response packet
582 */
583struct pldm_get_numeric_effecter_value_resp {
584 uint8_t completion_code;
585 uint8_t effecter_data_size;
586 uint8_t effecter_oper_state;
587 uint8_t pending_and_present_values[1];
588} __attribute__((packed));
589
Jolie Kuf798c8f2020-04-14 11:18:06 +0800590/** @struct pldm_get_sensor_reading_req
591 *
592 * Structure representing PLDM get sensor reading request
593 */
594struct pldm_get_sensor_reading_req {
595 uint16_t sensor_id;
596 bool8_t rearm_event_state;
597} __attribute__((packed));
598
599/** @struct pldm_get_sensor_reading_resp
600 *
601 * Structure representing PLDM get sensor reading response
602 */
603struct pldm_get_sensor_reading_resp {
604 uint8_t completion_code;
605 uint8_t sensor_data_size;
606 uint8_t sensor_operational_state;
607 uint8_t sensor_event_message_enable;
608 uint8_t present_state;
609 uint8_t previous_state;
610 uint8_t event_state;
611 uint8_t present_reading[1];
612} __attribute__((packed));
613
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500614/* Responder */
615
George Liu30b859f2020-01-07 15:03:22 +0800616/* SetNumericEffecterValue */
617
618/** @brief Decode SetNumericEffecterValue request data
619 *
620 * @param[in] msg - Request message
621 * @param[in] payload_length - Length of request message payload
622 * @param[out] effecter_id - used to identify and access the effecter
623 * @param[out] effecter_data_size - The bit width and format of the setting
624 * value for the effecter.
625 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
626 * @param[out] effecter_value - The setting value of numeric effecter being
627 * requested.
628 * @return pldm_completion_codes
629 */
630int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
631 size_t payload_length,
632 uint16_t *effecter_id,
633 uint8_t *effecter_data_size,
634 uint8_t *effecter_value);
635
636/** @brief Create a PLDM response message for SetNumericEffecterValue
637 *
638 * @param[in] instance_id - Message's instance id
639 * @param[in] completion_code - PLDM completion code
640 * @param[out] msg - Message will be written to this
641 * @param[in] payload_length - Length of request message payload
642 * @return pldm_completion_codes
643 * @note Caller is responsible for memory alloc and dealloc of param
644 * 'msg.body.payload'
645 */
646int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
647 uint8_t completion_code,
648 struct pldm_msg *msg,
649 size_t payload_length);
650
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500651/* SetStateEffecterStates */
652
653/** @brief Create a PLDM response message for SetStateEffecterStates
654 *
655 * @param[in] instance_id - Message's instance id
656 * @param[in] completion_code - PLDM completion code
657 * @param[out] msg - Message will be written to this
658 * @return pldm_completion_codes
659 * @note Caller is responsible for memory alloc and dealloc of param
660 * 'msg.body.payload'
661 */
662
663int encode_set_state_effecter_states_resp(uint8_t instance_id,
664 uint8_t completion_code,
665 struct pldm_msg *msg);
666
667/** @brief Decode SetStateEffecterStates request data
668 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500669 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500670 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500671 * @param[out] effecter_id - used to identify and access the effecter
672 * @param[out] comp_effecter_count - number of individual sets of effecter
673 * information. Upto eight sets of state effecter info can be accessed
674 * for a given effecter.
675 * @param[out] field - each unit is an instance of the stateFileld structure
676 * that is used to set the requested state for a particular effecter
677 * within the state effecter. This field holds the starting address of
678 * the stateField values. The user is responsible to allocate the
679 * memory prior to calling this command. Since the state field count is
680 * not known in advance, the user should allocate the maximum size
681 * always, which is 8 in number.
682 * @return pldm_completion_codes
683 */
vkaverapa6575b82019-04-03 05:33:52 -0500684
Zahed Hossain223a73d2019-07-04 12:46:18 -0500685int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500686 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500687 uint16_t *effecter_id,
688 uint8_t *comp_effecter_count,
689 set_effecter_state_field *field);
690
Sampa Misra7fcfb662019-05-08 13:13:53 -0500691/* GetPDR */
692
693/** @brief Create a PLDM response message for GetPDR
694 *
695 * @param[in] instance_id - Message's instance id
696 * @param[in] completion_code - PLDM completion code
697 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
698 * the PDR Repository
699 * @param[in] next_data_transfer_hndl - A handle that identifies the next
700 * portion of the PDR data to be transferred, if any
701 * @param[in] transfer_flag - Indicates the portion of PDR data being
702 * transferred
703 * @param[in] resp_cnt - The number of recordData bytes returned in this
704 * response
705 * @param[in] record_data - PDR data bytes of length resp_cnt
706 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
707 * in the last part of a PDR being transferred
708 * @param[out] msg - Message will be written to this
709 * @return pldm_completion_codes
710 * @note Caller is responsible for memory alloc and dealloc of param
711 * 'msg.payload'
712 */
713int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
714 uint32_t next_record_hndl,
715 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
716 uint16_t resp_cnt, const uint8_t *record_data,
717 uint8_t transfer_crc, struct pldm_msg *msg);
718
719/** @brief Decode GetPDR request data
720 *
721 * @param[in] msg - Request message
722 * @param[in] payload_length - Length of request message payload
723 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
724 * @param[out] data_transfer_hndl - Handle used to identify a particular
725 * multipart PDR data transfer operation
726 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
727 * portion of transfer
728 * @param[out] request_cnt - The maximum number of record bytes requested
729 * @param[out] record_chg_num - Used to determine whether the PDR has changed
730 * while PDR transfer is going on
731 * @return pldm_completion_codes
732 */
733
734int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
735 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
736 uint8_t *transfer_op_flag, uint16_t *request_cnt,
737 uint16_t *record_chg_num);
738
Jolie Ku3557bad2020-03-02 16:22:57 +0800739/* GetStateSensorReadings */
740
741/** @brief Decode GetStateSensorReadings request data
742 *
743 * @param[in] msg - Request message
744 * @param[in] payload_length - Length of request message payload
745 * @param[out] sensor_id - used to identify and access the simple or composite
746 * sensor
747 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
748 * particular sensor within the state sensor, where bit [0] corresponds
749 * to the first state sensor (sensor offset 0) and bit [7] corresponds
750 * to the eighth sensor (sensor offset 7), sequentially.
751 * @param[out] reserved - value: 0x00
752 * @return pldm_completion_codes
753 */
754
755int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
756 size_t payload_length,
757 uint16_t *sensor_id,
758 bitfield8_t *sensor_rearm,
759 uint8_t *reserved);
760
761/** @brief Encode GetStateSensorReadings response data
762 *
763 * @param[in] instance_id - Message's instance id
764 * @param[in] completion_code - PLDM completion code
765 * @param[out] comp_sensor_count - The number of individual sets of sensor
766 * information that this command accesses
767 * @param[out] field - Each stateField is an instance of a stateField structure
768 * that is used to return the present operational state setting and the
769 * present state and event state for a particular set of sensor
770 * information contained within the state sensor
771 * @param[out] msg - Message will be written to this
772 * @return pldm_completion_codes
773 */
774
775int encode_get_state_sensor_readings_resp(uint8_t instance_id,
776 uint8_t completion_code,
777 uint8_t comp_sensor_count,
778 get_sensor_state_field *field,
779 struct pldm_msg *msg);
780
Jolie Ku6787f172020-03-19 11:15:53 +0800781/* GetNumericEffecterValue */
782
783/** @brief Decode GetNumericEffecterValue request data
784 *
785 * @param[in] msg - Request message
786 * @param[in] payload_length - Length of request message payload
787 * @param[out] effecter_id - used to identify and access the effecter
788 * @return pldm_completion_codes
789 */
790int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
791 size_t payload_length,
792 uint16_t *effecter_id);
793
794/** @brief Create a PLDM response message for GetNumericEffecterValue
795 *
796 * @param[in] instance_id - Message's instance id
797 * @param[in] completion_code - PLDM completion code
798 * @param[in] effecter_data_size - The bit width and format of the setting
799 * value for the effecter.
800 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
801 * @param[in] effecter_oper_state - The state of the effecter itself
802 * @param[in] pending_value - The pending numeric value setting of the
803 * effecter. The effecterDataSize field indicates the number of
804 * bits used for this field
805 * @param[in] present_value - The present numeric value setting of the
806 * effecter. The effecterDataSize indicates the number of bits
807 * used for this field
808 * @param[out] msg - Message will be written to this
809 * @param[in] payload_length - Length of request message payload
810 * @return pldm_completion_codes
811 * @note Caller is responsible for memory alloc and dealloc of param
812 * 'msg.payload'
813 */
814int encode_get_numeric_effecter_value_resp(
815 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
816 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
817 struct pldm_msg *msg, size_t payload_length);
818
Jolie Kuf798c8f2020-04-14 11:18:06 +0800819/* GetSensorReading */
820
821/** @brief Decode GetSensorReading request data
822 *
823 * @param[in] msg - Request message
824 * @param[in] payload_length - Length of request message payload
825 * @param[out] sensor_id - A handle that is used to identify and access
826 * the sensor
827 * @param[out] rearm_event_state - true = manually re-arm EventState after
828 * responding to this request, false = no manual re-arm
829 * @return pldm_completion_codes
830 */
831
832int decode_get_sensor_reading_req(const struct pldm_msg *msg,
833 size_t payload_length, uint16_t *sensor_id,
834 bool8_t *rearm_event_state);
835
836/** @brief Encode GetSensorReading response data
837 *
838 * @param[in] instance_id - Message's instance id
839 * @param[in] completion_code - PLDM completion code
840 * @param[out] sensor_data_size - The bit width and format of reading and
841 * threshold values
842 * @param[out] sensor_operational_state - The state of the sensor itself
843 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
844 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
845 * stateEventsOnlyEnabled }
846 * @param[out] present_state - The most recently assessed state value monitored
847 * by the sensor
848 * @param[out] previous_state - The state that the presentState was entered
849 * from
850 * @param[out] event_state - Indicates which threshold crossing assertion
851 * events have been detected
852 * @param[out] present_reading - The present value indicated by the sensor
853 * @param[out] msg - Message will be written to this
854 * @param[in] payload_length - Length of request message payload
855 * @return pldm_completion_codes
856 */
857
858int encode_get_sensor_reading_resp(
859 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
860 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
861 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
862 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
863
Sampa Misra7fcfb662019-05-08 13:13:53 -0500864/* Requester */
865
George Liu820a9a52019-11-26 14:43:59 +0800866/* GetPDR */
867
868/** @brief Create a PLDM request message for GetPDR
869 *
870 * @param[in] instance_id - Message's instance id
871 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
872 * @param[in] data_transfer_hndl - Handle used to identify a particular
873 * multipart PDR data transfer operation
874 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
875 * portion of transfer
876 * @param[in] request_cnt - The maximum number of record bytes requested
877 * @param[in] record_chg_num - Used to determine whether the PDR has changed
878 * while PDR transfer is going on
879 * @param[out] msg - Message will be written to this
880 * @param[in] payload_length - Length of request message payload
881 * @return pldm_completion_codes
882 * @note Caller is responsible for memory alloc and dealloc of param
883 * 'msg.payload'
884 */
885int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
886 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
887 uint16_t request_cnt, uint16_t record_chg_num,
888 struct pldm_msg *msg, size_t payload_length);
889
890/** @brief Decode GetPDR response data
891 *
George Liu684a7162019-12-06 15:10:52 +0800892 * Note:
893 * * If the return value is not PLDM_SUCCESS, it represents a
894 * transport layer error.
895 * * If the completion_code value is not PLDM_SUCCESS, it represents a
896 * protocol layer error and all the out-parameters are invalid.
897 *
George Liu820a9a52019-11-26 14:43:59 +0800898 * @param[in] msg - Request message
899 * @param[in] payload_length - Length of request message payload
900 * @param[out] completion_code - PLDM completion code
901 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
902 * the PDR Repository
903 * @param[out] next_data_transfer_hndl - A handle that identifies the next
904 * portion of the PDR data to be transferred, if any
905 * @param[out] transfer_flag - Indicates the portion of PDR data being
906 * transferred
907 * @param[out] resp_cnt - The number of recordData bytes returned in this
908 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500909 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
910 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800911 * @param[in] record_data_length - Length of record_data
912 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
913 * in the last part of a PDR being transferred
914 * @return pldm_completion_codes
915 */
916int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
917 uint8_t *completion_code, uint32_t *next_record_hndl,
918 uint32_t *next_data_transfer_hndl,
919 uint8_t *transfer_flag, uint16_t *resp_cnt,
920 uint8_t *record_data, size_t record_data_length,
921 uint8_t *transfer_crc);
922
Sampa Misra7fcfb662019-05-08 13:13:53 -0500923/* SetStateEffecterStates */
924
vkaverap98a2c192019-04-03 05:33:52 -0500925/** @brief Create a PLDM request message for SetStateEffecterStates
926 *
927 * @param[in] instance_id - Message's instance id
928 * @param[in] effecter_id - used to identify and access the effecter
929 * @param[in] comp_effecter_count - number of individual sets of effecter
930 * information. Upto eight sets of state effecter info can be accessed
931 * for a given effecter.
932 * @param[in] field - each unit is an instance of the stateField structure
933 * that is used to set the requested state for a particular effecter
934 * within the state effecter. This field holds the starting address of
935 * the stateField values. The user is responsible to allocate the
936 * memory prior to calling this command. The user has to allocate the
937 * field parameter as sizeof(set_effecter_state_field) *
938 * comp_effecter_count
939 * @param[out] msg - Message will be written to this
940 * @return pldm_completion_codes
941 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500942 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500943 */
944
945int encode_set_state_effecter_states_req(uint8_t instance_id,
946 uint16_t effecter_id,
947 uint8_t comp_effecter_count,
948 set_effecter_state_field *field,
949 struct pldm_msg *msg);
950
951/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800952 *
953 * Note:
954 * * If the return value is not PLDM_SUCCESS, it represents a
955 * transport layer error.
956 * * If the completion_code value is not PLDM_SUCCESS, it represents a
957 * protocol layer error and all the out-parameters are invalid.
958 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500959 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500960 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500961 * @param[out] completion_code - PLDM completion code
962 * @return pldm_completion_codes
963 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500964int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500965 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500966 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800967
968/* SetNumericEffecterValue */
969
970/** @brief Create a PLDM request message for SetNumericEffecterValue
971 *
972 * @param[in] instance_id - Message's instance id
973 * @param[in] effecter_id - used to identify and access the effecter
974 * @param[in] effecter_data_size - The bit width and format of the setting
975 * value for the effecter.
976 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
977 * @param[in] effecter_value - The setting value of numeric effecter being
978 * requested.
979 * @param[in] payload_length - Length of request message payload
980 * @param[out] msg - Message will be written to this
981 * @return pldm_completion_codes
982 * @note Caller is responsible for memory alloc and dealloc of param
983 * 'msg.payload'
984 */
985int encode_set_numeric_effecter_value_req(
986 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
987 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
988
989/** @brief Decode SetNumericEffecterValue response data
990 * @param[in] msg - Request message
991 * @param[in] payload_length - Length of response message payload
992 * @param[out] completion_code - PLDM completion code
993 * @return pldm_completion_codes
994 */
995int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
996 size_t payload_length,
997 uint8_t *completion_code);
998
Jolie Ku3557bad2020-03-02 16:22:57 +0800999/** @brief Create a PLDM request message for GetStateSensorReadings
1000 *
1001 * @param[in] instance_id - Message's instance id
1002 * @param[in] sensor_id - used to identify and access the simple or composite
1003 * sensor
1004 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1005 * particular sensor within the state sensor, where bit [0] corresponds
1006 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1007 * to the eighth sensor (sensor offset 7), sequentially
1008 * @param[in] reserved - value: 0x00
1009 * @param[out] msg - Message will be written to this
1010 * @return pldm_completion_codes
1011 * @note Caller is responsible for memory alloc and dealloc of param
1012 * 'msg.payload'
1013 */
Jolie Ku3557bad2020-03-02 16:22:57 +08001014int encode_get_state_sensor_readings_req(uint8_t instance_id,
1015 uint16_t sensor_id,
1016 bitfield8_t sensor_rearm,
1017 uint8_t reserved,
1018 struct pldm_msg *msg);
1019
1020/** @brief Decode GetStateSensorReadings response data
1021 *
1022 * @param[in] msg - Request message
1023 * @param[in] payload_length - Length of response message payload
1024 * @param[out] completion_code - PLDM completion code
1025 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1026 * information that this command accesses
1027 * @param[out] field - Each stateField is an instance of a stateField structure
1028 * that is used to return the present operational state setting and the
1029 * present state and event state for a particular set of sensor
1030 * information contained within the state sensor
1031 * @return pldm_completion_codes
1032 */
1033
1034int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1035 size_t payload_length,
1036 uint8_t *completion_code,
1037 uint8_t *comp_sensor_count,
1038 get_sensor_state_field *field);
1039
Zahed Hossaind4abab12020-02-06 03:36:43 -06001040/* PlatformEventMessage */
1041
1042/** @brief Decode PlatformEventMessage request data
1043 * @param[in] msg - Request message
1044 * @param[in] payload_length - Length of response message payload
1045 * @param[out] format_version - Version of the event format
1046 * @param[out] tid - Terminus ID for the terminus that originated the event
1047 * message
1048 * @param[out] event_class - The class of event being sent
1049 * @param[out] event_data_offset - Offset where the event data should be read
1050 * from pldm msg
1051 * @return pldm_completion_codes
1052 */
1053int decode_platform_event_message_req(const struct pldm_msg *msg,
1054 size_t payload_length,
1055 uint8_t *format_version, uint8_t *tid,
1056 uint8_t *event_class,
1057 size_t *event_data_offset);
1058
1059/** @brief Encode PlatformEventMessage response data
1060 * @param[in] instance_id - Message's instance id
1061 * @param[in] completion_code - PLDM completion code
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001062 * @param[in] platform_event_status - Response status of the event message
1063 * command
Zahed Hossaind4abab12020-02-06 03:36:43 -06001064 * @param[out] msg - Message will be written to this
1065 * @return pldm_completion_codes
1066 * @note Caller is responsible for memory alloc and dealloc of param
1067 * 'msg.payload'
1068 */
1069int encode_platform_event_message_resp(uint8_t instance_id,
Pavithra Barithaya2ea1f072020-04-03 09:30:23 -05001070 uint8_t completion_code,
1071 uint8_t platform_event_status,
Zahed Hossaind4abab12020-02-06 03:36:43 -06001072 struct pldm_msg *msg);
1073
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001074/** @brief Encode PlatformEventMessage request data
1075 * @param[in] instance_id - Message's instance id
1076 * @param[in] format_version - Version of the event format
1077 * @param[in] tid - Terminus ID for the terminus that originated the event
1078 * message
1079 * @param[in] event_class - The class of event being sent
1080 * @param[in] event_data - the event data should be read from pldm msg
1081 * @param[in] event_data_length - Length of the event data
1082 * @param[out] msg - Request message
1083 * @return pldm_completion_codes
1084 * @note Caller is responsible for memory alloc and dealloc of param
1085 * 'msg.payload'
1086 */
Christian Geddes3bdb3c22020-05-01 14:55:39 -05001087int encode_platform_event_message_req(
1088 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1089 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1090 struct pldm_msg *msg, size_t payload_length);
Pavithra Barithaya35f2b2c2020-04-08 01:35:56 -05001091
1092/** @brief Decode PlatformEventMessage response data
1093 * @param[in] msg - Request message
1094 * @param[in] payload_length - Length of Response message payload
1095 * @param[out] completion_code - PLDM completion code
1096 * @param[out] platform_event_status - Response status of the event message
1097 * command
1098 * @return pldm_completion_codes
1099 */
1100int decode_platform_event_message_resp(const struct pldm_msg *msg,
1101 size_t payload_length,
1102 uint8_t *completion_code,
1103 uint8_t *platform_event_status);
1104
Zahed Hossain1c861712020-03-04 08:55:19 -06001105/** @brief Decode sensorEventData response data
1106 *
1107 * @param[in] event_data - event data from the response message
1108 * @param[in] event_data_length - length of the event data
1109 * @param[out] sensor_id - sensorID value of the sensor
1110 * @param[out] sensor_event_class_type - Type of sensor event class
1111 * @param[out] event_class_data_offset - Offset where the event class data
1112 * should be read from event data
1113 * @return pldm_completion_codes
1114 * @note Caller is responsible for memory alloc and dealloc of param
1115 * 'event_data'
1116 */
1117int decode_sensor_event_data(const uint8_t *event_data,
1118 size_t event_data_length, uint16_t *sensor_id,
1119 uint8_t *sensor_event_class_type,
1120 size_t *event_class_data_offset);
1121
1122/** @brief Decode sensorOpState response data
1123 *
1124 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1125 * @param[in] sensor_data_length - Length of sensor_data
1126 * @param[out] present_op_state - The sensorOperationalState value from the
1127 * state change that triggered the event message
1128 * @param[out] previous_op_state - The sensorOperationalState value for the
1129 * state from which the present state was entered
1130 * @return pldm_completion_codes
1131 * @note Caller is responsible for memory alloc and dealloc of param
1132 * 'sensor_data'
1133 */
1134int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1135 uint8_t *present_op_state,
1136 uint8_t *previous_op_state);
1137
1138/** @brief Decode stateSensorState response data
1139 *
1140 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1141 * @param[in] sensor_data_length - Length of sensor_data
1142 * @param[out] sensor_offset - Identifies which state sensor within a composite
1143 * state sensor the event is being returned for
1144 * @param[out] event_state - The event state value from the state change that
1145 * triggered the event message
1146 * @param[out] previous_event_state - The event state value for the state from
1147 * which the present event state was entered
1148 * @return pldm_completion_codes
1149 * @note Caller is responsible for memory alloc and dealloc of param
1150 * 'sensor_data'
1151 */
1152int decode_state_sensor_data(const uint8_t *sensor_data,
1153 size_t sensor_data_length, uint8_t *sensor_offset,
1154 uint8_t *event_state,
1155 uint8_t *previous_event_state);
1156
1157/** @brief Decode numericSensorState response data
1158 *
1159 * @param[in] sensor_data - sensor_data for sensorEventClass =
1160 * numericSensorState
1161 * @param[in] sensor_data_length - Length of sensor_data
1162 * @param[out] event_state - The eventState value from the state change that
1163 * triggered the event message
1164 * @param[out] previous_event_state - The eventState value for the state from
1165 * which the present state was entered
1166 * @param[out] sensor_data_size - The bit width and format of reading and
1167 * threshold values that the sensor returns
1168 * @param[out] present_reading - The present value indicated by the sensor
1169 * @return pldm_completion_codes
1170 * @note Caller is responsible for memory alloc and dealloc of param
1171 * 'sensor_data'
1172 */
1173int decode_numeric_sensor_data(const uint8_t *sensor_data,
1174 size_t sensor_data_length, uint8_t *event_state,
1175 uint8_t *previous_event_state,
1176 uint8_t *sensor_data_size,
1177 uint32_t *present_reading);
1178
Jolie Ku6787f172020-03-19 11:15:53 +08001179/* GetNumericEffecterValue */
1180
1181/** @brief Create a PLDM request message for GetNumericEffecterValue
1182 *
1183 * @param[in] instance_id - Message's instance id
1184 * @param[in] effecter_id - used to identify and access the effecter
1185 * @param[out] msg - Message will be written to this
1186 * @return pldm_completion_codes
1187 * @note Caller is responsible for memory alloc and dealloc of param
1188 * 'msg.payload'
1189 */
1190int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1191 uint16_t effecter_id,
1192 struct pldm_msg *msg);
1193
1194/** @brief Create a PLDM response message for GetNumericEffecterValue
1195 *
1196 * @param[in] msg - Request message
1197 * @param[in] payload_length - Length of request message payload
1198 * @param[out] completion_code - PLDM completion code
1199 * @param[out] effecter_data_size - The bit width and format of the setting
1200 * value for the effecter.
1201 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1202 * @param[out] effecter_oper_state - The state of the effecter itself
1203 * @param[out] pending_value - The pending numeric value setting of the
1204 * effecter. The effecterDataSize field indicates the number of
1205 * bits used for this field
1206 * @param[out] present_value - The present numeric value setting of the
1207 * effecter. The effecterDataSize indicates the number of bits
1208 * used for this field
1209 * @return pldm_completion_codes
1210 */
1211int decode_get_numeric_effecter_value_resp(
1212 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1213 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1214 uint8_t *pending_value, uint8_t *present_value);
1215
Zahed Hossain9be087c2020-04-02 02:26:41 -05001216/** @brief Decode pldmPDRRepositoryChgEvent response data
1217 *
1218 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1219 * @param[in] event_data_size - Length of event_data
1220 * @param[out] event_data_format - This field indicates if the changedRecords
1221 * are of PDR Types or PDR Record Handles
1222 * @param[out] number_of_change_records - The number of changeRecords following
1223 * this field
1224 * @param[out] change_record_data_offset - Identifies where changeRecord data
1225 * is located within event_data
1226 * @return pldm_completion_codes
1227 * @note Caller is responsible for memory alloc and dealloc of param
1228 * 'event_data'
1229 */
1230int decode_pldm_pdr_repository_chg_event_data(
1231 const uint8_t *event_data, size_t event_data_size,
1232 uint8_t *event_data_format, uint8_t *number_of_change_records,
1233 size_t *change_record_data_offset);
1234
Zach Clark36ad1f52020-04-13 07:04:15 -05001235/** @brief Encode PLDM PDR Repository Change eventData
1236 * @param[in] event_data_format - Format of this event data (e.g.
1237 * FORMAT_IS_PDR_HANDLES)
1238 * @param[in] number_of_change_records - Number of changeRecords in this
1239 * eventData
1240 * @param[in] event_data_operations - Array of eventDataOperations
1241 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1242 * should contain number_of_change_records elements.
1243 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1244 * for each changeRecord in this eventData. This array should contain
1245 * number_of_change_records elements.
1246 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1247 * one array per changeRecord in this eventData. The toplevel array should
1248 * contain number_of_change_records elements. Each subarray [i] should
1249 * contain numbers_of_change_entries[i] elements.
1250 * @param[in] event_data - The eventData will be encoded into this. This entire
1251 * structure must be max_change_records_size long. It must be large enough
1252 * to accomodate the data to be encoded. The caller is responsible for
1253 * allocating and deallocating it, including the variable-size
1254 * 'event_data.change_records' field. If this parameter is NULL,
1255 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1256 * to reflect the required size of the structure.
1257 * @param[out] actual_change_records_size - The actual number of meaningful
1258 * encoded bytes in event_data. The caller can over-allocate memory and use
1259 * this output to determine the real size of the structure.
1260 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1261 * encoded message would be larger than this value, an error is returned.
1262 * @return pldm_completion_codes
1263 * @note Caller is responsible for memory alloc and dealloc of param
1264 * 'event_data.change_records'
1265 */
1266int encode_pldm_pdr_repository_chg_event_data(
1267 uint8_t event_data_format, uint8_t number_of_change_records,
1268 const uint8_t *event_data_operations,
1269 const uint8_t *numbers_of_change_entries,
1270 const uint32_t *const *change_entries,
1271 struct pldm_pdr_repository_chg_event_data *event_data,
1272 size_t *actual_change_records_size, size_t max_change_records_size);
1273
Zahed Hossain9be087c2020-04-02 02:26:41 -05001274/** @brief Decode PldmPDRRepositoryChangeRecord response data
1275 *
1276 * @param[in] change_record_data - changeRecordData for
1277 * pldmPDRRepositoryChgEvent
1278 * @param[in] change_record_data_size - Length of change_record_data
1279 * @param[out] event_data_operation - This field indicates the changeEntries
1280 * operation types
1281 * @param[out] number_of_change_entries - The number of changeEntries following
1282 * this field
1283 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1284 * is located within change_record_data
1285 * @return pldm_completion_codes
1286 * @note Caller is responsible for memory alloc and dealloc of param
1287 * 'change_record_data'
1288 */
1289int decode_pldm_pdr_repository_change_record_data(
1290 const uint8_t *change_record_data, size_t change_record_data_size,
1291 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1292 size_t *change_entry_data_offset);
1293
Jolie Kuf798c8f2020-04-14 11:18:06 +08001294/* GetSensorReading */
1295
1296/** @brief Encode GetSensorReading request data
1297 *
1298 * @param[in] instance_id - Message's instance id
1299 * @param[in] sensor_id - A handle that is used to identify and access the
1300 * sensor
1301 * @param[in] rearm_event_state - true = manually re-arm EventState after
1302 * responding to this request, false = no manual re-arm
1303 * @param[out] msg - Message will be written to this
1304 * @return pldm_completion_codes
1305 * @note Caller is responsible for memory alloc and dealloc of param
1306 * 'msg.payload'
1307 */
1308int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1309 bool8_t rearm_event_state,
1310 struct pldm_msg *msg);
1311
1312/** @brief Decode GetSensorReading response data
1313 *
1314 * @param[in] msg - Request message
1315 * @param[in] payload_length - Length of response message payload
1316 * @param[out] completion_code - PLDM completion code
1317 * @param[out] sensor_data_size - The bit width and format of reading and
1318 * threshold values
1319 * @param[out] sensor_operational_state - The state of the sensor itself
1320 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1321 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1322 * stateEventsOnlyEnabled }
1323 * @param[out] present_state - The most recently assessed state value monitored
1324 * by the sensor
1325 * @param[out] previous_state - The state that the presentState was entered
1326 * from
1327 * @param[out] event_state - Indicates which threshold crossing assertion
1328 * events have been detected
1329 * @param[out] present_reading - The present value indicated by the sensor
1330 * @return pldm_completion_codes
1331 */
1332
1333int decode_get_sensor_reading_resp(
1334 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1335 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1336 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1337 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1338
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001339#ifdef __cplusplus
1340}
1341#endif
1342
1343#endif /* PLATFORM_H */