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