1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ 2 #ifndef PLATFORM_H 3 #define PLATFORM_H 4 5 #ifdef __cplusplus 6 extern "C" { 7 #endif 8 9 #include <assert.h> 10 #include <stdalign.h> 11 #include <stddef.h> 12 #include <stdint.h> 13 #include <uchar.h> 14 15 #include <libpldm/base.h> 16 #include <libpldm/compiler.h> 17 #include <libpldm/pdr.h> 18 #include <libpldm/pldm_types.h> 19 20 /** 21 * @brief PLDM response transfer flag for the Platform and control commands 22 * (GetPDRs, PollForPlatformEventMessage) 23 */ 24 enum pldm_platform_transfer_flag { 25 PLDM_PLATFORM_TRANSFER_START = 0x00, 26 PLDM_PLATFORM_TRANSFER_MIDDLE = 0x01, 27 PLDM_PLATFORM_TRANSFER_END = 0x04, 28 PLDM_PLATFORM_TRANSFER_START_AND_END = 0x05, 29 }; 30 31 /* Maximum size for request */ 32 #define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19 33 #define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4 34 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2 35 #define PLDM_GET_STATE_EFFECTER_STATES_REQ_BYTES 2 36 #define PLDM_GET_SENSOR_READING_REQ_BYTES 3 37 #define PLDM_SET_EVENT_RECEIVER_REQ_BYTES 3 38 #define PLDM_SET_EVENT_RECEIVER_REQ_HEARTBEAT_BYTES 2 39 /* Response lengths are inclusive of completion code */ 40 #define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1 41 42 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1 43 #define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4 44 45 #define PLDM_GET_PDR_REQ_BYTES 13 46 47 #define PLDM_SET_EVENT_RECEIVER_RESP_BYTES 1 48 49 /* Platform event supported request */ 50 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_REQ_BYTES 2 51 #define PLDM_EVENT_MESSAGE_BUFFER_SIZE_RESP_BYTES 3 52 53 #define PLDM_EVENT_MESSAGE_SUPPORTED_REQ_BYTES 1 54 #define PLDM_EVENT_MESSAGE_SUPPORTED_MIN_RESP_BYTES 4 55 56 /* PollForPlatformEventMessage PLDM request */ 57 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_REQ_BYTES 8 58 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_MIN_RESP_BYTES 4 59 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_RESP_BYTES 14 60 #define PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE_CHECKSUM_BYTES 4 61 62 /* Platform event message request */ 63 #define PLDM_PLATFORM_EVENT_ID_NULL 0x0000 64 #define PLDM_PLATFORM_EVENT_ID_FRAGMENT 0xffff 65 /* Platform event message response */ 66 #define PLDM_PLATFORM_EVENT_ID_NONE 0x0000 67 #define PLDM_PLATFORM_EVENT_ID_ACK 0xffff 68 69 /* Minimum response length */ 70 #define PLDM_GET_PDR_MIN_RESP_BYTES 12 71 #define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5 72 #define PLDM_GET_STATE_EFFECTER_STATES_MIN_RESP_BYTES 2 73 #define PLDM_GET_SENSOR_READING_MIN_RESP_BYTES 8 74 #define PLDM_GET_STATE_SENSOR_READINGS_MIN_RESP_BYTES 2 75 #define PLDM_GET_PDR_REPOSITORY_INFO_RESP_BYTES 41 76 77 /* Minimum length for PLDM PlatformEventMessage request */ 78 #define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3 79 #define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6 80 #define PLDM_PLATFORM_EVENT_MESSAGE_RESP_BYTES 2 81 #define PLDM_PLATFORM_EVENT_MESSAGE_FORMAT_VERSION 1 82 #define PLDM_PLATFORM_EVENT_MESSAGE_EVENT_ID 2 83 #define PLDM_PLATFORM_EVENT_MESSAGE_TRANFER_HANDLE 4 84 85 /* Minimum length of sensor event data */ 86 #define PLDM_MSG_POLL_EVENT_LENGTH 7 87 /* Minimum data length of CPER event type */ 88 #define PLDM_PLATFORM_CPER_EVENT_MIN_LENGTH 4 89 90 /* Minimum length of sensor event data */ 91 #define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5 92 #define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2 93 #define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3 94 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4 95 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7 96 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4 97 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5 98 #define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7 99 100 /* Minimum length of data for pldmPDRRepositoryChgEvent */ 101 #define PLDM_PDR_REPOSITORY_CHG_EVENT_MIN_LENGTH 2 102 #define PLDM_PDR_REPOSITORY_CHANGE_RECORD_MIN_LENGTH 2 103 104 /* Minimum length of numeric sensor PDR */ 105 #define PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH 57 106 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH 3 107 #define PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH 9 108 #define PLDM_PDR_NUMERIC_SENSOR_PDR_MIN_LENGTH \ 109 (PLDM_PDR_NUMERIC_SENSOR_PDR_FIXED_LENGTH + \ 110 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_SENSOR_DATA_SIZE_MIN_LENGTH + \ 111 PLDM_PDR_NUMERIC_SENSOR_PDR_VARIED_RANGE_FIELD_MIN_LENGTH) 112 113 /* Minimum length of numeric effecter PDR */ 114 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH 56 115 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH 2 116 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH 5 117 #define PLDM_PDR_NUMERIC_EFFECTER_PDR_MIN_LENGTH \ 118 (PLDM_PDR_NUMERIC_EFFECTER_PDR_FIXED_LENGTH + \ 119 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_EFFECTER_DATA_SIZE_MIN_LENGTH + \ 120 PLDM_PDR_NUMERIC_EFFECTER_PDR_VARIED_RANGE_FIELD_MIN_LENGTH) 121 122 /** 123 * Minimum length of entity auxiliary name effecter PDR includes size of hdr, 124 * entityType, entityInstanceNumber, entityContainerID, sharedNameCount and 125 * nameStringCount in `Table 95 - Entity Auxiliary Names PDR format` of DSP0248 126 * v1.2.2 127 */ 128 #define PLDM_PDR_ENTITY_AUXILIARY_NAME_PDR_MIN_LENGTH 8 129 130 #define PLDM_INVALID_EFFECTER_ID 0xffff 131 132 /* DSP0248 Table1 PLDM monitoring and control data types */ 133 #define PLDM_STR_UTF_8_MAX_LEN 256 134 #define PLDM_STR_UTF_16_MAX_LEN 256 135 136 /* Wire-format substructure sizes */ 137 #define PLDM_GET_EFFECTER_STATE_FIELD_SIZE 3 138 139 /* State fields count bounds */ 140 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MIN 1 141 #define PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX 8 142 143 /* Container ID */ 144 /** @brief Table 2 - Parts of the Entity Identification Information format in 145 * PLDM Platform and Control spec, DSP0248 v1.2.2. "If this value is 146 * 0x0000, the containing entity is considered to be the overall system" 147 */ 148 #define PLDM_PLATFORM_ENTITY_SYSTEM_CONTAINER_ID 0 149 150 enum pldm_effecter_data_size { 151 PLDM_EFFECTER_DATA_SIZE_UINT8, 152 PLDM_EFFECTER_DATA_SIZE_SINT8, 153 PLDM_EFFECTER_DATA_SIZE_UINT16, 154 PLDM_EFFECTER_DATA_SIZE_SINT16, 155 PLDM_EFFECTER_DATA_SIZE_UINT32, 156 PLDM_EFFECTER_DATA_SIZE_SINT32 157 }; 158 159 enum pldm_range_field_format { 160 PLDM_RANGE_FIELD_FORMAT_UINT8, 161 PLDM_RANGE_FIELD_FORMAT_SINT8, 162 PLDM_RANGE_FIELD_FORMAT_UINT16, 163 PLDM_RANGE_FIELD_FORMAT_SINT16, 164 PLDM_RANGE_FIELD_FORMAT_UINT32, 165 PLDM_RANGE_FIELD_FORMAT_SINT32, 166 PLDM_RANGE_FIELD_FORMAT_REAL32 167 }; 168 #define PLDM_RANGE_FIELD_FORMAT_MAX PLDM_RANGE_FIELD_FORMAT_REAL32 169 170 enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 }; 171 172 enum effecter_state { PLDM_INVALID_VALUE = 0xff }; 173 174 enum pldm_sensor_present_state { 175 PLDM_SENSOR_UNKNOWN = 0x0, 176 PLDM_SENSOR_NORMAL = 0x01, 177 PLDM_SENSOR_WARNING = 0x02, 178 PLDM_SENSOR_CRITICAL = 0x03, 179 PLDM_SENSOR_FATAL = 0x04, 180 PLDM_SENSOR_LOWERWARNING = 0x05, 181 PLDM_SENSOR_LOWERCRITICAL = 0x06, 182 PLDM_SENSOR_LOWERFATAL = 0x07, 183 PLDM_SENSOR_UPPERWARNING = 0x08, 184 PLDM_SENSOR_UPPERCRITICAL = 0x09, 185 PLDM_SENSOR_UPPERFATAL = 0x0a 186 }; 187 188 enum pldm_sensor_event_message_enable { 189 PLDM_NO_EVENT_GENERATION, 190 PLDM_EVENTS_DISABLED, 191 PLDM_EVENTS_ENABLED, 192 PLDM_OP_EVENTS_ONLY_ENABLED, 193 PLDM_STATE_EVENTS_ONLY_ENABLED 194 }; 195 196 enum pldm_effecter_oper_state { 197 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING, 198 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING, 199 EFFECTER_OPER_STATE_DISABLED, 200 EFFECTER_OPER_STATE_UNAVAILABLE, 201 EFFECTER_OPER_STATE_STATUSUNKNOWN, 202 EFFECTER_OPER_STATE_FAILED, 203 EFFECTER_OPER_STATE_INITIALIZING, 204 EFFECTER_OPER_STATE_SHUTTINGDOWN, 205 EFFECTER_OPER_STATE_INTEST 206 }; 207 208 enum pldm_platform_commands { 209 PLDM_SET_EVENT_RECEIVER = 0x04, 210 PLDM_PLATFORM_EVENT_MESSAGE = 0x0a, 211 PLDM_POLL_FOR_PLATFORM_EVENT_MESSAGE = 0x0b, 212 PLDM_EVENT_MESSAGE_SUPPORTED = 0x0c, 213 PLDM_EVENT_MESSAGE_BUFFER_SIZE = 0x0d, 214 PLDM_GET_SENSOR_READING = 0x11, 215 PLDM_GET_STATE_SENSOR_READINGS = 0x21, 216 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31, 217 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32, 218 PLDM_SET_STATE_EFFECTER_STATES = 0x39, 219 PLDM_GET_STATE_EFFECTER_STATES = 0x3a, 220 PLDM_GET_PDR_REPOSITORY_INFO = 0x50, 221 PLDM_GET_PDR = 0x51, 222 }; 223 224 /** @brief PLDM PDR types defined in DSP0248_1.2.0 section 28.2 225 */ 226 enum pldm_pdr_types { 227 PLDM_TERMINUS_LOCATOR_PDR = 1, 228 PLDM_NUMERIC_SENSOR_PDR = 2, 229 PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR = 3, 230 PLDM_STATE_SENSOR_PDR = 4, 231 PLDM_STATE_SENSOR_INITIALIZATION_PDR = 5, 232 PLDM_SENSOR_AUXILIARY_NAMES_PDR = 6, 233 PLDM_OEM_UNIT_PDR = 7, 234 PLDM_OEM_STATE_SET_PDR = 8, 235 PLDM_NUMERIC_EFFECTER_PDR = 9, 236 PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR = 10, 237 PLDM_STATE_EFFECTER_PDR = 11, 238 PLDM_STATE_EFFECTER_INITIALIZATION_PDR = 12, 239 PLDM_EFFECTER_AUXILIARY_NAMES_PDR = 13, 240 PLDM_EFFECTER_OEM_SEMANTIC_PDR = 14, 241 PLDM_PDR_ENTITY_ASSOCIATION = 15, 242 PLDM_ENTITY_AUXILIARY_NAMES_PDR = 16, 243 PLDM_OEM_ENTITY_ID_PDR = 17, 244 PLDM_INTERRUPT_ASSOCIATION_PDR = 18, 245 PLDM_EVENT_LOG_PDR = 19, 246 PLDM_PDR_FRU_RECORD_SET = 20, 247 PLDM_COMPACT_NUMERIC_SENSOR_PDR = 21, 248 PLDM_REDFISH_RESOURCE_PDR = 22, 249 PLDM_REDFISH_ENTITY_ASSOCIATION_PDR = 23, 250 PLDM_REDFISH_ACTION_PDR = 24, 251 PLDM_OEM_DEVICE_PDR = 126, 252 PLDM_OEM_PDR = 127, 253 }; 254 255 /** @brief PLDM effecter initialization schemes 256 */ 257 enum pldm_effecter_init { 258 PLDM_NO_INIT, 259 PLDM_USE_INIT_PDR, 260 PLDM_ENABLE_EFFECTER, 261 PLDM_DISABLE_EFECTER 262 }; 263 264 /** @brief PLDM Platform M&C completion codes 265 */ 266 enum pldm_platform_completion_codes { 267 PLDM_PLATFORM_INVALID_SENSOR_ID = 0x80, 268 PLDM_PLATFORM_REARM_UNAVAILABLE_IN_PRESENT_STATE = 0x81, 269 270 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80, 271 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81, 272 273 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80, 274 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81, 275 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82, 276 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83, 277 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84, 278 279 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82, 280 281 PLDM_PLATFORM_INVALID_PROTOCOL_TYPE = 0x80, 282 PLDM_PLATFORM_ENABLE_METHOD_NOT_SUPPORTED = 0x81, 283 PLDM_PLATFORM_HEARTBEAT_FREQUENCY_TOO_HIGH = 0x82, 284 }; 285 286 /** @brief PLDM Event types 287 */ 288 enum pldm_event_types { 289 PLDM_SENSOR_EVENT = 0x00, 290 PLDM_EFFECTER_EVENT = 0x01, 291 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02, 292 PLDM_REDFISH_MESSAGE_EVENT = 0x03, 293 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04, 294 PLDM_MESSAGE_POLL_EVENT = 0x05, 295 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06, 296 PLDM_CPER_EVENT = 0x07 297 }; 298 299 /** @brief PLDM sensorEventClass states 300 */ 301 enum sensor_event_class_states { 302 PLDM_SENSOR_OP_STATE, 303 PLDM_STATE_SENSOR_STATE, 304 PLDM_NUMERIC_SENSOR_STATE 305 }; 306 307 /** @brief PLDM sensor supported states 308 */ 309 enum pldm_sensor_operational_state { 310 PLDM_SENSOR_ENABLED, 311 PLDM_SENSOR_DISABLED, 312 PLDM_SENSOR_UNAVAILABLE, 313 PLDM_SENSOR_STATUSUNKOWN, 314 PLDM_SENSOR_FAILED, 315 PLDM_SENSOR_INITIALIZING, 316 PLDM_SENSOR_SHUTTINGDOWN, 317 PLDM_SENSOR_INTEST 318 }; 319 320 /** @brief PLDM pldmPDRRepositoryChgEvent class eventData format 321 */ 322 enum pldm_pdr_repository_chg_event_data_format { 323 REFRESH_ENTIRE_REPOSITORY, 324 FORMAT_IS_PDR_TYPES, 325 FORMAT_IS_PDR_HANDLES 326 }; 327 328 /** @brief PLDM pldmPDRRepositoryChgEvent class changeRecord format 329 * eventDataOperation. See CHANGELOG.md for info on the alias members. 330 */ 331 enum pldm_pdr_repository_chg_event_change_record_event_data_operation { 332 PLDM_REFRESH_ALL_RECORDS = 0, 333 PLDM_RECORDS_DELETED = 1, 334 PLDM_RECORDS_ADDED = 2, 335 PLDM_RECORDS_MODIFIED = 3, 336 337 PLDM_PDR_RECORDS_REFRESH_ALL = 0, 338 PLDM_PDR_RECORDS_DELETED = 1, 339 PLDM_PDR_RECORDS_ADDED = 2, 340 PLDM_PDR_RECORDS_MODIFIED = 3 341 }; 342 343 /** @brief PLDM NumericSensorStatePresentReading data type 344 */ 345 enum pldm_sensor_readings_data_type { 346 PLDM_SENSOR_DATA_SIZE_UINT8, 347 PLDM_SENSOR_DATA_SIZE_SINT8, 348 PLDM_SENSOR_DATA_SIZE_UINT16, 349 PLDM_SENSOR_DATA_SIZE_SINT16, 350 PLDM_SENSOR_DATA_SIZE_UINT32, 351 PLDM_SENSOR_DATA_SIZE_SINT32 352 }; 353 #define PLDM_SENSOR_DATA_SIZE_MAX PLDM_SENSOR_DATA_SIZE_SINT32 354 355 /** @brief PLDM PlatformEventMessage response status 356 */ 357 enum pldm_platform_event_status { 358 PLDM_EVENT_NO_LOGGING = 0x00, 359 PLDM_EVENT_LOGGING_DISABLED = 0x01, 360 PLDM_EVENT_LOG_FULL = 0x02, 361 PLDM_EVENT_ACCEPTED_FOR_LOGGING = 0x03, 362 PLDM_EVENT_LOGGED = 0x04, 363 PLDM_EVENT_LOGGING_REJECTED = 0x05 364 }; 365 366 /** @brief PLDM Terminus Locator PDR validity 367 */ 368 enum pldm_terminus_locator_pdr_validity { 369 PLDM_TL_PDR_NOT_VALID, 370 PLDM_TL_PDR_VALID 371 }; 372 373 /** @brief PLDM Terminus Locator type 374 */ 375 enum pldm_terminus_locator_type { 376 PLDM_TERMINUS_LOCATOR_TYPE_UID, 377 PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID, 378 PLDM_TERMINUS_LOCATOR_TYPE_SMBUS_RELATIVE, 379 PLDM_TERMINUS_LOCATOR_TYPE_SYS_SW 380 }; 381 382 /** @brief PLDM event message global enable for 383 * SetEventReceiver command 384 */ 385 enum pldm_event_message_global_enable { 386 PLDM_EVENT_MESSAGE_GLOBAL_DISABLE, 387 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC, 388 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_POLLING, 389 PLDM_EVENT_MESSAGE_GLOBAL_ENABLE_ASYNC_KEEP_ALIVE 390 }; 391 392 /** @brief PLDM DSP0248 1.2.1 table 74 sensorUnits enumeration 393 */ 394 enum pldm_sensor_units { 395 PLDM_SENSOR_UNIT_NONE = 0x00, 396 PLDM_SENSOR_UNIT_UNSPECIFIED, 397 PLDM_SENSOR_UNIT_DEGRESS_C, 398 PLDM_SENSOR_UNIT_DEGRESS_F, 399 PLDM_SENSOR_UNIT_KELVINS, 400 PLDM_SENSOR_UNIT_VOLTS, 401 PLDM_SENSOR_UNIT_AMPS, 402 PLDM_SENSOR_UNIT_WATTS, 403 PLDM_SENSOR_UNIT_JOULES, 404 PLDM_SENSOR_UNIT_COULOMBS, 405 PLDM_SENSOR_UNIT_VA, 406 PLDM_SENSOR_UNIT_NITS, 407 PLDM_SENSOR_UNIT_LUMENS, 408 PLDM_SENSOR_UNIT_LUX, 409 PLDM_SENSOR_UNIT_CANDELAS, 410 PLDM_SENSOR_UNIT_KPA, 411 PLDM_SENSOR_UNIT_PSI, 412 PLDM_SENSOR_UNIT_NEWTONS, 413 PLDM_SENSOR_UNIT_CFM, 414 PLDM_SENSOR_UNIT_RPM, 415 PLDM_SENSOR_UNIT_HERTZ, 416 PLDM_SENSOR_UNIT_SECONDS, 417 PLDM_SENSOR_UNIT_MINUTES, 418 PLDM_SENSOR_UNIT_HOURS, 419 PLDM_SENSOR_UNIT_DAYS, 420 PLDM_SENSOR_UNIT_WEEKS, 421 PLDM_SENSOR_UNIT_MILS, 422 PLDM_SENSOR_UNIT_INCHES, 423 PLDM_SENSOR_UNIT_FEET, 424 PLDM_SENSOR_UNIT_CUBIC_INCHES, 425 PLDM_SENSOR_UNIT_CUBIC_FEET, 426 PLDM_SENSOR_UNIT_METERS, 427 PLDM_SENSOR_UNIT_CUBIC_CENTERMETERS, 428 PLDM_SENSOR_UNIT_CUBIC_METERS, 429 PLDM_SENSOR_UNIT_LITERS, 430 PLDM_SENSOR_UNIT_FLUID_OUNCES, 431 PLDM_SENSOR_UNIT_RADIANS, 432 PLDM_SENSOR_UNIT_STERADIANS, 433 PLDM_SENSOR_UNIT_REVOLUTIONS, 434 PLDM_SENSOR_UNIT_CYCLES, 435 PLDM_SENSOR_UNIT_GRAVITIES, 436 PLDM_SENSOR_UNIT_OUNCES, 437 PLDM_SENSOR_UNIT_POUNDS, 438 PLDM_SENSOR_UNIT_FOOT_POUNDS, 439 PLDM_SENSOR_UNIT_OUNCE_INCHES, 440 PLDM_SENSOR_UNIT_GUESS, 441 PLDM_SENSOR_UNIT_GILBERTS, 442 PLDM_SENSOR_UNIT_HENRIES, 443 PLDM_SENSOR_UNIT_FARADS, 444 PLDM_SENSOR_UNIT_OHMS, 445 PLDM_SENSOR_UNIT_SIEMENS, 446 PLDM_SENSOR_UNIT_MOLES, 447 PLDM_SENSOR_UNIT_BECQUERELS, 448 PLDM_SENSOR_UNIT_PPM, 449 PLDM_SENSOR_UNIT_DECIBELS, 450 PLDM_SENSOR_UNIT_DBA, 451 PLDM_SENSOR_UNIT_DBC, 452 PLDM_SENSOR_UNIT_GRAYS, 453 PLDM_SENSOR_UNIT_SIEVERTS, 454 PLDM_SENSOR_UNIT_COLOR_TEMPERATURE_DEGRESS_K, 455 PLDM_SENSOR_UNIT_BITS, 456 PLDM_SENSOR_UNIT_BYTES, 457 PLDM_SENSOR_UNIT_WORDS, 458 PLDM_SENSOR_UNIT_DOUBLE_WORDS, 459 PLDM_SENSOR_UNIT_QUAD_WORDS, 460 PLDM_SENSOR_UNIT_PERCENTAGE, 461 PLDM_SENSOR_UNIT_PASCALS, 462 PLDM_SENSOR_UNIT_COUNTS, 463 PLDM_SENSOR_UNIT_GRAMS, 464 PLDM_SENSOR_UNIT_NEWTON_METERS, 465 PLDM_SENSOR_UNIT_HITS, 466 PLDM_SENSOR_UNIT_MISSES, 467 PLDM_SENSOR_UNIT_RETRIES, 468 PLDM_SENSOR_UNIT_OVERRUNS_OVERFLOWS, 469 PLDM_SENSOR_UNIT_UNDERRUNS, 470 PLDM_SENSOR_UNIT_COLLISIONS, 471 PLDM_SENSOR_UNIT_PACKETS, 472 PLDM_SENSOR_UNIT_MESSAGES, 473 PLDM_SENSOR_UNIT_CHARATERS, 474 PLDM_SENSOR_UNIT_ERRORS, 475 PLDM_SENSOR_UNIT_CORRECTED_ERRORS, 476 PLDM_SENSOR_UNIT_UNCORRECTABLE_ERRORS, 477 PLDM_SENSOR_UNIT_SQUARE_MILS, 478 PLDM_SENSOR_UNIT_SQUARE_INCHES, 479 PLDM_SENSOR_UNIT_SQUARE_FEET, 480 PLDM_SENSOR_UNIT_SQUARE_CENTIMETERS, 481 PLDM_SENSOR_UNIT_SQUARE_METERS, 482 PLDM_SENSOR_UNIT_OEMUNIT = 255 483 }; 484 485 enum pldm_occurrence_rate { 486 PLDM_RATE_UNIT_NONE = 0x0, 487 PLDM_RATE_UNIT_PER_MICRO_SECOND, 488 PLDM_RATE_UNIT_PER_MILLI_SECOND, 489 PLDM_RATE_UNIT_PER_SECOND, 490 PLDM_RATE_UNIT_PER_MINUTE, 491 PLDM_RATE_UNIT_PER_HOUR, 492 PLDM_RATE_UNIT_PER_DAY, 493 PLDM_RATE_UNIT_PER_WEEK, 494 PLDM_RATE_UNIT_PER_MONTH, 495 PLDM_RATE_UNIT_PER_YEAR 496 }; 497 498 /** @brief PLDM repository state */ 499 enum pldm_repository_state { 500 PLDM_AVAILABLE, 501 PLDM_UPDATE_IN_PROGRESS, 502 PLDM_FAILED 503 }; 504 505 /** @brief PLDM repository data transfer handler timeout */ 506 enum pldm_repository_data_transfer_handler_timeout { 507 PLDM_NO_TIMEOUT, 508 PLDM_DEFALUT_MINIMUM_TIMEOUT 509 }; 510 511 /** @brief PLDM event message type */ 512 enum pldm_event_message_type { 513 PLDM_MESSAGE_TYPE_NOT_CONFIGURED = 0x00, 514 PLDM_MESSAGE_TYPE_ASYNCHRONOUS = 0x01, 515 PLDM_MESSAGE_TYPE_SYNCHRONOUS = 0x02, 516 PLDM_MESSAGE_TYPE_ASYNCHRONOUS_WITH_HEARTBEAT = 0x03 517 }; 518 519 /** @struct pldm_pdr_hdr 520 * 521 * Structure representing PLDM common PDR header 522 */ 523 struct pldm_pdr_hdr { 524 uint32_t record_handle; 525 uint8_t version; 526 uint8_t type; 527 uint16_t record_change_num; 528 uint16_t length; 529 } __attribute__((packed)); 530 531 /** @struct pldm_terminus_locator_pdr 532 * 533 * Structure representing PLDM terminus locator PDR 534 */ 535 struct pldm_terminus_locator_pdr { 536 struct pldm_pdr_hdr hdr; 537 uint16_t terminus_handle; 538 uint8_t validity; 539 uint8_t tid; 540 uint16_t container_id; 541 uint8_t terminus_locator_type; 542 uint8_t terminus_locator_value_size; 543 uint8_t terminus_locator_value[1]; 544 } __attribute__((packed)); 545 546 /** @struct pldm_sensor_auxiliary_names_pdr 547 * 548 * Structure representing PLDM Sensor Auxiliary Names PDR 549 */ 550 struct pldm_sensor_auxiliary_names_pdr { 551 struct pldm_pdr_hdr hdr; 552 uint16_t terminus_handle; 553 uint16_t sensor_id; 554 uint8_t sensor_count; 555 uint8_t names[1]; 556 } __attribute__((packed)); 557 558 /** @struct pldm_terminus_locator_type_mctp_eid 559 * 560 * Structure representing terminus locator value for 561 * terminus locator type MCTP_EID 562 */ 563 struct pldm_terminus_locator_type_mctp_eid { 564 uint8_t eid; 565 } __attribute__((packed)); 566 567 /** @struct pldm_pdr_entity_association 568 * 569 * Structure representing PLDM Entity Association PDR 570 */ 571 struct pldm_pdr_entity_association { 572 uint16_t container_id; 573 uint8_t association_type; 574 pldm_entity container; 575 uint8_t num_children; 576 pldm_entity children[1]; 577 } __attribute__((packed)); 578 579 /** @struct pldm_pdr_fru_record_set 580 * 581 * Structure representing PLDM FRU record set PDR 582 */ 583 struct pldm_pdr_fru_record_set { 584 uint16_t terminus_handle; 585 uint16_t fru_rsi; 586 uint16_t entity_type; 587 union { 588 uint16_t entity_instance_num; 589 uint16_t entity_instance; 590 }; 591 uint16_t container_id; 592 } __attribute__((packed)); 593 594 /** @struct pldm_state_sensor_pdr 595 * 596 * Structure representing PLDM state sensor PDR 597 */ 598 struct pldm_state_sensor_pdr { 599 struct pldm_pdr_hdr hdr; 600 uint16_t terminus_handle; 601 uint16_t sensor_id; 602 uint16_t entity_type; 603 uint16_t entity_instance; 604 uint16_t container_id; 605 uint8_t sensor_init; 606 bool8_t sensor_auxiliary_names_pdr; 607 uint8_t composite_sensor_count; 608 uint8_t possible_states[1]; 609 } __attribute__((packed)); 610 611 /** @struct state_sensor_possible_states 612 * 613 * Structure representing state enums for state sensor 614 */ 615 struct state_sensor_possible_states { 616 uint16_t state_set_id; 617 uint8_t possible_states_size; 618 bitfield8_t states[1]; 619 } __attribute__((packed)); 620 621 /** @struct pldm_state_effecter_pdr 622 * 623 * Structure representing PLDM state effecter PDR 624 */ 625 struct pldm_state_effecter_pdr { 626 struct pldm_pdr_hdr hdr; 627 uint16_t terminus_handle; 628 uint16_t effecter_id; 629 uint16_t entity_type; 630 uint16_t entity_instance; 631 uint16_t container_id; 632 uint16_t effecter_semantic_id; 633 uint8_t effecter_init; 634 bool8_t has_description_pdr; 635 uint8_t composite_effecter_count; 636 uint8_t possible_states[1]; 637 } __attribute__((packed)); 638 639 /** @struct pldm_compact_numeric_sensor_pdr 640 * 641 * Structure representing PLDM compact numeric sensor PDR 642 */ 643 struct pldm_compact_numeric_sensor_pdr { 644 struct pldm_pdr_hdr hdr; 645 uint16_t terminus_handle; 646 uint16_t sensor_id; 647 uint16_t entity_type; 648 uint16_t entity_instance; 649 uint16_t container_id; 650 uint8_t sensor_name_length; 651 uint8_t base_unit; 652 int8_t unit_modifier; 653 uint8_t occurrence_rate; 654 bitfield8_t range_field_support; 655 int32_t warning_high; 656 int32_t warning_low; 657 int32_t critical_high; 658 int32_t critical_low; 659 int32_t fatal_high; 660 int32_t fatal_low; 661 uint8_t sensor_name[1]; 662 } __attribute__((packed)); 663 664 /** @brief Encode PLDM state sensor PDR 665 * 666 * @param[in/out] sensor Structure to encode. All members of 667 * sensor, except those mentioned in the @note below, should be initialized by 668 * the caller. 669 * @param[in] allocation_size Size of sensor allocation in bytes 670 * @param[in] possible_states Possible sensor states 671 * @param[in] possible_states_size Size of possible sensor states in bytes 672 * @param[out] actual_size Size of sensor PDR. Set to 0 on error. 673 * @return int pldm_completion_codes 674 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH 675 * 676 * @note The sensor parameter will be encoded in place. 677 * @note Caller is responsible for allocation of the sensor parameter. Caller 678 * must allocate enough space for the base structure and the 679 * sensor->possible_states array, otherwise the function will fail. 680 * @note sensor->hdr.length, .type, and .version will be set appropriately. 681 */ 682 int encode_state_sensor_pdr( 683 struct pldm_state_sensor_pdr *sensor, size_t allocation_size, 684 const struct state_sensor_possible_states *possible_states, 685 size_t possible_states_size, size_t *actual_size); 686 687 /** @union union_effecter_data_size 688 * 689 * The bit width and format of reading and threshold values that the effecter 690 * returns. 691 * Refer to: DSP0248_1.2.0: 28.11 Table 87 692 */ 693 typedef union { 694 uint8_t value_u8; 695 int8_t value_s8; 696 uint16_t value_u16; 697 int16_t value_s16; 698 uint32_t value_u32; 699 int32_t value_s32; 700 } union_effecter_data_size; 701 702 /** @union union_range_field_format 703 * 704 * Indicates the format used for the nominalValue, normalMax, and normalMin 705 * fields. 706 * Refer to: DSP0248_1.2.0: 28.11 Table 87 707 */ 708 typedef union { 709 uint8_t value_u8; 710 int8_t value_s8; 711 uint16_t value_u16; 712 int16_t value_s16; 713 uint32_t value_u32; 714 int32_t value_s32; 715 real32_t value_f32; 716 } union_range_field_format; 717 718 /** @struct pldm_numeric_effecter_value_pdr 719 * 720 * Structure representing PLDM numeric effecter value PDR 721 */ 722 struct pldm_numeric_effecter_value_pdr { 723 struct pldm_pdr_hdr hdr; 724 uint16_t terminus_handle; 725 uint16_t effecter_id; 726 uint16_t entity_type; 727 uint16_t entity_instance; 728 uint16_t container_id; 729 uint16_t effecter_semantic_id; 730 uint8_t effecter_init; 731 bool8_t effecter_auxiliary_names; 732 uint8_t base_unit; 733 int8_t unit_modifier; 734 uint8_t rate_unit; 735 uint8_t base_oem_unit_handle; 736 uint8_t aux_unit; 737 int8_t aux_unit_modifier; 738 uint8_t aux_rate_unit; 739 uint8_t aux_oem_unit_handle; 740 bool8_t is_linear; 741 uint8_t effecter_data_size; 742 real32_t resolution; 743 real32_t offset; 744 uint16_t accuracy; 745 uint8_t plus_tolerance; 746 uint8_t minus_tolerance; 747 real32_t state_transition_interval; 748 real32_t transition_interval; 749 union_effecter_data_size max_settable; 750 union_effecter_data_size min_settable; 751 uint8_t range_field_format; 752 bitfield8_t range_field_support; 753 union_range_field_format nominal_value; 754 union_range_field_format normal_max; 755 union_range_field_format normal_min; 756 union_range_field_format rated_max; 757 union_range_field_format rated_min; 758 } __attribute__((packed)); 759 760 /** @union union_sensor_data_size 761 * 762 * The bit width and format of reading and threshold values that the sensor 763 * returns. 764 * Refer to: DSP0248_1.2.0: 28.4 Table 78 765 */ 766 typedef union { 767 uint8_t value_u8; 768 int8_t value_s8; 769 uint16_t value_u16; 770 int16_t value_s16; 771 uint32_t value_u32; 772 int32_t value_s32; 773 } union_sensor_data_size; 774 775 /** @struct pldm_value_pdr_hdr 776 * 777 * Structure representing PLDM PDR header for unpacked value 778 * Refer to: DSP0248_1.2.0: 28.1 Table 75 779 */ 780 struct pldm_value_pdr_hdr { 781 uint32_t record_handle; 782 uint8_t version; 783 uint8_t type; 784 uint16_t record_change_num; 785 uint16_t length; 786 }; 787 788 /** @struct pldm_numeric_sensor_value_pdr 789 * 790 * Structure representing PLDM Numeric Sensor PDR for unpacked value 791 * Refer to: DSP0248_1.2.0: 28.4 Table 78 792 */ 793 struct pldm_numeric_sensor_value_pdr { 794 struct pldm_value_pdr_hdr hdr; 795 uint16_t terminus_handle; 796 uint16_t sensor_id; 797 uint16_t entity_type; 798 union { 799 uint16_t entity_instance_num; 800 uint16_t entity_instance; 801 }; 802 uint16_t container_id; 803 uint8_t sensor_init; 804 bool8_t sensor_auxiliary_names_pdr; 805 uint8_t base_unit; 806 int8_t unit_modifier; 807 uint8_t rate_unit; 808 uint8_t base_oem_unit_handle; 809 uint8_t aux_unit; 810 int8_t aux_unit_modifier; 811 uint8_t aux_rate_unit; 812 uint8_t rel; 813 uint8_t aux_oem_unit_handle; 814 bool8_t is_linear; 815 uint8_t sensor_data_size; 816 real32_t resolution; 817 real32_t offset; 818 uint16_t accuracy; 819 uint8_t plus_tolerance; 820 uint8_t minus_tolerance; 821 union_sensor_data_size hysteresis; 822 bitfield8_t supported_thresholds; 823 bitfield8_t threshold_and_hysteresis_volatility; 824 real32_t state_transition_interval; 825 real32_t update_interval; 826 union_sensor_data_size max_readable; 827 union_sensor_data_size min_readable; 828 uint8_t range_field_format; 829 bitfield8_t range_field_support; 830 union_range_field_format nominal_value; 831 union_range_field_format normal_max; 832 union_range_field_format normal_min; 833 union_range_field_format warning_high; 834 union_range_field_format warning_low; 835 union_range_field_format critical_high; 836 union_range_field_format critical_low; 837 union_range_field_format fatal_high; 838 union_range_field_format fatal_low; 839 }; 840 841 typedef char16_t pldm_utf16be; 842 843 struct pldm_entity_auxiliary_name { 844 /* name_language_tag type is char which terminator is 0x00*/ 845 char *tag; 846 /** 847 * entity_aux_name type is str_utf16be which terminator is 0x00 0x00. 848 * The two bytes of one characters is in BE order. 849 */ 850 pldm_utf16be *name; 851 }; 852 853 struct pldm_entity_auxiliary_names_pdr { 854 struct pldm_value_pdr_hdr hdr; 855 pldm_entity container; 856 uint8_t shared_name_count; 857 uint8_t name_string_count; 858 struct pldm_entity_auxiliary_name *names; 859 size_t auxiliary_name_data_size; 860 #ifndef __cplusplus 861 #if defined __has_attribute 862 /* 863 * auxiliary_name_data is organised in the fashion of struct-of-arrays, by 864 * contrast to the approach of an array-of-structs. By Table 95 the entity 865 * name data is provided in (ASCII, UTF16-BE) pairs, but we rearrange that 866 * to be an array of UTF16-BE strings followed by an array of ASCII strings, 867 * with the pairs associated by index, to maintain alignment. 868 */ 869 static_assert(__has_attribute(aligned), 870 "auxiliary_name_data risks undefined behaviour"); 871 char auxiliary_name_data[] 872 __attribute__((aligned(alignof(pldm_utf16be)))); 873 #else 874 #error("__has_attribute() support is required to uphold runtime safety") 875 #endif 876 #endif 877 }; 878 879 /** @struct state_effecter_possible_states 880 * 881 * Structure representing state enums for state effecter 882 */ 883 struct state_effecter_possible_states { 884 uint16_t state_set_id; 885 uint8_t possible_states_size; 886 bitfield8_t states[1]; 887 } __attribute__((packed)); 888 889 /** @struct pldm_effecter_aux_name_pdr 890 * 891 * Structure representing PLDM aux name numeric effecter value PDR 892 */ 893 struct pldm_effecter_aux_name_pdr { 894 struct pldm_pdr_hdr hdr; 895 uint16_t terminus_handle; 896 uint16_t effecter_id; 897 uint8_t effecter_count; 898 uint8_t effecter_names[1]; 899 } __attribute__((packed)); 900 901 /** @brief Encode PLDM state effecter PDR 902 * 903 * @param[in/out] effecter Structure to encode. All members of 904 * effecter, except those mentioned in 905 * the @note below, should be initialized 906 * by the caller. 907 * @param[in] allocation_size Size of effecter allocation in bytes 908 * @param[in] possible_states Possible effecter states 909 * @param[in] possible_states_size Size of possible effecter states in 910 * bytes 911 * @param[out] actual_size Size of effecter PDR. Set to 0 on 912 * error. 913 * @return int pldm_completion_codes 914 * PLDM_SUCCESS/PLDM_ERROR/PLDM_ERROR_INVALID_LENGTH 915 * 916 * @note The effecter parameter will be encoded in place. 917 * @note Caller is responsible for allocation of the effecter parameter. Caller 918 * must allocate enough space for the base structure and the 919 * effecter->possible_states array, otherwise the function will fail. 920 * @note effecter->hdr.length, .type, and .version will be set appropriately. 921 */ 922 int encode_state_effecter_pdr( 923 struct pldm_state_effecter_pdr *effecter, size_t allocation_size, 924 const struct state_effecter_possible_states *possible_states, 925 size_t possible_states_size, size_t *actual_size); 926 927 /** @struct set_effecter_state_field 928 * 929 * Structure representing a stateField in SetStateEffecterStates command */ 930 931 typedef struct state_field_for_state_effecter_set { 932 uint8_t set_request; //!< Whether to change the state 933 uint8_t effecter_state; //!< Expected state of the effecter 934 } __attribute__((packed)) set_effecter_state_field; 935 936 /** @struct get_sensor_readings_field 937 * 938 * Structure representing a stateField in GetStateSensorReadings command */ 939 940 typedef struct state_field_for_get_state_sensor_readings { 941 uint8_t sensor_op_state; //!< The state of the sensor itself 942 uint8_t present_state; //!< Return a state value 943 uint8_t previous_state; //!< The state that the presentState was entered 944 //! from. This must be different from the 945 //! present state 946 uint8_t event_state; //!< Return a state value from a PLDM State Set 947 //! that is associated with the sensor 948 } __attribute__((packed)) get_sensor_state_field; 949 950 /** @struct get_effecter_state_field 951 * 952 * Structure representing a stateField in GetStateEffecterStates command 953 */ 954 typedef struct state_field_for_get_state_effecter_states { 955 uint8_t effecter_op_state; //!< The state of the effecter itself 956 uint8_t pending_state; //!< The state that is currently being processed 957 uint8_t present_state; //!< Return a state value 958 } get_effecter_state_field; 959 960 /** @struct PLDM_SetStateEffecterStates_Request 961 * 962 * Structure representing PLDM set state effecter states request. 963 */ 964 struct pldm_set_state_effecter_states_req { 965 uint16_t effecter_id; 966 uint8_t comp_effecter_count; 967 set_effecter_state_field field[8]; 968 } __attribute__((packed)); 969 970 /** @struct pldm_get_pdr_repository_info_resp 971 * 972 * Structure representing GetPDRRepositoryInfo response packet 973 */ 974 struct pldm_pdr_repository_info_resp { 975 uint8_t completion_code; 976 uint8_t repository_state; 977 uint8_t update_time[PLDM_TIMESTAMP104_SIZE]; 978 uint8_t oem_update_time[PLDM_TIMESTAMP104_SIZE]; 979 uint32_t record_count; 980 uint32_t repository_size; 981 uint32_t largest_record_size; 982 uint8_t data_transfer_handle_timeout; 983 } __attribute__((packed)); 984 985 /** @struct pldm_get_pdr_resp 986 * 987 * structure representing GetPDR response packet 988 * transfer CRC is not part of the structure and will be 989 * added at the end of last packet in multipart transfer 990 */ 991 struct pldm_get_pdr_resp { 992 uint8_t completion_code; 993 uint32_t next_record_handle; 994 uint32_t next_data_transfer_handle; 995 uint8_t transfer_flag; 996 uint16_t response_count; 997 uint8_t record_data[1]; 998 } __attribute__((packed)); 999 1000 /** @struct pldm_get_pdr_req 1001 * 1002 * structure representing GetPDR request packet 1003 */ 1004 struct pldm_get_pdr_req { 1005 uint32_t record_handle; 1006 uint32_t data_transfer_handle; 1007 uint8_t transfer_op_flag; 1008 uint16_t request_count; 1009 uint16_t record_change_number; 1010 } __attribute__((packed)); 1011 1012 /** @struct pldm_set_event_receiver_req 1013 * 1014 * Structure representing SetEventReceiver command. 1015 * This structure applies only for MCTP as a transport type. 1016 */ 1017 struct pldm_set_event_receiver_req { 1018 uint8_t event_message_global_enable; 1019 uint8_t transport_protocol_type; 1020 uint8_t event_receiver_address_info; 1021 uint16_t heartbeat_timer; 1022 } __attribute__((packed)); 1023 1024 /** @struct pldm_event_message_buffer_size_req 1025 * 1026 * Structure representing EventMessageBufferSizes command request data 1027 */ 1028 struct pldm_event_message_buffer_size_req { 1029 uint16_t event_receiver_max_buffer_size; 1030 } __attribute__((packed)); 1031 1032 /** @struct pldm_event_message_buffer_size_resp 1033 * 1034 * Structure representing EventMessageBufferSizes command response data 1035 */ 1036 struct pldm_event_message_buffer_size_resp { 1037 uint8_t completion_code; 1038 uint16_t terminus_max_buffer_size; 1039 } __attribute__((packed)); 1040 1041 /** @struct pldm_platform_event_message_supported_req 1042 * 1043 * structure representing PlatformEventMessageSupported command request data 1044 */ 1045 struct pldm_event_message_supported_req { 1046 uint8_t format_version; 1047 } __attribute__((packed)); 1048 1049 /** @struct pldm_event_message_supported_response 1050 * 1051 * structure representing EventMessageSupported command response data 1052 */ 1053 struct pldm_event_message_supported_resp { 1054 uint8_t completion_code; 1055 uint8_t synchrony_configuration; 1056 bitfield8_t synchrony_configuration_supported; 1057 uint8_t number_event_class_returned; 1058 uint8_t event_class[1]; 1059 } __attribute__((packed)); 1060 1061 /** @struct pldm_set_numeric_effecter_value_req 1062 * 1063 * structure representing SetNumericEffecterValue request packet 1064 */ 1065 struct pldm_set_numeric_effecter_value_req { 1066 uint16_t effecter_id; 1067 uint8_t effecter_data_size; 1068 uint8_t effecter_value[1]; 1069 } __attribute__((packed)); 1070 1071 /** @struct pldm_get_state_sensor_readings_req 1072 * 1073 * Structure representing PLDM get state sensor readings request. 1074 */ 1075 struct pldm_get_state_sensor_readings_req { 1076 uint16_t sensor_id; 1077 bitfield8_t sensor_rearm; 1078 uint8_t reserved; 1079 } __attribute__((packed)); 1080 1081 /** @struct pldm_get_state_sensor_readings_resp 1082 * 1083 * Structure representing PLDM get state sensor readings response. 1084 */ 1085 struct pldm_get_state_sensor_readings_resp { 1086 uint8_t completion_code; 1087 uint8_t comp_sensor_count; 1088 get_sensor_state_field field[1]; 1089 } __attribute__((packed)); 1090 1091 /** @struct pldm_get_state_effecter_states_req 1092 * 1093 * structure representing GetStateEffecterStates request packet 1094 */ 1095 struct pldm_get_state_effecter_states_req { 1096 uint16_t effecter_id; 1097 }; 1098 1099 /** @struct pldm_get_state_effecter_states_resp 1100 * 1101 * Structure representing PLDM get state effecter states response. 1102 */ 1103 struct pldm_get_state_effecter_states_resp { 1104 uint8_t completion_code; 1105 uint8_t comp_effecter_count; 1106 get_effecter_state_field field[PLDM_GET_EFFECTER_STATE_FIELD_COUNT_MAX]; 1107 }; 1108 1109 /** @struct pldm_sensor_event 1110 * 1111 * structure representing sensorEventClass 1112 */ 1113 struct pldm_sensor_event_data { 1114 uint16_t sensor_id; 1115 uint8_t sensor_event_class_type; 1116 uint8_t event_class[1]; 1117 } __attribute__((packed)); 1118 1119 /** @struct pldm_state_sensor_state 1120 * 1121 * structure representing sensorEventClass for stateSensorState 1122 */ 1123 struct pldm_sensor_event_state_sensor_state { 1124 uint8_t sensor_offset; 1125 uint8_t event_state; 1126 uint8_t previous_event_state; 1127 } __attribute__((packed)); 1128 1129 /** @struct pldm_sensor_event_numeric_sensor_state 1130 * 1131 * structure representing sensorEventClass for stateSensorState 1132 */ 1133 struct pldm_sensor_event_numeric_sensor_state { 1134 uint8_t event_state; 1135 uint8_t previous_event_state; 1136 uint8_t sensor_data_size; 1137 uint8_t present_reading[1]; 1138 } __attribute__((packed)); 1139 1140 /** @struct pldm_sensor_event_sensor_op_state 1141 * 1142 * structure representing sensorEventClass for SensorOpState 1143 */ 1144 struct pldm_sensor_event_sensor_op_state { 1145 uint8_t present_op_state; 1146 uint8_t previous_op_state; 1147 } __attribute__((packed)); 1148 1149 /** @struct pldm_message_poll_event 1150 * 1151 * structure representing pldmMessagePollEvent 1152 */ 1153 struct pldm_message_poll_event { 1154 uint8_t format_version; 1155 uint16_t event_id; 1156 uint32_t data_transfer_handle; 1157 }; 1158 1159 /** @struct pldm_platform_cper_event 1160 * 1161 * structure representing cperEvent fields 1162 */ 1163 struct pldm_platform_cper_event { 1164 uint8_t format_version; 1165 uint8_t format_type; 1166 uint16_t event_data_length; 1167 #ifndef __cplusplus 1168 uint8_t event_data[] LIBPLDM_CC_COUNTED_BY(event_data_length); 1169 #endif 1170 }; 1171 1172 /** @brief PLDM CPER event format type */ 1173 enum pldm_platform_cper_event_format { 1174 PLDM_PLATFORM_CPER_EVENT_WITH_HEADER = 0x00, 1175 PLDM_PLATFORM_CPER_EVENT_WITHOUT_HEADER = 0x01 1176 }; 1177 1178 /** @struct pldm_platform_event_message_req 1179 * 1180 * structure representing PlatformEventMessage command request data 1181 */ 1182 struct pldm_platform_event_message_req { 1183 uint8_t format_version; 1184 uint8_t tid; 1185 uint8_t event_class; 1186 uint8_t event_data[1]; 1187 } __attribute__((packed)); 1188 1189 /** @struct pldm_poll_for_platform_event_message_req 1190 * 1191 * structure representing PollForPlatformEventMessage command request data 1192 */ 1193 struct pldm_poll_for_platform_event_message_req { 1194 uint8_t format_version; 1195 uint8_t transfer_operation_flag; 1196 uint32_t data_transfer_handle; 1197 uint16_t event_id_to_acknowledge; 1198 }; 1199 1200 /** @struct pldm_poll_for_platform_event_message_min_resp 1201 * 1202 * structure representing PollForPlatformEventMessage command response data 1203 */ 1204 struct pldm_poll_for_platform_event_message_min_resp { 1205 uint8_t completion_code; 1206 uint8_t tid; 1207 uint16_t event_id; 1208 }; 1209 1210 /** @struct pldm_platform_event_message_response 1211 * 1212 * structure representing PlatformEventMessage command response data 1213 */ 1214 struct pldm_platform_event_message_resp { 1215 uint8_t completion_code; 1216 uint8_t platform_event_status; 1217 } __attribute__((packed)); 1218 1219 /** @struct pldm_pdr_repository_chg_event_data 1220 * 1221 * structure representing pldmPDRRepositoryChgEvent class eventData 1222 */ 1223 struct pldm_pdr_repository_chg_event_data { 1224 uint8_t event_data_format; 1225 uint8_t number_of_change_records; 1226 uint8_t change_records[1]; 1227 } __attribute__((packed)); 1228 1229 /** @struct pldm_pdr_repository_chg_event_change_record_data 1230 * 1231 * structure representing pldmPDRRepositoryChgEvent class eventData's change 1232 * record data 1233 */ 1234 struct pldm_pdr_repository_change_record_data { 1235 uint8_t event_data_operation; 1236 uint8_t number_of_change_entries; 1237 uint32_t change_entry[1]; 1238 } __attribute__((packed)); 1239 1240 /** @struct pldm_get_numeric_effecter_value_req 1241 * 1242 * structure representing GetNumericEffecterValue request packet 1243 */ 1244 struct pldm_get_numeric_effecter_value_req { 1245 uint16_t effecter_id; 1246 } __attribute__((packed)); 1247 1248 /** @struct pldm_get_numeric_effecter_value_resp 1249 * 1250 * structure representing GetNumericEffecterValue response packet 1251 */ 1252 struct pldm_get_numeric_effecter_value_resp { 1253 uint8_t completion_code; 1254 uint8_t effecter_data_size; 1255 uint8_t effecter_oper_state; 1256 uint8_t pending_and_present_values[1]; 1257 } __attribute__((packed)); 1258 1259 /** @struct pldm_get_sensor_reading_req 1260 * 1261 * Structure representing PLDM get sensor reading request 1262 */ 1263 struct pldm_get_sensor_reading_req { 1264 uint16_t sensor_id; 1265 bool8_t rearm_event_state; 1266 } __attribute__((packed)); 1267 1268 /** @struct pldm_get_sensor_reading_resp 1269 * 1270 * Structure representing PLDM get sensor reading response 1271 */ 1272 struct pldm_get_sensor_reading_resp { 1273 uint8_t completion_code; 1274 uint8_t sensor_data_size; 1275 uint8_t sensor_operational_state; 1276 uint8_t sensor_event_message_enable; 1277 uint8_t present_state; 1278 uint8_t previous_state; 1279 uint8_t event_state; 1280 uint8_t present_reading[1]; 1281 } __attribute__((packed)); 1282 1283 /* Responder */ 1284 1285 /* SetNumericEffecterValue */ 1286 1287 /** @brief Decode SetNumericEffecterValue request data 1288 * 1289 * @param[in] msg - Request message 1290 * @param[in] payload_length - Length of request message payload 1291 * @param[out] effecter_id - used to identify and access the effecter 1292 * @param[out] effecter_data_size - The bit width and format of the setting 1293 * value for the effecter. 1294 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1295 * @param[out] effecter_value - The setting value of numeric effecter being 1296 * requested. 1297 * @return pldm_completion_codes 1298 */ 1299 int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg, 1300 size_t payload_length, 1301 uint16_t *effecter_id, 1302 uint8_t *effecter_data_size, 1303 uint8_t effecter_value[4]); 1304 1305 /** @brief Create a PLDM response message for SetNumericEffecterValue 1306 * 1307 * @param[in] instance_id - Message's instance id 1308 * @param[in] completion_code - PLDM completion code 1309 * @param[out] msg - Message will be written to this 1310 * @param[in] payload_length - Length of request message payload 1311 * @return pldm_completion_codes 1312 * @note Caller is responsible for memory alloc and dealloc of param 1313 * 'msg.body.payload' 1314 */ 1315 int encode_set_numeric_effecter_value_resp(uint8_t instance_id, 1316 uint8_t completion_code, 1317 struct pldm_msg *msg, 1318 size_t payload_length); 1319 1320 /* SetStateEffecterStates */ 1321 1322 /** @brief Create a PLDM response message for SetStateEffecterStates 1323 * 1324 * @param[in] instance_id - Message's instance id 1325 * @param[in] completion_code - PLDM completion code 1326 * @param[out] msg - Message will be written to this 1327 * @return pldm_completion_codes 1328 * @note Caller is responsible for memory alloc and dealloc of param 1329 * 'msg.body.payload' 1330 */ 1331 1332 int encode_set_state_effecter_states_resp(uint8_t instance_id, 1333 uint8_t completion_code, 1334 struct pldm_msg *msg); 1335 1336 /** @brief Decode SetStateEffecterStates request data 1337 * 1338 * @param[in] msg - Request message 1339 * @param[in] payload_length - Length of request message payload 1340 * @param[out] effecter_id - used to identify and access the effecter 1341 * @param[out] comp_effecter_count - number of individual sets of effecter 1342 * information. Upto eight sets of state effecter info can be accessed 1343 * for a given effecter. 1344 * @param[out] field - each unit is an instance of the stateFileld structure 1345 * that is used to set the requested state for a particular effecter 1346 * within the state effecter. This field holds the starting address of 1347 * the stateField values. The user is responsible to allocate the 1348 * memory prior to calling this command. Since the state field count is 1349 * not known in advance, the user should allocate the maximum size 1350 * always, which is 8 in number. 1351 * @return pldm_completion_codes 1352 */ 1353 1354 int decode_set_state_effecter_states_req(const struct pldm_msg *msg, 1355 size_t payload_length, 1356 uint16_t *effecter_id, 1357 uint8_t *comp_effecter_count, 1358 set_effecter_state_field *field); 1359 1360 /* GetPDR */ 1361 1362 /** @brief Create a PLDM response message for GetPDR 1363 * 1364 * @param[in] instance_id - Message's instance id 1365 * @param[in] completion_code - PLDM completion code 1366 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in 1367 * the PDR Repository 1368 * @param[in] next_data_transfer_hndl - A handle that identifies the next 1369 * portion of the PDR data to be transferred, if any 1370 * @param[in] transfer_flag - Indicates the portion of PDR data being 1371 * transferred 1372 * @param[in] resp_cnt - The number of recordData bytes returned in this 1373 * response 1374 * @param[in] record_data - PDR data bytes of length resp_cnt 1375 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only 1376 * in the last part of a PDR being transferred 1377 * @param[out] msg - Message will be written to this 1378 * @return pldm_completion_codes 1379 * @note Caller is responsible for memory alloc and dealloc of param 1380 * 'msg.payload' 1381 */ 1382 int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code, 1383 uint32_t next_record_hndl, 1384 uint32_t next_data_transfer_hndl, uint8_t transfer_flag, 1385 uint16_t resp_cnt, const uint8_t *record_data, 1386 uint8_t transfer_crc, struct pldm_msg *msg); 1387 1388 /** @brief Decode GetPDR request data 1389 * 1390 * @param[in] msg - Request message 1391 * @param[in] payload_length - Length of request message payload 1392 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved 1393 * @param[out] data_transfer_hndl - Handle used to identify a particular 1394 * multipart PDR data transfer operation 1395 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent 1396 * portion of transfer 1397 * @param[out] request_cnt - The maximum number of record bytes requested 1398 * @param[out] record_chg_num - Used to determine whether the PDR has changed 1399 * while PDR transfer is going on 1400 * @return pldm_completion_codes 1401 */ 1402 1403 int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length, 1404 uint32_t *record_hndl, uint32_t *data_transfer_hndl, 1405 uint8_t *transfer_op_flag, uint16_t *request_cnt, 1406 uint16_t *record_chg_num); 1407 1408 /* GetStateSensorReadings */ 1409 1410 /** @brief Decode GetStateSensorReadings request data 1411 * 1412 * @param[in] msg - Request message 1413 * @param[in] payload_length - Length of request message payload 1414 * @param[out] sensor_id - used to identify and access the simple or composite 1415 * sensor 1416 * @param[out] sensor_rearm - Each bit location in this field corresponds to a 1417 * particular sensor within the state sensor, where bit [0] corresponds 1418 * to the first state sensor (sensor offset 0) and bit [7] corresponds 1419 * to the eighth sensor (sensor offset 7), sequentially. 1420 * @param[out] reserved - value: 0x00 1421 * @return pldm_completion_codes 1422 */ 1423 1424 int decode_get_state_sensor_readings_req(const struct pldm_msg *msg, 1425 size_t payload_length, 1426 uint16_t *sensor_id, 1427 bitfield8_t *sensor_rearm, 1428 uint8_t *reserved); 1429 1430 /** @brief Encode GetStateSensorReadings response data 1431 * 1432 * @param[in] instance_id - Message's instance id 1433 * @param[in] completion_code - PLDM completion code 1434 * @param[out] comp_sensor_count - The number of individual sets of sensor 1435 * information that this command accesses 1436 * @param[out] field - Each stateField is an instance of a stateField structure 1437 * that is used to return the present operational state setting and the 1438 * present state and event state for a particular set of sensor 1439 * information contained within the state sensor 1440 * @param[out] msg - Message will be written to this 1441 * @return pldm_completion_codes 1442 */ 1443 1444 int encode_get_state_sensor_readings_resp(uint8_t instance_id, 1445 uint8_t completion_code, 1446 uint8_t comp_sensor_count, 1447 get_sensor_state_field *field, 1448 struct pldm_msg *msg); 1449 1450 /* GetNumericEffecterValue */ 1451 1452 /** @brief Decode GetNumericEffecterValue request data 1453 * 1454 * @param[in] msg - Request message 1455 * @param[in] payload_length - Length of request message payload 1456 * @param[out] effecter_id - used to identify and access the effecter 1457 * @return pldm_completion_codes 1458 */ 1459 int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg, 1460 size_t payload_length, 1461 uint16_t *effecter_id); 1462 1463 /** @brief Create a PLDM response message for GetNumericEffecterValue 1464 * 1465 * @param[in] instance_id - Message's instance id 1466 * @param[in] completion_code - PLDM completion code 1467 * @param[in] effecter_data_size - The bit width and format of the setting 1468 * value for the effecter. 1469 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1470 * @param[in] effecter_oper_state - The state of the effecter itself 1471 * @param[in] pending_value - The pending numeric value setting of the 1472 * effecter. The effecterDataSize field indicates the number of 1473 * bits used for this field 1474 * @param[in] present_value - The present numeric value setting of the 1475 * effecter. The effecterDataSize indicates the number of bits 1476 * used for this field 1477 * @param[out] msg - Message will be written to this 1478 * @param[in] payload_length - Length of request message payload 1479 * @return pldm_completion_codes 1480 * @note Caller is responsible for memory alloc and dealloc of param 1481 * 'msg.payload' 1482 */ 1483 int encode_get_numeric_effecter_value_resp( 1484 uint8_t instance_id, uint8_t completion_code, 1485 uint8_t effecter_data_size, uint8_t effecter_oper_state, 1486 const uint8_t *pending_value, const uint8_t *present_value, 1487 struct pldm_msg *msg, size_t payload_length); 1488 1489 /* GetSensorReading */ 1490 1491 /** @brief Decode GetSensorReading request data 1492 * 1493 * @param[in] msg - Request message 1494 * @param[in] payload_length - Length of request message payload 1495 * @param[out] sensor_id - A handle that is used to identify and access 1496 * the sensor 1497 * @param[out] rearm_event_state - true = manually re-arm EventState after 1498 * responding to this request, false = no manual re-arm 1499 * @return pldm_completion_codes 1500 */ 1501 1502 int decode_get_sensor_reading_req(const struct pldm_msg *msg, 1503 size_t payload_length, uint16_t *sensor_id, 1504 bool8_t *rearm_event_state); 1505 1506 /** @brief Encode GetSensorReading response data 1507 * 1508 * @param[in] instance_id - Message's instance id 1509 * @param[in] completion_code - PLDM completion code 1510 * @param[out] sensor_data_size - The bit width and format of reading and 1511 * threshold values 1512 * @param[out] sensor_operational_state - The state of the sensor itself 1513 * @param[out] sensor_event_message_enable - value: { noEventGeneration, 1514 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled, 1515 * stateEventsOnlyEnabled } 1516 * @param[out] present_state - The most recently assessed state value monitored 1517 * by the sensor 1518 * @param[out] previous_state - The state that the presentState was entered 1519 * from 1520 * @param[out] event_state - Indicates which threshold crossing assertion 1521 * events have been detected 1522 * @param[out] present_reading - The present value indicated by the sensor 1523 * @param[out] msg - Message will be written to this 1524 * @param[in] payload_length - Length of request message payload 1525 * @return pldm_completion_codes 1526 */ 1527 1528 int encode_get_sensor_reading_resp(uint8_t instance_id, uint8_t completion_code, 1529 uint8_t sensor_data_size, 1530 uint8_t sensor_operational_state, 1531 uint8_t sensor_event_message_enable, 1532 uint8_t present_state, 1533 uint8_t previous_state, uint8_t event_state, 1534 const uint8_t *present_reading, 1535 struct pldm_msg *msg, size_t payload_length); 1536 1537 /* Requester */ 1538 1539 /*GetPDRRepositoryInfo*/ 1540 1541 /** @brief Encode GetPDRRepositoryInfo response data 1542 * 1543 * @param[in] instance_id - Message's instance id 1544 * @param[in] completion_code - PLDM completion code 1545 * @param[in] repository_state - PLDM repository state 1546 * @param[in] update_time - When the standard PDR repository data was 1547 * originally created 1548 * @param[in] oem_update_time - when OEM PDRs in the PDR Repository were 1549 * originally created 1550 * @param[in] record_count - Total number of PDRs in this repository 1551 * @param[in] repository_size - Size of the PDR Repository in bytes 1552 * @param[in] largest_record_size - Size of the largest record in the PDR 1553 * Repository in bytes 1554 * @param[in] data_transfer_handle_timeout - Data transmission timeout 1555 * @param[out] msg - Message will be written to this 1556 * @return pldm_completion_codes 1557 */ 1558 int encode_get_pdr_repository_info_resp( 1559 uint8_t instance_id, uint8_t completion_code, uint8_t repository_state, 1560 const uint8_t *update_time, const uint8_t *oem_update_time, 1561 uint32_t record_count, uint32_t repository_size, 1562 uint32_t largest_record_size, uint8_t data_transfer_handle_timeout, 1563 struct pldm_msg *msg); 1564 1565 /** @brief Decode GetPDRRepositoryInfo response data 1566 * 1567 * @param[in] msg - Response message 1568 * @param[in] payload_length - Length of response message payload 1569 * @param[out] completion_code - PLDM completion code 1570 * @param[out] repository_state - PLDM repository state 1571 * @param[out] update_time - When the standard PDR repository data was 1572 * originally created 1573 * @param[out] oem_update_time - when OEM PDRs in the PDR Repository were 1574 * originally created 1575 * @param[out] record_count - Total number of PDRs in this repository 1576 * @param[out] repository_size - Size of the PDR Repository in bytes 1577 * @param[out] largest_record_size - Size of the largest record in the PDR 1578 * Repository in bytes 1579 * @param[out] data_transfer_handle_timeout - Data transmission timeout 1580 * @return pldm_completion_codes 1581 */ 1582 int decode_get_pdr_repository_info_resp( 1583 const struct pldm_msg *msg, size_t payload_length, 1584 uint8_t *completion_code, uint8_t *repository_state, 1585 uint8_t *update_time, uint8_t *oem_update_time, uint32_t *record_count, 1586 uint32_t *repository_size, uint32_t *largest_record_size, 1587 uint8_t *data_transfer_handle_timeout); 1588 1589 /** @brief Decode GetPDRRepositoryInfo response data 1590 * 1591 * @param[in] msg - Response message 1592 * @param[in] payload_length - Length of response message payload 1593 * @param[out] resp - The response structure to populate with the extracted message data. Output member values are host-endian. 1594 * 1595 * @return 0 on success, a negative errno value on failure. 1596 */ 1597 int decode_get_pdr_repository_info_resp_safe( 1598 const struct pldm_msg *msg, size_t payload_length, 1599 struct pldm_pdr_repository_info_resp *resp); 1600 1601 /* GetPDR */ 1602 1603 /** @brief Create a PLDM request message for GetPDR 1604 * 1605 * @param[in] instance_id - Message's instance id 1606 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved 1607 * @param[in] data_transfer_hndl - Handle used to identify a particular 1608 * multipart PDR data transfer operation 1609 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent 1610 * portion of transfer 1611 * @param[in] request_cnt - The maximum number of record bytes requested 1612 * @param[in] record_chg_num - Used to determine whether the PDR has changed 1613 * while PDR transfer is going on 1614 * @param[out] msg - Message will be written to this 1615 * @param[in] payload_length - Length of request message payload 1616 * @return pldm_completion_codes 1617 * @note Caller is responsible for memory alloc and dealloc of param 1618 * 'msg.payload' 1619 */ 1620 int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl, 1621 uint32_t data_transfer_hndl, uint8_t transfer_op_flag, 1622 uint16_t request_cnt, uint16_t record_chg_num, 1623 struct pldm_msg *msg, size_t payload_length); 1624 1625 /** @brief Decode GetPDR response data 1626 * 1627 * Note: 1628 * * If the return value is not PLDM_SUCCESS, it represents a 1629 * transport layer error. 1630 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1631 * protocol layer error and all the out-parameters are invalid. 1632 * 1633 * @param[in] msg - Request message 1634 * @param[in] payload_length - Length of request message payload 1635 * @param[out] completion_code - PLDM completion code 1636 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in 1637 * the PDR Repository 1638 * @param[out] next_data_transfer_hndl - A handle that identifies the next 1639 * portion of the PDR data to be transferred, if any 1640 * @param[out] transfer_flag - Indicates the portion of PDR data being 1641 * transferred 1642 * @param[out] resp_cnt - The number of recordData bytes returned in this 1643 * response 1644 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to 1645 * skip the copy and place the actual length in resp_cnt. 1646 * @param[in] record_data_length - Length of record_data 1647 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only 1648 * in the last part of a PDR being transferred 1649 * @return pldm_completion_codes 1650 */ 1651 int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length, 1652 uint8_t *completion_code, uint32_t *next_record_hndl, 1653 uint32_t *next_data_transfer_hndl, 1654 uint8_t *transfer_flag, uint16_t *resp_cnt, 1655 uint8_t *record_data, size_t record_data_length, 1656 uint8_t *transfer_crc); 1657 1658 /** @brief Decode GetPDR response data 1659 * 1660 * Note: 1661 * * If the return value is not PLDM_SUCCESS, it represents a 1662 * transport layer error. 1663 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1664 * protocol layer error and all the out-parameters are invalid. 1665 * 1666 * @param[in] msg - Request message 1667 * @param[in] payload_length - Length of request message payload 1668 * @param[out] resp - The response structure into which the message will be unpacked 1669 * @param[in] resp_len - The size of the resp object in memory 1670 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only 1671 * in the last part of a PDR being transferred 1672 * @return 0 on success, otherwise, a negative errno value on failure 1673 */ 1674 int decode_get_pdr_resp_safe(const struct pldm_msg *msg, size_t payload_length, 1675 struct pldm_get_pdr_resp *resp, size_t resp_len, 1676 uint8_t *transfer_crc); 1677 1678 /* SetStateEffecterStates */ 1679 1680 /** @brief Create a PLDM request message for SetStateEffecterStates 1681 * 1682 * @param[in] instance_id - Message's instance id 1683 * @param[in] effecter_id - used to identify and access the effecter 1684 * @param[in] comp_effecter_count - number of individual sets of effecter 1685 * information. Upto eight sets of state effecter info can be accessed 1686 * for a given effecter. 1687 * @param[in] field - each unit is an instance of the stateField structure 1688 * that is used to set the requested state for a particular effecter 1689 * within the state effecter. This field holds the starting address of 1690 * the stateField values. The user is responsible to allocate the 1691 * memory prior to calling this command. The user has to allocate the 1692 * field parameter as sizeof(set_effecter_state_field) * 1693 * comp_effecter_count 1694 * @param[out] msg - Message will be written to this 1695 * @return pldm_completion_codes 1696 * @note Caller is responsible for memory alloc and dealloc of param 1697 * 'msg.payload' 1698 */ 1699 1700 int encode_set_state_effecter_states_req(uint8_t instance_id, 1701 uint16_t effecter_id, 1702 uint8_t comp_effecter_count, 1703 set_effecter_state_field *field, 1704 struct pldm_msg *msg); 1705 1706 /** @brief Decode SetStateEffecterStates response data 1707 * 1708 * Note: 1709 * * If the return value is not PLDM_SUCCESS, it represents a 1710 * transport layer error. 1711 * * If the completion_code value is not PLDM_SUCCESS, it represents a 1712 * protocol layer error and all the out-parameters are invalid. 1713 * 1714 * @param[in] msg - Request message 1715 * @param[in] payload_length - Length of response message payload 1716 * @param[out] completion_code - PLDM completion code 1717 * @return pldm_completion_codes 1718 */ 1719 int decode_set_state_effecter_states_resp(const struct pldm_msg *msg, 1720 size_t payload_length, 1721 uint8_t *completion_code); 1722 1723 /* SetNumericEffecterValue */ 1724 1725 /** @brief Create a PLDM request message for SetNumericEffecterValue 1726 * 1727 * @param[in] instance_id - Message's instance id 1728 * @param[in] effecter_id - used to identify and access the effecter 1729 * @param[in] effecter_data_size - The bit width and format of the setting 1730 * value for the effecter. 1731 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 1732 * @param[in] effecter_value - The setting value of numeric effecter being 1733 * requested. 1734 * @param[in] payload_length - Length of request message payload 1735 * @param[out] msg - Message will be written to this 1736 * @return pldm_completion_codes 1737 * @note Caller is responsible for memory alloc and dealloc of param 1738 * 'msg.payload' 1739 */ 1740 int encode_set_numeric_effecter_value_req(uint8_t instance_id, 1741 uint16_t effecter_id, 1742 uint8_t effecter_data_size, 1743 const uint8_t *effecter_value, 1744 struct pldm_msg *msg, 1745 size_t payload_length); 1746 1747 /** @brief Decode SetNumericEffecterValue response data 1748 * @param[in] msg - Request message 1749 * @param[in] payload_length - Length of response message payload 1750 * @param[out] completion_code - PLDM completion code 1751 * @return pldm_completion_codes 1752 */ 1753 int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg, 1754 size_t payload_length, 1755 uint8_t *completion_code); 1756 1757 /** @brief Create a PLDM request message for GetStateSensorReadings 1758 * 1759 * @param[in] instance_id - Message's instance id 1760 * @param[in] sensor_id - used to identify and access the simple or composite 1761 * sensor 1762 * @param[in] sensorRearm - Each bit location in this field corresponds to a 1763 * particular sensor within the state sensor, where bit [0] corresponds 1764 * to the first state sensor (sensor offset 0) and bit [7] corresponds 1765 * to the eighth sensor (sensor offset 7), sequentially 1766 * @param[in] reserved - value: 0x00 1767 * @param[out] msg - Message will be written to this 1768 * @return pldm_completion_codes 1769 * @note Caller is responsible for memory alloc and dealloc of param 1770 * 'msg.payload' 1771 */ 1772 int encode_get_state_sensor_readings_req(uint8_t instance_id, 1773 uint16_t sensor_id, 1774 bitfield8_t sensor_rearm, 1775 uint8_t reserved, 1776 struct pldm_msg *msg); 1777 1778 /** @brief Decode GetStateSensorReadings response data 1779 * 1780 * @param[in] msg - Request message 1781 * @param[in] payload_length - Length of response message payload 1782 * @param[out] completion_code - PLDM completion code 1783 * @param[in,out] comp_sensor_count - The number of individual sets of sensor 1784 * information that this command accesses 1785 * @param[out] field - Each stateField is an instance of a stateField structure 1786 * that is used to return the present operational state setting and the 1787 * present state and event state for a particular set of sensor 1788 * information contained within the state sensor 1789 * @return pldm_completion_codes 1790 */ 1791 1792 int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg, 1793 size_t payload_length, 1794 uint8_t *completion_code, 1795 uint8_t *comp_sensor_count, 1796 get_sensor_state_field *field); 1797 1798 /* GetStateEffecterStates */ 1799 1800 /** @brief Decode GetStateEffecterStates request data 1801 * 1802 * @param[in] msg - Request message 1803 * @param[in] payload_length - Length of request message payload 1804 * @param[out] effecter_id - used to identify and access the effecter 1805 * @return pldm_completion_codes 1806 */ 1807 int decode_get_state_effecter_states_req(const struct pldm_msg *msg, 1808 size_t payload_length, 1809 uint16_t *effecter_id); 1810 1811 /** @brief Create a PLDM request message for GetStateEffecterStates 1812 * 1813 * @param[in] instance_id - Message's instance id 1814 * @param[in] effecter_id - used to identify and access the effecter 1815 * @param[out] msg - Message will be written to this 1816 * @param[in] payload_length - Length of request message payload 1817 * @return pldm_completion_codes 1818 * @note Caller is responsible for memory alloc and dealloc of param 1819 * 'msg.payload' 1820 */ 1821 int encode_get_state_effecter_states_req(uint8_t instance_id, 1822 uint16_t effecter_id, 1823 struct pldm_msg *msg, 1824 size_t payload_length); 1825 1826 /** @brief Decode GetStateEffecterStates response data 1827 * 1828 * @param[in] msg - Request message 1829 * @param[in] payload_length - Length of response message payload 1830 * @param[out] resp - Consists of PLDM completion code, the number 1831 * of individual sets of effecters information that this command 1832 * accesses and an instance of a stateField structure that is 1833 * used to return the present operational state setting and 1834 * the present state and event state for a particular set of effecter 1835 * information contained within the state effecter 1836 * @return pldm_completion_codes 1837 */ 1838 int decode_get_state_effecter_states_resp( 1839 const struct pldm_msg *msg, size_t payload_length, 1840 struct pldm_get_state_effecter_states_resp *resp); 1841 1842 /** @brief Encode GetStateEffecterStates response data 1843 * 1844 * @param[in] instance_id - Message's instance id 1845 * @param[in] resp - Consists of PLDM completion code, the number 1846 * of individual sets of effecters information that this command 1847 * accesses and an instance of a stateField structure that is 1848 * used to return the present operational state setting and 1849 * the present state and event state for a particular set of effecter 1850 * information contained within the state effecter 1851 * @param[out] msg - Message will be written to this 1852 * @param[in] payload_length - Length of response message payload 1853 * @return pldm_completion_codes 1854 */ 1855 int encode_get_state_effecter_states_resp( 1856 uint8_t instance_id, struct pldm_get_state_effecter_states_resp *resp, 1857 struct pldm_msg *msg, size_t payload_length); 1858 1859 /* PlatformEventMessage */ 1860 1861 /** @brief Decode PlatformEventMessage request data 1862 * @param[in] msg - Request message 1863 * @param[in] payload_length - Length of response message payload 1864 * @param[out] format_version - Version of the event format 1865 * @param[out] tid - Terminus ID for the terminus that originated the event 1866 * message 1867 * @param[out] event_class - The class of event being sent 1868 * @param[out] event_data_offset - Offset where the event data should be read 1869 * from pldm msg 1870 * @return pldm_completion_codes 1871 */ 1872 int decode_platform_event_message_req(const struct pldm_msg *msg, 1873 size_t payload_length, 1874 uint8_t *format_version, uint8_t *tid, 1875 uint8_t *event_class, 1876 size_t *event_data_offset); 1877 1878 /** @brief Decode PollForEventMessage request data 1879 * @param[in] msg - Request message 1880 * @param[in] payload_length - Length of response message payload 1881 * @param[out] format_version - Version of the event format 1882 * @param[out] transfer_operation_flag - The transfer operation flag 1883 * @param[out] data_transfer_handle - The data transfer handle 1884 * @param[out] event_id_to_acknowledge - The class of event being sent 1885 * from pldm msg 1886 * @return pldm_completion_codes 1887 */ 1888 int decode_poll_for_platform_event_message_req( 1889 const struct pldm_msg *msg, size_t payload_length, 1890 uint8_t *format_version, uint8_t *transfer_operation_flag, 1891 uint32_t *data_transfer_handle, uint16_t *event_id_to_acknowledge); 1892 1893 /** @brief Encode PlatformEventMessage response data 1894 * @param[in] instance_id - Message's instance id 1895 * @param[in] completion_code - PLDM completion code 1896 * @param[in] platform_event_status - Response status of the event message 1897 * command 1898 * @param[out] msg - Message will be written to this 1899 * @return pldm_completion_codes 1900 * @note Caller is responsible for memory alloc and dealloc of param 1901 * 'msg.payload' 1902 */ 1903 int encode_platform_event_message_resp(uint8_t instance_id, 1904 uint8_t completion_code, 1905 uint8_t platform_event_status, 1906 struct pldm_msg *msg); 1907 1908 /** @brief Encode PollForPlatformEventMessage response data 1909 * @param[in] instance_id - Message's instance id 1910 * @param[in] completion_code - PLDM completion code 1911 * @param[in] tid - Terminus ID 1912 * @param[in] event_id - The event id 1913 * @param[in] next_data_transfer_handle - The next data transfer handle 1914 * @param[in] transfer_flag - The transfer flag 1915 * @param[in] event_class - The event class 1916 * @param[in] event_data_size - The event data size 1917 * @param[in] event_data - The event data 1918 * @param[in] checksum - The checksum 1919 * @param[out] msg - Message will be written to this 1920 * @param[in] payload_length - Length of Response message payload 1921 * @return pldm_completion_codes 1922 * @note Caller is responsible for memory alloc and dealloc of param 1923 * 'msg.payload' 1924 */ 1925 int encode_poll_for_platform_event_message_resp( 1926 uint8_t instance_id, uint8_t completion_code, uint8_t tid, 1927 uint16_t event_id, uint32_t next_data_transfer_handle, 1928 uint8_t transfer_flag, uint8_t event_class, uint32_t event_data_size, 1929 uint8_t *event_data, uint32_t checksum, struct pldm_msg *msg, 1930 size_t payload_length); 1931 1932 /** @brief Encode PlatformEventMessage request data 1933 * @param[in] instance_id - Message's instance id 1934 * @param[in] format_version - Version of the event format 1935 * @param[in] tid - Terminus ID for the terminus that originated the event 1936 * message 1937 * @param[in] event_class - The class of event being sent 1938 * @param[in] event_data - the event data should be read from pldm msg 1939 * @param[in] event_data_length - Length of the event data 1940 * @param[out] msg - Request message 1941 * @return pldm_completion_codes 1942 * @note Caller is responsible for memory alloc and dealloc of param 1943 * 'msg.payload' 1944 */ 1945 int encode_platform_event_message_req( 1946 uint8_t instance_id, uint8_t format_version, uint8_t tid, 1947 uint8_t event_class, const uint8_t *event_data, 1948 size_t event_data_length, struct pldm_msg *msg, size_t payload_length); 1949 1950 /** @brief Encode PollForPlatformEventMessage request data 1951 * @param[in] instance_id - Message's instance id 1952 * @param[in] format_version - Version of the event format 1953 * @param[in] transfer_operation_flag - Transfer operation 1954 * @param[in] data_transfer_handle - The data transfer handle 1955 * @param[in] event_id_to_acknowledge - the event data to acknowleadge 1956 * @param[out] msg - Request message 1957 * @return pldm_completion_codes 1958 * @note Caller is responsible for memory alloc and dealloc of param 1959 * 'msg.payload' 1960 */ 1961 int encode_poll_for_platform_event_message_req(uint8_t instance_id, 1962 uint8_t format_version, 1963 uint8_t transfer_operation_flag, 1964 uint32_t data_transfer_handle, 1965 uint16_t event_id_to_acknowledge, 1966 struct pldm_msg *msg, 1967 size_t payload_length); 1968 1969 /** @brief Decode PollForPlatformEventMessage response data 1970 * @param[in] msg - Request message 1971 * @param[in] payload_length - Length of Response message payload 1972 * @param[out] completion_code - the completion code 1973 * @param[out] tid - the tid 1974 * @param[out] event_id - The event id 1975 * @param[out] next_data_transfer_handle - The next data transfer handle 1976 * @param[out] transfer_flag - The transfer flag 1977 * @param[out] event_class - The event class 1978 * @param[out] event_data_size - The event data size 1979 * @param[out] event_data - The event data. The event_data pointer points into 1980 * msg.payload and therefore has the same lifetime as msg.payload. 1981 * @param[out] event_data_integrity_checksum - The checksum 1982 * command 1983 * @return pldm_completion_codes 1984 * @note Caller is responsible for memory alloc and dealloc of param 1985 * 'msg.payload' 1986 */ 1987 int decode_poll_for_platform_event_message_resp( 1988 const struct pldm_msg *msg, size_t payload_length, 1989 uint8_t *completion_code, uint8_t *tid, uint16_t *event_id, 1990 uint32_t *next_data_transfer_handle, uint8_t *transfer_flag, 1991 uint8_t *event_class, uint32_t *event_data_size, void **event_data, 1992 uint32_t *event_data_integrity_checksum); 1993 1994 /** @brief Decode PlatformEventMessage response data 1995 * @param[in] msg - Request message 1996 * @param[in] payload_length - Length of Response message payload 1997 * @param[out] completion_code - PLDM completion code 1998 * @param[out] platform_event_status - Response status of the event message 1999 * command 2000 * @return pldm_completion_codes 2001 */ 2002 int decode_platform_event_message_resp(const struct pldm_msg *msg, 2003 size_t payload_length, 2004 uint8_t *completion_code, 2005 uint8_t *platform_event_status); 2006 2007 /** @brief Decode EventMessageBufferSize response data 2008 * @param[in] msg - Request message 2009 * @param[in] payload_length - Length of Response message payload 2010 * @param[out] completion_code - PLDM completion code 2011 * @return pldm_completion_codes 2012 */ 2013 int decode_event_message_buffer_size_resp(const struct pldm_msg *msg, 2014 size_t payload_length, 2015 uint8_t *completion_code, 2016 uint16_t *terminus_max_buffer_size); 2017 2018 /** @brief Encode EventMessageBufferSize request data 2019 * @param[in] instance_id - Message's instance id 2020 * @param[in] event_receiver_max_buffer_size - Max buffer size 2021 * @param[out] msg - Request message 2022 * @return pldm_completion_codes 2023 * @note Caller is responsible for memory alloc and dealloc of param 2024 * 'msg.payload' 2025 */ 2026 int encode_event_message_buffer_size_req(uint8_t instance_id, 2027 uint16_t event_receiver_max_buffer_size, 2028 struct pldm_msg *msg); 2029 2030 /** @brief Encode EventMessageSupported request data 2031 * 2032 * @param[in] instance_id - Message's instance id 2033 * @param[in] format_version - Version of the event format 2034 * @param[out] msg - Request message 2035 * 2036 * @return pldm_completion_codes 2037 * @note Caller is responsible for memory alloc and dealloc of param 2038 * 'msg.payload' 2039 */ 2040 int encode_event_message_supported_req(uint8_t instance_id, 2041 uint8_t format_version, 2042 struct pldm_msg *msg); 2043 2044 /** @brief Decode EventMessageSupported response data 2045 * 2046 * @param[in] msg - Request message 2047 * @param[in] payload_length - Length of Response message payload 2048 * @param[out] completion_code - PLDM completion code 2049 * @param[out] synchrony_config - the synchrony configuration 2050 * @param[out] synchrony_config_support - the synchrony configuration support 2051 * @param[out] number_event_class_returned - PLDM completion code 2052 * @param[out] event_class - the event classes 2053 * @param[in] event_class_count - the event class count 2054 * 2055 * @return pldm_completion_codes 2056 */ 2057 int decode_event_message_supported_resp(const struct pldm_msg *msg, 2058 size_t payload_length, 2059 uint8_t *completion_code, 2060 uint8_t *synchrony_config, 2061 bitfield8_t *synchrony_config_support, 2062 uint8_t *number_event_class_returned, 2063 uint8_t *event_class, 2064 uint8_t event_class_count); 2065 2066 /** @brief Decode sensorEventData response data 2067 * 2068 * @param[in] event_data - event data from the response message 2069 * @param[in] event_data_length - length of the event data 2070 * @param[out] sensor_id - sensorID value of the sensor 2071 * @param[out] sensor_event_class_type - Type of sensor event class 2072 * @param[out] event_class_data_offset - Offset where the event class data 2073 * should be read from event data 2074 * @return pldm_completion_codes 2075 * @note Caller is responsible for memory alloc and dealloc of param 2076 * 'event_data' 2077 */ 2078 int decode_sensor_event_data(const uint8_t *event_data, 2079 size_t event_data_length, uint16_t *sensor_id, 2080 uint8_t *sensor_event_class_type, 2081 size_t *event_class_data_offset); 2082 2083 /** @brief Decode sensorOpState response data 2084 * 2085 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState 2086 * @param[in] sensor_data_length - Length of sensor_data 2087 * @param[out] present_op_state - The sensorOperationalState value from the 2088 * state change that triggered the event message 2089 * @param[out] previous_op_state - The sensorOperationalState value for the 2090 * state from which the present state was entered 2091 * @return pldm_completion_codes 2092 * @note Caller is responsible for memory alloc and dealloc of param 2093 * 'sensor_data' 2094 */ 2095 int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length, 2096 uint8_t *present_op_state, 2097 uint8_t *previous_op_state); 2098 2099 /** @brief Decode stateSensorState response data 2100 * 2101 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState 2102 * @param[in] sensor_data_length - Length of sensor_data 2103 * @param[out] sensor_offset - Identifies which state sensor within a composite 2104 * state sensor the event is being returned for 2105 * @param[out] event_state - The event state value from the state change that 2106 * triggered the event message 2107 * @param[out] previous_event_state - The event state value for the state from 2108 * which the present event state was entered 2109 * @return pldm_completion_codes 2110 * @note Caller is responsible for memory alloc and dealloc of param 2111 * 'sensor_data' 2112 */ 2113 int decode_state_sensor_data(const uint8_t *sensor_data, 2114 size_t sensor_data_length, uint8_t *sensor_offset, 2115 uint8_t *event_state, 2116 uint8_t *previous_event_state); 2117 2118 /** @brief Decode numericSensorState response data 2119 * 2120 * @param[in] sensor_data - sensor_data for sensorEventClass = 2121 * numericSensorState 2122 * @param[in] sensor_data_length - Length of sensor_data 2123 * @param[out] event_state - The eventState value from the state change that 2124 * triggered the event message 2125 * @param[out] previous_event_state - The eventState value for the state from 2126 * which the present state was entered 2127 * @param[out] sensor_data_size - The bit width and format of reading and 2128 * threshold values that the sensor returns 2129 * @param[out] present_reading - The present value indicated by the sensor 2130 * @return pldm_completion_codes 2131 * @note Caller is responsible for memory alloc and dealloc of param 2132 * 'sensor_data' 2133 */ 2134 int decode_numeric_sensor_data(const uint8_t *sensor_data, 2135 size_t sensor_data_length, uint8_t *event_state, 2136 uint8_t *previous_event_state, 2137 uint8_t *sensor_data_size, 2138 uint32_t *present_reading); 2139 2140 /** @brief Decode Numeric Sensor Pdr data 2141 * 2142 * @param[in] pdr_data - pdr data for numeric sensor 2143 * @param[in] pdr_data_length - Length of pdr data 2144 * @param[out] pdr_value - unpacked numeric sensor PDR struct 2145 */ 2146 int decode_numeric_sensor_pdr_data( 2147 const void *pdr_data, size_t pdr_data_length, 2148 struct pldm_numeric_sensor_value_pdr *pdr_value); 2149 2150 /* GetNumericEffecterValue */ 2151 2152 /** @brief Create a PLDM request message for GetNumericEffecterValue 2153 * 2154 * @param[in] instance_id - Message's instance id 2155 * @param[in] effecter_id - used to identify and access the effecter 2156 * @param[out] msg - Message will be written to this 2157 * @return pldm_completion_codes 2158 * @note Caller is responsible for memory alloc and dealloc of param 2159 * 'msg.payload' 2160 */ 2161 int encode_get_numeric_effecter_value_req(uint8_t instance_id, 2162 uint16_t effecter_id, 2163 struct pldm_msg *msg); 2164 2165 /** @brief Create a PLDM response message for GetNumericEffecterValue 2166 * 2167 * @param[in] msg - Request message 2168 * @param[in] payload_length - Length of request message payload 2169 * @param[out] completion_code - PLDM completion code 2170 * @param[out] effecter_data_size - The bit width and format of the setting 2171 * value for the effecter. 2172 * value:{uint8,sint8,uint16,sint16,uint32,sint32} 2173 * @param[out] effecter_oper_state - The state of the effecter itself 2174 * @param[out] pending_value - The pending numeric value setting of the 2175 * effecter. The effecterDataSize field indicates the number of 2176 * bits used for this field 2177 * @param[out] present_value - The present numeric value setting of the 2178 * effecter. The effecterDataSize indicates the number of bits 2179 * used for this field 2180 * @return pldm_completion_codes 2181 */ 2182 int decode_get_numeric_effecter_value_resp(const struct pldm_msg *msg, 2183 size_t payload_length, 2184 uint8_t *completion_code, 2185 uint8_t *effecter_data_size, 2186 uint8_t *effecter_oper_state, 2187 uint8_t *pending_value, 2188 uint8_t *present_value); 2189 2190 /** @brief Decode pldmPDRRepositoryChgEvent response data 2191 * 2192 * @param[in] event_data - eventData for pldmPDRRepositoryChgEvent 2193 * @param[in] event_data_size - Length of event_data 2194 * @param[out] event_data_format - This field indicates if the changedRecords 2195 * are of PDR Types or PDR Record Handles 2196 * @param[out] number_of_change_records - The number of changeRecords following 2197 * this field 2198 * @param[out] change_record_data_offset - Identifies where changeRecord data 2199 * is located within event_data 2200 * @return pldm_completion_codes 2201 * @note Caller is responsible for memory alloc and dealloc of param 2202 * 'event_data' 2203 */ 2204 int decode_pldm_pdr_repository_chg_event_data( 2205 const uint8_t *event_data, size_t event_data_size, 2206 uint8_t *event_data_format, uint8_t *number_of_change_records, 2207 size_t *change_record_data_offset); 2208 2209 /** @brief Decode pldmMessagePollEvent event data type 2210 * 2211 * @param[in] event_data - event data from the response message 2212 * @param[in] event_data_length - length of the event data 2213 * @param[out] poll_event - the decoded pldm_message_poll_event struct 2214 * @return error code 2215 * @note Caller is responsible for memory alloc and dealloc of param 2216 * 'event_data' 2217 */ 2218 int decode_pldm_message_poll_event_data( 2219 const void *event_data, size_t event_data_length, 2220 struct pldm_message_poll_event *poll_event); 2221 2222 /** @brief Encode pldmMessagePollEvent event data type 2223 * 2224 * @param[in] poll_event - the encoded pldm_message_poll_event struct 2225 * @param[out] event_data - event data to the response message 2226 * @param[in] event_data_length - length of the event data 2227 * @return error code 2228 * @note The caller is responsible for allocating and deallocating the 2229 * event_data 2230 */ 2231 int encode_pldm_message_poll_event_data( 2232 const struct pldm_message_poll_event *poll_event, void *event_data, 2233 size_t event_data_length); 2234 2235 /** @brief Encode PLDM PDR Repository Change eventData 2236 * @param[in] event_data_format - Format of this event data (e.g. 2237 * FORMAT_IS_PDR_HANDLES) 2238 * @param[in] number_of_change_records - Number of changeRecords in this 2239 * eventData 2240 * @param[in] event_data_operations - Array of eventDataOperations 2241 * (e.g. RECORDS_ADDED) for each changeRecord in this eventData. This array 2242 * should contain number_of_change_records elements. 2243 * @param[in] numbers_of_change_entries - Array of numbers of changeEntrys 2244 * for each changeRecord in this eventData. This array should contain 2245 * number_of_change_records elements. 2246 * @param[in] change_entries - 2-dimensional array of arrays of changeEntrys, 2247 * one array per changeRecord in this eventData. The toplevel array should 2248 * contain number_of_change_records elements. Each subarray [i] should 2249 * contain numbers_of_change_entries[i] elements. 2250 * @param[in] event_data - The eventData will be encoded into this. This entire 2251 * structure must be max_change_records_size long. It must be large enough 2252 * to accommodate the data to be encoded. The caller is responsible for 2253 * allocating and deallocating it, including the variable-size 2254 * 'event_data.change_records' field. If this parameter is NULL, 2255 * PLDM_SUCCESS will be returned and actual_change_records_size will be set 2256 * to reflect the required size of the structure. 2257 * @param[out] actual_change_records_size - The actual number of meaningful 2258 * encoded bytes in event_data. The caller can over-allocate memory and use 2259 * this output to determine the real size of the structure. 2260 * @param[in] max_change_records_size - The size of event_data in bytes. If the 2261 * encoded message would be larger than this value, an error is returned. 2262 * @return pldm_completion_codes 2263 * @note Caller is responsible for memory alloc and dealloc of param 2264 * 'event_data.change_records' 2265 */ 2266 int encode_pldm_pdr_repository_chg_event_data( 2267 uint8_t event_data_format, uint8_t number_of_change_records, 2268 const uint8_t *event_data_operations, 2269 const uint8_t *numbers_of_change_entries, 2270 const uint32_t *const *change_entries, 2271 struct pldm_pdr_repository_chg_event_data *event_data, 2272 size_t *actual_change_records_size, size_t max_change_records_size); 2273 2274 /** @brief Encode event data for a PLDM Sensor Event 2275 * 2276 * @param[out] event_data The object to store the encoded event in 2277 * @param[in] event_data_size Size of the allocation for event_data 2278 * @param[in] sensor_id Sensor ID 2279 * @param[in] sensor_event_class Sensor event class 2280 * @param[in] sensor_offset Offset 2281 * @param[in] event_state Event state 2282 * @param[in] previous_event_state Previous event state 2283 * @param[out] actual_event_data_size The real size in bytes of the event_data 2284 * @return int pldm_completion_codes PLDM_SUCCESS/PLDM_ERROR_INVALID_LENGTH 2285 * @note If event_data is NULL, then *actual_event_data_size will be set to 2286 * reflect the size of the event data, and PLDM_SUCCESS will be returned. 2287 * @note The caller is responsible for allocating and deallocating the 2288 * event_data 2289 */ 2290 int encode_sensor_event_data(struct pldm_sensor_event_data *event_data, 2291 size_t event_data_size, uint16_t sensor_id, 2292 enum sensor_event_class_states sensor_event_class, 2293 uint8_t sensor_offset, uint8_t event_state, 2294 uint8_t previous_event_state, 2295 size_t *actual_event_data_size); 2296 2297 /** @brief Decode PldmPDRRepositoryChangeRecord response data 2298 * 2299 * @param[in] change_record_data - changeRecordData for 2300 * pldmPDRRepositoryChgEvent 2301 * @param[in] change_record_data_size - Length of change_record_data 2302 * @param[out] event_data_operation - This field indicates the changeEntries 2303 * operation types 2304 * @param[out] number_of_change_entries - The number of changeEntries following 2305 * this field 2306 * @param[out] change_entry_data_offset - Identifies where changeEntries data 2307 * is located within change_record_data 2308 * @return pldm_completion_codes 2309 * @note Caller is responsible for memory alloc and dealloc of param 2310 * 'change_record_data' 2311 */ 2312 int decode_pldm_pdr_repository_change_record_data( 2313 const uint8_t *change_record_data, size_t change_record_data_size, 2314 uint8_t *event_data_operation, uint8_t *number_of_change_entries, 2315 size_t *change_entry_data_offset); 2316 2317 /* GetSensorReading */ 2318 2319 /** @brief Encode GetSensorReading request data 2320 * 2321 * @param[in] instance_id - Message's instance id 2322 * @param[in] sensor_id - A handle that is used to identify and access the 2323 * sensor 2324 * @param[in] rearm_event_state - true = manually re-arm EventState after 2325 * responding to this request, false = no manual re-arm 2326 * @param[out] msg - Message will be written to this 2327 * @return pldm_completion_codes 2328 * @note Caller is responsible for memory alloc and dealloc of param 2329 * 'msg.payload' 2330 */ 2331 int encode_get_sensor_reading_req(uint8_t instance_id, uint16_t sensor_id, 2332 bool8_t rearm_event_state, 2333 struct pldm_msg *msg); 2334 2335 /** @brief Decode GetSensorReading response data 2336 * 2337 * @param[in] msg - Request message 2338 * @param[in] payload_length - Length of response message payload 2339 * @param[out] completion_code - PLDM completion code 2340 * @param[out] sensor_data_size - The bit width and format of reading and 2341 * threshold values 2342 * @param[out] sensor_operational_state - The state of the sensor itself 2343 * @param[out] sensor_event_message_enable - value: { noEventGeneration, 2344 * eventsDisabled, eventsEnabled, opEventsOnlyEnabled, 2345 * stateEventsOnlyEnabled } 2346 * @param[out] present_state - The most recently assessed state value monitored 2347 * by the sensor 2348 * @param[out] previous_state - The state that the presentState was entered 2349 * from 2350 * @param[out] event_state - Indicates which threshold crossing assertion 2351 * events have been detected 2352 * @param[out] present_reading - The present value indicated by the sensor 2353 * @return pldm_completion_codes 2354 */ 2355 2356 int decode_get_sensor_reading_resp( 2357 const struct pldm_msg *msg, size_t payload_length, 2358 uint8_t *completion_code, uint8_t *sensor_data_size, 2359 uint8_t *sensor_operational_state, uint8_t *sensor_event_message_enable, 2360 uint8_t *present_state, uint8_t *previous_state, uint8_t *event_state, 2361 uint8_t *present_reading); 2362 2363 /** @brief Encode the SetEventReceiver request message 2364 * 2365 * @param[in] instance_id - Message's instance id 2366 * @param[in] event_message_global_enable - This value is used to enable or 2367 * disable event message generation from the terminus value: { 2368 * disable, enableAsync, enablePolling, enableAsyncKeepAlive } 2369 * @param[in] transport_protocol_type - This value is provided in the request 2370 * to help the responder verify that the content of the 2371 * eventReceiverAddressInfo field used in this request is correct for 2372 * the messaging protocol supported by the terminus. 2373 * @param[in] event_receiver_address_info - this value is a medium and 2374 * protocol-specific address that the responder should use when 2375 * transmitting event messages using the indicated protocol 2376 * @param[in] heartbeat_timer - Amount of time in seconds after each elapsing 2377 * of which the terminus shall emit a heartbeat event to the receiver 2378 * @param[out] msg - Argument to capture the Message 2379 * @return pldm_completion_codes 2380 */ 2381 int encode_set_event_receiver_req(uint8_t instance_id, 2382 uint8_t event_message_global_enable, 2383 uint8_t transport_protocol_type, 2384 uint8_t event_receiver_address_info, 2385 uint16_t heartbeat_timer, 2386 struct pldm_msg *msg); 2387 2388 /** @brief Decode the SetEventReceiver response message 2389 * 2390 * @param[in] msg - Request message 2391 * @param[in] payload_length - Length of response message payload 2392 * @param[out] completion_code - PLDM completion code 2393 * @return pldm_completion_codes 2394 */ 2395 int decode_set_event_receiver_resp(const struct pldm_msg *msg, 2396 size_t payload_length, 2397 uint8_t *completion_code); 2398 2399 /** @brief Decode the SetEventReceiver request message 2400 * 2401 * @param[in] msg - Request message 2402 * @param[in] payload_length - Length of request message payload 2403 * @param[out] event_message_global_enable - This value is used to enable or 2404 * disable event message generation from the terminus value: { 2405 * disable, enableAsync, enablePolling, enableAsyncKeepAlive } 2406 * @param[out] transport_protocol_type - This value is provided in the request 2407 * to help the responder verify that the content of the 2408 * eventReceiverAddressInfo field used in this request is correct for 2409 * the messaging protocol supported by the terminus. 2410 * @param[out] event_receiver_address_info - This value is a medium and 2411 * protocol-specific address that the responder should use when 2412 * transmitting event messages using the indicated protocol 2413 * @param[out] heartbeat_timer - Amount of time in seconds after each elapsing 2414 * of which the terminus shall emit a heartbeat event to the receiver 2415 * @return pldm_completion_codes 2416 */ 2417 int decode_set_event_receiver_req(const struct pldm_msg *msg, 2418 size_t payload_length, 2419 uint8_t *event_message_global_enable, 2420 uint8_t *transport_protocol_type, 2421 uint8_t *event_receiver_address_info, 2422 uint16_t *heartbeat_timer); 2423 2424 /** @brief Encode the SetEventReceiver response message 2425 * 2426 * @param[in] instance_id - Message's instance id 2427 * @param[in] completion_code - PLDM completion code 2428 * @param[out] msg - Argument to capture the Message 2429 * @return pldm_completion_codes 2430 */ 2431 int encode_set_event_receiver_resp(uint8_t instance_id, uint8_t completion_code, 2432 struct pldm_msg *msg); 2433 2434 /** @brief Decode Numeric effecter Pdr data 2435 * 2436 * @param[in] pdr_data - PDR data of the numeric effecter in DSP0248_1.2.2 2437 * table 87. This must be a pointer to the PDR data in the GetPDR 2438 * message body 2439 * @param[in] pdr_data_length - Length of pdr data 2440 * @param[out] pdr_value - the numeric effecter PDR data struct 2441 */ 2442 int decode_numeric_effecter_pdr_data( 2443 const void *pdr_data, size_t pdr_data_length, 2444 struct pldm_numeric_effecter_value_pdr *pdr_value); 2445 2446 /** @brief Decode date fields from Entity Auxiliary name PDR 2447 * 2448 * @note Use case: 2449 * 1. Call `decode_entity_auxiliary_names_pdr()` to decode the Entity 2450 * Auxiliary names PDR raw data to the PDR data fields in 2451 * `struct pldm_entity_auxiliary_names_pdr` equivalent the fields in 2452 * `table 95` of DSP0248_1.2.2. Excepts the entity language tags and 2453 * names. 2454 * 2. Use the decoded `name_string_count` and size of 2455 * `struct pldm_entity_auxiliary_name` to allocate memory for the 2456 * `struct pldm_entity_auxiliary_name *names` field in 2457 * `struct pldm_entity_auxiliary_names_pdr`. 2458 * 3. Call `decode_pldm_entity_auxiliary_names_pdr_index()` to decode 2459 * `auxiliary_name_data[]` in `struct pldm_entity_auxiliary_names_pdr` 2460 * to the entity language tags and names in 2461 * `struct pldm_entity_auxiliary_name`. 2462 * 2463 * @param[in] data - PLDM response message which includes the entity 2464 * auxiliary name PDRs in DSP0248_1.2.2 table 95. 2465 * @param[in] data_length - Length of response message payload 2466 * @param[out] pdr - Entity auxiliary names pdr struct 2467 * @param[out] pdr_length - Entity auxiliary names pdr struct 2468 * 2469 * @return error code 2470 */ 2471 int decode_entity_auxiliary_names_pdr( 2472 const void *data, size_t data_length, 2473 struct pldm_entity_auxiliary_names_pdr *pdr, size_t pdr_length); 2474 2475 /** @brief Decode Entity Auxiliary name data. The API will update the name 2476 * directly to names field in the pdr struct. 2477 * 2478 * @pre The API will decode `auxiliary_name_data[]` array in 2479 * `struct pldm_entity_auxiliary_names_pdr pdr` to 2480 * the entity auxiliary language tags and names in 2481 * `struct pldm_entity_auxiliary_name *names` of the same pdr struct. 2482 * Before call the API, the caller has to allocate memory for the `names` 2483 * struct with the number of name(`name_string_count`) in PDR and size of 2484 * `struct pldm_entity_auxiliary_name`. 2485 * The value of `auxiliary_name_data` and `name_string_count` are decoded 2486 * by `decode_entity_auxiliary_names_pdr()` method so the caller has to 2487 * call that API first. 2488 * 2489 * @param[out] pdr_value - Entity auxiliary names pdr struct 2490 * @param[in] names_size - Size of names data 2491 * @return error code 2492 */ 2493 int decode_pldm_entity_auxiliary_names_pdr_index( 2494 struct pldm_entity_auxiliary_names_pdr *pdr_value); 2495 2496 /** @brief Decode PLDM Platform CPER event data type 2497 * 2498 * @param[in] event_data - event data from the response message 2499 * @param[in] event_data_length - length of the event data 2500 * @param[out] cper_event - the decoded pldm_platform_cper_event struct 2501 * @param[in] cper_event_length - the length of cper event 2502 * @return error code 2503 */ 2504 int decode_pldm_platform_cper_event(const void *event_data, 2505 size_t event_data_length, 2506 struct pldm_platform_cper_event *cper_event, 2507 size_t cper_event_length); 2508 2509 /** @brief Helper function to response CPER event event data 2510 * 2511 * @param[in] cper_event - the decoded pldm_platform_cper_event struct 2512 * @return cper event event data array pointer 2513 */ 2514 uint8_t * 2515 pldm_platform_cper_event_event_data(struct pldm_platform_cper_event *event); 2516 #ifdef __cplusplus 2517 } 2518 #endif 2519 2520 #endif /* PLATFORM_H */ 2521