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