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