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