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