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