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