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