blob: 82c2b285a8ef358f4eecefa5c3e0cb8497f7d999 [file] [log] [blame]
Sampa Misra0db1dfa2019-03-19 00:15:31 -05001#ifndef PLATFORM_H
2#define PLATFORM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -050012#include "pdr.h"
Sampa Misra0db1dfa2019-03-19 00:15:31 -050013
14/* Maximum size for request */
15#define PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES 19
Jolie Ku3557bad2020-03-02 16:22:57 +080016#define PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES 4
Sampa Misra0db1dfa2019-03-19 00:15:31 -050017/* Response lengths are inclusive of completion code */
18#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080019#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050020
George Liu30b859f2020-01-07 15:03:22 +080021#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
22#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
23
Sampa Misra7fcfb662019-05-08 13:13:53 -050024#define PLDM_GET_PDR_REQ_BYTES 13
25/* Minimum response length */
26#define PLDM_GET_PDR_MIN_RESP_BYTES 12
27
Zahed Hossaind4abab12020-02-06 03:36:43 -060028/* Minimum length for PLDM PlatformEventMessage request */
29#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
30#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
31
Zahed Hossain1c861712020-03-04 08:55:19 -060032/* Minumum length of senson event data */
33#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
34#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
35#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
36#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
37#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
38#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
39#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
40#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
41
George Liu30b859f2020-01-07 15:03:22 +080042enum pldm_effecter_data_size {
43 PLDM_EFFECTER_DATA_SIZE_UINT8,
44 PLDM_EFFECTER_DATA_SIZE_SINT8,
45 PLDM_EFFECTER_DATA_SIZE_UINT16,
46 PLDM_EFFECTER_DATA_SIZE_SINT16,
47 PLDM_EFFECTER_DATA_SIZE_UINT32,
48 PLDM_EFFECTER_DATA_SIZE_SINT32
49};
50
Sampa Misra0db1dfa2019-03-19 00:15:31 -050051enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
52
53enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
54
Jolie Ku3557bad2020-03-02 16:22:57 +080055enum sensor_operational_state {
56 ENABLED = 0x00,
57 DISABLED = 0x01,
58 UNAVAILABLE = 0x02,
59 STATUSUNKNOWN = 0x03,
60 FAILED = 0x04,
61 INITIALIZING = 0x05,
62 SHUTTINGDOWN = 0x06,
63 INTEST = 0x07
64};
65
66enum present_state {
67 UNKNOWN = 0x0,
68 NORMAL = 0x01,
69 WARNING = 0x02,
70 CRITICAL = 0x03,
71 FATAL = 0x04,
72 LOWERWARNING = 0x05,
73 LOWERCRITICAL = 0x06,
74 LOWERFATAL = 0x07,
75 UPPERWARNING = 0x08,
76 UPPERCRITICAL = 0x09,
77 UPPERFATAL = 0x0a
78};
79
Sampa Misra0db1dfa2019-03-19 00:15:31 -050080enum pldm_platform_commands {
Jolie Ku3557bad2020-03-02 16:22:57 +080081 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +080082 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050083 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -050084 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -060085 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -050086};
87
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050088/** @brief PLDM PDR types
89 */
90enum pldm_pdr_types {
91 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -050092 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -060093 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -050094};
95
96/** @brief PLDM effecter initialization schemes
97 */
98enum pldm_effecter_init {
99 PLDM_NO_INIT,
100 PLDM_USE_INIT_PDR,
101 PLDM_ENABLE_EFFECTER,
102 PLDM_DISABLE_EFECTER
103};
104
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530105/** @brief PLDM Platform M&C completion codes
106 */
107enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500108 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
109 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530110 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Sampa Misraa2fa0702019-05-31 01:28:55 -0500111 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530112};
113
Zahed Hossaind4abab12020-02-06 03:36:43 -0600114/** @brief PLDM Event types
115 */
116enum pldm_event_types {
117 PLDM_SENSOR_EVENT = 0x00,
118 PLDM_EFFECTER_EVENT = 0x01,
119 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
120 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
121 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
122 PLDM_MESSAGE_POLL_EVENT = 0x05,
123 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
124};
125
126/** @brief PLDM sensorEventClass states
127 */
128enum sensor_event_class_states {
129 PLDM_SENSOR_OP_STATE,
130 PLDM_STATE_SENSOR_STATE,
131 PLDM_NUMERIC_SENSOR_STATE
132};
133
134/** @brief PLDM sensor supported states
135 */
136enum pldm_sensor_operational_state {
137 PLDM_SENSOR_ENABLED,
138 PLDM_SENSOR_DISABLED,
139 PLDM_SENSOR_UNAVAILABLE,
140 PLDM_SENSOR_STATUSUNKOWN,
141 PLDM_SENSOR_FAILED,
142 PLDM_SENSOR_INITIALIZING,
143 PLDM_SENSOR_SHUTTINGDOWN,
144 PLDM_SENSOR_INTEST
145};
146
147/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
148 */
149enum pldm_pdr_repository_chg_event_data_format {
150 REFRESH_ENTIRE_REPOSITORY,
151 FORMAT_IS_PDR_TYPES,
152 FORMAT_IS_PDR_HANDLES
153};
154
Zahed Hossain1c861712020-03-04 08:55:19 -0600155/** @brief PLDM NumericSensorStatePresentReading data type
156 */
157enum pldm_sensor_readings_data_type {
158 PLDM_SENSOR_DATA_SIZE_UINT8,
159 PLDM_SENSOR_DATA_SIZE_SINT8,
160 PLDM_SENSOR_DATA_SIZE_UINT16,
161 PLDM_SENSOR_DATA_SIZE_SINT16,
162 PLDM_SENSOR_DATA_SIZE_UINT32,
163 PLDM_SENSOR_DATA_SIZE_SINT32
164};
165
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500166/** @struct pldm_pdr_hdr
167 *
168 * Structure representing PLDM common PDR header
169 */
170struct pldm_pdr_hdr {
171 uint32_t record_handle;
172 uint8_t version;
173 uint8_t type;
174 uint16_t record_change_num;
175 uint16_t length;
176} __attribute__((packed));
177
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500178/** @struct pldm_pdr_entity_association
179 *
180 * Structure representing PLDM Entity Association PDR
181 */
182struct pldm_pdr_entity_association {
183 uint16_t container_id;
184 uint8_t association_type;
185 pldm_entity container;
186 uint8_t num_children;
187 pldm_entity children[1];
188} __attribute__((packed));
189
Deepak Kodihallidb914672020-02-07 02:47:45 -0600190/** @struct pldm_pdr_fru_record_set
191 *
192 * Structure representing PLDM FRU record set PDR
193 */
194struct pldm_pdr_fru_record_set {
195 uint16_t terminus_handle;
196 uint16_t fru_rsi;
197 uint16_t entity_type;
198 uint16_t entity_instance_num;
199 uint16_t container_id;
200} __attribute__((packed));
201
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500202/** @struct pldm_state_effecter_pdr
203 *
204 * Structure representing PLDM state effecter PDR
205 */
206struct pldm_state_effecter_pdr {
207 struct pldm_pdr_hdr hdr;
208 uint16_t terminus_handle;
209 uint16_t effecter_id;
210 uint16_t entity_type;
211 uint16_t entity_instance;
212 uint16_t container_id;
213 uint16_t effecter_semantic_id;
214 uint8_t effecter_init;
215 bool8_t has_description_pdr;
216 uint8_t composite_effecter_count;
217 uint8_t possible_states[1];
218} __attribute__((packed));
219
220/** @struct state_effecter_possible_states
221 *
222 * Structure representing state enums for state effecter
223 */
224struct state_effecter_possible_states {
225 uint16_t state_set_id;
226 uint8_t possible_states_size;
227 bitfield8_t states[1];
228} __attribute__((packed));
229
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500230/** @struct set_effecter_state_field
231 *
232 * Structure representing a stateField in SetStateEffecterStates command */
233
234typedef struct state_field_for_state_effecter_set {
235 uint8_t set_request; //!< Whether to change the state
236 uint8_t effecter_state; //!< Expected state of the effecter
237} __attribute__((packed)) set_effecter_state_field;
238
Jolie Ku3557bad2020-03-02 16:22:57 +0800239/** @struct get_sensor_readings_field
240 *
241 * Structure representing a stateField in GetStateSensorReadings command */
242
243typedef struct state_field_for_get_state_sensor_readings {
244 uint8_t sensor_op_state; //!< The state of the sensor itself
245 uint8_t present_state; //!< Return a state value
246 uint8_t previous_state; //!< The state that the presentState was entered
247 //! from. This must be different from the
248 //! present state
249 uint8_t event_state; //!< Return a state value from a PLDM State Set
250 //! that is associated with the sensor
251} __attribute__((packed)) get_sensor_state_field;
252
Priyanga7257fdf2019-06-10 01:59:45 -0500253/** @struct PLDM_SetStateEffecterStates_Request
254 *
255 * Structure representing PLDM set state effecter states request.
256 */
257struct pldm_set_state_effecter_states_req {
258 uint16_t effecter_id;
259 uint8_t comp_effecter_count;
260 set_effecter_state_field field[8];
261} __attribute__((packed));
262
Sampa Misra7fcfb662019-05-08 13:13:53 -0500263/** @struct pldm_get_pdr_resp
264 *
265 * structure representing GetPDR response packet
266 * transfer CRC is not part of the structure and will be
267 * added at the end of last packet in multipart transfer
268 */
269struct pldm_get_pdr_resp {
270 uint8_t completion_code;
271 uint32_t next_record_handle;
272 uint32_t next_data_transfer_handle;
273 uint8_t transfer_flag;
274 uint16_t response_count;
275 uint8_t record_data[1];
276} __attribute__((packed));
277
278/** @struct pldm_get_pdr_req
279 *
280 * structure representing GetPDR request packet
281 */
282struct pldm_get_pdr_req {
283 uint32_t record_handle;
284 uint32_t data_transfer_handle;
285 uint8_t transfer_op_flag;
286 uint16_t request_count;
287 uint16_t record_change_number;
288} __attribute__((packed));
289
George Liu30b859f2020-01-07 15:03:22 +0800290/** @struct pldm_set_numeric_effecter_value_req
291 *
292 * structure representing SetNumericEffecterValue request packet
293 */
294struct pldm_set_numeric_effecter_value_req {
295 uint16_t effecter_id;
296 uint8_t effecter_data_size;
297 uint8_t effecter_value[1];
298} __attribute__((packed));
299
Jolie Ku3557bad2020-03-02 16:22:57 +0800300/** @struct pldm_get_state_sensor_readings_req
301 *
302 * Structure representing PLDM get state sensor readings request.
303 */
304struct pldm_get_state_sensor_readings_req {
305 uint16_t sensor_id;
306 bitfield8_t sensor_rearm;
307 uint8_t reserved;
308} __attribute__((packed));
309
310/** @struct pldm_get_state_sensor_readings_resp
311 *
312 * Structure representing PLDM get state sensor readings response.
313 */
314struct pldm_get_state_sensor_readings_resp {
315 uint8_t completion_code;
316 uint8_t comp_sensor_count;
317 get_sensor_state_field field[1];
318} __attribute__((packed));
319
Zahed Hossaind4abab12020-02-06 03:36:43 -0600320/** @struct pldm_sensor_event
321 *
322 * structure representing sensorEventClass
323 */
324struct pldm_sensor_event_data {
325 uint16_t sensor_id;
326 uint8_t sensor_event_class_type;
327 uint8_t event_class[1];
328} __attribute__((packed));
329
330/** @struct pldm_state_sensor_state
331 *
332 * structure representing sensorEventClass for stateSensorState
333 */
334struct pldm_sensor_event_state_sensor_state {
335 uint8_t sensor_offset;
336 uint8_t event_state;
337 uint8_t previous_event_state;
338} __attribute__((packed));
339
340/** @struct pldm_sensor_event_numeric_sensor_state
341 *
342 * structure representing sensorEventClass for stateSensorState
343 */
344struct pldm_sensor_event_numeric_sensor_state {
345 uint8_t event_state;
346 uint8_t previous_event_state;
347 uint8_t sensor_data_size;
348 uint8_t present_reading[1];
349} __attribute__((packed));
350
351/** @struct pldm_sensor_event_sensor_op_state
352 *
353 * structure representing sensorEventClass for SensorOpState
354 */
355struct pldm_sensor_event_sensor_op_state {
356 uint8_t present_op_state;
357 uint8_t previous_op_state;
358} __attribute__((packed));
359
360/** @struct pldm_platform_event_message_req
361 *
362 * structure representing PlatformEventMessage command request data
363 */
364struct pldm_platform_event_message_req {
365 uint8_t format_version;
366 uint8_t tid;
367 uint8_t event_class;
368 uint8_t event_data[1];
369} __attribute__((packed));
370
371/** @struct pldm_platform_event_message_response
372 *
373 * structure representing PlatformEventMessage command response data
374 */
375struct pldm_platform_event_message_resp {
376 uint8_t completion_code;
377 uint8_t status;
378} __attribute__((packed));
379
380/** @struct pldm_pdr_repository_chg_event_data
381 *
382 * structure representing pldmPDRRepositoryChgEvent class eventData
383 */
384struct pldm_pdr_repository_chg_event_data {
385 uint8_t event_data_format;
386 uint8_t number_of_change_records;
387 uint8_t change_records[1];
388} __attribute__((packed));
389
390/** @struct pldm_pdr_repository_chg_event_change_record_data
391 *
392 * structure representing pldmPDRRepositoryChgEvent class eventData's change
393 * record data
394 */
395struct pldm_pdr_repository_change_record_data {
396 uint8_t event_data_operation;
397 uint8_t number_of_change_entries;
398 uint32_t change_entry[1];
399} __attribute__((packed));
400
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500401/* Responder */
402
George Liu30b859f2020-01-07 15:03:22 +0800403/* SetNumericEffecterValue */
404
405/** @brief Decode SetNumericEffecterValue request data
406 *
407 * @param[in] msg - Request message
408 * @param[in] payload_length - Length of request message payload
409 * @param[out] effecter_id - used to identify and access the effecter
410 * @param[out] effecter_data_size - The bit width and format of the setting
411 * value for the effecter.
412 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
413 * @param[out] effecter_value - The setting value of numeric effecter being
414 * requested.
415 * @return pldm_completion_codes
416 */
417int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
418 size_t payload_length,
419 uint16_t *effecter_id,
420 uint8_t *effecter_data_size,
421 uint8_t *effecter_value);
422
423/** @brief Create a PLDM response message for SetNumericEffecterValue
424 *
425 * @param[in] instance_id - Message's instance id
426 * @param[in] completion_code - PLDM completion code
427 * @param[out] msg - Message will be written to this
428 * @param[in] payload_length - Length of request message payload
429 * @return pldm_completion_codes
430 * @note Caller is responsible for memory alloc and dealloc of param
431 * 'msg.body.payload'
432 */
433int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
434 uint8_t completion_code,
435 struct pldm_msg *msg,
436 size_t payload_length);
437
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500438/* SetStateEffecterStates */
439
440/** @brief Create a PLDM response message for SetStateEffecterStates
441 *
442 * @param[in] instance_id - Message's instance id
443 * @param[in] completion_code - PLDM completion code
444 * @param[out] msg - Message will be written to this
445 * @return pldm_completion_codes
446 * @note Caller is responsible for memory alloc and dealloc of param
447 * 'msg.body.payload'
448 */
449
450int encode_set_state_effecter_states_resp(uint8_t instance_id,
451 uint8_t completion_code,
452 struct pldm_msg *msg);
453
454/** @brief Decode SetStateEffecterStates request data
455 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500456 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500457 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500458 * @param[out] effecter_id - used to identify and access the effecter
459 * @param[out] comp_effecter_count - number of individual sets of effecter
460 * information. Upto eight sets of state effecter info can be accessed
461 * for a given effecter.
462 * @param[out] field - each unit is an instance of the stateFileld structure
463 * that is used to set the requested state for a particular effecter
464 * within the state effecter. This field holds the starting address of
465 * the stateField values. The user is responsible to allocate the
466 * memory prior to calling this command. Since the state field count is
467 * not known in advance, the user should allocate the maximum size
468 * always, which is 8 in number.
469 * @return pldm_completion_codes
470 */
vkaverapa6575b82019-04-03 05:33:52 -0500471
Zahed Hossain223a73d2019-07-04 12:46:18 -0500472int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500473 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500474 uint16_t *effecter_id,
475 uint8_t *comp_effecter_count,
476 set_effecter_state_field *field);
477
Sampa Misra7fcfb662019-05-08 13:13:53 -0500478/* GetPDR */
479
480/** @brief Create a PLDM response message for GetPDR
481 *
482 * @param[in] instance_id - Message's instance id
483 * @param[in] completion_code - PLDM completion code
484 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
485 * the PDR Repository
486 * @param[in] next_data_transfer_hndl - A handle that identifies the next
487 * portion of the PDR data to be transferred, if any
488 * @param[in] transfer_flag - Indicates the portion of PDR data being
489 * transferred
490 * @param[in] resp_cnt - The number of recordData bytes returned in this
491 * response
492 * @param[in] record_data - PDR data bytes of length resp_cnt
493 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
494 * in the last part of a PDR being transferred
495 * @param[out] msg - Message will be written to this
496 * @return pldm_completion_codes
497 * @note Caller is responsible for memory alloc and dealloc of param
498 * 'msg.payload'
499 */
500int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
501 uint32_t next_record_hndl,
502 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
503 uint16_t resp_cnt, const uint8_t *record_data,
504 uint8_t transfer_crc, struct pldm_msg *msg);
505
506/** @brief Decode GetPDR request data
507 *
508 * @param[in] msg - Request message
509 * @param[in] payload_length - Length of request message payload
510 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
511 * @param[out] data_transfer_hndl - Handle used to identify a particular
512 * multipart PDR data transfer operation
513 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
514 * portion of transfer
515 * @param[out] request_cnt - The maximum number of record bytes requested
516 * @param[out] record_chg_num - Used to determine whether the PDR has changed
517 * while PDR transfer is going on
518 * @return pldm_completion_codes
519 */
520
521int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
522 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
523 uint8_t *transfer_op_flag, uint16_t *request_cnt,
524 uint16_t *record_chg_num);
525
Jolie Ku3557bad2020-03-02 16:22:57 +0800526/* GetStateSensorReadings */
527
528/** @brief Decode GetStateSensorReadings request data
529 *
530 * @param[in] msg - Request message
531 * @param[in] payload_length - Length of request message payload
532 * @param[out] sensor_id - used to identify and access the simple or composite
533 * sensor
534 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
535 * particular sensor within the state sensor, where bit [0] corresponds
536 * to the first state sensor (sensor offset 0) and bit [7] corresponds
537 * to the eighth sensor (sensor offset 7), sequentially.
538 * @param[out] reserved - value: 0x00
539 * @return pldm_completion_codes
540 */
541
542int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
543 size_t payload_length,
544 uint16_t *sensor_id,
545 bitfield8_t *sensor_rearm,
546 uint8_t *reserved);
547
548/** @brief Encode GetStateSensorReadings response data
549 *
550 * @param[in] instance_id - Message's instance id
551 * @param[in] completion_code - PLDM completion code
552 * @param[out] comp_sensor_count - The number of individual sets of sensor
553 * information that this command accesses
554 * @param[out] field - Each stateField is an instance of a stateField structure
555 * that is used to return the present operational state setting and the
556 * present state and event state for a particular set of sensor
557 * information contained within the state sensor
558 * @param[out] msg - Message will be written to this
559 * @return pldm_completion_codes
560 */
561
562int encode_get_state_sensor_readings_resp(uint8_t instance_id,
563 uint8_t completion_code,
564 uint8_t comp_sensor_count,
565 get_sensor_state_field *field,
566 struct pldm_msg *msg);
567
Sampa Misra7fcfb662019-05-08 13:13:53 -0500568/* Requester */
569
George Liu820a9a52019-11-26 14:43:59 +0800570/* GetPDR */
571
572/** @brief Create a PLDM request message for GetPDR
573 *
574 * @param[in] instance_id - Message's instance id
575 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
576 * @param[in] data_transfer_hndl - Handle used to identify a particular
577 * multipart PDR data transfer operation
578 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
579 * portion of transfer
580 * @param[in] request_cnt - The maximum number of record bytes requested
581 * @param[in] record_chg_num - Used to determine whether the PDR has changed
582 * while PDR transfer is going on
583 * @param[out] msg - Message will be written to this
584 * @param[in] payload_length - Length of request message payload
585 * @return pldm_completion_codes
586 * @note Caller is responsible for memory alloc and dealloc of param
587 * 'msg.payload'
588 */
589int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
590 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
591 uint16_t request_cnt, uint16_t record_chg_num,
592 struct pldm_msg *msg, size_t payload_length);
593
594/** @brief Decode GetPDR response data
595 *
George Liu684a7162019-12-06 15:10:52 +0800596 * Note:
597 * * If the return value is not PLDM_SUCCESS, it represents a
598 * transport layer error.
599 * * If the completion_code value is not PLDM_SUCCESS, it represents a
600 * protocol layer error and all the out-parameters are invalid.
601 *
George Liu820a9a52019-11-26 14:43:59 +0800602 * @param[in] msg - Request message
603 * @param[in] payload_length - Length of request message payload
604 * @param[out] completion_code - PLDM completion code
605 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
606 * the PDR Repository
607 * @param[out] next_data_transfer_hndl - A handle that identifies the next
608 * portion of the PDR data to be transferred, if any
609 * @param[out] transfer_flag - Indicates the portion of PDR data being
610 * transferred
611 * @param[out] resp_cnt - The number of recordData bytes returned in this
612 * response
613 * @param[out] record_data - PDR data bytes of length resp_cnt
614 * @param[in] record_data_length - Length of record_data
615 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
616 * in the last part of a PDR being transferred
617 * @return pldm_completion_codes
618 */
619int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
620 uint8_t *completion_code, uint32_t *next_record_hndl,
621 uint32_t *next_data_transfer_hndl,
622 uint8_t *transfer_flag, uint16_t *resp_cnt,
623 uint8_t *record_data, size_t record_data_length,
624 uint8_t *transfer_crc);
625
Sampa Misra7fcfb662019-05-08 13:13:53 -0500626/* SetStateEffecterStates */
627
vkaverap98a2c192019-04-03 05:33:52 -0500628/** @brief Create a PLDM request message for SetStateEffecterStates
629 *
630 * @param[in] instance_id - Message's instance id
631 * @param[in] effecter_id - used to identify and access the effecter
632 * @param[in] comp_effecter_count - number of individual sets of effecter
633 * information. Upto eight sets of state effecter info can be accessed
634 * for a given effecter.
635 * @param[in] field - each unit is an instance of the stateField structure
636 * that is used to set the requested state for a particular effecter
637 * within the state effecter. This field holds the starting address of
638 * the stateField values. The user is responsible to allocate the
639 * memory prior to calling this command. The user has to allocate the
640 * field parameter as sizeof(set_effecter_state_field) *
641 * comp_effecter_count
642 * @param[out] msg - Message will be written to this
643 * @return pldm_completion_codes
644 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500645 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500646 */
647
648int encode_set_state_effecter_states_req(uint8_t instance_id,
649 uint16_t effecter_id,
650 uint8_t comp_effecter_count,
651 set_effecter_state_field *field,
652 struct pldm_msg *msg);
653
654/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800655 *
656 * Note:
657 * * If the return value is not PLDM_SUCCESS, it represents a
658 * transport layer error.
659 * * If the completion_code value is not PLDM_SUCCESS, it represents a
660 * protocol layer error and all the out-parameters are invalid.
661 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500662 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500663 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500664 * @param[out] completion_code - PLDM completion code
665 * @return pldm_completion_codes
666 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500667int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500668 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500669 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800670
671/* SetNumericEffecterValue */
672
673/** @brief Create a PLDM request message for SetNumericEffecterValue
674 *
675 * @param[in] instance_id - Message's instance id
676 * @param[in] effecter_id - used to identify and access the effecter
677 * @param[in] effecter_data_size - The bit width and format of the setting
678 * value for the effecter.
679 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
680 * @param[in] effecter_value - The setting value of numeric effecter being
681 * requested.
682 * @param[in] payload_length - Length of request message payload
683 * @param[out] msg - Message will be written to this
684 * @return pldm_completion_codes
685 * @note Caller is responsible for memory alloc and dealloc of param
686 * 'msg.payload'
687 */
688int encode_set_numeric_effecter_value_req(
689 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
690 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
691
692/** @brief Decode SetNumericEffecterValue response data
693 * @param[in] msg - Request message
694 * @param[in] payload_length - Length of response message payload
695 * @param[out] completion_code - PLDM completion code
696 * @return pldm_completion_codes
697 */
698int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
699 size_t payload_length,
700 uint8_t *completion_code);
701
Jolie Ku3557bad2020-03-02 16:22:57 +0800702/** @brief Create a PLDM request message for GetStateSensorReadings
703 *
704 * @param[in] instance_id - Message's instance id
705 * @param[in] sensor_id - used to identify and access the simple or composite
706 * sensor
707 * @param[in] sensorRearm - Each bit location in this field corresponds to a
708 * particular sensor within the state sensor, where bit [0] corresponds
709 * to the first state sensor (sensor offset 0) and bit [7] corresponds
710 * to the eighth sensor (sensor offset 7), sequentially
711 * @param[in] reserved - value: 0x00
712 * @param[out] msg - Message will be written to this
713 * @return pldm_completion_codes
714 * @note Caller is responsible for memory alloc and dealloc of param
715 * 'msg.payload'
716 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800717int encode_get_state_sensor_readings_req(uint8_t instance_id,
718 uint16_t sensor_id,
719 bitfield8_t sensor_rearm,
720 uint8_t reserved,
721 struct pldm_msg *msg);
722
723/** @brief Decode GetStateSensorReadings response data
724 *
725 * @param[in] msg - Request message
726 * @param[in] payload_length - Length of response message payload
727 * @param[out] completion_code - PLDM completion code
728 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
729 * information that this command accesses
730 * @param[out] field - Each stateField is an instance of a stateField structure
731 * that is used to return the present operational state setting and the
732 * present state and event state for a particular set of sensor
733 * information contained within the state sensor
734 * @return pldm_completion_codes
735 */
736
737int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
738 size_t payload_length,
739 uint8_t *completion_code,
740 uint8_t *comp_sensor_count,
741 get_sensor_state_field *field);
742
Zahed Hossaind4abab12020-02-06 03:36:43 -0600743/* PlatformEventMessage */
744
745/** @brief Decode PlatformEventMessage request data
746 * @param[in] msg - Request message
747 * @param[in] payload_length - Length of response message payload
748 * @param[out] format_version - Version of the event format
749 * @param[out] tid - Terminus ID for the terminus that originated the event
750 * message
751 * @param[out] event_class - The class of event being sent
752 * @param[out] event_data_offset - Offset where the event data should be read
753 * from pldm msg
754 * @return pldm_completion_codes
755 */
756int decode_platform_event_message_req(const struct pldm_msg *msg,
757 size_t payload_length,
758 uint8_t *format_version, uint8_t *tid,
759 uint8_t *event_class,
760 size_t *event_data_offset);
761
762/** @brief Encode PlatformEventMessage response data
763 * @param[in] instance_id - Message's instance id
764 * @param[in] completion_code - PLDM completion code
765 * @param[in] status - Response status of the event message command
766 * @param[out] msg - Message will be written to this
767 * @return pldm_completion_codes
768 * @note Caller is responsible for memory alloc and dealloc of param
769 * 'msg.payload'
770 */
771int encode_platform_event_message_resp(uint8_t instance_id,
772 uint8_t completion_code, uint8_t status,
773 struct pldm_msg *msg);
774
Zahed Hossain1c861712020-03-04 08:55:19 -0600775/** @brief Decode sensorEventData response data
776 *
777 * @param[in] event_data - event data from the response message
778 * @param[in] event_data_length - length of the event data
779 * @param[out] sensor_id - sensorID value of the sensor
780 * @param[out] sensor_event_class_type - Type of sensor event class
781 * @param[out] event_class_data_offset - Offset where the event class data
782 * should be read from event data
783 * @return pldm_completion_codes
784 * @note Caller is responsible for memory alloc and dealloc of param
785 * 'event_data'
786 */
787int decode_sensor_event_data(const uint8_t *event_data,
788 size_t event_data_length, uint16_t *sensor_id,
789 uint8_t *sensor_event_class_type,
790 size_t *event_class_data_offset);
791
792/** @brief Decode sensorOpState response data
793 *
794 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
795 * @param[in] sensor_data_length - Length of sensor_data
796 * @param[out] present_op_state - The sensorOperationalState value from the
797 * state change that triggered the event message
798 * @param[out] previous_op_state - The sensorOperationalState value for the
799 * state from which the present state was entered
800 * @return pldm_completion_codes
801 * @note Caller is responsible for memory alloc and dealloc of param
802 * 'sensor_data'
803 */
804int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
805 uint8_t *present_op_state,
806 uint8_t *previous_op_state);
807
808/** @brief Decode stateSensorState response data
809 *
810 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
811 * @param[in] sensor_data_length - Length of sensor_data
812 * @param[out] sensor_offset - Identifies which state sensor within a composite
813 * state sensor the event is being returned for
814 * @param[out] event_state - The event state value from the state change that
815 * triggered the event message
816 * @param[out] previous_event_state - The event state value for the state from
817 * which the present event state was entered
818 * @return pldm_completion_codes
819 * @note Caller is responsible for memory alloc and dealloc of param
820 * 'sensor_data'
821 */
822int decode_state_sensor_data(const uint8_t *sensor_data,
823 size_t sensor_data_length, uint8_t *sensor_offset,
824 uint8_t *event_state,
825 uint8_t *previous_event_state);
826
827/** @brief Decode numericSensorState response data
828 *
829 * @param[in] sensor_data - sensor_data for sensorEventClass =
830 * numericSensorState
831 * @param[in] sensor_data_length - Length of sensor_data
832 * @param[out] event_state - The eventState value from the state change that
833 * triggered the event message
834 * @param[out] previous_event_state - The eventState value for the state from
835 * which the present state was entered
836 * @param[out] sensor_data_size - The bit width and format of reading and
837 * threshold values that the sensor returns
838 * @param[out] present_reading - The present value indicated by the sensor
839 * @return pldm_completion_codes
840 * @note Caller is responsible for memory alloc and dealloc of param
841 * 'sensor_data'
842 */
843int decode_numeric_sensor_data(const uint8_t *sensor_data,
844 size_t sensor_data_length, uint8_t *event_state,
845 uint8_t *previous_event_state,
846 uint8_t *sensor_data_size,
847 uint32_t *present_reading);
848
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500849#ifdef __cplusplus
850}
851#endif
852
853#endif /* PLATFORM_H */