Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 1 | #ifndef PLATFORM_H |
| 2 | #define PLATFORM_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | #include "base.h" |
| 12 | |
| 13 | /* Maximum size for request */ |
| 14 | #define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19 |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 15 | #define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4 |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 16 | /* Response lengths are inclusive of completion code */ |
| 17 | #define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1 |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 18 | #define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34 |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 19 | |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 20 | #define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1 |
| 21 | #define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4 |
| 22 | |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 23 | #define PLDM_GET_PDR_REQ_BYTES 13 |
| 24 | /* Minimum response length */ |
| 25 | #define PLDM_GET_PDR_MIN_RESP_BYTES 12 |
| 26 | |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 27 | enum pldm_effecter_data_size { |
| 28 | PLDM_EFFECTER_DATA_SIZE_UINT8, |
| 29 | PLDM_EFFECTER_DATA_SIZE_SINT8, |
| 30 | PLDM_EFFECTER_DATA_SIZE_UINT16, |
| 31 | PLDM_EFFECTER_DATA_SIZE_SINT16, |
| 32 | PLDM_EFFECTER_DATA_SIZE_UINT32, |
| 33 | PLDM_EFFECTER_DATA_SIZE_SINT32 |
| 34 | }; |
| 35 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 36 | enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 }; |
| 37 | |
| 38 | enum effecter_state { PLDM_INVALID_VALUE = 0xFF }; |
| 39 | |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 40 | enum sensor_operational_state { |
| 41 | ENABLED = 0x00, |
| 42 | DISABLED = 0x01, |
| 43 | UNAVAILABLE = 0x02, |
| 44 | STATUSUNKNOWN = 0x03, |
| 45 | FAILED = 0x04, |
| 46 | INITIALIZING = 0x05, |
| 47 | SHUTTINGDOWN = 0x06, |
| 48 | INTEST = 0x07 |
| 49 | }; |
| 50 | |
| 51 | enum present_state { |
| 52 | UNKNOWN = 0x0, |
| 53 | NORMAL = 0x01, |
| 54 | WARNING = 0x02, |
| 55 | CRITICAL = 0x03, |
| 56 | FATAL = 0x04, |
| 57 | LOWERWARNING = 0x05, |
| 58 | LOWERCRITICAL = 0x06, |
| 59 | LOWERFATAL = 0x07, |
| 60 | UPPERWARNING = 0x08, |
| 61 | UPPERCRITICAL = 0x09, |
| 62 | UPPERFATAL = 0x0a |
| 63 | }; |
| 64 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 65 | enum pldm_platform_commands { |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 66 | PLDM_GET_STATE_SENSOR_READINGS = 0x21, |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 67 | PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31, |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 68 | PLDM_SET_STATE_EFFECTER_STATES = 0x39, |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 69 | PLDM_GET_PDR = 0x51, |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 70 | }; |
| 71 | |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 72 | /** @brief PLDM PDR types |
| 73 | */ |
| 74 | enum pldm_pdr_types { |
| 75 | PLDM_STATE_EFFECTER_PDR = 11, |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 76 | PLDM_PDR_FRU_RECORD_SET = 20, |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /** @brief PLDM effecter initialization schemes |
| 80 | */ |
| 81 | enum pldm_effecter_init { |
| 82 | PLDM_NO_INIT, |
| 83 | PLDM_USE_INIT_PDR, |
| 84 | PLDM_ENABLE_EFFECTER, |
| 85 | PLDM_DISABLE_EFECTER |
| 86 | }; |
| 87 | |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 88 | /** @brief PLDM Platform M&C completion codes |
| 89 | */ |
| 90 | enum pldm_platform_completion_codes { |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 91 | PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80, |
| 92 | PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81, |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 93 | PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82, |
Sampa Misra | a2fa070 | 2019-05-31 01:28:55 -0500 | [diff] [blame] | 94 | PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82, |
Deepak Kodihalli | 557dfb0 | 2019-05-12 13:11:17 +0530 | [diff] [blame] | 95 | }; |
| 96 | |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 97 | /** @struct pldm_pdr_hdr |
| 98 | * |
| 99 | * Structure representing PLDM common PDR header |
| 100 | */ |
| 101 | struct pldm_pdr_hdr { |
| 102 | uint32_t record_handle; |
| 103 | uint8_t version; |
| 104 | uint8_t type; |
| 105 | uint16_t record_change_num; |
| 106 | uint16_t length; |
| 107 | } __attribute__((packed)); |
| 108 | |
Deepak Kodihalli | db91467 | 2020-02-07 02:47:45 -0600 | [diff] [blame] | 109 | /** @struct pldm_pdr_fru_record_set |
| 110 | * |
| 111 | * Structure representing PLDM FRU record set PDR |
| 112 | */ |
| 113 | struct pldm_pdr_fru_record_set { |
| 114 | uint16_t terminus_handle; |
| 115 | uint16_t fru_rsi; |
| 116 | uint16_t entity_type; |
| 117 | uint16_t entity_instance_num; |
| 118 | uint16_t container_id; |
| 119 | } __attribute__((packed)); |
| 120 | |
Deepak Kodihalli | c6e8fb5 | 2019-05-02 08:35:31 -0500 | [diff] [blame] | 121 | /** @struct pldm_state_effecter_pdr |
| 122 | * |
| 123 | * Structure representing PLDM state effecter PDR |
| 124 | */ |
| 125 | struct pldm_state_effecter_pdr { |
| 126 | struct pldm_pdr_hdr hdr; |
| 127 | uint16_t terminus_handle; |
| 128 | uint16_t effecter_id; |
| 129 | uint16_t entity_type; |
| 130 | uint16_t entity_instance; |
| 131 | uint16_t container_id; |
| 132 | uint16_t effecter_semantic_id; |
| 133 | uint8_t effecter_init; |
| 134 | bool8_t has_description_pdr; |
| 135 | uint8_t composite_effecter_count; |
| 136 | uint8_t possible_states[1]; |
| 137 | } __attribute__((packed)); |
| 138 | |
| 139 | /** @struct state_effecter_possible_states |
| 140 | * |
| 141 | * Structure representing state enums for state effecter |
| 142 | */ |
| 143 | struct state_effecter_possible_states { |
| 144 | uint16_t state_set_id; |
| 145 | uint8_t possible_states_size; |
| 146 | bitfield8_t states[1]; |
| 147 | } __attribute__((packed)); |
| 148 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 149 | /** @struct set_effecter_state_field |
| 150 | * |
| 151 | * Structure representing a stateField in SetStateEffecterStates command */ |
| 152 | |
| 153 | typedef struct state_field_for_state_effecter_set { |
| 154 | uint8_t set_request; //!< Whether to change the state |
| 155 | uint8_t effecter_state; //!< Expected state of the effecter |
| 156 | } __attribute__((packed)) set_effecter_state_field; |
| 157 | |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 158 | /** @struct get_sensor_readings_field |
| 159 | * |
| 160 | * Structure representing a stateField in GetStateSensorReadings command */ |
| 161 | |
| 162 | typedef struct state_field_for_get_state_sensor_readings { |
| 163 | uint8_t sensor_op_state; //!< The state of the sensor itself |
| 164 | uint8_t present_state; //!< Return a state value |
| 165 | uint8_t previous_state; //!< The state that the presentState was entered |
| 166 | //! from. This must be different from the |
| 167 | //! present state |
| 168 | uint8_t event_state; //!< Return a state value from a PLDM State Set |
| 169 | //! that is associated with the sensor |
| 170 | } __attribute__((packed)) get_sensor_state_field; |
| 171 | |
Priyanga | 7257fdf | 2019-06-10 01:59:45 -0500 | [diff] [blame] | 172 | /** @struct PLDM_SetStateEffecterStates_Request |
| 173 | * |
| 174 | * Structure representing PLDM set state effecter states request. |
| 175 | */ |
| 176 | struct pldm_set_state_effecter_states_req { |
| 177 | uint16_t effecter_id; |
| 178 | uint8_t comp_effecter_count; |
| 179 | set_effecter_state_field field[8]; |
| 180 | } __attribute__((packed)); |
| 181 | |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 182 | /** @struct pldm_get_pdr_resp |
| 183 | * |
| 184 | * structure representing GetPDR response packet |
| 185 | * transfer CRC is not part of the structure and will be |
| 186 | * added at the end of last packet in multipart transfer |
| 187 | */ |
| 188 | struct pldm_get_pdr_resp { |
| 189 | uint8_t completion_code; |
| 190 | uint32_t next_record_handle; |
| 191 | uint32_t next_data_transfer_handle; |
| 192 | uint8_t transfer_flag; |
| 193 | uint16_t response_count; |
| 194 | uint8_t record_data[1]; |
| 195 | } __attribute__((packed)); |
| 196 | |
| 197 | /** @struct pldm_get_pdr_req |
| 198 | * |
| 199 | * structure representing GetPDR request packet |
| 200 | */ |
| 201 | struct pldm_get_pdr_req { |
| 202 | uint32_t record_handle; |
| 203 | uint32_t data_transfer_handle; |
| 204 | uint8_t transfer_op_flag; |
| 205 | uint16_t request_count; |
| 206 | uint16_t record_change_number; |
| 207 | } __attribute__((packed)); |
| 208 | |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 209 | /** @struct pldm_set_numeric_effecter_value_req |
| 210 | * |
| 211 | * structure representing SetNumericEffecterValue request packet |
| 212 | */ |
| 213 | struct pldm_set_numeric_effecter_value_req { |
| 214 | uint16_t effecter_id; |
| 215 | uint8_t effecter_data_size; |
| 216 | uint8_t effecter_value[1]; |
| 217 | } __attribute__((packed)); |
| 218 | |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 219 | /** @struct pldm_get_state_sensor_readings_req |
| 220 | * |
| 221 | * Structure representing PLDM get state sensor readings request. |
| 222 | */ |
| 223 | struct pldm_get_state_sensor_readings_req { |
| 224 | uint16_t sensor_id; |
| 225 | bitfield8_t sensor_rearm; |
| 226 | uint8_t reserved; |
| 227 | } __attribute__((packed)); |
| 228 | |
| 229 | /** @struct pldm_get_state_sensor_readings_resp |
| 230 | * |
| 231 | * Structure representing PLDM get state sensor readings response. |
| 232 | */ |
| 233 | struct pldm_get_state_sensor_readings_resp { |
| 234 | uint8_t completion_code; |
| 235 | uint8_t comp_sensor_count; |
| 236 | get_sensor_state_field field[1]; |
| 237 | } __attribute__((packed)); |
| 238 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 239 | /* Responder */ |
| 240 | |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 241 | /* SetNumericEffecterValue */ |
| 242 | |
| 243 | /** @brief Decode SetNumericEffecterValue request data |
| 244 | * |
| 245 | * @param[in] msg - Request message |
| 246 | * @param[in] payload_length - Length of request message payload |
| 247 | * @param[out] effecter_id - used to identify and access the effecter |
| 248 | * @param[out] effecter_data_size - The bit width and format of the setting |
| 249 | * value for the effecter. |
| 250 | * value:{uint8,sint8,uint16,sint16,uint32,sint32} |
| 251 | * @param[out] effecter_value - The setting value of numeric effecter being |
| 252 | * requested. |
| 253 | * @return pldm_completion_codes |
| 254 | */ |
| 255 | int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg, |
| 256 | size_t payload_length, |
| 257 | uint16_t *effecter_id, |
| 258 | uint8_t *effecter_data_size, |
| 259 | uint8_t *effecter_value); |
| 260 | |
| 261 | /** @brief Create a PLDM response message for SetNumericEffecterValue |
| 262 | * |
| 263 | * @param[in] instance_id - Message's instance id |
| 264 | * @param[in] completion_code - PLDM completion code |
| 265 | * @param[out] msg - Message will be written to this |
| 266 | * @param[in] payload_length - Length of request message payload |
| 267 | * @return pldm_completion_codes |
| 268 | * @note Caller is responsible for memory alloc and dealloc of param |
| 269 | * 'msg.body.payload' |
| 270 | */ |
| 271 | int encode_set_numeric_effecter_value_resp(uint8_t instance_id, |
| 272 | uint8_t completion_code, |
| 273 | struct pldm_msg *msg, |
| 274 | size_t payload_length); |
| 275 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 276 | /* SetStateEffecterStates */ |
| 277 | |
| 278 | /** @brief Create a PLDM response message for SetStateEffecterStates |
| 279 | * |
| 280 | * @param[in] instance_id - Message's instance id |
| 281 | * @param[in] completion_code - PLDM completion code |
| 282 | * @param[out] msg - Message will be written to this |
| 283 | * @return pldm_completion_codes |
| 284 | * @note Caller is responsible for memory alloc and dealloc of param |
| 285 | * 'msg.body.payload' |
| 286 | */ |
| 287 | |
| 288 | int encode_set_state_effecter_states_resp(uint8_t instance_id, |
| 289 | uint8_t completion_code, |
| 290 | struct pldm_msg *msg); |
| 291 | |
| 292 | /** @brief Decode SetStateEffecterStates request data |
| 293 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 294 | * @param[in] msg - Request message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 295 | * @param[in] payload_length - Length of request message payload |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 296 | * @param[out] effecter_id - used to identify and access the effecter |
| 297 | * @param[out] comp_effecter_count - number of individual sets of effecter |
| 298 | * information. Upto eight sets of state effecter info can be accessed |
| 299 | * for a given effecter. |
| 300 | * @param[out] field - each unit is an instance of the stateFileld structure |
| 301 | * that is used to set the requested state for a particular effecter |
| 302 | * within the state effecter. This field holds the starting address of |
| 303 | * the stateField values. The user is responsible to allocate the |
| 304 | * memory prior to calling this command. Since the state field count is |
| 305 | * not known in advance, the user should allocate the maximum size |
| 306 | * always, which is 8 in number. |
| 307 | * @return pldm_completion_codes |
| 308 | */ |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 309 | |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 310 | int decode_set_state_effecter_states_req(const struct pldm_msg *msg, |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 311 | size_t payload_length, |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 312 | uint16_t *effecter_id, |
| 313 | uint8_t *comp_effecter_count, |
| 314 | set_effecter_state_field *field); |
| 315 | |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 316 | /* GetPDR */ |
| 317 | |
| 318 | /** @brief Create a PLDM response message for GetPDR |
| 319 | * |
| 320 | * @param[in] instance_id - Message's instance id |
| 321 | * @param[in] completion_code - PLDM completion code |
| 322 | * @param[in] next_record_hndl - The recordHandle for the PDR that is next in |
| 323 | * the PDR Repository |
| 324 | * @param[in] next_data_transfer_hndl - A handle that identifies the next |
| 325 | * portion of the PDR data to be transferred, if any |
| 326 | * @param[in] transfer_flag - Indicates the portion of PDR data being |
| 327 | * transferred |
| 328 | * @param[in] resp_cnt - The number of recordData bytes returned in this |
| 329 | * response |
| 330 | * @param[in] record_data - PDR data bytes of length resp_cnt |
| 331 | * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only |
| 332 | * in the last part of a PDR being transferred |
| 333 | * @param[out] msg - Message will be written to this |
| 334 | * @return pldm_completion_codes |
| 335 | * @note Caller is responsible for memory alloc and dealloc of param |
| 336 | * 'msg.payload' |
| 337 | */ |
| 338 | int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code, |
| 339 | uint32_t next_record_hndl, |
| 340 | uint32_t next_data_transfer_hndl, uint8_t transfer_flag, |
| 341 | uint16_t resp_cnt, const uint8_t *record_data, |
| 342 | uint8_t transfer_crc, struct pldm_msg *msg); |
| 343 | |
| 344 | /** @brief Decode GetPDR request data |
| 345 | * |
| 346 | * @param[in] msg - Request message |
| 347 | * @param[in] payload_length - Length of request message payload |
| 348 | * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved |
| 349 | * @param[out] data_transfer_hndl - Handle used to identify a particular |
| 350 | * multipart PDR data transfer operation |
| 351 | * @param[out] transfer_op_flag - Flag to indicate the first or subsequent |
| 352 | * portion of transfer |
| 353 | * @param[out] request_cnt - The maximum number of record bytes requested |
| 354 | * @param[out] record_chg_num - Used to determine whether the PDR has changed |
| 355 | * while PDR transfer is going on |
| 356 | * @return pldm_completion_codes |
| 357 | */ |
| 358 | |
| 359 | int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length, |
| 360 | uint32_t *record_hndl, uint32_t *data_transfer_hndl, |
| 361 | uint8_t *transfer_op_flag, uint16_t *request_cnt, |
| 362 | uint16_t *record_chg_num); |
| 363 | |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 364 | /* GetStateSensorReadings */ |
| 365 | |
| 366 | /** @brief Decode GetStateSensorReadings request data |
| 367 | * |
| 368 | * @param[in] msg - Request message |
| 369 | * @param[in] payload_length - Length of request message payload |
| 370 | * @param[out] sensor_id - used to identify and access the simple or composite |
| 371 | * sensor |
| 372 | * @param[out] sensor_rearm - Each bit location in this field corresponds to a |
| 373 | * particular sensor within the state sensor, where bit [0] corresponds |
| 374 | * to the first state sensor (sensor offset 0) and bit [7] corresponds |
| 375 | * to the eighth sensor (sensor offset 7), sequentially. |
| 376 | * @param[out] reserved - value: 0x00 |
| 377 | * @return pldm_completion_codes |
| 378 | */ |
| 379 | |
| 380 | int decode_get_state_sensor_readings_req(const struct pldm_msg *msg, |
| 381 | size_t payload_length, |
| 382 | uint16_t *sensor_id, |
| 383 | bitfield8_t *sensor_rearm, |
| 384 | uint8_t *reserved); |
| 385 | |
| 386 | /** @brief Encode GetStateSensorReadings response data |
| 387 | * |
| 388 | * @param[in] instance_id - Message's instance id |
| 389 | * @param[in] completion_code - PLDM completion code |
| 390 | * @param[out] comp_sensor_count - The number of individual sets of sensor |
| 391 | * information that this command accesses |
| 392 | * @param[out] field - Each stateField is an instance of a stateField structure |
| 393 | * that is used to return the present operational state setting and the |
| 394 | * present state and event state for a particular set of sensor |
| 395 | * information contained within the state sensor |
| 396 | * @param[out] msg - Message will be written to this |
| 397 | * @return pldm_completion_codes |
| 398 | */ |
| 399 | |
| 400 | int encode_get_state_sensor_readings_resp(uint8_t instance_id, |
| 401 | uint8_t completion_code, |
| 402 | uint8_t comp_sensor_count, |
| 403 | get_sensor_state_field *field, |
| 404 | struct pldm_msg *msg); |
| 405 | |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 406 | /* Requester */ |
| 407 | |
George Liu | 820a9a5 | 2019-11-26 14:43:59 +0800 | [diff] [blame] | 408 | /* GetPDR */ |
| 409 | |
| 410 | /** @brief Create a PLDM request message for GetPDR |
| 411 | * |
| 412 | * @param[in] instance_id - Message's instance id |
| 413 | * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved |
| 414 | * @param[in] data_transfer_hndl - Handle used to identify a particular |
| 415 | * multipart PDR data transfer operation |
| 416 | * @param[in] transfer_op_flag - Flag to indicate the first or subsequent |
| 417 | * portion of transfer |
| 418 | * @param[in] request_cnt - The maximum number of record bytes requested |
| 419 | * @param[in] record_chg_num - Used to determine whether the PDR has changed |
| 420 | * while PDR transfer is going on |
| 421 | * @param[out] msg - Message will be written to this |
| 422 | * @param[in] payload_length - Length of request message payload |
| 423 | * @return pldm_completion_codes |
| 424 | * @note Caller is responsible for memory alloc and dealloc of param |
| 425 | * 'msg.payload' |
| 426 | */ |
| 427 | int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl, |
| 428 | uint32_t data_transfer_hndl, uint8_t transfer_op_flag, |
| 429 | uint16_t request_cnt, uint16_t record_chg_num, |
| 430 | struct pldm_msg *msg, size_t payload_length); |
| 431 | |
| 432 | /** @brief Decode GetPDR response data |
| 433 | * |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 434 | * Note: |
| 435 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 436 | * transport layer error. |
| 437 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 438 | * protocol layer error and all the out-parameters are invalid. |
| 439 | * |
George Liu | 820a9a5 | 2019-11-26 14:43:59 +0800 | [diff] [blame] | 440 | * @param[in] msg - Request message |
| 441 | * @param[in] payload_length - Length of request message payload |
| 442 | * @param[out] completion_code - PLDM completion code |
| 443 | * @param[out] next_record_hndl - The recordHandle for the PDR that is next in |
| 444 | * the PDR Repository |
| 445 | * @param[out] next_data_transfer_hndl - A handle that identifies the next |
| 446 | * portion of the PDR data to be transferred, if any |
| 447 | * @param[out] transfer_flag - Indicates the portion of PDR data being |
| 448 | * transferred |
| 449 | * @param[out] resp_cnt - The number of recordData bytes returned in this |
| 450 | * response |
| 451 | * @param[out] record_data - PDR data bytes of length resp_cnt |
| 452 | * @param[in] record_data_length - Length of record_data |
| 453 | * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only |
| 454 | * in the last part of a PDR being transferred |
| 455 | * @return pldm_completion_codes |
| 456 | */ |
| 457 | int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length, |
| 458 | uint8_t *completion_code, uint32_t *next_record_hndl, |
| 459 | uint32_t *next_data_transfer_hndl, |
| 460 | uint8_t *transfer_flag, uint16_t *resp_cnt, |
| 461 | uint8_t *record_data, size_t record_data_length, |
| 462 | uint8_t *transfer_crc); |
| 463 | |
Sampa Misra | 7fcfb66 | 2019-05-08 13:13:53 -0500 | [diff] [blame] | 464 | /* SetStateEffecterStates */ |
| 465 | |
vkaverap | 98a2c19 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 466 | /** @brief Create a PLDM request message for SetStateEffecterStates |
| 467 | * |
| 468 | * @param[in] instance_id - Message's instance id |
| 469 | * @param[in] effecter_id - used to identify and access the effecter |
| 470 | * @param[in] comp_effecter_count - number of individual sets of effecter |
| 471 | * information. Upto eight sets of state effecter info can be accessed |
| 472 | * for a given effecter. |
| 473 | * @param[in] field - each unit is an instance of the stateField structure |
| 474 | * that is used to set the requested state for a particular effecter |
| 475 | * within the state effecter. This field holds the starting address of |
| 476 | * the stateField values. The user is responsible to allocate the |
| 477 | * memory prior to calling this command. The user has to allocate the |
| 478 | * field parameter as sizeof(set_effecter_state_field) * |
| 479 | * comp_effecter_count |
| 480 | * @param[out] msg - Message will be written to this |
| 481 | * @return pldm_completion_codes |
| 482 | * @note Caller is responsible for memory alloc and dealloc of param |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 483 | * 'msg.payload' |
vkaverap | 98a2c19 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 484 | */ |
| 485 | |
| 486 | int encode_set_state_effecter_states_req(uint8_t instance_id, |
| 487 | uint16_t effecter_id, |
| 488 | uint8_t comp_effecter_count, |
| 489 | set_effecter_state_field *field, |
| 490 | struct pldm_msg *msg); |
| 491 | |
| 492 | /** @brief Decode SetStateEffecterStates response data |
George Liu | 684a716 | 2019-12-06 15:10:52 +0800 | [diff] [blame] | 493 | * |
| 494 | * Note: |
| 495 | * * If the return value is not PLDM_SUCCESS, it represents a |
| 496 | * transport layer error. |
| 497 | * * If the completion_code value is not PLDM_SUCCESS, it represents a |
| 498 | * protocol layer error and all the out-parameters are invalid. |
| 499 | * |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 500 | * @param[in] msg - Request message |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 501 | * @param[in] payload_length - Length of response message payload |
vkaverap | 98a2c19 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 502 | * @param[out] completion_code - PLDM completion code |
| 503 | * @return pldm_completion_codes |
| 504 | */ |
Zahed Hossain | 223a73d | 2019-07-04 12:46:18 -0500 | [diff] [blame] | 505 | int decode_set_state_effecter_states_resp(const struct pldm_msg *msg, |
vkaverap | a6575b8 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 506 | size_t payload_length, |
vkaverap | 98a2c19 | 2019-04-03 05:33:52 -0500 | [diff] [blame] | 507 | uint8_t *completion_code); |
George Liu | 30b859f | 2020-01-07 15:03:22 +0800 | [diff] [blame] | 508 | |
| 509 | /* SetNumericEffecterValue */ |
| 510 | |
| 511 | /** @brief Create a PLDM request message for SetNumericEffecterValue |
| 512 | * |
| 513 | * @param[in] instance_id - Message's instance id |
| 514 | * @param[in] effecter_id - used to identify and access the effecter |
| 515 | * @param[in] effecter_data_size - The bit width and format of the setting |
| 516 | * value for the effecter. |
| 517 | * value:{uint8,sint8,uint16,sint16,uint32,sint32} |
| 518 | * @param[in] effecter_value - The setting value of numeric effecter being |
| 519 | * requested. |
| 520 | * @param[in] payload_length - Length of request message payload |
| 521 | * @param[out] msg - Message will be written to this |
| 522 | * @return pldm_completion_codes |
| 523 | * @note Caller is responsible for memory alloc and dealloc of param |
| 524 | * 'msg.payload' |
| 525 | */ |
| 526 | int encode_set_numeric_effecter_value_req( |
| 527 | uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size, |
| 528 | uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length); |
| 529 | |
| 530 | /** @brief Decode SetNumericEffecterValue response data |
| 531 | * @param[in] msg - Request message |
| 532 | * @param[in] payload_length - Length of response message payload |
| 533 | * @param[out] completion_code - PLDM completion code |
| 534 | * @return pldm_completion_codes |
| 535 | */ |
| 536 | int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg, |
| 537 | size_t payload_length, |
| 538 | uint8_t *completion_code); |
| 539 | |
Jolie Ku | 3557bad | 2020-03-02 16:22:57 +0800 | [diff] [blame^] | 540 | /** @brief Create a PLDM request message for GetStateSensorReadings |
| 541 | * |
| 542 | * @param[in] instance_id - Message's instance id |
| 543 | * @param[in] sensor_id - used to identify and access the simple or composite |
| 544 | * sensor |
| 545 | * @param[in] sensorRearm - Each bit location in this field corresponds to a |
| 546 | * particular sensor within the state sensor, where bit [0] corresponds |
| 547 | * to the first state sensor (sensor offset 0) and bit [7] corresponds |
| 548 | * to the eighth sensor (sensor offset 7), sequentially |
| 549 | * @param[in] reserved - value: 0x00 |
| 550 | * @param[out] msg - Message will be written to this |
| 551 | * @return pldm_completion_codes |
| 552 | * @note Caller is responsible for memory alloc and dealloc of param |
| 553 | * 'msg.payload' |
| 554 | */ |
| 555 | |
| 556 | int encode_get_state_sensor_readings_req(uint8_t instance_id, |
| 557 | uint16_t sensor_id, |
| 558 | bitfield8_t sensor_rearm, |
| 559 | uint8_t reserved, |
| 560 | struct pldm_msg *msg); |
| 561 | |
| 562 | /** @brief Decode GetStateSensorReadings response data |
| 563 | * |
| 564 | * @param[in] msg - Request message |
| 565 | * @param[in] payload_length - Length of response message payload |
| 566 | * @param[out] completion_code - PLDM completion code |
| 567 | * @param[in,out] comp_sensor_count - The number of individual sets of sensor |
| 568 | * information that this command accesses |
| 569 | * @param[out] field - Each stateField is an instance of a stateField structure |
| 570 | * that is used to return the present operational state setting and the |
| 571 | * present state and event state for a particular set of sensor |
| 572 | * information contained within the state sensor |
| 573 | * @return pldm_completion_codes |
| 574 | */ |
| 575 | |
| 576 | int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg, |
| 577 | size_t payload_length, |
| 578 | uint8_t *completion_code, |
| 579 | uint8_t *comp_sensor_count, |
| 580 | get_sensor_state_field *field); |
| 581 | |
Sampa Misra | 0db1dfa | 2019-03-19 00:15:31 -0500 | [diff] [blame] | 582 | #ifdef __cplusplus |
| 583 | } |
| 584 | #endif |
| 585 | |
| 586 | #endif /* PLATFORM_H */ |