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