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