blob: f0eea5154d5085ed68c0e193ff9ad1a29d55e38a [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
1205/* GetPDR */
1206
1207/** @brief Create a PLDM request message for GetPDR
1208 *
1209 * @param[in] instance_id - Message's instance id
1210 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
1211 * @param[in] data_transfer_hndl - Handle used to identify a particular
1212 * multipart PDR data transfer operation
1213 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
1214 * portion of transfer
1215 * @param[in] request_cnt - The maximum number of record bytes requested
1216 * @param[in] record_chg_num - Used to determine whether the PDR has changed
1217 * while PDR transfer is going on
1218 * @param[out] msg - Message will be written to this
1219 * @param[in] payload_length - Length of request message payload
1220 * @return pldm_completion_codes
1221 * @note Caller is responsible for memory alloc and dealloc of param
1222 * 'msg.payload'
1223 */
1224int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
1225 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
1226 uint16_t request_cnt, uint16_t record_chg_num,
1227 struct pldm_msg *msg, size_t payload_length);
1228
1229/** @brief Decode GetPDR response data
1230 *
1231 * Note:
1232 * * If the return value is not PLDM_SUCCESS, it represents a
1233 * transport layer error.
1234 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1235 * protocol layer error and all the out-parameters are invalid.
1236 *
1237 * @param[in] msg - Request message
1238 * @param[in] payload_length - Length of request message payload
1239 * @param[out] completion_code - PLDM completion code
1240 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
1241 * the PDR Repository
1242 * @param[out] next_data_transfer_hndl - A handle that identifies the next
1243 * portion of the PDR data to be transferred, if any
1244 * @param[out] transfer_flag - Indicates the portion of PDR data being
1245 * transferred
1246 * @param[out] resp_cnt - The number of recordData bytes returned in this
1247 * response
1248 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
1249 * skip the copy and place the actual length in resp_cnt.
1250 * @param[in] record_data_length - Length of record_data
1251 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
1252 * in the last part of a PDR being transferred
1253 * @return pldm_completion_codes
1254 */
1255int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
1256 uint8_t *completion_code, uint32_t *next_record_hndl,
1257 uint32_t *next_data_transfer_hndl,
1258 uint8_t *transfer_flag, uint16_t *resp_cnt,
1259 uint8_t *record_data, size_t record_data_length,
1260 uint8_t *transfer_crc);
1261
1262/* SetStateEffecterStates */
1263
1264/** @brief Create a PLDM request message for SetStateEffecterStates
1265 *
1266 * @param[in] instance_id - Message's instance id
1267 * @param[in] effecter_id - used to identify and access the effecter
1268 * @param[in] comp_effecter_count - number of individual sets of effecter
1269 * information. Upto eight sets of state effecter info can be accessed
1270 * for a given effecter.
1271 * @param[in] field - each unit is an instance of the stateField structure
1272 * that is used to set the requested state for a particular effecter
1273 * within the state effecter. This field holds the starting address of
1274 * the stateField values. The user is responsible to allocate the
1275 * memory prior to calling this command. The user has to allocate the
1276 * field parameter as sizeof(set_effecter_state_field) *
1277 * comp_effecter_count
1278 * @param[out] msg - Message will be written to this
1279 * @return pldm_completion_codes
1280 * @note Caller is responsible for memory alloc and dealloc of param
1281 * 'msg.payload'
1282 */
1283
1284int encode_set_state_effecter_states_req(uint8_t instance_id,
1285 uint16_t effecter_id,
1286 uint8_t comp_effecter_count,
1287 set_effecter_state_field *field,
1288 struct pldm_msg *msg);
1289
1290/** @brief Decode SetStateEffecterStates response data
1291 *
1292 * Note:
1293 * * If the return value is not PLDM_SUCCESS, it represents a
1294 * transport layer error.
1295 * * If the completion_code value is not PLDM_SUCCESS, it represents a
1296 * protocol layer error and all the out-parameters are invalid.
1297 *
1298 * @param[in] msg - Request message
1299 * @param[in] payload_length - Length of response message payload
1300 * @param[out] completion_code - PLDM completion code
1301 * @return pldm_completion_codes
1302 */
1303int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
1304 size_t payload_length,
1305 uint8_t *completion_code);
1306
1307/* SetNumericEffecterValue */
1308
1309/** @brief Create a PLDM request message for SetNumericEffecterValue
1310 *
1311 * @param[in] instance_id - Message's instance id
1312 * @param[in] effecter_id - used to identify and access the effecter
1313 * @param[in] effecter_data_size - The bit width and format of the setting
1314 * value for the effecter.
1315 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1316 * @param[in] effecter_value - The setting value of numeric effecter being
1317 * requested.
1318 * @param[in] payload_length - Length of request message payload
1319 * @param[out] msg - Message will be written to this
1320 * @return pldm_completion_codes
1321 * @note Caller is responsible for memory alloc and dealloc of param
1322 * 'msg.payload'
1323 */
1324int encode_set_numeric_effecter_value_req(
1325 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
1326 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
1327
1328/** @brief Decode SetNumericEffecterValue response data
1329 * @param[in] msg - Request message
1330 * @param[in] payload_length - Length of response message payload
1331 * @param[out] completion_code - PLDM completion code
1332 * @return pldm_completion_codes
1333 */
1334int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
1335 size_t payload_length,
1336 uint8_t *completion_code);
1337
1338/** @brief Create a PLDM request message for GetStateSensorReadings
1339 *
1340 * @param[in] instance_id - Message's instance id
1341 * @param[in] sensor_id - used to identify and access the simple or composite
1342 * sensor
1343 * @param[in] sensorRearm - Each bit location in this field corresponds to a
1344 * particular sensor within the state sensor, where bit [0] corresponds
1345 * to the first state sensor (sensor offset 0) and bit [7] corresponds
1346 * to the eighth sensor (sensor offset 7), sequentially
1347 * @param[in] reserved - value: 0x00
1348 * @param[out] msg - Message will be written to this
1349 * @return pldm_completion_codes
1350 * @note Caller is responsible for memory alloc and dealloc of param
1351 * 'msg.payload'
1352 */
1353int encode_get_state_sensor_readings_req(uint8_t instance_id,
1354 uint16_t sensor_id,
1355 bitfield8_t sensor_rearm,
1356 uint8_t reserved,
1357 struct pldm_msg *msg);
1358
1359/** @brief Decode GetStateSensorReadings response data
1360 *
1361 * @param[in] msg - Request message
1362 * @param[in] payload_length - Length of response message payload
1363 * @param[out] completion_code - PLDM completion code
1364 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
1365 * information that this command accesses
1366 * @param[out] field - Each stateField is an instance of a stateField structure
1367 * that is used to return the present operational state setting and the
1368 * present state and event state for a particular set of sensor
1369 * information contained within the state sensor
1370 * @return pldm_completion_codes
1371 */
1372
1373int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
1374 size_t payload_length,
1375 uint8_t *completion_code,
1376 uint8_t *comp_sensor_count,
1377 get_sensor_state_field *field);
1378
1379/* PlatformEventMessage */
1380
1381/** @brief Decode PlatformEventMessage request data
1382 * @param[in] msg - Request message
1383 * @param[in] payload_length - Length of response message payload
1384 * @param[out] format_version - Version of the event format
1385 * @param[out] tid - Terminus ID for the terminus that originated the event
1386 * message
1387 * @param[out] event_class - The class of event being sent
1388 * @param[out] event_data_offset - Offset where the event data should be read
1389 * from pldm msg
1390 * @return pldm_completion_codes
1391 */
1392int decode_platform_event_message_req(const struct pldm_msg *msg,
1393 size_t payload_length,
1394 uint8_t *format_version, uint8_t *tid,
1395 uint8_t *event_class,
1396 size_t *event_data_offset);
1397
1398/** @brief Encode PlatformEventMessage response data
1399 * @param[in] instance_id - Message's instance id
1400 * @param[in] completion_code - PLDM completion code
1401 * @param[in] platform_event_status - Response status of the event message
1402 * command
1403 * @param[out] msg - Message will be written to this
1404 * @return pldm_completion_codes
1405 * @note Caller is responsible for memory alloc and dealloc of param
1406 * 'msg.payload'
1407 */
1408int encode_platform_event_message_resp(uint8_t instance_id,
1409 uint8_t completion_code,
1410 uint8_t platform_event_status,
1411 struct pldm_msg *msg);
1412
1413/** @brief Encode PlatformEventMessage request data
1414 * @param[in] instance_id - Message's instance id
1415 * @param[in] format_version - Version of the event format
1416 * @param[in] tid - Terminus ID for the terminus that originated the event
1417 * message
1418 * @param[in] event_class - The class of event being sent
1419 * @param[in] event_data - the event data should be read from pldm msg
1420 * @param[in] event_data_length - Length of the event data
1421 * @param[out] msg - Request message
1422 * @return pldm_completion_codes
1423 * @note Caller is responsible for memory alloc and dealloc of param
1424 * 'msg.payload'
1425 */
1426int encode_platform_event_message_req(
1427 uint8_t instance_id, uint8_t format_version, uint8_t tid,
1428 uint8_t event_class, const uint8_t *event_data, size_t event_data_length,
1429 struct pldm_msg *msg, size_t payload_length);
1430
1431/** @brief Decode PlatformEventMessage response data
1432 * @param[in] msg - Request message
1433 * @param[in] payload_length - Length of Response message payload
1434 * @param[out] completion_code - PLDM completion code
1435 * @param[out] platform_event_status - Response status of the event message
1436 * command
1437 * @return pldm_completion_codes
1438 */
1439int decode_platform_event_message_resp(const struct pldm_msg *msg,
1440 size_t payload_length,
1441 uint8_t *completion_code,
1442 uint8_t *platform_event_status);
1443
Dung Caod6ae8982022-11-02 10:00:10 +07001444/** @brief Decode EventMessageBufferSize response data
1445 * @param[in] msg - Request message
1446 * @param[in] payload_length - Length of Response message payload
1447 * @param[out] completion_code - PLDM completion code
1448 * @return pldm_completion_codes
1449 */
1450int decode_event_message_buffer_size_resp(const struct pldm_msg *msg,
1451 size_t payload_length,
1452 uint8_t *completion_code,
1453 uint16_t *terminus_max_buffer_size);
1454
1455/** @brief Encode EventMessageBufferSize request data
1456 * @param[in] instance_id - Message's instance id
1457 * @param[in] event_receiver_max_buffer_size - Max buffer size
1458 * @param[out] msg - Request message
1459 * @return pldm_completion_codes
1460 * @note Caller is responsible for memory alloc and dealloc of param
1461 * 'msg.payload'
1462 */
1463int encode_event_message_buffer_size_req(
1464 uint8_t instance_id, uint16_t event_receiver_max_buffer_size,
1465 struct pldm_msg *msg);
1466
Andrew Jeffery9c766792022-08-10 23:12:49 +09301467/** @brief Decode sensorEventData response data
1468 *
1469 * @param[in] event_data - event data from the response message
1470 * @param[in] event_data_length - length of the event data
1471 * @param[out] sensor_id - sensorID value of the sensor
1472 * @param[out] sensor_event_class_type - Type of sensor event class
1473 * @param[out] event_class_data_offset - Offset where the event class data
1474 * should be read from event data
1475 * @return pldm_completion_codes
1476 * @note Caller is responsible for memory alloc and dealloc of param
1477 * 'event_data'
1478 */
1479int decode_sensor_event_data(const uint8_t *event_data,
1480 size_t event_data_length, uint16_t *sensor_id,
1481 uint8_t *sensor_event_class_type,
1482 size_t *event_class_data_offset);
1483
1484/** @brief Decode sensorOpState response data
1485 *
1486 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
1487 * @param[in] sensor_data_length - Length of sensor_data
1488 * @param[out] present_op_state - The sensorOperationalState value from the
1489 * state change that triggered the event message
1490 * @param[out] previous_op_state - The sensorOperationalState value for the
1491 * state from which the present state was entered
1492 * @return pldm_completion_codes
1493 * @note Caller is responsible for memory alloc and dealloc of param
1494 * 'sensor_data'
1495 */
1496int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
1497 uint8_t *present_op_state,
1498 uint8_t *previous_op_state);
1499
1500/** @brief Decode stateSensorState response data
1501 *
1502 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
1503 * @param[in] sensor_data_length - Length of sensor_data
1504 * @param[out] sensor_offset - Identifies which state sensor within a composite
1505 * state sensor the event is being returned for
1506 * @param[out] event_state - The event state value from the state change that
1507 * triggered the event message
1508 * @param[out] previous_event_state - The event state value for the state from
1509 * which the present event state was entered
1510 * @return pldm_completion_codes
1511 * @note Caller is responsible for memory alloc and dealloc of param
1512 * 'sensor_data'
1513 */
1514int decode_state_sensor_data(const uint8_t *sensor_data,
1515 size_t sensor_data_length, uint8_t *sensor_offset,
1516 uint8_t *event_state,
1517 uint8_t *previous_event_state);
1518
1519/** @brief Decode numericSensorState response data
1520 *
1521 * @param[in] sensor_data - sensor_data for sensorEventClass =
1522 * numericSensorState
1523 * @param[in] sensor_data_length - Length of sensor_data
1524 * @param[out] event_state - The eventState value from the state change that
1525 * triggered the event message
1526 * @param[out] previous_event_state - The eventState value for the state from
1527 * which the present state was entered
1528 * @param[out] sensor_data_size - The bit width and format of reading and
1529 * threshold values that the sensor returns
1530 * @param[out] present_reading - The present value indicated by the sensor
1531 * @return pldm_completion_codes
1532 * @note Caller is responsible for memory alloc and dealloc of param
1533 * 'sensor_data'
1534 */
1535int decode_numeric_sensor_data(const uint8_t *sensor_data,
1536 size_t sensor_data_length, uint8_t *event_state,
1537 uint8_t *previous_event_state,
1538 uint8_t *sensor_data_size,
1539 uint32_t *present_reading);
1540
1541/* GetNumericEffecterValue */
1542
1543/** @brief Create a PLDM request message for GetNumericEffecterValue
1544 *
1545 * @param[in] instance_id - Message's instance id
1546 * @param[in] effecter_id - used to identify and access the effecter
1547 * @param[out] msg - Message will be written to this
1548 * @return pldm_completion_codes
1549 * @note Caller is responsible for memory alloc and dealloc of param
1550 * 'msg.payload'
1551 */
1552int encode_get_numeric_effecter_value_req(uint8_t instance_id,
1553 uint16_t effecter_id,
1554 struct pldm_msg *msg);
1555
1556/** @brief Create a PLDM response message for GetNumericEffecterValue
1557 *
1558 * @param[in] msg - Request message
1559 * @param[in] payload_length - Length of request message payload
1560 * @param[out] completion_code - PLDM completion code
1561 * @param[out] effecter_data_size - The bit width and format of the setting
1562 * value for the effecter.
1563 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
1564 * @param[out] effecter_oper_state - The state of the effecter itself
1565 * @param[out] pending_value - The pending numeric value setting of the
1566 * effecter. The effecterDataSize field indicates the number of
1567 * bits used for this field
1568 * @param[out] present_value - The present numeric value setting of the
1569 * effecter. The effecterDataSize indicates the number of bits
1570 * used for this field
1571 * @return pldm_completion_codes
1572 */
1573int decode_get_numeric_effecter_value_resp(
1574 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1575 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
1576 uint8_t *pending_value, uint8_t *present_value);
1577
1578/** @brief Decode pldmPDRRepositoryChgEvent response data
1579 *
1580 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent
1581 * @param[in] event_data_size - Length of event_data
1582 * @param[out] event_data_format - This field indicates if the changedRecords
1583 * are of PDR Types or PDR Record Handles
1584 * @param[out] number_of_change_records - The number of changeRecords following
1585 * this field
1586 * @param[out] change_record_data_offset - Identifies where changeRecord data
1587 * is located within event_data
1588 * @return pldm_completion_codes
1589 * @note Caller is responsible for memory alloc and dealloc of param
1590 * 'event_data'
1591 */
1592int decode_pldm_pdr_repository_chg_event_data(
1593 const uint8_t *event_data, size_t event_data_size,
1594 uint8_t *event_data_format, uint8_t *number_of_change_records,
1595 size_t *change_record_data_offset);
1596
1597/** @brief Encode PLDM PDR Repository Change eventData
1598 * @param[in] event_data_format - Format of this event data (e.g.
1599 * FORMAT_IS_PDR_HANDLES)
1600 * @param[in] number_of_change_records - Number of changeRecords in this
1601 * eventData
1602 * @param[in] event_data_operations - Array of eventDataOperations
1603 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array
1604 * should contain number_of_change_records elements.
1605 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys
1606 * for each changeRecord in this eventData. This array should contain
1607 * number_of_change_records elements.
1608 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys,
1609 * one array per changeRecord in this eventData. The toplevel array should
1610 * contain number_of_change_records elements. Each subarray [i] should
1611 * contain numbers_of_change_entries[i] elements.
1612 * @param[in] event_data - The eventData will be encoded into this. This entire
1613 * structure must be max_change_records_size long. It must be large enough
1614 * to accomodate the data to be encoded. The caller is responsible for
1615 * allocating and deallocating it, including the variable-size
1616 * 'event_data.change_records' field. If this parameter is NULL,
1617 * PLDM_SUCCESS will be returned and actual_change_records_size will be set
1618 * to reflect the required size of the structure.
1619 * @param[out] actual_change_records_size - The actual number of meaningful
1620 * encoded bytes in event_data. The caller can over-allocate memory and use
1621 * this output to determine the real size of the structure.
1622 * @param[in] max_change_records_size - The size of event_data in bytes. If the
1623 * encoded message would be larger than this value, an error is returned.
1624 * @return pldm_completion_codes
1625 * @note Caller is responsible for memory alloc and dealloc of param
1626 * 'event_data.change_records'
1627 */
1628int encode_pldm_pdr_repository_chg_event_data(
1629 uint8_t event_data_format, uint8_t number_of_change_records,
1630 const uint8_t *event_data_operations,
1631 const uint8_t *numbers_of_change_entries,
1632 const uint32_t *const *change_entries,
1633 struct pldm_pdr_repository_chg_event_data *event_data,
1634 size_t *actual_change_records_size, size_t max_change_records_size);
1635
1636/** @brief Encode event data for a PLDM Sensor Event
1637 *
1638 * @param[out] event_data The object to store the encoded event in
1639 * @param[in] event_data_size Size of the allocation for event_data
1640 * @param[in] sensor_id Sensor ID
1641 * @param[in] sensor_event_class Sensor event class
1642 * @param[in] sensor_offset Offset
1643 * @param[in] event_state Event state
1644 * @param[in] previous_event_state Previous event state
1645 * @param[out] actual_event_data_size The real size in bytes of the event_data
1646 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH
1647 * @note If event_data is NULL, then *actual_event_data_size will be set to
1648 * reflect the size of the event data, and PLDM_SUCCESS will be returned.
1649 * @note The caller is responsible for allocating and deallocating the
1650 * event_data
1651 */
1652int encode_sensor_event_data(struct pldm_sensor_event_data *event_data,
1653 size_t event_data_size, uint16_t sensor_id,
1654 enum sensor_event_class_states sensor_event_class,
1655 uint8_t sensor_offset, uint8_t event_state,
1656 uint8_t previous_event_state,
1657 size_t *actual_event_data_size);
1658
1659/** @brief Decode PldmPDRRepositoryChangeRecord response data
1660 *
1661 * @param[in] change_record_data - changeRecordData for
1662 * pldmPDRRepositoryChgEvent
1663 * @param[in] change_record_data_size - Length of change_record_data
1664 * @param[out] event_data_operation - This field indicates the changeEntries
1665 * operation types
1666 * @param[out] number_of_change_entries - The number of changeEntries following
1667 * this field
1668 * @param[out] change_entry_data_offset - Identifies where changeEntries data
1669 * is located within change_record_data
1670 * @return pldm_completion_codes
1671 * @note Caller is responsible for memory alloc and dealloc of param
1672 * 'change_record_data'
1673 */
1674int decode_pldm_pdr_repository_change_record_data(
1675 const uint8_t *change_record_data, size_t change_record_data_size,
1676 uint8_t *event_data_operation, uint8_t *number_of_change_entries,
1677 size_t *change_entry_data_offset);
1678
1679/* GetSensorReading */
1680
1681/** @brief Encode GetSensorReading request data
1682 *
1683 * @param[in] instance_id - Message's instance id
1684 * @param[in] sensor_id - A handle that is used to identify and access the
1685 * sensor
1686 * @param[in] rearm_event_state - true = manually re-arm EventState after
1687 * responding to this request, false = no manual re-arm
1688 * @param[out] msg - Message will be written to this
1689 * @return pldm_completion_codes
1690 * @note Caller is responsible for memory alloc and dealloc of param
1691 * 'msg.payload'
1692 */
1693int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id,
1694 bool8_t rearm_event_state,
1695 struct pldm_msg *msg);
1696
1697/** @brief Decode GetSensorReading response data
1698 *
1699 * @param[in] msg - Request message
1700 * @param[in] payload_length - Length of response message payload
1701 * @param[out] completion_code - PLDM completion code
1702 * @param[out] sensor_data_size - The bit width and format of reading and
1703 * threshold values
1704 * @param[out] sensor_operational_state - The state of the sensor itself
1705 * @param[out] sensor_event_message_enable - value: { noEventGeneration,
1706 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled,
1707 * stateEventsOnlyEnabled }
1708 * @param[out] present_state - The most recently assessed state value monitored
1709 * by the sensor
1710 * @param[out] previous_state - The state that the presentState was entered
1711 * from
1712 * @param[out] event_state - Indicates which threshold crossing assertion
1713 * events have been detected
1714 * @param[out] present_reading - The present value indicated by the sensor
1715 * @return pldm_completion_codes
1716 */
1717
1718int decode_get_sensor_reading_resp(
1719 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
1720 uint8_t *sensor_data_size, uint8_t *sensor_operational_state,
1721 uint8_t *sensor_event_message_enable, uint8_t *present_state,
1722 uint8_t *previous_state, uint8_t *event_state, uint8_t *present_reading);
1723
1724/** @brief Encode the SetEventReceiver request message
1725 *
1726 * @param[in] instance_id - Message's instance id
1727 * @param[in] event_message_global_enable - This value is used to enable or
1728 * disable event message generation from the terminus value: {
1729 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1730 * @param[in] transport_protocol_type - This value is provided in the request
1731 * to help the responder verify that the content of the
1732 * eventReceiverAddressInfo field used in this request is correct for
1733 * the messaging protocol supported by the terminus.
1734 * @param[in] event_receiver_address_info - this value is a medium and
1735 * protocol-specific address that the responder should use when
1736 * transmitting event messages using the indicated protocol
1737 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing
1738 * of which the terminus shall emit a heartbeat event to the receiver
1739 * @param[out] msg - Argument to capture the Message
1740 * @return pldm_completion_codes
1741 */
1742int encode_set_event_receiver_req(uint8_t instance_id,
1743 uint8_t event_message_global_enable,
1744 uint8_t transport_protocol_type,
1745 uint8_t event_receiver_address_info,
1746 uint16_t heartbeat_timer,
1747 struct pldm_msg *msg);
1748
1749/** @brief Decode the SetEventReceiver response message
1750 *
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_set_event_receiver_resp(const struct pldm_msg *msg,
1757 size_t payload_length,
1758 uint8_t *completion_code);
1759
1760/** @brief Decode the SetEventReceiver request message
1761 *
1762 * @param[in] msg - Request message
1763 * @param[in] payload_length - Length of request message payload
1764 * @param[out] event_message_global_enable - This value is used to enable or
1765 * disable event message generation from the terminus value: {
1766 * disable, enableAsync, enablePolling, enableAsyncKeepAlive }
1767 * @param[out] transport_protocol_type - This value is provided in the request
1768 * to help the responder verify that the content of the
1769 * eventReceiverAddressInfo field used in this request is correct for
1770 * the messaging protocol supported by the terminus.
1771 * @param[out] event_receiver_address_info - This value is a medium and
1772 * protocol-specific address that the responder should use when
1773 * transmitting event messages using the indicated protocol
1774 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing
1775 * of which the terminus shall emit a heartbeat event to the receiver
1776 * @return pldm_completion_codes
1777 */
1778int decode_set_event_receiver_req(const struct pldm_msg *msg,
1779 size_t payload_length,
1780 uint8_t *event_message_global_enable,
1781 uint8_t *transport_protocol_type,
1782 uint8_t *event_receiver_address_info,
1783 uint16_t *heartbeat_timer);
1784
1785/** @brief Encode the SetEventReceiver response message
1786 *
1787 * @param[in] instance_id - Message's instance id
1788 * @param[in] completion_code - PLDM completion code
1789 * @param[out] msg - Argument to capture the Message
1790 * @return pldm_completion_codes
1791 */
1792int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code,
1793 struct pldm_msg *msg);
1794
1795#ifdef __cplusplus
1796}
1797#endif
1798
1799#endif /* PLATFORM_H */