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