xref: /openbmc/libpldm/include/libpldm/platform.h (revision dacfa354)
1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2 #ifndef PLATFORM_H
3 #define PLATFORM_H
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
9 #include <assert.h>
10 #include <stdalign.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 #include <uchar.h>
14 
15 #include <libpldm/base.h>
16 #include <libpldm/pdr.h>
17 #include <libpldm/pldm_types.h>
18 
19 /**
20  * @brief PLDM response transfer flag for the Platform and control commands
21  *        (GetPDRs, PollForPlatformEventMessage)
22  */
23 enum pldm_platform_transfer_flag {
24 	PLDM_PLATFORM_TRANSFER_START = 0x00,
25 	PLDM_PLATFORM_TRANSFER_MIDDLE = 0x01,
26 	PLDM_PLATFORM_TRANSFER_END = 0x04,
27 	PLDM_PLATFORM_TRANSFER_START_AND_END = 0x05,
28 };
29 
30 /* Maximum size for request */
31 #define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES  19
32 #define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES  4
33 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
34 #define PLDM_GET_STATE_EFFECTER_STATES_REQ_BYTES  2
35 #define PLDM_GET_SENSOR_READING_REQ_BYTES	  3
36 #define PLDM_SET_EVENT_RECEIVER_REQ_BYTES	  5
37 /* Response lengths are inclusive of completion code */
38 #define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
39 
40 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES    1
41 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
42 
43 #define PLDM_GET_PDR_REQ_BYTES 13
44 
45 #define PLDM_SET_EVENT_RECEIVER_RESP_BYTES 1
46 
47 /* Platform event supported request */
48 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_REQ_BYTES  2
49 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES 3
50 
51 #define PLDM_EVENT_MESSAGE_SUPPORTED_REQ_BYTES	    1
52 #define PLDM_EVENT_MESSAGE_SUPPORTED_MIN_RESP_BYTES 4
53 
54 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_REQ_BYTES	    8
55 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES 4
56 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_RESP_BYTES	    14
57 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_CHECKSUM_BYTES 4
58 
59 /* Minimum response length */
60 #define PLDM_GET_PDR_MIN_RESP_BYTES		       12
61 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
62 #define PLDM_GET_STATE_EFFECTER_STATES_MIN_RESP_BYTES  2
63 #define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES	       8
64 #define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES  2
65 #define PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES	       41
66 
67 /* Minimum length for PLDM PlatformEventMessage request */
68 #define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES		 3
69 #define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
70 #define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES			 2
71 #define PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION		 1
72 #define PLDM_PLATFORM_EVENT_MESSAGE_EVENT_ID			 2
73 #define PLDM_PLATFORM_EVENT_MESSAGE_TRANFER_HANDLE		 4
74 
75 /* Minimum length of sensor event data */
76 #define PLDM_MSG_POLL_EVENT_LENGTH 7
77 
78 /* Minimum length of sensor event data */
79 #define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH			 5
80 #define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH		 2
81 #define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH	 3
82 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH	 4
83 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH	 7
84 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH	 4
85 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
86 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
87 
88 /* Minimum length of data for pldmPDRRepositoryChgEvent */
89 #define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH     2
90 #define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2
91 
92 /* Minimum length of numeric sensor PDR */
93 #define PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH		       57
94 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH 3
95 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH      9
96 #define PLDM_PDR_NUMERIC_SENSOR_PDR_MIN_LENGTH                                 \
97 	(PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH +                            \
98 	 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH +      \
99 	 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH)
100 
101 /* Minimum length of numeric effecter PDR */
102 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH			   56
103 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH 2
104 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH	   5
105 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_MIN_LENGTH                               \
106 	(PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH +                          \
107 	 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH +  \
108 	 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH)
109 
110 /**
111  * Minimum length of entity auxiliary name effecter PDR includes size of hdr,
112  * entityType, entityInstanceNumber, entityContainerID, sharedNameCount and
113  * nameStringCount in `Table 95 - Entity Auxiliary Names PDR format` of DSP0248
114  * v1.2.2
115  */
116 #define PLDM_PDR_ENTITY_AUXILIARY_NAME_PDR_MIN_LENGTH 8
117 
118 #define PLDM_INVALID_EFFECTER_ID 0xffff
119 
120 /* DSP0248 Table1 PLDM monitoring and control data types */
121 #define PLDM_STR_UTF_8_MAX_LEN	256
122 #define PLDM_STR_UTF_16_MAX_LEN 256
123 
124 /* Wire-format substructure sizes */
125 #define PLDM_GET_EFFECTER_STATE_FIELD_SIZE 3
126 
127 /* State fields count bounds */
128 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MIN 1
129 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX 8
130 
131 /* Container ID */
132 /** @brief Table 2 - Parts of the Entity Identification Information format in
133  *         PLDM Platform and Control spec, DSP0248 v1.2.2. "If this value is
134  *         0x0000, the containing entity is considered to be the overall system"
135  */
136 #define PLDM_PLATFORM_ENTITY_SYSTEM_CONTAINER_ID 0
137 
138 enum pldm_effecter_data_size {
139 	PLDM_EFFECTER_DATA_SIZE_UINT8,
140 	PLDM_EFFECTER_DATA_SIZE_SINT8,
141 	PLDM_EFFECTER_DATA_SIZE_UINT16,
142 	PLDM_EFFECTER_DATA_SIZE_SINT16,
143 	PLDM_EFFECTER_DATA_SIZE_UINT32,
144 	PLDM_EFFECTER_DATA_SIZE_SINT32
145 };
146 
147 enum pldm_range_field_format {
148 	PLDM_RANGE_FIELD_FORMAT_UINT8,
149 	PLDM_RANGE_FIELD_FORMAT_SINT8,
150 	PLDM_RANGE_FIELD_FORMAT_UINT16,
151 	PLDM_RANGE_FIELD_FORMAT_SINT16,
152 	PLDM_RANGE_FIELD_FORMAT_UINT32,
153 	PLDM_RANGE_FIELD_FORMAT_SINT32,
154 	PLDM_RANGE_FIELD_FORMAT_REAL32
155 };
156 #define PLDM_RANGE_FIELD_FORMAT_MAX PLDM_RANGE_FIELD_FORMAT_REAL32
157 
158 enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
159 
160 enum effecter_state { PLDM_INVALID_VALUE = 0xff };
161 
162 enum pldm_sensor_present_state {
163 	PLDM_SENSOR_UNKNOWN = 0x0,
164 	PLDM_SENSOR_NORMAL = 0x01,
165 	PLDM_SENSOR_WARNING = 0x02,
166 	PLDM_SENSOR_CRITICAL = 0x03,
167 	PLDM_SENSOR_FATAL = 0x04,
168 	PLDM_SENSOR_LOWERWARNING = 0x05,
169 	PLDM_SENSOR_LOWERCRITICAL = 0x06,
170 	PLDM_SENSOR_LOWERFATAL = 0x07,
171 	PLDM_SENSOR_UPPERWARNING = 0x08,
172 	PLDM_SENSOR_UPPERCRITICAL = 0x09,
173 	PLDM_SENSOR_UPPERFATAL = 0x0a
174 };
175 
176 enum pldm_sensor_event_message_enable {
177 	PLDM_NO_EVENT_GENERATION,
178 	PLDM_EVENTS_DISABLED,
179 	PLDM_EVENTS_ENABLED,
180 	PLDM_OP_EVENTS_ONLY_ENABLED,
181 	PLDM_STATE_EVENTS_ONLY_ENABLED
182 };
183 
184 enum pldm_effecter_oper_state {
185 	EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
186 	EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
187 	EFFECTER_OPER_STATE_DISABLED,
188 	EFFECTER_OPER_STATE_UNAVAILABLE,
189 	EFFECTER_OPER_STATE_STATUSUNKNOWN,
190 	EFFECTER_OPER_STATE_FAILED,
191 	EFFECTER_OPER_STATE_INITIALIZING,
192 	EFFECTER_OPER_STATE_SHUTTINGDOWN,
193 	EFFECTER_OPER_STATE_INTEST
194 };
195 
196 enum pldm_platform_commands {
197 	PLDM_SET_EVENT_RECEIVER = 0x04,
198 	PLDM_PLATFORM_EVENT_MESSAGE = 0x0a,
199 	PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE = 0x0b,
200 	PLDM_EVENT_MESSAGE_SUPPORTED = 0x0c,
201 	PLDM_EVENT_MESSAGE_BUFFER_SIZE = 0x0d,
202 	PLDM_GET_SENSOR_READING = 0x11,
203 	PLDM_GET_STATE_SENSOR_READINGS = 0x21,
204 	PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
205 	PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
206 	PLDM_SET_STATE_EFFECTER_STATES = 0x39,
207 	PLDM_GET_STATE_EFFECTER_STATES = 0x3a,
208 	PLDM_GET_PDR_REPOSITORY_INFO = 0x50,
209 	PLDM_GET_PDR = 0x51,
210 };
211 
212 /** @brief PLDM PDR types defined in DSP0248_1.2.0 section 28.2
213  */
214 enum pldm_pdr_types {
215 	PLDM_TERMINUS_LOCATOR_PDR = 1,
216 	PLDM_NUMERIC_SENSOR_PDR = 2,
217 	PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3,
218 	PLDM_STATE_SENSOR_PDR = 4,
219 	PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5,
220 	PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6,
221 	PLDM_OEM_UNIT_PDR = 7,
222 	PLDM_OEM_STATE_SET_PDR = 8,
223 	PLDM_NUMERIC_EFFECTER_PDR = 9,
224 	PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10,
225 	PLDM_STATE_EFFECTER_PDR = 11,
226 	PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12,
227 	PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13,
228 	PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14,
229 	PLDM_PDR_ENTITY_ASSOCIATION = 15,
230 	PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16,
231 	PLDM_OEM_ENTITY_ID_PDR = 17,
232 	PLDM_INTERRUPT_ASSOCIATION_PDR = 18,
233 	PLDM_EVENT_LOG_PDR = 19,
234 	PLDM_PDR_FRU_RECORD_SET = 20,
235 	PLDM_COMPACT_NUMERIC_SENSOR_PDR = 21,
236 	PLDM_REDFISH_RESOURCE_PDR = 22,
237 	PLDM_REDFISH_ENTITY_ASSOCIATION_PDR = 23,
238 	PLDM_REDFISH_ACTION_PDR = 24,
239 	PLDM_OEM_DEVICE_PDR = 126,
240 	PLDM_OEM_PDR = 127,
241 };
242 
243 /** @brief PLDM effecter initialization schemes
244  */
245 enum pldm_effecter_init {
246 	PLDM_NO_INIT,
247 	PLDM_USE_INIT_PDR,
248 	PLDM_ENABLE_EFFECTER,
249 	PLDM_DISABLE_EFECTER
250 };
251 
252 /** @brief PLDM Platform M&C completion codes
253  */
254 enum pldm_platform_completion_codes {
255 	PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80,
256 	PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81,
257 
258 	PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
259 	PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
260 
261 	PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
262 	PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
263 	PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
264 	PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
265 	PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
266 
267 	PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
268 
269 	PLDM_PLATFORM_INVALID_PROTOCOL_TYPE = 0x80,
270 	PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED = 0x81,
271 	PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH = 0x82,
272 };
273 
274 /** @brief PLDM Event types
275  */
276 enum pldm_event_types {
277 	PLDM_SENSOR_EVENT = 0x00,
278 	PLDM_EFFECTER_EVENT = 0x01,
279 	PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
280 	PLDM_REDFISH_MESSAGE_EVENT = 0x03,
281 	PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
282 	PLDM_MESSAGE_POLL_EVENT = 0x05,
283 	PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
284 };
285 
286 /** @brief PLDM sensorEventClass states
287  */
288 enum sensor_event_class_states {
289 	PLDM_SENSOR_OP_STATE,
290 	PLDM_STATE_SENSOR_STATE,
291 	PLDM_NUMERIC_SENSOR_STATE
292 };
293 
294 /** @brief PLDM sensor supported states
295  */
296 enum pldm_sensor_operational_state {
297 	PLDM_SENSOR_ENABLED,
298 	PLDM_SENSOR_DISABLED,
299 	PLDM_SENSOR_UNAVAILABLE,
300 	PLDM_SENSOR_STATUSUNKOWN,
301 	PLDM_SENSOR_FAILED,
302 	PLDM_SENSOR_INITIALIZING,
303 	PLDM_SENSOR_SHUTTINGDOWN,
304 	PLDM_SENSOR_INTEST
305 };
306 
307 /** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
308  */
309 enum pldm_pdr_repository_chg_event_data_format {
310 	REFRESH_ENTIRE_REPOSITORY,
311 	FORMAT_IS_PDR_TYPES,
312 	FORMAT_IS_PDR_HANDLES
313 };
314 
315 /** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format
316  * eventDataOperation. See CHANGELOG.md for info on the alias members.
317  */
318 enum pldm_pdr_repository_chg_event_change_record_event_data_operation {
319 	PLDM_REFRESH_ALL_RECORDS = 0,
320 	PLDM_RECORDS_DELETED = 1,
321 	PLDM_RECORDS_ADDED = 2,
322 	PLDM_RECORDS_MODIFIED = 3,
323 
324 	PLDM_PDR_RECORDS_REFRESH_ALL = 0,
325 	PLDM_PDR_RECORDS_DELETED = 1,
326 	PLDM_PDR_RECORDS_ADDED = 2,
327 	PLDM_PDR_RECORDS_MODIFIED = 3
328 };
329 
330 /** @brief PLDM NumericSensorStatePresentReading data type
331  */
332 enum pldm_sensor_readings_data_type {
333 	PLDM_SENSOR_DATA_SIZE_UINT8,
334 	PLDM_SENSOR_DATA_SIZE_SINT8,
335 	PLDM_SENSOR_DATA_SIZE_UINT16,
336 	PLDM_SENSOR_DATA_SIZE_SINT16,
337 	PLDM_SENSOR_DATA_SIZE_UINT32,
338 	PLDM_SENSOR_DATA_SIZE_SINT32
339 };
340 #define PLDM_SENSOR_DATA_SIZE_MAX PLDM_SENSOR_DATA_SIZE_SINT32
341 
342 /** @brief PLDM PlatformEventMessage response status
343  */
344 enum pldm_platform_event_status {
345 	PLDM_EVENT_NO_LOGGING = 0x00,
346 	PLDM_EVENT_LOGGING_DISABLED = 0x01,
347 	PLDM_EVENT_LOG_FULL = 0x02,
348 	PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03,
349 	PLDM_EVENT_LOGGED = 0x04,
350 	PLDM_EVENT_LOGGING_REJECTED = 0x05
351 };
352 
353 /** @brief PLDM Terminus Locator PDR validity
354  */
355 enum pldm_terminus_locator_pdr_validity {
356 	PLDM_TL_PDR_NOT_VALID,
357 	PLDM_TL_PDR_VALID
358 };
359 
360 /** @brief PLDM Terminus Locator type
361  */
362 enum pldm_terminus_locator_type {
363 	PLDM_TERMINUS_LOCATOR_TYPE_UID,
364 	PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID,
365 	PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE,
366 	PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW
367 };
368 
369 /** @brief PLDM event message global enable for
370  *  SetEventReceiver command
371  */
372 enum pldm_event_message_global_enable {
373 	PLDM_EVENT_MESSAGE_GLOBAL_DISABLE,
374 	PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC,
375 	PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_POLLING,
376 	PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE
377 };
378 
379 /** @brief PLDM DSP0248 1.2.1 table 74 sensorUnits enumeration
380  */
381 enum pldm_sensor_units {
382 	PLDM_SENSOR_UNIT_NONE = 0x00,
383 	PLDM_SENSOR_UNIT_UNSPECIFIED,
384 	PLDM_SENSOR_UNIT_DEGRESS_C,
385 	PLDM_SENSOR_UNIT_DEGRESS_F,
386 	PLDM_SENSOR_UNIT_KELVINS,
387 	PLDM_SENSOR_UNIT_VOLTS,
388 	PLDM_SENSOR_UNIT_AMPS,
389 	PLDM_SENSOR_UNIT_WATTS,
390 	PLDM_SENSOR_UNIT_JOULES,
391 	PLDM_SENSOR_UNIT_COULOMBS,
392 	PLDM_SENSOR_UNIT_VA,
393 	PLDM_SENSOR_UNIT_NITS,
394 	PLDM_SENSOR_UNIT_LUMENS,
395 	PLDM_SENSOR_UNIT_LUX,
396 	PLDM_SENSOR_UNIT_CANDELAS,
397 	PLDM_SENSOR_UNIT_KPA,
398 	PLDM_SENSOR_UNIT_PSI,
399 	PLDM_SENSOR_UNIT_NEWTONS,
400 	PLDM_SENSOR_UNIT_CFM,
401 	PLDM_SENSOR_UNIT_RPM,
402 	PLDM_SENSOR_UNIT_HERTZ,
403 	PLDM_SENSOR_UNIT_SECONDS,
404 	PLDM_SENSOR_UNIT_MINUTES,
405 	PLDM_SENSOR_UNIT_HOURS,
406 	PLDM_SENSOR_UNIT_DAYS,
407 	PLDM_SENSOR_UNIT_WEEKS,
408 	PLDM_SENSOR_UNIT_MILS,
409 	PLDM_SENSOR_UNIT_INCHES,
410 	PLDM_SENSOR_UNIT_FEET,
411 	PLDM_SENSOR_UNIT_CUBIC_INCHES,
412 	PLDM_SENSOR_UNIT_CUBIC_FEET,
413 	PLDM_SENSOR_UNIT_METERS,
414 	PLDM_SENSOR_UNIT_CUBIC_CENTERMETERS,
415 	PLDM_SENSOR_UNIT_CUBIC_METERS,
416 	PLDM_SENSOR_UNIT_LITERS,
417 	PLDM_SENSOR_UNIT_FLUID_OUNCES,
418 	PLDM_SENSOR_UNIT_RADIANS,
419 	PLDM_SENSOR_UNIT_STERADIANS,
420 	PLDM_SENSOR_UNIT_REVOLUTIONS,
421 	PLDM_SENSOR_UNIT_CYCLES,
422 	PLDM_SENSOR_UNIT_GRAVITIES,
423 	PLDM_SENSOR_UNIT_OUNCES,
424 	PLDM_SENSOR_UNIT_POUNDS,
425 	PLDM_SENSOR_UNIT_FOOT_POUNDS,
426 	PLDM_SENSOR_UNIT_OUNCE_INCHES,
427 	PLDM_SENSOR_UNIT_GUESS,
428 	PLDM_SENSOR_UNIT_GILBERTS,
429 	PLDM_SENSOR_UNIT_HENRIES,
430 	PLDM_SENSOR_UNIT_FARADS,
431 	PLDM_SENSOR_UNIT_OHMS,
432 	PLDM_SENSOR_UNIT_SIEMENS,
433 	PLDM_SENSOR_UNIT_MOLES,
434 	PLDM_SENSOR_UNIT_BECQUERELS,
435 	PLDM_SENSOR_UNIT_PPM,
436 	PLDM_SENSOR_UNIT_DECIBELS,
437 	PLDM_SENSOR_UNIT_DBA,
438 	PLDM_SENSOR_UNIT_DBC,
439 	PLDM_SENSOR_UNIT_GRAYS,
440 	PLDM_SENSOR_UNIT_SIEVERTS,
441 	PLDM_SENSOR_UNIT_COLOR_TEMPERATURE_DEGRESS_K,
442 	PLDM_SENSOR_UNIT_BITS,
443 	PLDM_SENSOR_UNIT_BYTES,
444 	PLDM_SENSOR_UNIT_WORDS,
445 	PLDM_SENSOR_UNIT_DOUBLE_WORDS,
446 	PLDM_SENSOR_UNIT_QUAD_WORDS,
447 	PLDM_SENSOR_UNIT_PERCENTAGE,
448 	PLDM_SENSOR_UNIT_PASCALS,
449 	PLDM_SENSOR_UNIT_COUNTS,
450 	PLDM_SENSOR_UNIT_GRAMS,
451 	PLDM_SENSOR_UNIT_NEWTON_METERS,
452 	PLDM_SENSOR_UNIT_HITS,
453 	PLDM_SENSOR_UNIT_MISSES,
454 	PLDM_SENSOR_UNIT_RETRIES,
455 	PLDM_SENSOR_UNIT_OVERRUNS_OVERFLOWS,
456 	PLDM_SENSOR_UNIT_UNDERRUNS,
457 	PLDM_SENSOR_UNIT_COLLISIONS,
458 	PLDM_SENSOR_UNIT_PACKETS,
459 	PLDM_SENSOR_UNIT_MESSAGES,
460 	PLDM_SENSOR_UNIT_CHARATERS,
461 	PLDM_SENSOR_UNIT_ERRORS,
462 	PLDM_SENSOR_UNIT_CORRECTED_ERRORS,
463 	PLDM_SENSOR_UNIT_UNCORRECTABLE_ERRORS,
464 	PLDM_SENSOR_UNIT_SQUARE_MILS,
465 	PLDM_SENSOR_UNIT_SQUARE_INCHES,
466 	PLDM_SENSOR_UNIT_SQUARE_FEET,
467 	PLDM_SENSOR_UNIT_SQUARE_CENTIMETERS,
468 	PLDM_SENSOR_UNIT_SQUARE_METERS,
469 	PLDM_SENSOR_UNIT_OEMUNIT = 255
470 };
471 
472 enum pldm_occurrence_rate {
473 	PLDM_RATE_UNIT_NONE = 0x0,
474 	PLDM_RATE_UNIT_PER_MICRO_SECOND,
475 	PLDM_RATE_UNIT_PER_MILLI_SECOND,
476 	PLDM_RATE_UNIT_PER_SECOND,
477 	PLDM_RATE_UNIT_PER_MINUTE,
478 	PLDM_RATE_UNIT_PER_HOUR,
479 	PLDM_RATE_UNIT_PER_DAY,
480 	PLDM_RATE_UNIT_PER_WEEK,
481 	PLDM_RATE_UNIT_PER_MONTH,
482 	PLDM_RATE_UNIT_PER_YEAR
483 };
484 
485 /** @brief PLDM repository state */
486 enum pldm_repository_state {
487 	PLDM_AVAILABLE,
488 	PLDM_UPDATE_IN_PROGRESS,
489 	PLDM_FAILED
490 };
491 
492 /** @brief PLDM repository data transfer handler timeout */
493 enum pldm_repository_data_transfer_handler_timeout {
494 	PLDM_NO_TIMEOUT,
495 	PLDM_DEFALUT_MINIMUM_TIMEOUT
496 };
497 
498 /** @brief PLDM event message type */
499 enum pldm_event_message_type {
500 	PLDM_MESSAGE_TYPE_NOT_CONFIGURED = 0x00,
501 	PLDM_MESSAGE_TYPE_ASYNCHRONOUS = 0x01,
502 	PLDM_MESSAGE_TYPE_SYNCHRONOUS = 0x02,
503 	PLDM_MESSAGE_TYPE_ASYNCHRONOUS_WITH_HEARTBEAT = 0x03
504 };
505 
506 /** @struct pldm_pdr_hdr
507  *
508  *  Structure representing PLDM common PDR header
509  */
510 struct pldm_pdr_hdr {
511 	uint32_t record_handle;
512 	uint8_t version;
513 	uint8_t type;
514 	uint16_t record_change_num;
515 	uint16_t length;
516 } __attribute__((packed));
517 
518 /** @struct pldm_terminus_locator_pdr
519  *
520  *  Structure representing PLDM terminus locator PDR
521  */
522 struct pldm_terminus_locator_pdr {
523 	struct pldm_pdr_hdr hdr;
524 	uint16_t terminus_handle;
525 	uint8_t validity;
526 	uint8_t tid;
527 	uint16_t container_id;
528 	uint8_t terminus_locator_type;
529 	uint8_t terminus_locator_value_size;
530 	uint8_t terminus_locator_value[1];
531 } __attribute__((packed));
532 
533 /** @struct pldm_sensor_auxiliary_names_pdr
534  *
535  *  Structure representing PLDM Sensor Auxiliary Names PDR
536  */
537 struct pldm_sensor_auxiliary_names_pdr {
538 	struct pldm_pdr_hdr hdr;
539 	uint16_t terminus_handle;
540 	uint16_t sensor_id;
541 	uint8_t sensor_count;
542 	uint8_t names[1];
543 } __attribute__((packed));
544 
545 /** @struct pldm_terminus_locator_type_mctp_eid
546  *
547  *  Structure representing terminus locator value for
548  *  terminus locator type MCTP_EID
549  */
550 struct pldm_terminus_locator_type_mctp_eid {
551 	uint8_t eid;
552 } __attribute__((packed));
553 
554 /** @struct pldm_pdr_entity_association
555  *
556  *  Structure representing PLDM Entity Association PDR
557  */
558 struct pldm_pdr_entity_association {
559 	uint16_t container_id;
560 	uint8_t association_type;
561 	pldm_entity container;
562 	uint8_t num_children;
563 	pldm_entity children[1];
564 } __attribute__((packed));
565 
566 /** @struct pldm_pdr_fru_record_set
567  *
568  *  Structure representing PLDM FRU record set PDR
569  */
570 struct pldm_pdr_fru_record_set {
571 	uint16_t terminus_handle;
572 	uint16_t fru_rsi;
573 	uint16_t entity_type;
574 	union {
575 		uint16_t entity_instance_num;
576 		uint16_t entity_instance;
577 	};
578 	uint16_t container_id;
579 } __attribute__((packed));
580 
581 /** @struct pldm_state_sensor_pdr
582  *
583  *  Structure representing PLDM state sensor PDR
584  */
585 struct pldm_state_sensor_pdr {
586 	struct pldm_pdr_hdr hdr;
587 	uint16_t terminus_handle;
588 	uint16_t sensor_id;
589 	uint16_t entity_type;
590 	uint16_t entity_instance;
591 	uint16_t container_id;
592 	uint8_t sensor_init;
593 	bool8_t sensor_auxiliary_names_pdr;
594 	uint8_t composite_sensor_count;
595 	uint8_t possible_states[1];
596 } __attribute__((packed));
597 
598 /** @struct state_sensor_possible_states
599  *
600  *  Structure representing state enums for state sensor
601  */
602 struct state_sensor_possible_states {
603 	uint16_t state_set_id;
604 	uint8_t possible_states_size;
605 	bitfield8_t states[1];
606 } __attribute__((packed));
607 
608 /** @struct pldm_state_effecter_pdr
609  *
610  *  Structure representing PLDM state effecter PDR
611  */
612 struct pldm_state_effecter_pdr {
613 	struct pldm_pdr_hdr hdr;
614 	uint16_t terminus_handle;
615 	uint16_t effecter_id;
616 	uint16_t entity_type;
617 	uint16_t entity_instance;
618 	uint16_t container_id;
619 	uint16_t effecter_semantic_id;
620 	uint8_t effecter_init;
621 	bool8_t has_description_pdr;
622 	uint8_t composite_effecter_count;
623 	uint8_t possible_states[1];
624 } __attribute__((packed));
625 
626 /** @struct pldm_compact_numeric_sensor_pdr
627  *
628  *  Structure representing PLDM compact numeric sensor PDR
629  */
630 struct pldm_compact_numeric_sensor_pdr {
631 	struct pldm_pdr_hdr hdr;
632 	uint16_t terminus_handle;
633 	uint16_t sensor_id;
634 	uint16_t entity_type;
635 	uint16_t entity_instance;
636 	uint16_t container_id;
637 	uint8_t sensor_name_length;
638 	uint8_t base_unit;
639 	int8_t unit_modifier;
640 	uint8_t occurrence_rate;
641 	bitfield8_t range_field_support;
642 	int32_t warning_high;
643 	int32_t warning_low;
644 	int32_t critical_high;
645 	int32_t critical_low;
646 	int32_t fatal_high;
647 	int32_t fatal_low;
648 	uint8_t sensor_name[1];
649 } __attribute__((packed));
650 
651 /** @brief Encode PLDM state sensor PDR
652  *
653  * @param[in/out] sensor                 Structure to encode. All members of
654  * sensor, except those mentioned in the @note below, should be initialized by
655  * the caller.
656  * @param[in]     allocation_size        Size of sensor allocation in bytes
657  * @param[in]     possible_states        Possible sensor states
658  * @param[in]     possible_states_size   Size of possible sensor states in bytes
659  * @param[out]    actual_size            Size of sensor PDR. Set to 0 on error.
660  * @return int    pldm_completion_codes
661  *                PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
662  *
663  * @note The sensor parameter will be encoded in place.
664  * @note Caller is responsible for allocation of the sensor parameter. Caller
665  *       must allocate enough space for the base structure and the
666  *       sensor->possible_states array, otherwise the function will fail.
667  * @note sensor->hdr.length, .type, and .version will be set appropriately.
668  */
669 int encode_state_sensor_pdr(
670 	struct pldm_state_sensor_pdr *sensor, size_t allocation_size,
671 	const struct state_sensor_possible_states *possible_states,
672 	size_t possible_states_size, size_t *actual_size);
673 
674 /** @union union_effecter_data_size
675  *
676  *  The bit width and format of reading and threshold values that the effecter
677  *  returns.
678  *  Refer to: DSP0248_1.2.0: 28.11 Table 87
679  */
680 typedef union {
681 	uint8_t value_u8;
682 	int8_t value_s8;
683 	uint16_t value_u16;
684 	int16_t value_s16;
685 	uint32_t value_u32;
686 	int32_t value_s32;
687 } union_effecter_data_size;
688 
689 /** @union union_range_field_format
690  *
691  *  Indicates the format used for the nominalValue, normalMax, and normalMin
692  *  fields.
693  *  Refer to: DSP0248_1.2.0: 28.11 Table 87
694  */
695 typedef union {
696 	uint8_t value_u8;
697 	int8_t value_s8;
698 	uint16_t value_u16;
699 	int16_t value_s16;
700 	uint32_t value_u32;
701 	int32_t value_s32;
702 	real32_t value_f32;
703 } union_range_field_format;
704 
705 /** @struct pldm_numeric_effecter_value_pdr
706  *
707  *  Structure representing PLDM numeric effecter value PDR
708  */
709 struct pldm_numeric_effecter_value_pdr {
710 	struct pldm_pdr_hdr hdr;
711 	uint16_t terminus_handle;
712 	uint16_t effecter_id;
713 	uint16_t entity_type;
714 	uint16_t entity_instance;
715 	uint16_t container_id;
716 	uint16_t effecter_semantic_id;
717 	uint8_t effecter_init;
718 	bool8_t effecter_auxiliary_names;
719 	uint8_t base_unit;
720 	int8_t unit_modifier;
721 	uint8_t rate_unit;
722 	uint8_t base_oem_unit_handle;
723 	uint8_t aux_unit;
724 	int8_t aux_unit_modifier;
725 	uint8_t aux_rate_unit;
726 	uint8_t aux_oem_unit_handle;
727 	bool8_t is_linear;
728 	uint8_t effecter_data_size;
729 	real32_t resolution;
730 	real32_t offset;
731 	uint16_t accuracy;
732 	uint8_t plus_tolerance;
733 	uint8_t minus_tolerance;
734 	real32_t state_transition_interval;
735 	real32_t transition_interval;
736 	union_effecter_data_size max_settable;
737 	union_effecter_data_size min_settable;
738 	uint8_t range_field_format;
739 	bitfield8_t range_field_support;
740 	union_range_field_format nominal_value;
741 	union_range_field_format normal_max;
742 	union_range_field_format normal_min;
743 	union_range_field_format rated_max;
744 	union_range_field_format rated_min;
745 } __attribute__((packed));
746 
747 /** @union union_sensor_data_size
748  *
749  *  The bit width and format of reading and threshold values that the sensor
750  *  returns.
751  *  Refer to: DSP0248_1.2.0: 28.4 Table 78
752  */
753 typedef union {
754 	uint8_t value_u8;
755 	int8_t value_s8;
756 	uint16_t value_u16;
757 	int16_t value_s16;
758 	uint32_t value_u32;
759 	int32_t value_s32;
760 } union_sensor_data_size;
761 
762 /** @struct pldm_value_pdr_hdr
763  *
764  *  Structure representing PLDM PDR header for unpacked value
765  *  Refer to: DSP0248_1.2.0: 28.1 Table 75
766  */
767 struct pldm_value_pdr_hdr {
768 	uint32_t record_handle;
769 	uint8_t version;
770 	uint8_t type;
771 	uint16_t record_change_num;
772 	uint16_t length;
773 };
774 
775 /** @struct pldm_numeric_sensor_value_pdr
776  *
777  *  Structure representing PLDM Numeric Sensor PDR for unpacked value
778  *  Refer to: DSP0248_1.2.0: 28.4 Table 78
779  */
780 struct pldm_numeric_sensor_value_pdr {
781 	struct pldm_value_pdr_hdr hdr;
782 	uint16_t terminus_handle;
783 	uint16_t sensor_id;
784 	uint16_t entity_type;
785 	union {
786 		uint16_t entity_instance_num;
787 		uint16_t entity_instance;
788 	};
789 	uint16_t container_id;
790 	uint8_t sensor_init;
791 	bool8_t sensor_auxiliary_names_pdr;
792 	uint8_t base_unit;
793 	int8_t unit_modifier;
794 	uint8_t rate_unit;
795 	uint8_t base_oem_unit_handle;
796 	uint8_t aux_unit;
797 	int8_t aux_unit_modifier;
798 	uint8_t aux_rate_unit;
799 	uint8_t rel;
800 	uint8_t aux_oem_unit_handle;
801 	bool8_t is_linear;
802 	uint8_t sensor_data_size;
803 	real32_t resolution;
804 	real32_t offset;
805 	uint16_t accuracy;
806 	uint8_t plus_tolerance;
807 	uint8_t minus_tolerance;
808 	union_sensor_data_size hysteresis;
809 	bitfield8_t supported_thresholds;
810 	bitfield8_t threshold_and_hysteresis_volatility;
811 	real32_t state_transition_interval;
812 	real32_t update_interval;
813 	union_sensor_data_size max_readable;
814 	union_sensor_data_size min_readable;
815 	uint8_t range_field_format;
816 	bitfield8_t range_field_support;
817 	union_range_field_format nominal_value;
818 	union_range_field_format normal_max;
819 	union_range_field_format normal_min;
820 	union_range_field_format warning_high;
821 	union_range_field_format warning_low;
822 	union_range_field_format critical_high;
823 	union_range_field_format critical_low;
824 	union_range_field_format fatal_high;
825 	union_range_field_format fatal_low;
826 };
827 
828 typedef char16_t pldm_utf16be;
829 
830 struct pldm_entity_auxiliary_name {
831 	/* name_language_tag type is char which terminator is 0x00*/
832 	char *tag;
833 	/**
834 	 * entity_aux_name type is str_utf16be which terminator is 0x00 0x00.
835 	 * The two bytes of one characters is in BE order.
836 	 */
837 	pldm_utf16be *name;
838 };
839 
840 struct pldm_entity_auxiliary_names_pdr {
841 	struct pldm_value_pdr_hdr hdr;
842 	pldm_entity container;
843 	uint8_t shared_name_count;
844 	uint8_t name_string_count;
845 	struct pldm_entity_auxiliary_name *names;
846 	size_t auxiliary_name_data_size;
847 #ifndef __cplusplus
848 #if defined __has_attribute
849 	/*
850 	 * auxiliary_name_data is organised in the fashion of struct-of-arrays, by
851 	 * contrast to the approach of an array-of-structs. By Table 95 the entity
852 	 * name data is provided in (ASCII, UTF16-BE) pairs, but we rearrange that
853 	 * to be an array of UTF16-BE strings followed by an array of ASCII strings,
854 	 * with the pairs associated by index, to maintain alignment.
855 	 */
856 	static_assert(__has_attribute(aligned),
857 		      "auxiliary_name_data risks undefined behaviour");
858 	char auxiliary_name_data[]
859 		__attribute__((aligned(alignof(pldm_utf16be))));
860 #else
861 #error("__has_attribute() support is required to uphold runtime safety")
862 #endif
863 #endif
864 };
865 
866 /** @struct state_effecter_possible_states
867  *
868  *  Structure representing state enums for state effecter
869  */
870 struct state_effecter_possible_states {
871 	uint16_t state_set_id;
872 	uint8_t possible_states_size;
873 	bitfield8_t states[1];
874 } __attribute__((packed));
875 
876 /** @struct pldm_effecter_aux_name_pdr
877  *
878  *  Structure representing PLDM aux name numeric effecter value PDR
879  */
880 struct pldm_effecter_aux_name_pdr {
881 	struct pldm_pdr_hdr hdr;
882 	uint16_t terminus_handle;
883 	uint16_t effecter_id;
884 	uint8_t effecter_count;
885 	uint8_t effecter_names[1];
886 } __attribute__((packed));
887 
888 /** @brief Encode PLDM state effecter PDR
889  *
890  * @param[in/out] effecter               Structure to encode. All members of
891  *                                       effecter, except those mentioned in
892  *                                       the @note below, should be initialized
893  *                                       by the caller.
894  * @param[in]     allocation_size        Size of effecter allocation in bytes
895  * @param[in]     possible_states        Possible effecter states
896  * @param[in]     possible_states_size   Size of possible effecter states in
897  *                                       bytes
898  * @param[out]    actual_size            Size of effecter PDR. Set to 0 on
899  *                                       error.
900  * @return int    pldm_completion_codes
901  *                PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH
902  *
903  * @note The effecter parameter will be encoded in place.
904  * @note Caller is responsible for allocation of the effecter parameter. Caller
905  *       must allocate enough space for the base structure and the
906  *       effecter->possible_states array, otherwise the function will fail.
907  * @note effecter->hdr.length, .type, and .version will be set appropriately.
908  */
909 int encode_state_effecter_pdr(
910 	struct pldm_state_effecter_pdr *effecter, size_t allocation_size,
911 	const struct state_effecter_possible_states *possible_states,
912 	size_t possible_states_size, size_t *actual_size);
913 
914 /** @struct set_effecter_state_field
915  *
916  *  Structure representing a stateField in SetStateEffecterStates command */
917 
918 typedef struct state_field_for_state_effecter_set {
919 	uint8_t set_request;	//!< Whether to change the state
920 	uint8_t effecter_state; //!< Expected state of the effecter
921 } __attribute__((packed)) set_effecter_state_field;
922 
923 /** @struct get_sensor_readings_field
924  *
925  *  Structure representing a stateField in GetStateSensorReadings command */
926 
927 typedef struct state_field_for_get_state_sensor_readings {
928 	uint8_t sensor_op_state; //!< The state of the sensor itself
929 	uint8_t present_state;	 //!< Return a state value
930 	uint8_t previous_state; //!< The state that the presentState was entered
931 				//! from. This must be different from the
932 				//! present state
933 	uint8_t event_state;	//!< Return a state value from a PLDM State Set
934 				//! that is associated with the sensor
935 } __attribute__((packed)) get_sensor_state_field;
936 
937 /** @struct get_effecter_state_field
938  *
939  *  Structure representing a stateField in GetStateEffecterStates command
940  */
941 typedef struct state_field_for_get_state_effecter_states {
942 	uint8_t effecter_op_state; //!< The state of the effecter itself
943 	uint8_t pending_state; //!< The state that is currently being processed
944 	uint8_t present_state; //!< Return a state value
945 } get_effecter_state_field;
946 
947 /** @struct PLDM_SetStateEffecterStates_Request
948  *
949  *  Structure representing PLDM set state effecter states request.
950  */
951 struct pldm_set_state_effecter_states_req {
952 	uint16_t effecter_id;
953 	uint8_t comp_effecter_count;
954 	set_effecter_state_field field[8];
955 } __attribute__((packed));
956 
957 /** @struct pldm_get_pdr_repository_info_resp
958  *
959  *  Structure representing GetPDRRepositoryInfo response packet
960  */
961 struct pldm_pdr_repository_info_resp {
962 	uint8_t completion_code;
963 	uint8_t repository_state;
964 	uint8_t update_time[PLDM_TIMESTAMP104_SIZE];
965 	uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE];
966 	uint32_t record_count;
967 	uint32_t repository_size;
968 	uint32_t largest_record_size;
969 	uint8_t data_transfer_handle_timeout;
970 } __attribute__((packed));
971 
972 /** @struct pldm_get_pdr_resp
973  *
974  *  structure representing GetPDR response packet
975  *  transfer CRC is not part of the structure and will be
976  *  added at the end of last packet in multipart transfer
977  */
978 struct pldm_get_pdr_resp {
979 	uint8_t completion_code;
980 	uint32_t next_record_handle;
981 	uint32_t next_data_transfer_handle;
982 	uint8_t transfer_flag;
983 	uint16_t response_count;
984 	uint8_t record_data[1];
985 } __attribute__((packed));
986 
987 /** @struct pldm_get_pdr_req
988  *
989  *  structure representing GetPDR request packet
990  */
991 struct pldm_get_pdr_req {
992 	uint32_t record_handle;
993 	uint32_t data_transfer_handle;
994 	uint8_t transfer_op_flag;
995 	uint16_t request_count;
996 	uint16_t record_change_number;
997 } __attribute__((packed));
998 
999 /** @struct pldm_set_event_receiver_req
1000  *
1001  * Structure representing SetEventReceiver command.
1002  * This structure applies only for MCTP as a transport type.
1003  */
1004 struct pldm_set_event_receiver_req {
1005 	uint8_t event_message_global_enable;
1006 	uint8_t transport_protocol_type;
1007 	uint8_t event_receiver_address_info;
1008 	uint16_t heartbeat_timer;
1009 } __attribute__((packed));
1010 
1011 /** @struct pldm_event_message_buffer_size_req
1012  *
1013  *  Structure representing EventMessageBufferSizes command request data
1014  */
1015 struct pldm_event_message_buffer_size_req {
1016 	uint16_t event_receiver_max_buffer_size;
1017 } __attribute__((packed));
1018 
1019 /** @struct pldm_event_message_buffer_size_resp
1020  *
1021  *  Structure representing EventMessageBufferSizes command response data
1022  */
1023 struct pldm_event_message_buffer_size_resp {
1024 	uint8_t completion_code;
1025 	uint16_t terminus_max_buffer_size;
1026 } __attribute__((packed));
1027 
1028 /** @struct pldm_platform_event_message_supported_req
1029  *
1030  *  structure representing PlatformEventMessageSupported command request data
1031  */
1032 struct pldm_event_message_supported_req {
1033 	uint8_t format_version;
1034 } __attribute__((packed));
1035 
1036 /** @struct pldm_event_message_supported_response
1037  *
1038  *  structure representing EventMessageSupported command response data
1039  */
1040 struct pldm_event_message_supported_resp {
1041 	uint8_t completion_code;
1042 	uint8_t synchrony_configuration;
1043 	bitfield8_t synchrony_configuration_supported;
1044 	uint8_t number_event_class_returned;
1045 	uint8_t event_class[1];
1046 } __attribute__((packed));
1047 
1048 /** @struct pldm_set_numeric_effecter_value_req
1049  *
1050  *  structure representing SetNumericEffecterValue request packet
1051  */
1052 struct pldm_set_numeric_effecter_value_req {
1053 	uint16_t effecter_id;
1054 	uint8_t effecter_data_size;
1055 	uint8_t effecter_value[1];
1056 } __attribute__((packed));
1057 
1058 /** @struct pldm_get_state_sensor_readings_req
1059  *
1060  *  Structure representing PLDM get state sensor readings request.
1061  */
1062 struct pldm_get_state_sensor_readings_req {
1063 	uint16_t sensor_id;
1064 	bitfield8_t sensor_rearm;
1065 	uint8_t reserved;
1066 } __attribute__((packed));
1067 
1068 /** @struct pldm_get_state_sensor_readings_resp
1069  *
1070  *  Structure representing PLDM get state sensor readings response.
1071  */
1072 struct pldm_get_state_sensor_readings_resp {
1073 	uint8_t completion_code;
1074 	uint8_t comp_sensor_count;
1075 	get_sensor_state_field field[1];
1076 } __attribute__((packed));
1077 
1078 /** @struct pldm_get_state_effecter_states_req
1079  *
1080  *  structure representing GetStateEffecterStates request packet
1081  */
1082 struct pldm_get_state_effecter_states_req {
1083 	uint16_t effecter_id;
1084 };
1085 
1086 /** @struct pldm_get_state_effecter_states_resp
1087  *
1088  *  Structure representing PLDM get state effecter states response.
1089  */
1090 struct pldm_get_state_effecter_states_resp {
1091 	uint8_t completion_code;
1092 	uint8_t comp_effecter_count;
1093 	get_effecter_state_field field[PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX];
1094 };
1095 
1096 /** @struct pldm_sensor_event
1097  *
1098  *  structure representing sensorEventClass
1099  */
1100 struct pldm_sensor_event_data {
1101 	uint16_t sensor_id;
1102 	uint8_t sensor_event_class_type;
1103 	uint8_t event_class[1];
1104 } __attribute__((packed));
1105 
1106 /** @struct pldm_state_sensor_state
1107  *
1108  *  structure representing sensorEventClass for stateSensorState
1109  */
1110 struct pldm_sensor_event_state_sensor_state {
1111 	uint8_t sensor_offset;
1112 	uint8_t event_state;
1113 	uint8_t previous_event_state;
1114 } __attribute__((packed));
1115 
1116 /** @struct pldm_sensor_event_numeric_sensor_state
1117  *
1118  *  structure representing sensorEventClass for stateSensorState
1119  */
1120 struct pldm_sensor_event_numeric_sensor_state {
1121 	uint8_t event_state;
1122 	uint8_t previous_event_state;
1123 	uint8_t sensor_data_size;
1124 	uint8_t present_reading[1];
1125 } __attribute__((packed));
1126 
1127 /** @struct pldm_sensor_event_sensor_op_state
1128  *
1129  *  structure representing sensorEventClass for SensorOpState
1130  */
1131 struct pldm_sensor_event_sensor_op_state {
1132 	uint8_t present_op_state;
1133 	uint8_t previous_op_state;
1134 } __attribute__((packed));
1135 
1136 /** @struct pldm_platform_event_message_req
1137  *
1138  *  structure representing PlatformEventMessage command request data
1139  */
1140 struct pldm_platform_event_message_req {
1141 	uint8_t format_version;
1142 	uint8_t tid;
1143 	uint8_t event_class;
1144 	uint8_t event_data[1];
1145 } __attribute__((packed));
1146 
1147 /** @struct pldm_poll_for_platform_event_message_req
1148  *
1149  *  structure representing PollForPlatformEventMessage command request data
1150  */
1151 struct pldm_poll_for_platform_event_message_req {
1152 	uint8_t format_version;
1153 	uint8_t transfer_operation_flag;
1154 	uint32_t data_transfer_handle;
1155 	uint16_t event_id_to_acknowledge;
1156 };
1157 
1158 /** @struct pldm_poll_for_platform_event_message_min_resp
1159  *
1160  *  structure representing PollForPlatformEventMessage command response data
1161  */
1162 struct pldm_poll_for_platform_event_message_min_resp {
1163 	uint8_t completion_code;
1164 	uint8_t tid;
1165 	uint16_t event_id;
1166 };
1167 
1168 /** @struct pldm_platform_event_message_response
1169  *
1170  *  structure representing PlatformEventMessage command response data
1171  */
1172 struct pldm_platform_event_message_resp {
1173 	uint8_t completion_code;
1174 	uint8_t platform_event_status;
1175 } __attribute__((packed));
1176 
1177 /** @struct pldm_pdr_repository_chg_event_data
1178  *
1179  *  structure representing pldmPDRRepositoryChgEvent class eventData
1180  */
1181 struct pldm_pdr_repository_chg_event_data {
1182 	uint8_t event_data_format;
1183 	uint8_t number_of_change_records;
1184 	uint8_t change_records[1];
1185 } __attribute__((packed));
1186 
1187 /** @struct pldm_pdr_repository_chg_event_change_record_data
1188  *
1189  *  structure representing pldmPDRRepositoryChgEvent class eventData's change
1190  *  record data
1191  */
1192 struct pldm_pdr_repository_change_record_data {
1193 	uint8_t event_data_operation;
1194 	uint8_t number_of_change_entries;
1195 	uint32_t change_entry[1];
1196 } __attribute__((packed));
1197 
1198 /** @struct pldm_get_numeric_effecter_value_req
1199  *
1200  *  structure representing GetNumericEffecterValue request packet
1201  */
1202 struct pldm_get_numeric_effecter_value_req {
1203 	uint16_t effecter_id;
1204 } __attribute__((packed));
1205 
1206 /** @struct pldm_get_numeric_effecter_value_resp
1207  *
1208  *  structure representing GetNumericEffecterValue response packet
1209  */
1210 struct pldm_get_numeric_effecter_value_resp {
1211 	uint8_t completion_code;
1212 	uint8_t effecter_data_size;
1213 	uint8_t effecter_oper_state;
1214 	uint8_t pending_and_present_values[1];
1215 } __attribute__((packed));
1216 
1217 /** @struct pldm_get_sensor_reading_req
1218  *
1219  *  Structure representing PLDM get sensor reading request
1220  */
1221 struct pldm_get_sensor_reading_req {
1222 	uint16_t sensor_id;
1223 	bool8_t rearm_event_state;
1224 } __attribute__((packed));
1225 
1226 /** @struct pldm_get_sensor_reading_resp
1227  *
1228  *  Structure representing PLDM get sensor reading response
1229  */
1230 struct pldm_get_sensor_reading_resp {
1231 	uint8_t completion_code;
1232 	uint8_t sensor_data_size;
1233 	uint8_t sensor_operational_state;
1234 	uint8_t sensor_event_message_enable;
1235 	uint8_t present_state;
1236 	uint8_t previous_state;
1237 	uint8_t event_state;
1238 	uint8_t present_reading[1];
1239 } __attribute__((packed));
1240 
1241 /* Responder */
1242 
1243 /* SetNumericEffecterValue */
1244 
1245 /** @brief Decode SetNumericEffecterValue request data
1246  *
1247  *  @param[in] msg - Request message
1248  *  @param[in] payload_length - Length of request message payload
1249  *  @param[out] effecter_id - used to identify and access the effecter
1250  *  @param[out] effecter_data_size - The bit width and format of the setting
1251  * 				value for the effecter.
1252  * 				value:{uint8,sint8,uint16,sint16,uint32,sint32}
1253  *  @param[out] effecter_value - The setting value of numeric effecter being
1254  * 				requested.
1255  *  @return pldm_completion_codes
1256  */
1257 int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
1258 					  size_t payload_length,
1259 					  uint16_t *effecter_id,
1260 					  uint8_t *effecter_data_size,
1261 					  uint8_t effecter_value[4]);
1262 
1263 /** @brief Create a PLDM response message for SetNumericEffecterValue
1264  *
1265  *  @param[in] instance_id - Message's instance id
1266  *  @param[in] completion_code - PLDM completion code
1267  *  @param[out] msg - Message will be written to this
1268  *  @param[in] payload_length - Length of request message payload
1269  *  @return pldm_completion_codes
1270  *  @note  Caller is responsible for memory alloc and dealloc of param
1271  *         'msg.body.payload'
1272  */
1273 int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
1274 					   uint8_t completion_code,
1275 					   struct pldm_msg *msg,
1276 					   size_t payload_length);
1277 
1278 /* SetStateEffecterStates */
1279 
1280 /** @brief Create a PLDM response message for SetStateEffecterStates
1281  *
1282  *  @param[in] instance_id - Message's instance id
1283  *  @param[in] completion_code - PLDM completion code
1284  *  @param[out] msg - Message will be written to this
1285  *  @return pldm_completion_codes
1286  *  @note  Caller is responsible for memory alloc and dealloc of param
1287  *         'msg.body.payload'
1288  */
1289 
1290 int encode_set_state_effecter_states_resp(uint8_t instance_id,
1291 					  uint8_t completion_code,
1292 					  struct pldm_msg *msg);
1293 
1294 /** @brief Decode SetStateEffecterStates request data
1295  *
1296  *  @param[in] msg - Request message
1297  *  @param[in] payload_length - Length of request message payload
1298  *  @param[out] effecter_id - used to identify and access the effecter
1299  *  @param[out] comp_effecter_count - number of individual sets of effecter
1300  *         information. Upto eight sets of state effecter info can be accessed
1301  *         for a given effecter.
1302  *  @param[out] field - each unit is an instance of the stateFileld structure
1303  *         that is used to set the requested state for a particular effecter
1304  *         within the state effecter. This field holds the starting address of
1305  *         the stateField values. The user is responsible to allocate the
1306  *         memory prior to calling this command. Since the state field count is
1307  *         not known in advance, the user should allocate the maximum size
1308  *         always, which is 8 in number.
1309  *  @return pldm_completion_codes
1310  */
1311 
1312 int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
1313 					 size_t payload_length,
1314 					 uint16_t *effecter_id,
1315 					 uint8_t *comp_effecter_count,
1316 					 set_effecter_state_field *field);
1317 
1318 /* GetPDR */
1319 
1320 /** @brief Create a PLDM response message for GetPDR
1321  *
1322  *  @param[in] instance_id - Message's instance id
1323  *  @param[in] completion_code - PLDM completion code
1324  *  @param[in] next_record_hndl - The recordHandle for the PDR that is next in
1325  *        the PDR Repository
1326  *  @param[in] next_data_transfer_hndl - A handle that identifies the next
1327  *        portion of the PDR data to be transferred, if any
1328  *  @param[in] transfer_flag - Indicates the portion of PDR data being
1329  *        transferred
1330  *  @param[in] resp_cnt - The number of recordData bytes returned in this
1331  *        response
1332  *  @param[in] record_data - PDR data bytes of length resp_cnt
1333  *  @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
1334  *        in the last part of a PDR being transferred
1335  *  @param[out] msg - Message will be written to this
1336  *  @return pldm_completion_codes
1337  *  @note  Caller is responsible for memory alloc and dealloc of param
1338  *         'msg.payload'
1339  */
1340 int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
1341 			uint32_t next_record_hndl,
1342 			uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
1343 			uint16_t resp_cnt, const uint8_t *record_data,
1344 			uint8_t transfer_crc, struct pldm_msg *msg);
1345 
1346 /** @brief Decode GetPDR request data
1347  *
1348  *  @param[in] msg - Request message
1349  *  @param[in] payload_length - Length of request message payload
1350  *  @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
1351  *  @param[out] data_transfer_hndl - Handle used to identify a particular
1352  *         multipart PDR data transfer operation
1353  *  @param[out] transfer_op_flag - Flag to indicate the first or subsequent
1354  *         portion of transfer
1355  *  @param[out] request_cnt - The maximum number of record bytes requested
1356  *  @param[out] record_chg_num - Used to determine whether the PDR has changed
1357  *        while PDR transfer is going on
1358  *  @return pldm_completion_codes
1359  */
1360 
1361 int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
1362 		       uint32_t *record_hndl, uint32_t *data_transfer_hndl,
1363 		       uint8_t *transfer_op_flag, uint16_t *request_cnt,
1364 		       uint16_t *record_chg_num);
1365 
1366 /* GetStateSensorReadings */
1367 
1368 /** @brief Decode GetStateSensorReadings request data
1369  *
1370  *  @param[in] msg - Request message
1371  *  @param[in] payload_length - Length of request message payload
1372  *  @param[out] sensor_id - used to identify and access the simple or composite
1373  *         sensor
1374  *  @param[out] sensor_rearm - Each bit location in this field corresponds to a
1375  *         particular sensor within the state sensor, where bit [0] corresponds
1376  *         to the first state sensor (sensor offset 0) and bit [7] corresponds
1377  *         to the eighth sensor (sensor offset 7), sequentially.
1378  *  @param[out] reserved - value: 0x00
1379  *  @return pldm_completion_codes
1380  */
1381 
1382 int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
1383 					 size_t payload_length,
1384 					 uint16_t *sensor_id,
1385 					 bitfield8_t *sensor_rearm,
1386 					 uint8_t *reserved);
1387 
1388 /** @brief Encode GetStateSensorReadings response data
1389  *
1390  *  @param[in] instance_id - Message's instance id
1391  *  @param[in] completion_code - PLDM completion code
1392  *  @param[out] comp_sensor_count - The number of individual sets of sensor
1393  *         information that this command accesses
1394  *  @param[out] field - Each stateField is an instance of a stateField structure
1395  *         that is used to return the present operational state setting and the
1396  *         present state and event state for a particular set of sensor
1397  *         information contained within the state sensor
1398  *  @param[out] msg - Message will be written to this
1399  *  @return pldm_completion_codes
1400  */
1401 
1402 int encode_get_state_sensor_readings_resp(uint8_t instance_id,
1403 					  uint8_t completion_code,
1404 					  uint8_t comp_sensor_count,
1405 					  get_sensor_state_field *field,
1406 					  struct pldm_msg *msg);
1407 
1408 /* GetNumericEffecterValue */
1409 
1410 /** @brief Decode GetNumericEffecterValue request data
1411  *
1412  *  @param[in] msg - Request message
1413  *  @param[in] payload_length - Length of request message payload
1414  *  @param[out] effecter_id - used to identify and access the effecter
1415  *  @return pldm_completion_codes
1416  */
1417 int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
1418 					  size_t payload_length,
1419 					  uint16_t *effecter_id);
1420 
1421 /** @brief Create a PLDM response message for GetNumericEffecterValue
1422  *
1423  *  @param[in] instance_id - Message's instance id
1424  *  @param[in] completion_code - PLDM completion code
1425  *  @param[in] effecter_data_size - The bit width and format of the setting
1426  *             value for the effecter.
1427  * 	       value:{uint8,sint8,uint16,sint16,uint32,sint32}
1428  *  @param[in] effecter_oper_state - The state of the effecter itself
1429  *  @param[in] pending_value - The pending numeric value setting of the
1430  *             effecter. The effecterDataSize field indicates the number of
1431  *             bits used for this field
1432  *  @param[in] present_value - The present numeric value setting of the
1433  *             effecter. The effecterDataSize indicates the number of bits
1434  *             used for this field
1435  *  @param[out] msg - Message will be written to this
1436  *  @param[in] payload_length - Length of request message payload
1437  *  @return pldm_completion_codes
1438  *  @note  Caller is responsible for memory alloc and dealloc of param
1439  *         'msg.payload'
1440  */
1441 int encode_get_numeric_effecter_value_resp(
1442 	uint8_t instance_id, uint8_t completion_code,
1443 	uint8_t effecter_data_size, uint8_t effecter_oper_state,
1444 	const uint8_t *pending_value, const uint8_t *present_value,
1445 	struct pldm_msg *msg, size_t payload_length);
1446 
1447 /* GetSensorReading */
1448 
1449 /** @brief Decode GetSensorReading request data
1450  *
1451  *  @param[in] msg - Request message
1452  *  @param[in] payload_length - Length of request message payload
1453  *  @param[out] sensor_id - A handle that is used to identify and access
1454  *         the sensor
1455  *  @param[out] rearm_event_state - true =  manually re-arm EventState after
1456  *         responding to this request, false = no manual re-arm
1457  *  @return pldm_completion_codes
1458  */
1459 
1460 int decode_get_sensor_reading_req(const struct pldm_msg *msg,
1461 				  size_t payload_length, uint16_t *sensor_id,
1462 				  bool8_t *rearm_event_state);
1463 
1464 /** @brief Encode GetSensorReading response data
1465  *
1466  *  @param[in] instance_id - Message's instance id
1467  *  @param[in] completion_code - PLDM completion code
1468  *  @param[out] sensor_data_size - The bit width and format of reading and
1469  *         threshold values
1470  *  @param[out] sensor_operational_state - The state of the sensor itself
1471  *  @param[out] sensor_event_message_enable - value: { noEventGeneration,
1472  *         eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1473  *         stateEventsOnlyEnabled }
1474  *  @param[out] present_state - The most recently assessed state value monitored
1475  *         by the sensor
1476  *  @param[out] previous_state - The state that the presentState was entered
1477  *         from
1478  *  @param[out] event_state - Indicates which threshold crossing assertion
1479  *         events have been detected
1480  *  @param[out] present_reading - The present value indicated by the sensor
1481  *  @param[out] msg - Message will be written to this
1482  *  @param[in] payload_length - Length of request message payload
1483  *  @return pldm_completion_codes
1484  */
1485 
1486 int encode_get_sensor_reading_resp(uint8_t instance_id, uint8_t completion_code,
1487 				   uint8_t sensor_data_size,
1488 				   uint8_t sensor_operational_state,
1489 				   uint8_t sensor_event_message_enable,
1490 				   uint8_t present_state,
1491 				   uint8_t previous_state, uint8_t event_state,
1492 				   const uint8_t *present_reading,
1493 				   struct pldm_msg *msg, size_t payload_length);
1494 
1495 /* Requester */
1496 
1497 /*GetPDRRepositoryInfo*/
1498 
1499 /** @brief Encode GetPDRRepositoryInfo response data
1500  *
1501  *  @param[in] instance_id - Message's instance id
1502  *  @param[in] completion_code - PLDM completion code
1503  *  @param[in] repository_state - PLDM repository state
1504  *  @param[in] update_time - When the standard PDR repository data was
1505  *                           originally created
1506  *  @param[in] oem_update_time - when OEM PDRs in the PDR Repository were
1507  *                               originally created
1508  *  @param[in] record_count - Total number of PDRs in this repository
1509  *  @param[in] repository_size - Size of the PDR Repository in bytes
1510  *  @param[in] largest_record_size - Size of the largest record in the PDR
1511  * Repository in bytes
1512  *  @param[in] data_transfer_handle_timeout - Data transmission timeout
1513  *  @param[out] msg - Message will be written to this
1514  *  @return pldm_completion_codes
1515  */
1516 int encode_get_pdr_repository_info_resp(
1517 	uint8_t instance_id, uint8_t completion_code, uint8_t repository_state,
1518 	const uint8_t *update_time, const uint8_t *oem_update_time,
1519 	uint32_t record_count, uint32_t repository_size,
1520 	uint32_t largest_record_size, uint8_t data_transfer_handle_timeout,
1521 	struct pldm_msg *msg);
1522 
1523 /** @brief Decode GetPDRRepositoryInfo response data
1524  *
1525  *  @param[in] msg - Response message
1526  *  @param[in] payload_length - Length of response message payload
1527  *  @param[out] completion_code - PLDM completion code
1528  *  @param[out] repository_state - PLDM repository state
1529  *  @param[out] update_time - When the standard PDR repository data was
1530  *                           originally created
1531  *  @param[out] oem_update_time - when OEM PDRs in the PDR Repository were
1532  *                               originally created
1533  *  @param[out] record_count - Total number of PDRs in this repository
1534  *  @param[out] repository_size - Size of the PDR Repository in bytes
1535  *  @param[out] largest_record_size - Size of the largest record in the PDR
1536  * Repository in bytes
1537  *  @param[out] data_transfer_handle_timeout - Data transmission timeout
1538  *  @return pldm_completion_codes
1539  */
1540 int decode_get_pdr_repository_info_resp(
1541 	const struct pldm_msg *msg, size_t payload_length,
1542 	uint8_t *completion_code, uint8_t *repository_state,
1543 	uint8_t *update_time, uint8_t *oem_update_time, uint32_t *record_count,
1544 	uint32_t *repository_size, uint32_t *largest_record_size,
1545 	uint8_t *data_transfer_handle_timeout);
1546 
1547 /* GetPDR */
1548 
1549 /** @brief Create a PLDM request message for GetPDR
1550  *
1551  *  @param[in] instance_id - Message's instance id
1552  *  @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
1553  *  @param[in] data_transfer_hndl - Handle used to identify a particular
1554  *         multipart PDR data transfer operation
1555  *  @param[in] transfer_op_flag - Flag to indicate the first or subsequent
1556  *         portion of transfer
1557  *  @param[in] request_cnt - The maximum number of record bytes requested
1558  *  @param[in] record_chg_num - Used to determine whether the PDR has changed
1559  *        while PDR transfer is going on
1560  *  @param[out] msg - Message will be written to this
1561  *  @param[in] payload_length - Length of request message payload
1562  *  @return pldm_completion_codes
1563  *  @note  Caller is responsible for memory alloc and dealloc of param
1564  *         'msg.payload'
1565  */
1566 int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
1567 		       uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
1568 		       uint16_t request_cnt, uint16_t record_chg_num,
1569 		       struct pldm_msg *msg, size_t payload_length);
1570 
1571 /** @brief Decode GetPDR response data
1572  *
1573  *  Note:
1574  *  * If the return value is not PLDM_SUCCESS, it represents a
1575  * transport layer error.
1576  *  * If the completion_code value is not PLDM_SUCCESS, it represents a
1577  * protocol layer error and all the out-parameters are invalid.
1578  *
1579  *  @param[in] msg - Request message
1580  *  @param[in] payload_length - Length of request message payload
1581  *  @param[out] completion_code - PLDM completion code
1582  *  @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1583  *        the PDR Repository
1584  *  @param[out] next_data_transfer_hndl - A handle that identifies the next
1585  *        portion of the PDR data to be transferred, if any
1586  *  @param[out] transfer_flag - Indicates the portion of PDR data being
1587  *        transferred
1588  *  @param[out] resp_cnt - The number of recordData bytes returned in this
1589  *        response
1590  *  @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1591  *        skip the copy and place the actual length in resp_cnt.
1592  *  @param[in] record_data_length - Length of record_data
1593  *  @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1594  *        in the last part of a PDR being transferred
1595  *  @return pldm_completion_codes
1596  */
1597 int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1598 			uint8_t *completion_code, uint32_t *next_record_hndl,
1599 			uint32_t *next_data_transfer_hndl,
1600 			uint8_t *transfer_flag, uint16_t *resp_cnt,
1601 			uint8_t *record_data, size_t record_data_length,
1602 			uint8_t *transfer_crc);
1603 
1604 /* SetStateEffecterStates */
1605 
1606 /** @brief Create a PLDM request message for SetStateEffecterStates
1607  *
1608  *  @param[in] instance_id - Message's instance id
1609  *  @param[in] effecter_id - used to identify and access the effecter
1610  *  @param[in] comp_effecter_count - number of individual sets of effecter
1611  *         information. Upto eight sets of state effecter info can be accessed
1612  *         for a given effecter.
1613  *  @param[in] field - each unit is an instance of the stateField structure
1614  *         that is used to set the requested state for a particular effecter
1615  *         within the state effecter. This field holds the starting address of
1616  *         the stateField values. The user is responsible to allocate the
1617  *         memory prior to calling this command. The user has to allocate the
1618  *         field parameter as sizeof(set_effecter_state_field) *
1619  *         comp_effecter_count
1620  *  @param[out] msg - Message will be written to this
1621  *  @return pldm_completion_codes
1622  *  @note  Caller is responsible for memory alloc and dealloc of param
1623  *         'msg.payload'
1624  */
1625 
1626 int encode_set_state_effecter_states_req(uint8_t instance_id,
1627 					 uint16_t effecter_id,
1628 					 uint8_t comp_effecter_count,
1629 					 set_effecter_state_field *field,
1630 					 struct pldm_msg *msg);
1631 
1632 /** @brief Decode SetStateEffecterStates response data
1633  *
1634  *  Note:
1635  *  * If the return value is not PLDM_SUCCESS, it represents a
1636  * transport layer error.
1637  *  * If the completion_code value is not PLDM_SUCCESS, it represents a
1638  * protocol layer error and all the out-parameters are invalid.
1639  *
1640  *  @param[in] msg - Request message
1641  *  @param[in] payload_length - Length of response message payload
1642  *  @param[out] completion_code - PLDM completion code
1643  *  @return pldm_completion_codes
1644  */
1645 int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
1646 					  size_t payload_length,
1647 					  uint8_t *completion_code);
1648 
1649 /* SetNumericEffecterValue */
1650 
1651 /** @brief Create a PLDM request message for SetNumericEffecterValue
1652  *
1653  *  @param[in] instance_id - Message's instance id
1654  *  @param[in] effecter_id - used to identify and access the effecter
1655  *  @param[in] effecter_data_size - The bit width and format of the setting
1656  * 				value for the effecter.
1657  * 				value:{uint8,sint8,uint16,sint16,uint32,sint32}
1658  *  @param[in] effecter_value - The setting value of numeric effecter being
1659  * 				requested.
1660  *  @param[in] payload_length - Length of request message payload
1661  *  @param[out] msg - Message will be written to this
1662  *  @return pldm_completion_codes
1663  *  @note  Caller is responsible for memory alloc and dealloc of param
1664  *         'msg.payload'
1665  */
1666 int encode_set_numeric_effecter_value_req(uint8_t instance_id,
1667 					  uint16_t effecter_id,
1668 					  uint8_t effecter_data_size,
1669 					  const uint8_t *effecter_value,
1670 					  struct pldm_msg *msg,
1671 					  size_t payload_length);
1672 
1673 /** @brief Decode SetNumericEffecterValue response data
1674  *  @param[in] msg - Request message
1675  *  @param[in] payload_length - Length of response message payload
1676  *  @param[out] completion_code - PLDM completion code
1677  *  @return pldm_completion_codes
1678  */
1679 int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1680 					   size_t payload_length,
1681 					   uint8_t *completion_code);
1682 
1683 /** @brief Create a PLDM request message for GetStateSensorReadings
1684  *
1685  *  @param[in] instance_id - Message's instance id
1686  *  @param[in] sensor_id - used to identify and access the simple or composite
1687  *         sensor
1688  *  @param[in] sensorRearm - Each bit location in this field corresponds to a
1689  *         particular sensor within the state sensor, where bit [0] corresponds
1690  *         to the first state sensor (sensor offset 0) and bit [7] corresponds
1691  *         to the eighth sensor (sensor offset 7), sequentially
1692  *  @param[in] reserved - value: 0x00
1693  *  @param[out] msg - Message will be written to this
1694  *  @return pldm_completion_codes
1695  *  @note  Caller is responsible for memory alloc and dealloc of param
1696  *         'msg.payload'
1697  */
1698 int encode_get_state_sensor_readings_req(uint8_t instance_id,
1699 					 uint16_t sensor_id,
1700 					 bitfield8_t sensor_rearm,
1701 					 uint8_t reserved,
1702 					 struct pldm_msg *msg);
1703 
1704 /** @brief Decode GetStateSensorReadings response data
1705  *
1706  *  @param[in] msg - Request message
1707  *  @param[in] payload_length - Length of response message payload
1708  *  @param[out] completion_code - PLDM completion code
1709  *  @param[in,out] comp_sensor_count - The number of individual sets of sensor
1710  *         information that this command accesses
1711  *  @param[out] field - Each stateField is an instance of a stateField structure
1712  *         that is used to return the present operational state setting and the
1713  *         present state and event state for a particular set of sensor
1714  *         information contained within the state sensor
1715  *  @return pldm_completion_codes
1716  */
1717 
1718 int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1719 					  size_t payload_length,
1720 					  uint8_t *completion_code,
1721 					  uint8_t *comp_sensor_count,
1722 					  get_sensor_state_field *field);
1723 
1724 /* GetStateEffecterStates */
1725 
1726 /** @brief Decode GetStateEffecterStates request data
1727  *
1728  *  @param[in] msg - Request message
1729  *  @param[in] payload_length - Length of request message payload
1730  *  @param[out] effecter_id - used to identify and access the effecter
1731  *  @return pldm_completion_codes
1732  */
1733 int decode_get_state_effecter_states_req(const struct pldm_msg *msg,
1734 					 size_t payload_length,
1735 					 uint16_t *effecter_id);
1736 
1737 /** @brief Create a PLDM request message for GetStateEffecterStates
1738  *
1739  *  @param[in] instance_id - Message's instance id
1740  *  @param[in] effecter_id - used to identify and access the effecter
1741  *  @param[out] msg - Message will be written to this
1742  *  @param[in] payload_length - Length of request message payload
1743  *  @return pldm_completion_codes
1744  *  @note  Caller is responsible for memory alloc and dealloc of param
1745  *         'msg.payload'
1746  */
1747 int encode_get_state_effecter_states_req(uint8_t instance_id,
1748 					 uint16_t effecter_id,
1749 					 struct pldm_msg *msg,
1750 					 size_t payload_length);
1751 
1752 /** @brief Decode GetStateEffecterStates response data
1753  *
1754  *  @param[in] msg - Request message
1755  *  @param[in] payload_length - Length of response message payload
1756  *  @param[out] resp - Consists of PLDM completion code, the number
1757 *          of individual sets of effecters information that this command
1758 *          accesses and an instance of a stateField structure that is
1759 *          used to return the present operational state setting and
1760 *          the present state and event state for a particular set of effecter
1761 *          information contained within the state effecter
1762  *  @return pldm_completion_codes
1763  */
1764 int decode_get_state_effecter_states_resp(
1765 	const struct pldm_msg *msg, size_t payload_length,
1766 	struct pldm_get_state_effecter_states_resp *resp);
1767 
1768 /** @brief Encode GetStateEffecterStates response data
1769  *
1770  *  @param[in] instance_id - Message's instance id
1771  *  @param[in] resp - Consists of PLDM completion code, the number
1772 *          of individual sets of effecters information that this command
1773 *          accesses and an instance of a stateField structure that is
1774 *          used to return the present operational state setting and
1775 *          the present state and event state for a particular set of effecter
1776 *          information contained within the state effecter
1777  *  @param[out] msg - Message will be written to this
1778  *  @param[in] payload_length - Length of response message payload
1779  *  @return pldm_completion_codes
1780  */
1781 int encode_get_state_effecter_states_resp(
1782 	uint8_t instance_id, struct pldm_get_state_effecter_states_resp *resp,
1783 	struct pldm_msg *msg, size_t payload_length);
1784 
1785 /* PlatformEventMessage */
1786 
1787 /** @brief Decode PlatformEventMessage request data
1788  *  @param[in] msg - Request message
1789  *  @param[in] payload_length - Length of response message payload
1790  *  @param[out] format_version - Version of the event format
1791  *  @param[out] tid - Terminus ID for the terminus that originated the event
1792  * message
1793  *  @param[out] event_class - The class of event being sent
1794  *  @param[out] event_data_offset - Offset where the event data should be read
1795  * from pldm msg
1796  *  @return pldm_completion_codes
1797  */
1798 int decode_platform_event_message_req(const struct pldm_msg *msg,
1799 				      size_t payload_length,
1800 				      uint8_t *format_version, uint8_t *tid,
1801 				      uint8_t *event_class,
1802 				      size_t *event_data_offset);
1803 
1804 /** @brief Decode PollForEventMessage request data
1805  *  @param[in] msg - Request message
1806  *  @param[in] payload_length - Length of response message payload
1807  *  @param[out] format_version - Version of the event format
1808  *  @param[out] transfer_operation_flag - The transfer operation flag
1809  *  @param[out] data_transfer_handle - The data transfer handle
1810  *  @param[out] event_id_to_acknowledge - The class of event being sent
1811  *  from pldm msg
1812  *  @return pldm_completion_codes
1813  */
1814 int decode_poll_for_platform_event_message_req(
1815 	const struct pldm_msg *msg, size_t payload_length,
1816 	uint8_t *format_version, uint8_t *transfer_operation_flag,
1817 	uint32_t *data_transfer_handle, uint16_t *event_id_to_acknowledge);
1818 
1819 /** @brief Encode PlatformEventMessage response data
1820  *  @param[in] instance_id - Message's instance id
1821  *  @param[in] completion_code - PLDM completion code
1822  *  @param[in] platform_event_status - Response status of the event message
1823  * command
1824  *  @param[out] msg - Message will be written to this
1825  *  @return pldm_completion_codes
1826  *  @note  Caller is responsible for memory alloc and dealloc of param
1827  *         'msg.payload'
1828  */
1829 int encode_platform_event_message_resp(uint8_t instance_id,
1830 				       uint8_t completion_code,
1831 				       uint8_t platform_event_status,
1832 				       struct pldm_msg *msg);
1833 
1834 /** @brief Encode PollForPlatformEventMessage response data
1835  *  @param[in] instance_id - Message's instance id
1836  *  @param[in] completion_code - PLDM completion code
1837  *  @param[in] tid - Terminus ID
1838  *  @param[in] event_id - The event id
1839  *  @param[in] next_data_transfer_handle - The next data transfer handle
1840  *  @param[in] transfer_flag - The transfer flag
1841  *  @param[in] event_class - The event class
1842  *  @param[in] event_data_size - The event data size
1843  *  @param[in] event_data - The event data
1844  *  @param[in] checksum - The checksum
1845  *  @param[out] msg - Message will be written to this
1846  *  @param[in] payload_length - Length of Response message payload
1847  *  @return pldm_completion_codes
1848  *  @note Caller is responsible for memory alloc and dealloc of param
1849  *  'msg.payload'
1850  */
1851 int encode_poll_for_platform_event_message_resp(
1852 	uint8_t instance_id, uint8_t completion_code, uint8_t tid,
1853 	uint16_t event_id, uint32_t next_data_transfer_handle,
1854 	uint8_t transfer_flag, uint8_t event_class, uint32_t event_data_size,
1855 	uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg,
1856 	size_t payload_length);
1857 
1858 /** @brief Encode PlatformEventMessage request data
1859  * @param[in] instance_id - Message's instance id
1860  * @param[in] format_version - Version of the event format
1861  * @param[in] tid - Terminus ID for the terminus that originated the event
1862  * message
1863  * @param[in] event_class - The class of event being sent
1864  * @param[in] event_data - the event data should be read from pldm msg
1865  * @param[in] event_data_length - Length of the event data
1866  * @param[out] msg - Request message
1867  * @return pldm_completion_codes
1868  * @note Caller is responsible for memory alloc and dealloc of param
1869  * 'msg.payload'
1870  */
1871 int encode_platform_event_message_req(
1872 	uint8_t instance_id, uint8_t format_version, uint8_t tid,
1873 	uint8_t event_class, const uint8_t *event_data,
1874 	size_t event_data_length, struct pldm_msg *msg, size_t payload_length);
1875 
1876 /** @brief Encode PollForPlatformEventMessage request data
1877  *  @param[in] instance_id - Message's instance id
1878  *  @param[in] format_version - Version of the event format
1879  *  @param[in] transfer_operation_flag - Transfer operation
1880  *  @param[in] data_transfer_handle - The data transfer handle
1881  *  @param[in] event_id_to_acknowledge - the event data to acknowleadge
1882  *  @param[out] msg - Request message
1883  *  @return pldm_completion_codes
1884  *  @note Caller is responsible for memory alloc and dealloc of param
1885  *  'msg.payload'
1886  */
1887 int encode_poll_for_platform_event_message_req(uint8_t instance_id,
1888 					       uint8_t format_version,
1889 					       uint8_t transfer_operation_flag,
1890 					       uint32_t data_transfer_handle,
1891 					       uint16_t event_id_to_acknowledge,
1892 					       struct pldm_msg *msg,
1893 					       size_t payload_length);
1894 
1895 /** @brief Decode PollForPlatformEventMessage response data
1896  *  @param[in] msg - Request message
1897  *  @param[in] payload_length - Length of Response message payload
1898  *  @param[out] completion_code - the completion code
1899  *  @param[out] tid - the tid
1900  *  @param[out] event_id - The event id
1901  *  @param[out] next_data_transfer_handle - The next data transfer handle
1902  *  @param[out] transfer_flag - The transfer flag
1903  *  @param[out] event_class - The event class
1904  *  @param[out] event_data_size - The event data size
1905  *  @param[out] event_data - The event data. The event_data pointer points into
1906  *  msg.payload and therefore has the same lifetime as msg.payload.
1907  *  @param[out] event_data_integrity_checksum - The checksum
1908  *  command
1909  *  @return pldm_completion_codes
1910  *  @note Caller is responsible for memory alloc and dealloc of param
1911  *  'msg.payload'
1912  */
1913 int decode_poll_for_platform_event_message_resp(
1914 	const struct pldm_msg *msg, size_t payload_length,
1915 	uint8_t *completion_code, uint8_t *tid, uint16_t *event_id,
1916 	uint32_t *next_data_transfer_handle, uint8_t *transfer_flag,
1917 	uint8_t *event_class, uint32_t *event_data_size, void **event_data,
1918 	uint32_t *event_data_integrity_checksum);
1919 
1920 /** @brief Decode PlatformEventMessage response data
1921  * @param[in] msg - Request message
1922  * @param[in] payload_length - Length of Response message payload
1923  * @param[out] completion_code - PLDM completion code
1924  * @param[out] platform_event_status - Response status of the event message
1925  * command
1926  * @return pldm_completion_codes
1927  */
1928 int decode_platform_event_message_resp(const struct pldm_msg *msg,
1929 				       size_t payload_length,
1930 				       uint8_t *completion_code,
1931 				       uint8_t *platform_event_status);
1932 
1933 /** @brief Decode EventMessageBufferSize response data
1934  *  @param[in] msg - Request message
1935  *  @param[in] payload_length - Length of Response message payload
1936  *  @param[out] completion_code - PLDM completion code
1937  *  @return pldm_completion_codes
1938  */
1939 int decode_event_message_buffer_size_resp(const struct pldm_msg *msg,
1940 					  size_t payload_length,
1941 					  uint8_t *completion_code,
1942 					  uint16_t *terminus_max_buffer_size);
1943 
1944 /** @brief Encode EventMessageBufferSize request data
1945  *  @param[in] instance_id - Message's instance id
1946  *  @param[in] event_receiver_max_buffer_size - Max buffer size
1947  *  @param[out] msg - Request message
1948  *  @return pldm_completion_codes
1949  *  @note Caller is responsible for memory alloc and dealloc of param
1950  *  'msg.payload'
1951  */
1952 int encode_event_message_buffer_size_req(uint8_t instance_id,
1953 					 uint16_t event_receiver_max_buffer_size,
1954 					 struct pldm_msg *msg);
1955 
1956 /** @brief Encode EventMessageSupported request data
1957  *
1958  *  @param[in] instance_id - Message's instance id
1959  *  @param[in] format_version - Version of the event format
1960  *  @param[out] msg - Request message
1961  *
1962  *  @return pldm_completion_codes
1963  *  @note Caller is responsible for memory alloc and dealloc of param
1964  *  'msg.payload'
1965  */
1966 int encode_event_message_supported_req(uint8_t instance_id,
1967 				       uint8_t format_version,
1968 				       struct pldm_msg *msg);
1969 
1970 /** @brief Decode EventMessageSupported response data
1971  *
1972  *  @param[in] msg - Request message
1973  *  @param[in] payload_length - Length of Response message payload
1974  *  @param[out] completion_code - PLDM completion code
1975  *  @param[out] synchrony_config - the synchrony configuration
1976  *  @param[out] synchrony_config_support - the synchrony configuration support
1977  *  @param[out] number_event_class_returned - PLDM completion code
1978  *  @param[out] event_class - the event classes
1979  *  @param[in] event_class_count - the event class count
1980  *
1981  *  @return pldm_completion_codes
1982  */
1983 int decode_event_message_supported_resp(const struct pldm_msg *msg,
1984 					size_t payload_length,
1985 					uint8_t *completion_code,
1986 					uint8_t *synchrony_config,
1987 					bitfield8_t *synchrony_config_support,
1988 					uint8_t *number_event_class_returned,
1989 					uint8_t *event_class,
1990 					uint8_t event_class_count);
1991 
1992 /** @brief Decode sensorEventData response data
1993  *
1994  *  @param[in] event_data - event data from the response message
1995  *  @param[in] event_data_length - length of the event data
1996  *  @param[out] sensor_id -  sensorID value of the sensor
1997  *  @param[out] sensor_event_class_type - Type of sensor event class
1998  *  @param[out] event_class_data_offset - Offset where the event class data
1999  * should be read from event data
2000  *  @return pldm_completion_codes
2001  *  @note  Caller is responsible for memory alloc and dealloc of param
2002  *         'event_data'
2003  */
2004 int decode_sensor_event_data(const uint8_t *event_data,
2005 			     size_t event_data_length, uint16_t *sensor_id,
2006 			     uint8_t *sensor_event_class_type,
2007 			     size_t *event_class_data_offset);
2008 
2009 /** @brief Decode sensorOpState response data
2010  *
2011  *  @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
2012  *  @param[in] sensor_data_length - Length of sensor_data
2013  *  @param[out] present_op_state - The sensorOperationalState value from the
2014  * state change that triggered the event message
2015  *  @param[out] previous_op_state - The sensorOperationalState value for the
2016  * state from which the present state was entered
2017  *  @return pldm_completion_codes
2018  *  @note  Caller is responsible for memory alloc and dealloc of param
2019  *         'sensor_data'
2020  */
2021 int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
2022 			  uint8_t *present_op_state,
2023 			  uint8_t *previous_op_state);
2024 
2025 /** @brief Decode stateSensorState response data
2026  *
2027  *  @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
2028  *  @param[in] sensor_data_length - Length of sensor_data
2029  *  @param[out] sensor_offset - Identifies which state sensor within a composite
2030  * state sensor the event is being returned for
2031  *  @param[out] event_state - The event state value from the state change that
2032  * triggered the event message
2033  *  @param[out] previous_event_state - The event state value for the state from
2034  * which the present event state was entered
2035  *  @return pldm_completion_codes
2036  *  @note  Caller is responsible for memory alloc and dealloc of param
2037  *         'sensor_data'
2038  */
2039 int decode_state_sensor_data(const uint8_t *sensor_data,
2040 			     size_t sensor_data_length, uint8_t *sensor_offset,
2041 			     uint8_t *event_state,
2042 			     uint8_t *previous_event_state);
2043 
2044 /** @brief Decode numericSensorState response data
2045  *
2046  *  @param[in] sensor_data - sensor_data for sensorEventClass =
2047  * numericSensorState
2048  *  @param[in] sensor_data_length - Length of sensor_data
2049  *  @param[out] event_state - The eventState value from the state change that
2050  * triggered the event message
2051  *  @param[out] previous_event_state - The eventState value for the state from
2052  * which the present state was entered
2053  *  @param[out] sensor_data_size - The bit width and format of reading and
2054  * threshold values that the sensor returns
2055  *  @param[out] present_reading - The present value indicated by the sensor
2056  *  @return pldm_completion_codes
2057  *  @note  Caller is responsible for memory alloc and dealloc of param
2058  *         'sensor_data'
2059  */
2060 int decode_numeric_sensor_data(const uint8_t *sensor_data,
2061 			       size_t sensor_data_length, uint8_t *event_state,
2062 			       uint8_t *previous_event_state,
2063 			       uint8_t *sensor_data_size,
2064 			       uint32_t *present_reading);
2065 
2066 /** @brief Decode Numeric Sensor Pdr data
2067  *
2068  *  @param[in] pdr_data - pdr data for numeric sensor
2069  *  @param[in] pdr_data_length - Length of pdr data
2070  *  @param[out] pdr_value - unpacked numeric sensor PDR struct
2071  */
2072 int decode_numeric_sensor_pdr_data(
2073 	const void *pdr_data, size_t pdr_data_length,
2074 	struct pldm_numeric_sensor_value_pdr *pdr_value);
2075 
2076 /* GetNumericEffecterValue */
2077 
2078 /** @brief Create a PLDM request message for GetNumericEffecterValue
2079  *
2080  *  @param[in] instance_id - Message's instance id
2081  *  @param[in] effecter_id - used to identify and access the effecter
2082  *  @param[out] msg - Message will be written to this
2083  *  @return pldm_completion_codes
2084  *  @note  Caller is responsible for memory alloc and dealloc of param
2085  *         'msg.payload'
2086  */
2087 int encode_get_numeric_effecter_value_req(uint8_t instance_id,
2088 					  uint16_t effecter_id,
2089 					  struct pldm_msg *msg);
2090 
2091 /** @brief Create a PLDM response message for GetNumericEffecterValue
2092  *
2093  *  @param[in] msg - Request message
2094  *  @param[in] payload_length - Length of request message payload
2095  *  @param[out] completion_code - PLDM completion code
2096  *  @param[out] effecter_data_size - The bit width and format of the setting
2097  *		value for the effecter.
2098  *		value:{uint8,sint8,uint16,sint16,uint32,sint32}
2099  *  @param[out] effecter_oper_state - The state of the effecter itself
2100  *  @param[out] pending_value - The pending numeric value setting of the
2101  *              effecter. The effecterDataSize field indicates the number of
2102  *              bits used for this field
2103  *  @param[out] present_value - The present numeric value setting of the
2104  *              effecter. The effecterDataSize indicates the number of bits
2105  *              used for this field
2106  *  @return pldm_completion_codes
2107  */
2108 int decode_get_numeric_effecter_value_resp(const struct pldm_msg *msg,
2109 					   size_t payload_length,
2110 					   uint8_t *completion_code,
2111 					   uint8_t *effecter_data_size,
2112 					   uint8_t *effecter_oper_state,
2113 					   uint8_t *pending_value,
2114 					   uint8_t *present_value);
2115 
2116 /** @brief Decode pldmPDRRepositoryChgEvent response data
2117  *
2118  *  @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
2119  *  @param[in] event_data_size - Length of event_data
2120  *  @param[out] event_data_format - This field indicates if the changedRecords
2121  * are of PDR Types or PDR Record Handles
2122  *  @param[out] number_of_change_records - The number of changeRecords following
2123  * this field
2124  *  @param[out] change_record_data_offset - Identifies where changeRecord data
2125  * is located within event_data
2126  *  @return pldm_completion_codes
2127  *  @note  Caller is responsible for memory alloc and dealloc of param
2128  *         'event_data'
2129  */
2130 int decode_pldm_pdr_repository_chg_event_data(
2131 	const uint8_t *event_data, size_t event_data_size,
2132 	uint8_t *event_data_format, uint8_t *number_of_change_records,
2133 	size_t *change_record_data_offset);
2134 
2135 /** @brief Decode pldmMessagePollEvent event data type
2136  *
2137  *  @param[in] event_data - event data from the response message
2138  *  @param[in] event_data_length - length of the event data
2139  *  @param[out] format_version - Version of the event format
2140  *  @param[out] event_id - The event id
2141  *  @param[out] data_transfer_handle - The data transfer handle
2142  *  should be read from event data
2143  *  @return pldm_completion_codes
2144  *  @note  Caller is responsible for memory alloc and dealloc of param
2145  *         'event_data'
2146  */
2147 int decode_pldm_message_poll_event_data(const uint8_t *event_data,
2148 					size_t event_data_length,
2149 					uint8_t *format_version,
2150 					uint16_t *event_id,
2151 					uint32_t *data_transfer_handle);
2152 
2153 /** @brief Encode pldmMessagePollEvent event data type
2154  *
2155  *  @param[in] format_version - Version of the event format
2156  *  @param[in] event_id - The event id
2157  *  @param[in] data_transfer_handle - The data transfer handle
2158  *  @param[out] event_data - event data to the response message
2159  *  @param[in] event_data_length - length of the event data
2160  *  @return pldm_completion_codes
2161  *  @note The caller is responsible for allocating and deallocating the
2162  *        event_data
2163  */
2164 int encode_pldm_message_poll_event_data(uint8_t format_version,
2165 					uint16_t event_id,
2166 					uint32_t data_transfer_handle,
2167 					uint8_t *event_data,
2168 					size_t event_data_length);
2169 
2170 /** @brief Encode PLDM PDR Repository Change eventData
2171  *  @param[in] event_data_format - Format of this event data (e.g.
2172  * FORMAT_IS_PDR_HANDLES)
2173  *  @param[in] number_of_change_records - Number of changeRecords in this
2174  * eventData
2175  *  @param[in] event_data_operations - Array of eventDataOperations
2176  *      (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
2177  * should contain number_of_change_records elements.
2178  *  @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
2179  *      for each changeRecord in this eventData. This array should contain
2180  *      number_of_change_records elements.
2181  *  @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
2182  *      one array per changeRecord in this eventData. The toplevel array should
2183  *      contain number_of_change_records elements. Each subarray [i] should
2184  *      contain numbers_of_change_entries[i] elements.
2185  *  @param[in] event_data - The eventData will be encoded into this. This entire
2186  *      structure must be max_change_records_size long. It must be large enough
2187  *      to accommodate the data to be encoded. The caller is responsible for
2188  *      allocating and deallocating it, including the variable-size
2189  *      'event_data.change_records' field. If this parameter is NULL,
2190  *      PLDM_SUCCESS will be returned and actual_change_records_size will be set
2191  *      to reflect the required size of the structure.
2192  *  @param[out] actual_change_records_size - The actual number of meaningful
2193  *      encoded bytes in event_data. The caller can over-allocate memory and use
2194  *      this output to determine the real size of the structure.
2195  *  @param[in] max_change_records_size - The size of event_data in bytes. If the
2196  *      encoded message would be larger than this value, an error is returned.
2197  *  @return pldm_completion_codes
2198  *  @note  Caller is responsible for memory alloc and dealloc of param
2199  * 'event_data.change_records'
2200  */
2201 int encode_pldm_pdr_repository_chg_event_data(
2202 	uint8_t event_data_format, uint8_t number_of_change_records,
2203 	const uint8_t *event_data_operations,
2204 	const uint8_t *numbers_of_change_entries,
2205 	const uint32_t *const *change_entries,
2206 	struct pldm_pdr_repository_chg_event_data *event_data,
2207 	size_t *actual_change_records_size, size_t max_change_records_size);
2208 
2209 /** @brief Encode event data for a PLDM Sensor Event
2210  *
2211  *  @param[out] event_data              The object to store the encoded event in
2212  *  @param[in] event_data_size          Size of the allocation for event_data
2213  *  @param[in] sensor_id                Sensor ID
2214  *  @param[in] sensor_event_class       Sensor event class
2215  *  @param[in] sensor_offset            Offset
2216  *  @param[in] event_state              Event state
2217  *  @param[in] previous_event_state     Previous event state
2218  *  @param[out] actual_event_data_size  The real size in bytes of the event_data
2219  *  @return int pldm_completion_codes   PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
2220  *  @note If event_data is NULL, then *actual_event_data_size will be set to
2221  *        reflect the size of the event data, and PLDM_SUCCESS will be returned.
2222  *  @note The caller is responsible for allocating and deallocating the
2223  *        event_data
2224  */
2225 int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
2226 			     size_t event_data_size, uint16_t sensor_id,
2227 			     enum sensor_event_class_states sensor_event_class,
2228 			     uint8_t sensor_offset, uint8_t event_state,
2229 			     uint8_t previous_event_state,
2230 			     size_t *actual_event_data_size);
2231 
2232 /** @brief Decode PldmPDRRepositoryChangeRecord response data
2233  *
2234  *  @param[in] change_record_data - changeRecordData for
2235  * pldmPDRRepositoryChgEvent
2236  *  @param[in] change_record_data_size - Length of change_record_data
2237  *  @param[out] event_data_operation - This field indicates the changeEntries
2238  * operation types
2239  *  @param[out] number_of_change_entries - The number of changeEntries following
2240  * this field
2241  *  @param[out] change_entry_data_offset - Identifies where changeEntries data
2242  * is located within change_record_data
2243  *  @return pldm_completion_codes
2244  *  @note  Caller is responsible for memory alloc and dealloc of param
2245  *         'change_record_data'
2246  */
2247 int decode_pldm_pdr_repository_change_record_data(
2248 	const uint8_t *change_record_data, size_t change_record_data_size,
2249 	uint8_t *event_data_operation, uint8_t *number_of_change_entries,
2250 	size_t *change_entry_data_offset);
2251 
2252 /* GetSensorReading */
2253 
2254 /** @brief Encode GetSensorReading request data
2255  *
2256  *  @param[in] instance_id - Message's instance id
2257  *  @param[in] sensor_id - A handle that is used to identify and access the
2258  *         sensor
2259  *  @param[in] rearm_event_state - true =  manually re-arm EventState after
2260  *         responding to this request, false = no manual re-arm
2261  *  @param[out] msg - Message will be written to this
2262  *  @return pldm_completion_codes
2263  *  @note	Caller is responsible for memory alloc and dealloc of param
2264  * 		'msg.payload'
2265  */
2266 int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
2267 				  bool8_t rearm_event_state,
2268 				  struct pldm_msg *msg);
2269 
2270 /** @brief Decode GetSensorReading response data
2271  *
2272  *  @param[in] msg - Request message
2273  *  @param[in] payload_length - Length of response message payload
2274  *  @param[out] completion_code - PLDM completion code
2275  *  @param[out] sensor_data_size - The bit width and format of reading and
2276  *         threshold values
2277  *  @param[out] sensor_operational_state - The state of the sensor itself
2278  *  @param[out] sensor_event_message_enable - value: { noEventGeneration,
2279  *         eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
2280  *         stateEventsOnlyEnabled }
2281  *  @param[out] present_state - The most recently assessed state value monitored
2282  *         by the sensor
2283  *  @param[out] previous_state - The state that the presentState was entered
2284  *         from
2285  *  @param[out] event_state - Indicates which threshold crossing assertion
2286  *         events have been detected
2287  *  @param[out] present_reading - The present value indicated by the sensor
2288  *  @return pldm_completion_codes
2289  */
2290 
2291 int decode_get_sensor_reading_resp(
2292 	const struct pldm_msg *msg, size_t payload_length,
2293 	uint8_t *completion_code, uint8_t *sensor_data_size,
2294 	uint8_t *sensor_operational_state, uint8_t *sensor_event_message_enable,
2295 	uint8_t *present_state, uint8_t *previous_state, uint8_t *event_state,
2296 	uint8_t *present_reading);
2297 
2298 /** @brief Encode the SetEventReceiver request message
2299  *
2300  * @param[in] instance_id - Message's instance id
2301  * @param[in] event_message_global_enable - This value is used to enable or
2302  *        disable event message generation from the terminus value: {
2303  *        disable, enableAsync, enablePolling, enableAsyncKeepAlive }
2304  * @param[in] transport_protocol_type - This value is provided in the request
2305  *        to help the responder verify that the content of the
2306  *        eventReceiverAddressInfo field used in this request is correct for
2307  *        the messaging protocol supported by the terminus.
2308  * @param[in] event_receiver_address_info - this value is a medium and
2309  *        protocol-specific address that the responder should use when
2310  *        transmitting event messages using the indicated protocol
2311  * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing
2312  *        of which the terminus shall emit a heartbeat event to the receiver
2313  * @param[out] msg - Argument to capture the Message
2314  * @return pldm_completion_codes
2315  */
2316 int encode_set_event_receiver_req(uint8_t instance_id,
2317 				  uint8_t event_message_global_enable,
2318 				  uint8_t transport_protocol_type,
2319 				  uint8_t event_receiver_address_info,
2320 				  uint16_t heartbeat_timer,
2321 				  struct pldm_msg *msg);
2322 
2323 /** @brief Decode the SetEventReceiver response message
2324  *
2325  * @param[in] msg - Request message
2326  * @param[in] payload_length - Length of response message payload
2327  * @param[out] completion_code - PLDM completion code
2328  * @return pldm_completion_codes
2329  */
2330 int decode_set_event_receiver_resp(const struct pldm_msg *msg,
2331 				   size_t payload_length,
2332 				   uint8_t *completion_code);
2333 
2334 /** @brief Decode the SetEventReceiver request message
2335  *
2336  * @param[in] msg - Request message
2337  * @param[in] payload_length - Length of request message payload
2338  * @param[out] event_message_global_enable - This value is used to enable or
2339  *        disable event message generation from the terminus value: {
2340  *        disable, enableAsync, enablePolling, enableAsyncKeepAlive }
2341  * @param[out] transport_protocol_type - This value is provided in the request
2342  *        to help the responder verify that the content of the
2343  *        eventReceiverAddressInfo field used in this request is correct for
2344  *        the messaging protocol supported by the terminus.
2345  * @param[out] event_receiver_address_info - This value is a medium and
2346  *        protocol-specific address that the responder should use when
2347  *        transmitting event messages using the indicated protocol
2348  * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing
2349  *        of which the terminus shall emit a heartbeat event to the receiver
2350  * @return pldm_completion_codes
2351  */
2352 int decode_set_event_receiver_req(const struct pldm_msg *msg,
2353 				  size_t payload_length,
2354 				  uint8_t *event_message_global_enable,
2355 				  uint8_t *transport_protocol_type,
2356 				  uint8_t *event_receiver_address_info,
2357 				  uint16_t *heartbeat_timer);
2358 
2359 /** @brief Encode the SetEventReceiver response message
2360  *
2361  *  @param[in] instance_id - Message's instance id
2362  *  @param[in] completion_code - PLDM completion code
2363  *  @param[out] msg - Argument to capture the Message
2364  *  @return pldm_completion_codes
2365  */
2366 int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code,
2367 				   struct pldm_msg *msg);
2368 
2369 /** @brief Decode Numeric effecter Pdr data
2370  *
2371  *  @param[in] pdr_data - PDR data of the numeric effecter in DSP0248_1.2.2
2372  *         table 87. This must be a pointer to the PDR data in the GetPDR
2373  *         message body
2374  *  @param[in] pdr_data_length - Length of pdr data
2375  *  @param[out] pdr_value - the numeric effecter PDR data struct
2376  */
2377 int decode_numeric_effecter_pdr_data(
2378 	const void *pdr_data, size_t pdr_data_length,
2379 	struct pldm_numeric_effecter_value_pdr *pdr_value);
2380 
2381 /** @brief Decode date fields from Entity Auxiliary name PDR
2382  *
2383  *  @note Use case:
2384  *        1. Call `decode_entity_auxiliary_names_pdr()` to decode the Entity
2385  *           Auxiliary names PDR raw data to the PDR data fields in
2386  *           `struct pldm_entity_auxiliary_names_pdr` equivalent the fields in
2387  *           `table 95` of DSP0248_1.2.2. Excepts the entity language tags and
2388  *           names.
2389  *        2. Use the decoded `name_string_count` and size of
2390  *           `struct pldm_entity_auxiliary_name` to allocate memory for the
2391  *           `struct pldm_entity_auxiliary_name *names` field in
2392  *           `struct pldm_entity_auxiliary_names_pdr`.
2393  *        3. Call `decode_pldm_entity_auxiliary_names_pdr_index()` to decode
2394  *           `auxiliary_name_data[]` in `struct pldm_entity_auxiliary_names_pdr`
2395  *           to the entity language tags and names in
2396  *           `struct pldm_entity_auxiliary_name`.
2397  *
2398  *  @param[in] data - PLDM response message which includes the entity
2399  *                        auxiliary name PDRs in DSP0248_1.2.2 table 95.
2400  *  @param[in] data_length - Length of response message payload
2401  *  @param[out] pdr - Entity auxiliary names pdr struct
2402  *  @param[out] pdr_length - Entity auxiliary names pdr struct
2403  *
2404  *  @return error code
2405  */
2406 int decode_entity_auxiliary_names_pdr(
2407 	const void *data, size_t data_length,
2408 	struct pldm_entity_auxiliary_names_pdr *pdr, size_t pdr_length);
2409 
2410 /** @brief Decode Entity Auxiliary name data. The API will update the name
2411  *         directly to names field in the pdr struct.
2412  *
2413  *  @pre The API will decode `auxiliary_name_data[]` array in
2414  *       `struct pldm_entity_auxiliary_names_pdr pdr` to
2415  *       the entity auxiliary language tags and names in
2416  *       `struct pldm_entity_auxiliary_name *names` of the same pdr struct.
2417  *       Before call the API, the caller has to allocate memory for the `names`
2418  *       struct with the number of name(`name_string_count`) in PDR and size of
2419  *       `struct pldm_entity_auxiliary_name`.
2420  *       The value of `auxiliary_name_data` and `name_string_count` are decoded
2421  *       by `decode_entity_auxiliary_names_pdr()` method so the caller has to
2422  *       call that API first.
2423  *
2424  *  @param[out] pdr_value - Entity auxiliary names pdr struct
2425  *  @param[in] names_size - Size of names data
2426  *  @return error code
2427  */
2428 int decode_pldm_entity_auxiliary_names_pdr_index(
2429 	struct pldm_entity_auxiliary_names_pdr *pdr_value);
2430 #ifdef __cplusplus
2431 }
2432 #endif
2433 
2434 #endif /* PLATFORM_H */
2435