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