blob: e03d8c2ef9a9b4168ce676815275e0c08cd84e40 [file] [log] [blame]
Andrew Jeffery9c766792022-08-10 23:12:49 +09301#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12#include "pdr.h"
13
14/* Maximum size for request */
15#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
16#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
17#define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
18#define PLDM_GET_SENSOR_READING_REQ_BYTES 3
19#define PLDM_SET_EVENT_RECEIVER_REQ_BYTES 5
20/* Response lengths are inclusive of completion code */
21#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
22
23#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
24#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
25
26#define PLDM_GET_PDR_REQ_BYTES 13
27
28#define PLDM_SET_EVENT_RECEIVER_RESP_BYTES 1
29/* Minimum response length */
30#define PLDM_GET_PDR_MIN_RESP_BYTES 12
31#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
32#define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8
33#define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES 2
34#define PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES 41
35
36/* Minimum length for PLDM PlatformEventMessage request */
37#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
38#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
39#define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2
40#define PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION 1
41
42/* Minumum length of senson event data */
43#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
44#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
45#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
46#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
47#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
48#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
49#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
50#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
51
52/* Minimum length of data for pldmPDRRepositoryChgEvent */
53#define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2
54#define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2
55
56#define PLDM_INVALID_EFFECTER_ID 0xFFFF
57#define PLDM_TID_RESERVED 0xFF
58
59enum pldm_effecter_data_size {
60 PLDM_EFFECTER_DATA_SIZE_UINT8,
61 PLDM_EFFECTER_DATA_SIZE_SINT8,
62 PLDM_EFFECTER_DATA_SIZE_UINT16,
63 PLDM_EFFECTER_DATA_SIZE_SINT16,
64 PLDM_EFFECTER_DATA_SIZE_UINT32,
65 PLDM_EFFECTER_DATA_SIZE_SINT32
66};
67
68enum pldm_range_field_format {
69 PLDM_RANGE_FIELD_FORMAT_UINT8,
70 PLDM_RANGE_FIELD_FORMAT_SINT8,
71 PLDM_RANGE_FIELD_FORMAT_UINT16,
72 PLDM_RANGE_FIELD_FORMAT_SINT16,
73 PLDM_RANGE_FIELD_FORMAT_UINT32,
74 PLDM_RANGE_FIELD_FORMAT_SINT32,
75 PLDM_RANGE_FIELD_FORMAT_REAL32
76};
77
78enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
79
80enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
81
82enum pldm_sensor_present_state {
83 PLDM_SENSOR_UNKNOWN = 0x0,
84 PLDM_SENSOR_NORMAL = 0x01,
85 PLDM_SENSOR_WARNING = 0x02,
86 PLDM_SENSOR_CRITICAL = 0x03,
87 PLDM_SENSOR_FATAL = 0x04,
88 PLDM_SENSOR_LOWERWARNING = 0x05,
89 PLDM_SENSOR_LOWERCRITICAL = 0x06,
90 PLDM_SENSOR_LOWERFATAL = 0x07,
91 PLDM_SENSOR_UPPERWARNING = 0x08,
92 PLDM_SENSOR_UPPERCRITICAL = 0x09,
93 PLDM_SENSOR_UPPERFATAL = 0x0a
94};
95
96enum pldm_sensor_event_message_enable {
97 PLDM_NO_EVENT_GENERATION,
98 PLDM_EVENTS_DISABLED,
99 PLDM_EVENTS_ENABLED,
100 PLDM_OP_EVENTS_ONLY_ENABLED,
101 PLDM_STATE_EVENTS_ONLY_ENABLED
102};
103
104enum pldm_effecter_oper_state {
105 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
106 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
107 EFFECTER_OPER_STATE_DISABLED,
108 EFFECTER_OPER_STATE_UNAVAILABLE,
109 EFFECTER_OPER_STATE_STATUSUNKNOWN,
110 EFFECTER_OPER_STATE_FAILED,
111 EFFECTER_OPER_STATE_INITIALIZING,
112 EFFECTER_OPER_STATE_SHUTTINGDOWN,
113 EFFECTER_OPER_STATE_INTEST
114};
115
116enum pldm_platform_commands {
117 PLDM_SET_EVENT_RECEIVER = 0x04,
118 PLDM_GET_SENSOR_READING = 0x11,
119 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
120 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
121 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
122 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
123 PLDM_GET_PDR_REPOSITORY_INFO = 0x50,
124 PLDM_GET_PDR = 0x51,
125 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
126};
127
128/** @brief PLDM PDR types
129 */
130enum pldm_pdr_types {
131 PLDM_TERMINUS_LOCATOR_PDR = 1,
132 PLDM_NUMERIC_SENSOR_PDR = 2,
133 PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3,
134 PLDM_STATE_SENSOR_PDR = 4,
135 PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5,
136 PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6,
137 PLDM_OEM_UNIT_PDR = 7,
138 PLDM_OEM_STATE_SET_PDR = 8,
139 PLDM_NUMERIC_EFFECTER_PDR = 9,
140 PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10,
141 PLDM_STATE_EFFECTER_PDR = 11,
142 PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12,
143 PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13,
144 PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14,
145 PLDM_PDR_ENTITY_ASSOCIATION = 15,
146 PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16,
147 PLDM_OEM_ENTITY_ID_PDR = 17,
148 PLDM_INTERRUPT_ASSOCIATION_PDR = 18,
149 PLDM_EVENT_LOG_PDR = 19,
150 PLDM_PDR_FRU_RECORD_SET = 20,
151 PLDM_OEM_DEVICE_PDR = 126,
152 PLDM_OEM_PDR = 127,
153};
154
155/** @brief PLDM effecter initialization schemes
156 */
157enum pldm_effecter_init {
158 PLDM_NO_INIT,
159 PLDM_USE_INIT_PDR,
160 PLDM_ENABLE_EFFECTER,
161 PLDM_DISABLE_EFECTER
162};
163
164/** @brief PLDM Platform M&C completion codes
165 */
166enum pldm_platform_completion_codes {
167 PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80,
168 PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81,
169
170 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
171 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
172
173 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
174 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
175 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
176 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
177 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
178
179 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
180
181 PLDM_PLATFORM_INVALID_PROTOCOL_TYPE = 0x80,
182 PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED = 0x81,
183 PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH = 0x82,
184};
185
186/** @brief PLDM Event types
187 */
188enum pldm_event_types {
189 PLDM_SENSOR_EVENT = 0x00,
190 PLDM_EFFECTER_EVENT = 0x01,
191 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
192 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
193 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
194 PLDM_MESSAGE_POLL_EVENT = 0x05,
195 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
196};
197
198/** @brief PLDM sensorEventClass states
199 */
200enum sensor_event_class_states {
201 PLDM_SENSOR_OP_STATE,
202 PLDM_STATE_SENSOR_STATE,
203 PLDM_NUMERIC_SENSOR_STATE
204};
205
206/** @brief PLDM sensor supported states
207 */
208enum pldm_sensor_operational_state {
209 PLDM_SENSOR_ENABLED,
210 PLDM_SENSOR_DISABLED,
211 PLDM_SENSOR_UNAVAILABLE,
212 PLDM_SENSOR_STATUSUNKOWN,
213 PLDM_SENSOR_FAILED,
214 PLDM_SENSOR_INITIALIZING,
215 PLDM_SENSOR_SHUTTINGDOWN,
216 PLDM_SENSOR_INTEST
217};
218
219/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
220 */
221enum pldm_pdr_repository_chg_event_data_format {
222 REFRESH_ENTIRE_REPOSITORY,
223 FORMAT_IS_PDR_TYPES,
224 FORMAT_IS_PDR_HANDLES
225};
226
227/** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
228 * eventDataOperation
229 */
230enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
231 PLDM_REFRESH_ALL_RECORDS,
232 PLDM_RECORDS_DELETED,
233 PLDM_RECORDS_ADDED,
234 PLDM_RECORDS_MODIFIED
235};
236
237/** @brief PLDM NumericSensorStatePresentReading data type
238 */
239enum pldm_sensor_readings_data_type {
240 PLDM_SENSOR_DATA_SIZE_UINT8,
241 PLDM_SENSOR_DATA_SIZE_SINT8,
242 PLDM_SENSOR_DATA_SIZE_UINT16,
243 PLDM_SENSOR_DATA_SIZE_SINT16,
244 PLDM_SENSOR_DATA_SIZE_UINT32,
245 PLDM_SENSOR_DATA_SIZE_SINT32
246};
247
248/** @brief PLDM PlatformEventMessage response status
249 */
250enum pldm_platform_event_status {
251 PLDM_EVENT_NO_LOGGING = 0x00,
252 PLDM_EVENT_LOGGING_DISABLED = 0x01,
253 PLDM_EVENT_LOG_FULL = 0x02,
254 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
255 PLDM_EVENT_LOGGED = 0x04,
256 PLDM_EVENT_LOGGING_REJECTED = 0x05
257};
258
259/** @brief PLDM Terminus Locator PDR validity
260 */
261enum pldm_terminus_locator_pdr_validity {
262 PLDM_TL_PDR_NOT_VALID,
263 PLDM_TL_PDR_VALID
264};
265
266/** @brief PLDM Terminus Locator type
267 */
268enum pldm_terminus_locator_type {
269 PLDM_TERMINUS_LOCATOR_TYPE_UID,
270 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID,
271 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE,
272 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW
273};
274
275/** @brief PLDM event message global enable for
276 * SetEventReceiver command
277 */
278enum pldm_event_message_global_enable {
279 PLDM_EVENT_MESSAGE_GLOBAL_DISABLE,
280 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC,
281 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_POLLING,
282 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE
283};
284
285/** @brief PLDM respository state */
286enum pldm_repository_state {
287 PLDM_AVAILABLE,
288 PLDM_UPDATE_IN_PROGRESS,
289 PLDM_FAILED
290};
291
292/** @brief PLDM respository data transfer handler timeout */
293enum pldm_repository_data_transfer_handler_timeout {
294 PLDM_NO_TIMEOUT,
295 PLDM_DEFALUT_MINIMUM_TIMEOUT
296};
297
298/** @struct pldm_pdr_hdr
299 *
300 * Structure representing PLDM common PDR header
301 */
302struct pldm_pdr_hdr {
303 uint32_t record_handle;
304 uint8_t version;
305 uint8_t type;
306 uint16_t record_change_num;
307 uint16_t length;
308} __attribute__((packed));
309
310/** @struct pldm_terminus_locator_pdr
311 *
312 * Structure representing PLDM terminus locator PDR
313 */
314struct pldm_terminus_locator_pdr {
315 struct pldm_pdr_hdr hdr;
316 uint16_t terminus_handle;
317 uint8_t validity;
318 uint8_t tid;
319 uint16_t container_id;
320 uint8_t terminus_locator_type;
321 uint8_t terminus_locator_value_size;
322 uint8_t terminus_locator_value[1];
323} __attribute__((packed));
324
325/** @struct pldm_terminus_locator_type_mctp_eid
326 *
327 * Structure representing terminus locator value for
328 * terminus locator type MCTP_EID
329 */
330struct pldm_terminus_locator_type_mctp_eid {
331 uint8_t eid;
332} __attribute__((packed));
333
334/** @struct pldm_pdr_entity_association
335 *
336 * Structure representing PLDM Entity Association PDR
337 */
338struct pldm_pdr_entity_association {
339 uint16_t container_id;
340 uint8_t association_type;
341 pldm_entity container;
342 uint8_t num_children;
343 pldm_entity children[1];
344} __attribute__((packed));
345
346/** @struct pldm_pdr_fru_record_set
347 *
348 * Structure representing PLDM FRU record set PDR
349 */
350struct pldm_pdr_fru_record_set {
351 uint16_t terminus_handle;
352 uint16_t fru_rsi;
353 uint16_t entity_type;
354 uint16_t entity_instance_num;
355 uint16_t container_id;
356} __attribute__((packed));
357
358/** @struct pldm_state_sensor_pdr
359 *
360 * Structure representing PLDM state sensor PDR
361 */
362struct pldm_state_sensor_pdr {
363 struct pldm_pdr_hdr hdr;
364 uint16_t terminus_handle;
365 uint16_t sensor_id;
366 uint16_t entity_type;
367 uint16_t entity_instance;
368 uint16_t container_id;
369 uint8_t sensor_init;
370 bool8_t sensor_auxiliary_names_pdr;
371 uint8_t composite_sensor_count;
372 uint8_t possible_states[1];
373} __attribute__((packed));
374
375/** @struct state_sensor_possible_states
376 *
377 * Structure representing state enums for state sensor
378 */
379struct state_sensor_possible_states {
380 uint16_t state_set_id;
381 uint8_t possible_states_size;
382 bitfield8_t states[1];
383} __attribute__((packed));
384
385/** @struct pldm_state_effecter_pdr
386 *
387 * Structure representing PLDM state effecter PDR
388 */
389struct pldm_state_effecter_pdr {
390 struct pldm_pdr_hdr hdr;
391 uint16_t terminus_handle;
392 uint16_t effecter_id;
393 uint16_t entity_type;
394 uint16_t entity_instance;
395 uint16_t container_id;
396 uint16_t effecter_semantic_id;
397 uint8_t effecter_init;
398 bool8_t has_description_pdr;
399 uint8_t composite_effecter_count;
400 uint8_t possible_states[1];
401} __attribute__((packed));
402
403/** @brief Encode PLDM state sensor PDR
404 *
405 * @param[in/out] sensor Structure to encode. All members of
406 * sensor, except those mentioned in the @note below, should be initialized by
407 * the caller.
408 * @param[in] allocation_size Size of sensor allocation in bytes
409 * @param[in] possible_states Possible sensor states
410 * @param[in] possible_states_size Size of possible sensor states in bytes
411 * @param[out] actual_size Size of sensor PDR. Set to 0 on error.
412 * @return int pldm_completion_codes
413 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
414 *
415 * @note The sensor parameter will be encoded in place.
416 * @note Caller is responsible for allocation of the sensor parameter. Caller
417 * must allocate enough space for the base structure and the
418 * sensor->possible_states array, otherwise the function will fail.
419 * @note sensor->hdr.length, .type, and .version will be set appropriately.
420 */
421int encode_state_sensor_pdr(
422 struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
423 const struct state_sensor_possible_states *possible_states,
424 size_t possible_states_size, size_t *actual_size);
425
426/** @union union_effecter_data_size
427 *
428 * The bit width and format of reading and threshold values that the effecter
429 * returns.
430 * Refer to: DSP0248_1.2.0: 28.11 Table 87
431 */
432typedef union {
433 uint8_t value_u8;
434 int8_t value_s8;
435 uint16_t value_u16;
436 int16_t value_s16;
437 uint32_t value_u32;
438 int32_t value_s32;
439} union_effecter_data_size;
440
441/** @union union_range_field_format
442 *
443 * Indicates the format used for the nominalValue, normalMax, and normalMin
444 * fields.
445 * Refer to: DSP0248_1.2.0: 28.11 Table 87
446 */
447typedef union {
448 uint8_t value_u8;
449 int8_t value_s8;
450 uint16_t value_u16;
451 int16_t value_s16;
452 uint32_t value_u32;
453 int32_t value_s32;
454 real32_t value_f32;
455} union_range_field_format;
456
457/** @struct pldm_numeric_effecter_value_pdr
458 *
459 * Structure representing PLDM numeric effecter value PDR
460 */
461struct pldm_numeric_effecter_value_pdr {
462 struct pldm_pdr_hdr hdr;
463 uint16_t terminus_handle;
464 uint16_t effecter_id;
465 uint16_t entity_type;
466 uint16_t entity_instance;
467 uint16_t container_id;
468 uint16_t effecter_semantic_id;
469 uint8_t effecter_init;
470 bool8_t effecter_auxiliary_names;
471 uint8_t base_unit;
472 int8_t unit_modifier;
473 uint8_t rate_unit;
474 uint8_t base_oem_unit_handle;
475 uint8_t aux_unit;
476 int8_t aux_unit_modifier;
477 uint8_t aux_rate_unit;
478 uint8_t aux_oem_unit_handle;
479 bool8_t is_linear;
480 uint8_t effecter_data_size;
481 real32_t resolution;
482 real32_t offset;
483 uint16_t accuracy;
484 uint8_t plus_tolerance;
485 uint8_t minus_tolerance;
486 real32_t state_transition_interval;
487 real32_t transition_interval;
488 union_effecter_data_size max_settable;
489 union_effecter_data_size min_settable;
490 uint8_t range_field_format;
491 bitfield8_t range_field_support;
492 union_range_field_format nominal_value;
493 union_range_field_format normal_max;
494 union_range_field_format normal_min;
495 union_range_field_format rated_max;
496 union_range_field_format rated_min;
497} __attribute__((packed));
498
499/** @struct state_effecter_possible_states
500 *
501 * Structure representing state enums for state effecter
502 */
503struct state_effecter_possible_states {
504 uint16_t state_set_id;
505 uint8_t possible_states_size;
506 bitfield8_t states[1];
507} __attribute__((packed));
508
509/** @brief Encode PLDM state effecter PDR
510 *
511 * @param[in/out] effecter Structure to encode. All members of
512 * effecter, except those mentioned in
513 * the @note below, should be initialized
514 * by the caller.
515 * @param[in] allocation_size Size of effecter allocation in bytes
516 * @param[in] possible_states Possible effecter states
517 * @param[in] possible_states_size Size of possible effecter states in
518 * bytes
519 * @param[out] actual_size Size of effecter PDR. Set to 0 on
520 * error.
521 * @return int pldm_completion_codes
522 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
523 *
524 * @note The effecter parameter will be encoded in place.
525 * @note Caller is responsible for allocation of the effecter parameter. Caller
526 * must allocate enough space for the base structure and the
527 * effecter->possible_states array, otherwise the function will fail.
528 * @note effecter->hdr.length, .type, and .version will be set appropriately.
529 */
530int encode_state_effecter_pdr(
531 struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
532 const struct state_effecter_possible_states *possible_states,
533 size_t possible_states_size, size_t *actual_size);
534
535/** @struct set_effecter_state_field
536 *
537 * Structure representing a stateField in SetStateEffecterStates command */
538
539typedef struct state_field_for_state_effecter_set {
540 uint8_t set_request; //!< Whether to change the state
541 uint8_t effecter_state; //!< Expected state of the effecter
542} __attribute__((packed)) set_effecter_state_field;
543
544/** @struct get_sensor_readings_field
545 *
546 * Structure representing a stateField in GetStateSensorReadings command */
547
548typedef struct state_field_for_get_state_sensor_readings {
549 uint8_t sensor_op_state; //!< The state of the sensor itself
550 uint8_t present_state; //!< Return a state value
551 uint8_t previous_state; //!< The state that the presentState was entered
552 //! from. This must be different from the
553 //! present state
554 uint8_t event_state; //!< Return a state value from a PLDM State Set
555 //! that is associated with the sensor
556} __attribute__((packed)) get_sensor_state_field;
557
558/** @struct PLDM_SetStateEffecterStates_Request
559 *
560 * Structure representing PLDM set state effecter states request.
561 */
562struct pldm_set_state_effecter_states_req {
563 uint16_t effecter_id;
564 uint8_t comp_effecter_count;
565 set_effecter_state_field field[8];
566} __attribute__((packed));
567
568/** @struct pldm_get_pdr_repository_info_resp
569 *
570 * Structure representing GetPDRRepositoryInfo response packet
571 */
572struct pldm_pdr_repository_info_resp {
573 uint8_t completion_code;
574 uint8_t repository_state;
575 uint8_t update_time[PLDM_TIMESTAMP104_SIZE];
576 uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE];
577 uint32_t record_count;
578 uint32_t repository_size;
579 uint32_t largest_record_size;
580 uint8_t data_transfer_handle_timeout;
581} __attribute__((packed));
582
583/** @struct pldm_get_pdr_resp
584 *
585 * structure representing GetPDR response packet
586 * transfer CRC is not part of the structure and will be
587 * added at the end of last packet in multipart transfer
588 */
589struct pldm_get_pdr_resp {
590 uint8_t completion_code;
591 uint32_t next_record_handle;
592 uint32_t next_data_transfer_handle;
593 uint8_t transfer_flag;
594 uint16_t response_count;
595 uint8_t record_data[1];
596} __attribute__((packed));
597
598/** @struct pldm_get_pdr_req
599 *
600 * structure representing GetPDR request packet
601 */
602struct pldm_get_pdr_req {
603 uint32_t record_handle;
604 uint32_t data_transfer_handle;
605 uint8_t transfer_op_flag;
606 uint16_t request_count;
607 uint16_t record_change_number;
608} __attribute__((packed));
609
610/** @struct pldm_set_event_receiver_req
611 *
612 * Structure representing SetEventReceiver command.
613 * This structure applies only for MCTP as a transport type.
614 */
615struct pldm_set_event_receiver_req {
616 uint8_t event_message_global_enable;
617 uint8_t transport_protocol_type;
618 uint8_t event_receiver_address_info;
619 uint16_t heartbeat_timer;
620} __attribute__((packed));
621
622/** @struct pldm_set_numeric_effecter_value_req
623 *
624 * structure representing SetNumericEffecterValue request packet
625 */
626struct pldm_set_numeric_effecter_value_req {
627 uint16_t effecter_id;
628 uint8_t effecter_data_size;
629 uint8_t effecter_value[1];
630} __attribute__((packed));
631
632/** @struct pldm_get_state_sensor_readings_req
633 *
634 * Structure representing PLDM get state sensor readings request.
635 */
636struct pldm_get_state_sensor_readings_req {
637 uint16_t sensor_id;
638 bitfield8_t sensor_rearm;
639 uint8_t reserved;
640} __attribute__((packed));
641
642/** @struct pldm_get_state_sensor_readings_resp
643 *
644 * Structure representing PLDM get state sensor readings response.
645 */
646struct pldm_get_state_sensor_readings_resp {
647 uint8_t completion_code;
648 uint8_t comp_sensor_count;
649 get_sensor_state_field field[1];
650} __attribute__((packed));
651
652/** @struct pldm_sensor_event
653 *
654 * structure representing sensorEventClass
655 */
656struct pldm_sensor_event_data {
657 uint16_t sensor_id;
658 uint8_t sensor_event_class_type;
659 uint8_t event_class[1];
660} __attribute__((packed));
661
662/** @struct pldm_state_sensor_state
663 *
664 * structure representing sensorEventClass for stateSensorState
665 */
666struct pldm_sensor_event_state_sensor_state {
667 uint8_t sensor_offset;
668 uint8_t event_state;
669 uint8_t previous_event_state;
670} __attribute__((packed));
671
672/** @struct pldm_sensor_event_numeric_sensor_state
673 *
674 * structure representing sensorEventClass for stateSensorState
675 */
676struct pldm_sensor_event_numeric_sensor_state {
677 uint8_t event_state;
678 uint8_t previous_event_state;
679 uint8_t sensor_data_size;
680 uint8_t present_reading[1];
681} __attribute__((packed));
682
683/** @struct pldm_sensor_event_sensor_op_state
684 *
685 * structure representing sensorEventClass for SensorOpState
686 */
687struct pldm_sensor_event_sensor_op_state {
688 uint8_t present_op_state;
689 uint8_t previous_op_state;
690} __attribute__((packed));
691
692/** @struct pldm_platform_event_message_req
693 *
694 * structure representing PlatformEventMessage command request data
695 */
696struct pldm_platform_event_message_req {
697 uint8_t format_version;
698 uint8_t tid;
699 uint8_t event_class;
700 uint8_t event_data[1];
701} __attribute__((packed));
702
703/** @struct pldm_platform_event_message_response
704 *
705 * structure representing PlatformEventMessage command response data
706 */
707struct pldm_platform_event_message_resp {
708 uint8_t completion_code;
709 uint8_t platform_event_status;
710} __attribute__((packed));
711
712/** @struct pldm_pdr_repository_chg_event_data
713 *
714 * structure representing pldmPDRRepositoryChgEvent class eventData
715 */
716struct pldm_pdr_repository_chg_event_data {
717 uint8_t event_data_format;
718 uint8_t number_of_change_records;
719 uint8_t change_records[1];
720} __attribute__((packed));
721
722/** @struct pldm_pdr_repository_chg_event_change_record_data
723 *
724 * structure representing pldmPDRRepositoryChgEvent class eventData's change
725 * record data
726 */
727struct pldm_pdr_repository_change_record_data {
728 uint8_t event_data_operation;
729 uint8_t number_of_change_entries;
730 uint32_t change_entry[1];
731} __attribute__((packed));
732
733/** @struct pldm_get_numeric_effecter_value_req
734 *
735 * structure representing GetNumericEffecterValue request packet
736 */
737struct pldm_get_numeric_effecter_value_req {
738 uint16_t effecter_id;
739} __attribute__((packed));
740
741/** @struct pldm_get_numeric_effecter_value_resp
742 *
743 * structure representing GetNumericEffecterValue response packet
744 */
745struct pldm_get_numeric_effecter_value_resp {
746 uint8_t completion_code;
747 uint8_t effecter_data_size;
748 uint8_t effecter_oper_state;
749 uint8_t pending_and_present_values[1];
750} __attribute__((packed));
751
752/** @struct pldm_get_sensor_reading_req
753 *
754 * Structure representing PLDM get sensor reading request
755 */
756struct pldm_get_sensor_reading_req {
757 uint16_t sensor_id;
758 bool8_t rearm_event_state;
759} __attribute__((packed));
760
761/** @struct pldm_get_sensor_reading_resp
762 *
763 * Structure representing PLDM get sensor reading response
764 */
765struct pldm_get_sensor_reading_resp {
766 uint8_t completion_code;
767 uint8_t sensor_data_size;
768 uint8_t sensor_operational_state;
769 uint8_t sensor_event_message_enable;
770 uint8_t present_state;
771 uint8_t previous_state;
772 uint8_t event_state;
773 uint8_t present_reading[1];
774} __attribute__((packed));
775
776/* Responder */
777
778/* SetNumericEffecterValue */
779
780/** @brief Decode SetNumericEffecterValue request data
781 *
782 * @param[in] msg - Request message
783 * @param[in] payload_length - Length of request message payload
784 * @param[out] effecter_id - used to identify and access the effecter
785 * @param[out] effecter_data_size - The bit width and format of the setting
786 * value for the effecter.
787 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
788 * @param[out] effecter_value - The setting value of numeric effecter being
789 * requested.
790 * @return pldm_completion_codes
791 */
792int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
793 size_t payload_length,
794 uint16_t *effecter_id,
795 uint8_t *effecter_data_size,
796 uint8_t *effecter_value);
797
798/** @brief Create a PLDM response message for SetNumericEffecterValue
799 *
800 * @param[in] instance_id - Message's instance id
801 * @param[in] completion_code - PLDM completion code
802 * @param[out] msg - Message will be written to this
803 * @param[in] payload_length - Length of request message payload
804 * @return pldm_completion_codes
805 * @note Caller is responsible for memory alloc and dealloc of param
806 * 'msg.body.payload'
807 */
808int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
809 uint8_t completion_code,
810 struct pldm_msg *msg,
811 size_t payload_length);
812
813/* SetStateEffecterStates */
814
815/** @brief Create a PLDM response message for SetStateEffecterStates
816 *
817 * @param[in] instance_id - Message's instance id
818 * @param[in] completion_code - PLDM completion code
819 * @param[out] msg - Message will be written to this
820 * @return pldm_completion_codes
821 * @note Caller is responsible for memory alloc and dealloc of param
822 * 'msg.body.payload'
823 */
824
825int encode_set_state_effecter_states_resp(uint8_t instance_id,
826 uint8_t completion_code,
827 struct pldm_msg *msg);
828
829/** @brief Decode SetStateEffecterStates request data
830 *
831 * @param[in] msg - Request message
832 * @param[in] payload_length - Length of request message payload
833 * @param[out] effecter_id - used to identify and access the effecter
834 * @param[out] comp_effecter_count - number of individual sets of effecter
835 * information. Upto eight sets of state effecter info can be accessed
836 * for a given effecter.
837 * @param[out] field - each unit is an instance of the stateFileld structure
838 * that is used to set the requested state for a particular effecter
839 * within the state effecter. This field holds the starting address of
840 * the stateField values. The user is responsible to allocate the
841 * memory prior to calling this command. Since the state field count is
842 * not known in advance, the user should allocate the maximum size
843 * always, which is 8 in number.
844 * @return pldm_completion_codes
845 */
846
847int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
848 size_t payload_length,
849 uint16_t *effecter_id,
850 uint8_t *comp_effecter_count,
851 set_effecter_state_field *field);
852
853/* GetPDR */
854
855/** @brief Create a PLDM response message for GetPDR
856 *
857 * @param[in] instance_id - Message's instance id
858 * @param[in] completion_code - PLDM completion code
859 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
860 * the PDR Repository
861 * @param[in] next_data_transfer_hndl - A handle that identifies the next
862 * portion of the PDR data to be transferred, if any
863 * @param[in] transfer_flag - Indicates the portion of PDR data being
864 * transferred
865 * @param[in] resp_cnt - The number of recordData bytes returned in this
866 * response
867 * @param[in] record_data - PDR data bytes of length resp_cnt
868 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
869 * in the last part of a PDR being transferred
870 * @param[out] msg - Message will be written to this
871 * @return pldm_completion_codes
872 * @note Caller is responsible for memory alloc and dealloc of param
873 * 'msg.payload'
874 */
875int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
876 uint32_t next_record_hndl,
877 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
878 uint16_t resp_cnt, const uint8_t *record_data,
879 uint8_t transfer_crc, struct pldm_msg *msg);
880
881/** @brief Decode GetPDR request data
882 *
883 * @param[in] msg - Request message
884 * @param[in] payload_length - Length of request message payload
885 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
886 * @param[out] data_transfer_hndl - Handle used to identify a particular
887 * multipart PDR data transfer operation
888 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
889 * portion of transfer
890 * @param[out] request_cnt - The maximum number of record bytes requested
891 * @param[out] record_chg_num - Used to determine whether the PDR has changed
892 * while PDR transfer is going on
893 * @return pldm_completion_codes
894 */
895
896int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
897 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
898 uint8_t *transfer_op_flag, uint16_t *request_cnt,
899 uint16_t *record_chg_num);
900
901/* GetStateSensorReadings */
902
903/** @brief Decode GetStateSensorReadings request data
904 *
905 * @param[in] msg - Request message
906 * @param[in] payload_length - Length of request message payload
907 * @param[out] sensor_id - used to identify and access the simple or composite
908 * sensor
909 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
910 * particular sensor within the state sensor, where bit [0] corresponds
911 * to the first state sensor (sensor offset 0) and bit [7] corresponds
912 * to the eighth sensor (sensor offset 7), sequentially.
913 * @param[out] reserved - value: 0x00
914 * @return pldm_completion_codes
915 */
916
917int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
918 size_t payload_length,
919 uint16_t *sensor_id,
920 bitfield8_t *sensor_rearm,
921 uint8_t *reserved);
922
923/** @brief Encode GetStateSensorReadings response data
924 *
925 * @param[in] instance_id - Message's instance id
926 * @param[in] completion_code - PLDM completion code
927 * @param[out] comp_sensor_count - The number of individual sets of sensor
928 * information that this command accesses
929 * @param[out] field - Each stateField is an instance of a stateField structure
930 * that is used to return the present operational state setting and the
931 * present state and event state for a particular set of sensor
932 * information contained within the state sensor
933 * @param[out] msg - Message will be written to this
934 * @return pldm_completion_codes
935 */
936
937int encode_get_state_sensor_readings_resp(uint8_t instance_id,
938 uint8_t completion_code,
939 uint8_t comp_sensor_count,
940 get_sensor_state_field *field,
941 struct pldm_msg *msg);
942
943/* GetNumericEffecterValue */
944
945/** @brief Decode GetNumericEffecterValue request data
946 *
947 * @param[in] msg - Request message
948 * @param[in] payload_length - Length of request message payload
949 * @param[out] effecter_id - used to identify and access the effecter
950 * @return pldm_completion_codes
951 */
952int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
953 size_t payload_length,
954 uint16_t *effecter_id);
955
956/** @brief Create a PLDM response message for GetNumericEffecterValue
957 *
958 * @param[in] instance_id - Message's instance id
959 * @param[in] completion_code - PLDM completion code
960 * @param[in] effecter_data_size - The bit width and format of the setting
961 * value for the effecter.
962 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
963 * @param[in] effecter_oper_state - The state of the effecter itself
964 * @param[in] pending_value - The pending numeric value setting of the
965 * effecter. The effecterDataSize field indicates the number of
966 * bits used for this field
967 * @param[in] present_value - The present numeric value setting of the
968 * effecter. The effecterDataSize indicates the number of bits
969 * used for this field
970 * @param[out] msg - Message will be written to this
971 * @param[in] payload_length - Length of request message payload
972 * @return pldm_completion_codes
973 * @note Caller is responsible for memory alloc and dealloc of param
974 * 'msg.payload'
975 */
976int encode_get_numeric_effecter_value_resp(
977 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
978 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
979 struct pldm_msg *msg, size_t payload_length);
980
981/* GetSensorReading */
982
983/** @brief Decode GetSensorReading request data
984 *
985 * @param[in] msg - Request message
986 * @param[in] payload_length - Length of request message payload
987 * @param[out] sensor_id - A handle that is used to identify and access
988 * the sensor
989 * @param[out] rearm_event_state - true = manually re-arm EventState after
990 * responding to this request, false = no manual re-arm
991 * @return pldm_completion_codes
992 */
993
994int decode_get_sensor_reading_req(const struct pldm_msg *msg,
995 size_t payload_length, uint16_t *sensor_id,
996 bool8_t *rearm_event_state);
997
998/** @brief Encode GetSensorReading response data
999 *
1000 * @param[in] instance_id - Message's instance id
1001 * @param[in] completion_code - PLDM completion code
1002 * @param[out] sensor_data_size - The bit width and format of reading and
1003 * threshold values
1004 * @param[out] sensor_operational_state - The state of the sensor itself
1005 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1006 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1007 * stateEventsOnlyEnabled }
1008 * @param[out] present_state - The most recently assessed state value monitored
1009 * by the sensor
1010 * @param[out] previous_state - The state that the presentState was entered
1011 * from
1012 * @param[out] event_state - Indicates which threshold crossing assertion
1013 * events have been detected
1014 * @param[out] present_reading - The present value indicated by the sensor
1015 * @param[out] msg - Message will be written to this
1016 * @param[in] payload_length - Length of request message payload
1017 * @return pldm_completion_codes
1018 */
1019
1020int encode_get_sensor_reading_resp(
1021 uint8_t instance_id, uint8_t completion_code, uint8_t sensor_data_size,
1022 uint8_t sensor_operational_state, uint8_t sensor_event_message_enable,
1023 uint8_t present_state, uint8_t previous_state, uint8_t event_state,
1024 uint8_t *present_reading, struct pldm_msg *msg, size_t payload_length);
1025
1026/* Requester */
1027
1028/*GetPDRRepositoryInfo*/
1029
1030/** @brief Encode GetPDRRepositoryInfo response data
1031 *
1032 * @param[in] instance_id - Message's instance id
1033 * @param[in] completion_code - PLDM completion code
1034 * @param[in] repository_state - PLDM repository state
1035 * @param[in] update_time - When the standard PDR repository data was
1036 * originally created
1037 * @param[in] oem_update_time - when OEM PDRs in the PDR Repository were
1038 * originally created
1039 * @param[in] record_count - Total number of PDRs in this repository
1040 * @param[in] repository_size - Size of the PDR Repository in bytes
1041 * @param[in] largest_record_size - Size of the largest record in the PDR
1042 * Repository in bytes
1043 * @param[in] data_transfer_handle_timeout - Data transmission timeout
1044 * @param[out] msg - Message will be written to this
1045 * @return pldm_completion_codes
1046 */
1047int encode_get_pdr_repository_info_resp(
1048 uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
1049 const uint8_t *update_time, const uint8_t *oem_update_time,
1050 uint32_t record_count, uint32_t repository_size,
1051 uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
1052 struct pldm_msg *msg);
1053
1054/* GetPDR */
1055
1056/** @brief Create a PLDM request message for GetPDR
1057 *
1058 * @param[in] instance_id - Message's instance id
1059 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
1060 * @param[in] data_transfer_hndl - Handle used to identify a particular
1061 * multipart PDR data transfer operation
1062 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
1063 * portion of transfer
1064 * @param[in] request_cnt - The maximum number of record bytes requested
1065 * @param[in] record_chg_num - Used to determine whether the PDR has changed
1066 * while PDR transfer is going on
1067 * @param[out] msg - Message will be written to this
1068 * @param[in] payload_length - Length of request message payload
1069 * @return pldm_completion_codes
1070 * @note Caller is responsible for memory alloc and dealloc of param
1071 * 'msg.payload'
1072 */
1073int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
1074 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
1075 uint16_t request_cnt, uint16_t record_chg_num,
1076 struct pldm_msg *msg, size_t payload_length);
1077
1078/** @brief Decode GetPDR response data
1079 *
1080 * Note:
1081 * * If the return value is not PLDM_SUCCESS, it represents a
1082 * transport layer error.
1083 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1084 * protocol layer error and all the out-parameters are invalid.
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] next_record_hndl - The recordHandle for the PDR that is next in
1090 * the PDR Repository
1091 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1092 * portion of the PDR data to be transferred, if any
1093 * @param[out] transfer_flag - Indicates the portion of PDR data being
1094 * transferred
1095 * @param[out] resp_cnt - The number of recordData bytes returned in this
1096 * response
1097 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1098 * skip the copy and place the actual length in resp_cnt.
1099 * @param[in] record_data_length - Length of record_data
1100 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1101 * in the last part of a PDR being transferred
1102 * @return pldm_completion_codes
1103 */
1104int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1105 uint8_t *completion_code, uint32_t *next_record_hndl,
1106 uint32_t *next_data_transfer_hndl,
1107 uint8_t *transfer_flag, uint16_t *resp_cnt,
1108 uint8_t *record_data, size_t record_data_length,
1109 uint8_t *transfer_crc);
1110
1111/* SetStateEffecterStates */
1112
1113/** @brief Create a PLDM request message for SetStateEffecterStates
1114 *
1115 * @param[in] instance_id - Message's instance id
1116 * @param[in] effecter_id - used to identify and access the effecter
1117 * @param[in] comp_effecter_count - number of individual sets of effecter
1118 * information. Upto eight sets of state effecter info can be accessed
1119 * for a given effecter.
1120 * @param[in] field - each unit is an instance of the stateField structure
1121 * that is used to set the requested state for a particular effecter
1122 * within the state effecter. This field holds the starting address of
1123 * the stateField values. The user is responsible to allocate the
1124 * memory prior to calling this command. The user has to allocate the
1125 * field parameter as sizeof(set_effecter_state_field) *
1126 * comp_effecter_count
1127 * @param[out] msg - Message will be written to this
1128 * @return pldm_completion_codes
1129 * @note Caller is responsible for memory alloc and dealloc of param
1130 * 'msg.payload'
1131 */
1132
1133int encode_set_state_effecter_states_req(uint8_t instance_id,
1134 uint16_t effecter_id,
1135 uint8_t comp_effecter_count,
1136 set_effecter_state_field *field,
1137 struct pldm_msg *msg);
1138
1139/** @brief Decode SetStateEffecterStates response data
1140 *
1141 * Note:
1142 * * If the return value is not PLDM_SUCCESS, it represents a
1143 * transport layer error.
1144 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1145 * protocol layer error and all the out-parameters are invalid.
1146 *
1147 * @param[in] msg - Request message
1148 * @param[in] payload_length - Length of response message payload
1149 * @param[out] completion_code - PLDM completion code
1150 * @return pldm_completion_codes
1151 */
1152int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
1153 size_t payload_length,
1154 uint8_t *completion_code);
1155
1156/* SetNumericEffecterValue */
1157
1158/** @brief Create a PLDM request message for SetNumericEffecterValue
1159 *
1160 * @param[in] instance_id - Message's instance id
1161 * @param[in] effecter_id - used to identify and access the effecter
1162 * @param[in] effecter_data_size - The bit width and format of the setting
1163 * value for the effecter.
1164 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1165 * @param[in] effecter_value - The setting value of numeric effecter being
1166 * requested.
1167 * @param[in] payload_length - Length of request message payload
1168 * @param[out] msg - Message will be written to this
1169 * @return pldm_completion_codes
1170 * @note Caller is responsible for memory alloc and dealloc of param
1171 * 'msg.payload'
1172 */
1173int encode_set_numeric_effecter_value_req(
1174 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1175 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1176
1177/** @brief Decode SetNumericEffecterValue response data
1178 * @param[in] msg - Request message
1179 * @param[in] payload_length - Length of response message payload
1180 * @param[out] completion_code - PLDM completion code
1181 * @return pldm_completion_codes
1182 */
1183int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1184 size_t payload_length,
1185 uint8_t *completion_code);
1186
1187/** @brief Create a PLDM request message for GetStateSensorReadings
1188 *
1189 * @param[in] instance_id - Message's instance id
1190 * @param[in] sensor_id - used to identify and access the simple or composite
1191 * sensor
1192 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1193 * particular sensor within the state sensor, where bit [0] corresponds
1194 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1195 * to the eighth sensor (sensor offset 7), sequentially
1196 * @param[in] reserved - value: 0x00
1197 * @param[out] msg - Message will be written to this
1198 * @return pldm_completion_codes
1199 * @note Caller is responsible for memory alloc and dealloc of param
1200 * 'msg.payload'
1201 */
1202int encode_get_state_sensor_readings_req(uint8_t instance_id,
1203 uint16_t sensor_id,
1204 bitfield8_t sensor_rearm,
1205 uint8_t reserved,
1206 struct pldm_msg *msg);
1207
1208/** @brief Decode GetStateSensorReadings response data
1209 *
1210 * @param[in] msg - Request message
1211 * @param[in] payload_length - Length of response message payload
1212 * @param[out] completion_code - PLDM completion code
1213 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1214 * information that this command accesses
1215 * @param[out] field - Each stateField is an instance of a stateField structure
1216 * that is used to return the present operational state setting and the
1217 * present state and event state for a particular set of sensor
1218 * information contained within the state sensor
1219 * @return pldm_completion_codes
1220 */
1221
1222int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1223 size_t payload_length,
1224 uint8_t *completion_code,
1225 uint8_t *comp_sensor_count,
1226 get_sensor_state_field *field);
1227
1228/* PlatformEventMessage */
1229
1230/** @brief Decode PlatformEventMessage request data
1231 * @param[in] msg - Request message
1232 * @param[in] payload_length - Length of response message payload
1233 * @param[out] format_version - Version of the event format
1234 * @param[out] tid - Terminus ID for the terminus that originated the event
1235 * message
1236 * @param[out] event_class - The class of event being sent
1237 * @param[out] event_data_offset - Offset where the event data should be read
1238 * from pldm msg
1239 * @return pldm_completion_codes
1240 */
1241int decode_platform_event_message_req(const struct pldm_msg *msg,
1242 size_t payload_length,
1243 uint8_t *format_version, uint8_t *tid,
1244 uint8_t *event_class,
1245 size_t *event_data_offset);
1246
1247/** @brief Encode PlatformEventMessage response data
1248 * @param[in] instance_id - Message's instance id
1249 * @param[in] completion_code - PLDM completion code
1250 * @param[in] platform_event_status - Response status of the event message
1251 * command
1252 * @param[out] msg - Message will be written to this
1253 * @return pldm_completion_codes
1254 * @note Caller is responsible for memory alloc and dealloc of param
1255 * 'msg.payload'
1256 */
1257int encode_platform_event_message_resp(uint8_t instance_id,
1258 uint8_t completion_code,
1259 uint8_t platform_event_status,
1260 struct pldm_msg *msg);
1261
1262/** @brief Encode PlatformEventMessage request data
1263 * @param[in] instance_id - Message's instance id
1264 * @param[in] format_version - Version of the event format
1265 * @param[in] tid - Terminus ID for the terminus that originated the event
1266 * message
1267 * @param[in] event_class - The class of event being sent
1268 * @param[in] event_data - the event data should be read from pldm msg
1269 * @param[in] event_data_length - Length of the event data
1270 * @param[out] msg - Request message
1271 * @return pldm_completion_codes
1272 * @note Caller is responsible for memory alloc and dealloc of param
1273 * 'msg.payload'
1274 */
1275int encode_platform_event_message_req(
1276 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1277 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1278 struct pldm_msg *msg, size_t payload_length);
1279
1280/** @brief Decode PlatformEventMessage response data
1281 * @param[in] msg - Request message
1282 * @param[in] payload_length - Length of Response message payload
1283 * @param[out] completion_code - PLDM completion code
1284 * @param[out] platform_event_status - Response status of the event message
1285 * command
1286 * @return pldm_completion_codes
1287 */
1288int decode_platform_event_message_resp(const struct pldm_msg *msg,
1289 size_t payload_length,
1290 uint8_t *completion_code,
1291 uint8_t *platform_event_status);
1292
1293/** @brief Decode sensorEventData response data
1294 *
1295 * @param[in] event_data - event data from the response message
1296 * @param[in] event_data_length - length of the event data
1297 * @param[out] sensor_id - sensorID value of the sensor
1298 * @param[out] sensor_event_class_type - Type of sensor event class
1299 * @param[out] event_class_data_offset - Offset where the event class data
1300 * should be read from event data
1301 * @return pldm_completion_codes
1302 * @note Caller is responsible for memory alloc and dealloc of param
1303 * 'event_data'
1304 */
1305int decode_sensor_event_data(const uint8_t *event_data,
1306 size_t event_data_length, uint16_t *sensor_id,
1307 uint8_t *sensor_event_class_type,
1308 size_t *event_class_data_offset);
1309
1310/** @brief Decode sensorOpState response data
1311 *
1312 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1313 * @param[in] sensor_data_length - Length of sensor_data
1314 * @param[out] present_op_state - The sensorOperationalState value from the
1315 * state change that triggered the event message
1316 * @param[out] previous_op_state - The sensorOperationalState value for the
1317 * state from which the present state was entered
1318 * @return pldm_completion_codes
1319 * @note Caller is responsible for memory alloc and dealloc of param
1320 * 'sensor_data'
1321 */
1322int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1323 uint8_t *present_op_state,
1324 uint8_t *previous_op_state);
1325
1326/** @brief Decode stateSensorState response data
1327 *
1328 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1329 * @param[in] sensor_data_length - Length of sensor_data
1330 * @param[out] sensor_offset - Identifies which state sensor within a composite
1331 * state sensor the event is being returned for
1332 * @param[out] event_state - The event state value from the state change that
1333 * triggered the event message
1334 * @param[out] previous_event_state - The event state value for the state from
1335 * which the present event state was entered
1336 * @return pldm_completion_codes
1337 * @note Caller is responsible for memory alloc and dealloc of param
1338 * 'sensor_data'
1339 */
1340int decode_state_sensor_data(const uint8_t *sensor_data,
1341 size_t sensor_data_length, uint8_t *sensor_offset,
1342 uint8_t *event_state,
1343 uint8_t *previous_event_state);
1344
1345/** @brief Decode numericSensorState response data
1346 *
1347 * @param[in] sensor_data - sensor_data for sensorEventClass =
1348 * numericSensorState
1349 * @param[in] sensor_data_length - Length of sensor_data
1350 * @param[out] event_state - The eventState value from the state change that
1351 * triggered the event message
1352 * @param[out] previous_event_state - The eventState value for the state from
1353 * which the present state was entered
1354 * @param[out] sensor_data_size - The bit width and format of reading and
1355 * threshold values that the sensor returns
1356 * @param[out] present_reading - The present value indicated by the sensor
1357 * @return pldm_completion_codes
1358 * @note Caller is responsible for memory alloc and dealloc of param
1359 * 'sensor_data'
1360 */
1361int decode_numeric_sensor_data(const uint8_t *sensor_data,
1362 size_t sensor_data_length, uint8_t *event_state,
1363 uint8_t *previous_event_state,
1364 uint8_t *sensor_data_size,
1365 uint32_t *present_reading);
1366
1367/* GetNumericEffecterValue */
1368
1369/** @brief Create a PLDM request message for GetNumericEffecterValue
1370 *
1371 * @param[in] instance_id - Message's instance id
1372 * @param[in] effecter_id - used to identify and access the effecter
1373 * @param[out] msg - Message will be written to this
1374 * @return pldm_completion_codes
1375 * @note Caller is responsible for memory alloc and dealloc of param
1376 * 'msg.payload'
1377 */
1378int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1379 uint16_t effecter_id,
1380 struct pldm_msg *msg);
1381
1382/** @brief Create a PLDM response message for GetNumericEffecterValue
1383 *
1384 * @param[in] msg - Request message
1385 * @param[in] payload_length - Length of request message payload
1386 * @param[out] completion_code - PLDM completion code
1387 * @param[out] effecter_data_size - The bit width and format of the setting
1388 * value for the effecter.
1389 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1390 * @param[out] effecter_oper_state - The state of the effecter itself
1391 * @param[out] pending_value - The pending numeric value setting of the
1392 * effecter. The effecterDataSize field indicates the number of
1393 * bits used for this field
1394 * @param[out] present_value - The present numeric value setting of the
1395 * effecter. The effecterDataSize indicates the number of bits
1396 * used for this field
1397 * @return pldm_completion_codes
1398 */
1399int decode_get_numeric_effecter_value_resp(
1400 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1401 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1402 uint8_t *pending_value, uint8_t *present_value);
1403
1404/** @brief Decode pldmPDRRepositoryChgEvent response data
1405 *
1406 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1407 * @param[in] event_data_size - Length of event_data
1408 * @param[out] event_data_format - This field indicates if the changedRecords
1409 * are of PDR Types or PDR Record Handles
1410 * @param[out] number_of_change_records - The number of changeRecords following
1411 * this field
1412 * @param[out] change_record_data_offset - Identifies where changeRecord data
1413 * is located within event_data
1414 * @return pldm_completion_codes
1415 * @note Caller is responsible for memory alloc and dealloc of param
1416 * 'event_data'
1417 */
1418int decode_pldm_pdr_repository_chg_event_data(
1419 const uint8_t *event_data, size_t event_data_size,
1420 uint8_t *event_data_format, uint8_t *number_of_change_records,
1421 size_t *change_record_data_offset);
1422
1423/** @brief Encode PLDM PDR Repository Change eventData
1424 * @param[in] event_data_format - Format of this event data (e.g.
1425 * FORMAT_IS_PDR_HANDLES)
1426 * @param[in] number_of_change_records - Number of changeRecords in this
1427 * eventData
1428 * @param[in] event_data_operations - Array of eventDataOperations
1429 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1430 * should contain number_of_change_records elements.
1431 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1432 * for each changeRecord in this eventData. This array should contain
1433 * number_of_change_records elements.
1434 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1435 * one array per changeRecord in this eventData. The toplevel array should
1436 * contain number_of_change_records elements. Each subarray [i] should
1437 * contain numbers_of_change_entries[i] elements.
1438 * @param[in] event_data - The eventData will be encoded into this. This entire
1439 * structure must be max_change_records_size long. It must be large enough
1440 * to accomodate the data to be encoded. The caller is responsible for
1441 * allocating and deallocating it, including the variable-size
1442 * 'event_data.change_records' field. If this parameter is NULL,
1443 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1444 * to reflect the required size of the structure.
1445 * @param[out] actual_change_records_size - The actual number of meaningful
1446 * encoded bytes in event_data. The caller can over-allocate memory and use
1447 * this output to determine the real size of the structure.
1448 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1449 * encoded message would be larger than this value, an error is returned.
1450 * @return pldm_completion_codes
1451 * @note Caller is responsible for memory alloc and dealloc of param
1452 * 'event_data.change_records'
1453 */
1454int encode_pldm_pdr_repository_chg_event_data(
1455 uint8_t event_data_format, uint8_t number_of_change_records,
1456 const uint8_t *event_data_operations,
1457 const uint8_t *numbers_of_change_entries,
1458 const uint32_t *const *change_entries,
1459 struct pldm_pdr_repository_chg_event_data *event_data,
1460 size_t *actual_change_records_size, size_t max_change_records_size);
1461
1462/** @brief Encode event data for a PLDM Sensor Event
1463 *
1464 * @param[out] event_data The object to store the encoded event in
1465 * @param[in] event_data_size Size of the allocation for event_data
1466 * @param[in] sensor_id Sensor ID
1467 * @param[in] sensor_event_class Sensor event class
1468 * @param[in] sensor_offset Offset
1469 * @param[in] event_state Event state
1470 * @param[in] previous_event_state Previous event state
1471 * @param[out] actual_event_data_size The real size in bytes of the event_data
1472 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1473 * @note If event_data is NULL, then *actual_event_data_size will be set to
1474 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1475 * @note The caller is responsible for allocating and deallocating the
1476 * event_data
1477 */
1478int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1479 size_t event_data_size, uint16_t sensor_id,
1480 enum sensor_event_class_states sensor_event_class,
1481 uint8_t sensor_offset, uint8_t event_state,
1482 uint8_t previous_event_state,
1483 size_t *actual_event_data_size);
1484
1485/** @brief Decode PldmPDRRepositoryChangeRecord response data
1486 *
1487 * @param[in] change_record_data - changeRecordData for
1488 * pldmPDRRepositoryChgEvent
1489 * @param[in] change_record_data_size - Length of change_record_data
1490 * @param[out] event_data_operation - This field indicates the changeEntries
1491 * operation types
1492 * @param[out] number_of_change_entries - The number of changeEntries following
1493 * this field
1494 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1495 * is located within change_record_data
1496 * @return pldm_completion_codes
1497 * @note Caller is responsible for memory alloc and dealloc of param
1498 * 'change_record_data'
1499 */
1500int decode_pldm_pdr_repository_change_record_data(
1501 const uint8_t *change_record_data, size_t change_record_data_size,
1502 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1503 size_t *change_entry_data_offset);
1504
1505/* GetSensorReading */
1506
1507/** @brief Encode GetSensorReading request data
1508 *
1509 * @param[in] instance_id - Message's instance id
1510 * @param[in] sensor_id - A handle that is used to identify and access the
1511 * sensor
1512 * @param[in] rearm_event_state - true = manually re-arm EventState after
1513 * responding to this request, false = no manual re-arm
1514 * @param[out] msg - Message will be written to this
1515 * @return pldm_completion_codes
1516 * @note Caller is responsible for memory alloc and dealloc of param
1517 * 'msg.payload'
1518 */
1519int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1520 bool8_t rearm_event_state,
1521 struct pldm_msg *msg);
1522
1523/** @brief Decode GetSensorReading response data
1524 *
1525 * @param[in] msg - Request message
1526 * @param[in] payload_length - Length of response message payload
1527 * @param[out] completion_code - PLDM completion code
1528 * @param[out] sensor_data_size - The bit width and format of reading and
1529 * threshold values
1530 * @param[out] sensor_operational_state - The state of the sensor itself
1531 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1532 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1533 * stateEventsOnlyEnabled }
1534 * @param[out] present_state - The most recently assessed state value monitored
1535 * by the sensor
1536 * @param[out] previous_state - The state that the presentState was entered
1537 * from
1538 * @param[out] event_state - Indicates which threshold crossing assertion
1539 * events have been detected
1540 * @param[out] present_reading - The present value indicated by the sensor
1541 * @return pldm_completion_codes
1542 */
1543
1544int decode_get_sensor_reading_resp(
1545 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1546 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1547 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1548 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1549
1550/** @brief Encode the SetEventReceiver request message
1551 *
1552 * @param[in] instance_id - Message's instance id
1553 * @param[in] event_message_global_enable - This value is used to enable or
1554 * disable event message generation from the terminus value: {
1555 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1556 * @param[in] transport_protocol_type - This value is provided in the request
1557 * to help the responder verify that the content of the
1558 * eventReceiverAddressInfo field used in this request is correct for
1559 * the messaging protocol supported by the terminus.
1560 * @param[in] event_receiver_address_info - this value is a medium and
1561 * protocol-specific address that the responder should use when
1562 * transmitting event messages using the indicated protocol
1563 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing
1564 * of which the terminus shall emit a heartbeat event to the receiver
1565 * @param[out] msg - Argument to capture the Message
1566 * @return pldm_completion_codes
1567 */
1568int encode_set_event_receiver_req(uint8_t instance_id,
1569 uint8_t event_message_global_enable,
1570 uint8_t transport_protocol_type,
1571 uint8_t event_receiver_address_info,
1572 uint16_t heartbeat_timer,
1573 struct pldm_msg *msg);
1574
1575/** @brief Decode the SetEventReceiver response message
1576 *
1577 * @param[in] msg - Request message
1578 * @param[in] payload_length - Length of response message payload
1579 * @param[out] completion_code - PLDM completion code
1580 * @return pldm_completion_codes
1581 */
1582int decode_set_event_receiver_resp(const struct pldm_msg *msg,
1583 size_t payload_length,
1584 uint8_t *completion_code);
1585
1586/** @brief Decode the SetEventReceiver request message
1587 *
1588 * @param[in] msg - Request message
1589 * @param[in] payload_length - Length of request message payload
1590 * @param[out] event_message_global_enable - This value is used to enable or
1591 * disable event message generation from the terminus value: {
1592 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1593 * @param[out] transport_protocol_type - This value is provided in the request
1594 * to help the responder verify that the content of the
1595 * eventReceiverAddressInfo field used in this request is correct for
1596 * the messaging protocol supported by the terminus.
1597 * @param[out] event_receiver_address_info - This value is a medium and
1598 * protocol-specific address that the responder should use when
1599 * transmitting event messages using the indicated protocol
1600 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing
1601 * of which the terminus shall emit a heartbeat event to the receiver
1602 * @return pldm_completion_codes
1603 */
1604int decode_set_event_receiver_req(const struct pldm_msg *msg,
1605 size_t payload_length,
1606 uint8_t *event_message_global_enable,
1607 uint8_t *transport_protocol_type,
1608 uint8_t *event_receiver_address_info,
1609 uint16_t *heartbeat_timer);
1610
1611/** @brief Encode the SetEventReceiver response message
1612 *
1613 * @param[in] instance_id - Message's instance id
1614 * @param[in] completion_code - PLDM completion code
1615 * @param[out] msg - Argument to capture the Message
1616 * @return pldm_completion_codes
1617 */
1618int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code,
1619 struct pldm_msg *msg);
1620
1621#ifdef __cplusplus
1622}
1623#endif
1624
1625#endif /* PLATFORM_H */