blob: 0ee050abd1b22cf50c8819f6dbb38dae9d175451 [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
Jolie Ku6787f172020-03-19 11:15:53 +080017#define PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES 2
Sampa Misra0db1dfa2019-03-19 00:15:31 -050018/* Response lengths are inclusive of completion code */
19#define PLDM_SET_STATE_EFFECTER_STATES_RESP_BYTES 1
Jolie Ku3557bad2020-03-02 16:22:57 +080020#define PLDM_GET_STATE_SENSOR_READINGS_RESP_BYTES 34
Sampa Misra0db1dfa2019-03-19 00:15:31 -050021
George Liu30b859f2020-01-07 15:03:22 +080022#define PLDM_SET_NUMERIC_EFFECTER_VALUE_RESP_BYTES 1
23#define PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES 4
24
Sampa Misra7fcfb662019-05-08 13:13:53 -050025#define PLDM_GET_PDR_REQ_BYTES 13
26/* Minimum response length */
27#define PLDM_GET_PDR_MIN_RESP_BYTES 12
Jolie Ku6787f172020-03-19 11:15:53 +080028#define PLDM_GET_NUMERIC_EFFECTER_VALUE_MIN_RESP_BYTES 5
Sampa Misra7fcfb662019-05-08 13:13:53 -050029
Zahed Hossaind4abab12020-02-06 03:36:43 -060030/* Minimum length for PLDM PlatformEventMessage request */
31#define PLDM_PLATFORM_EVENT_MESSAGE_MIN_REQ_BYTES 3
32#define PLDM_PLATFORM_EVENT_MESSAGE_STATE_SENSOR_STATE_REQ_BYTES 6
33
Zahed Hossain1c861712020-03-04 08:55:19 -060034/* Minumum length of senson event data */
35#define PLDM_SENSOR_EVENT_DATA_MIN_LENGTH 5
36#define PLDM_SENSOR_EVENT_SENSOR_OP_STATE_DATA_LENGTH 2
37#define PLDM_SENSOR_EVENT_STATE_SENSOR_STATE_DATA_LENGTH 3
38#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MIN_DATA_LENGTH 4
39#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_MAX_DATA_LENGTH 7
40#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_8BIT_DATA_LENGTH 4
41#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_16BIT_DATA_LENGTH 5
42#define PLDM_SENSOR_EVENT_NUMERIC_SENSOR_STATE_32BIT_DATA_LENGTH 7
43
George Liu30b859f2020-01-07 15:03:22 +080044enum pldm_effecter_data_size {
45 PLDM_EFFECTER_DATA_SIZE_UINT8,
46 PLDM_EFFECTER_DATA_SIZE_SINT8,
47 PLDM_EFFECTER_DATA_SIZE_UINT16,
48 PLDM_EFFECTER_DATA_SIZE_SINT16,
49 PLDM_EFFECTER_DATA_SIZE_UINT32,
50 PLDM_EFFECTER_DATA_SIZE_SINT32
51};
52
Sampa Misra0db1dfa2019-03-19 00:15:31 -050053enum set_request { PLDM_NO_CHANGE = 0x00, PLDM_REQUEST_SET = 0x01 };
54
55enum effecter_state { PLDM_INVALID_VALUE = 0xFF };
56
Jolie Ku3557bad2020-03-02 16:22:57 +080057enum sensor_operational_state {
58 ENABLED = 0x00,
59 DISABLED = 0x01,
60 UNAVAILABLE = 0x02,
61 STATUSUNKNOWN = 0x03,
62 FAILED = 0x04,
63 INITIALIZING = 0x05,
64 SHUTTINGDOWN = 0x06,
65 INTEST = 0x07
66};
67
68enum present_state {
69 UNKNOWN = 0x0,
70 NORMAL = 0x01,
71 WARNING = 0x02,
72 CRITICAL = 0x03,
73 FATAL = 0x04,
74 LOWERWARNING = 0x05,
75 LOWERCRITICAL = 0x06,
76 LOWERFATAL = 0x07,
77 UPPERWARNING = 0x08,
78 UPPERCRITICAL = 0x09,
79 UPPERFATAL = 0x0a
80};
81
Jolie Ku6787f172020-03-19 11:15:53 +080082enum pldm_effecter_oper_state {
83 EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
84 EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
85 EFFECTER_OPER_STATE_DISABLED,
86 EFFECTER_OPER_STATE_UNAVAILABLE,
87 EFFECTER_OPER_STATE_STATUSUNKNOWN,
88 EFFECTER_OPER_STATE_FAILED,
89 EFFECTER_OPER_STATE_INITIALIZING,
90 EFFECTER_OPER_STATE_SHUTTINGDOWN,
91 EFFECTER_OPER_STATE_INTEST
92};
93
Sampa Misra0db1dfa2019-03-19 00:15:31 -050094enum pldm_platform_commands {
Jolie Ku3557bad2020-03-02 16:22:57 +080095 PLDM_GET_STATE_SENSOR_READINGS = 0x21,
George Liu30b859f2020-01-07 15:03:22 +080096 PLDM_SET_NUMERIC_EFFECTER_VALUE = 0x31,
Jolie Ku6787f172020-03-19 11:15:53 +080097 PLDM_GET_NUMERIC_EFFECTER_VALUE = 0x32,
Sampa Misra0db1dfa2019-03-19 00:15:31 -050098 PLDM_SET_STATE_EFFECTER_STATES = 0x39,
Sampa Misra7fcfb662019-05-08 13:13:53 -050099 PLDM_GET_PDR = 0x51,
Zahed Hossaind4abab12020-02-06 03:36:43 -0600100 PLDM_PLATFORM_EVENT_MESSAGE = 0x0A
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500101};
102
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500103/** @brief PLDM PDR types
104 */
105enum pldm_pdr_types {
106 PLDM_STATE_EFFECTER_PDR = 11,
Deepak Kodihalli0a738f02020-03-10 01:56:21 -0500107 PLDM_PDR_ENTITY_ASSOCIATION = 15,
Deepak Kodihallidb914672020-02-07 02:47:45 -0600108 PLDM_PDR_FRU_RECORD_SET = 20,
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500109};
110
111/** @brief PLDM effecter initialization schemes
112 */
113enum pldm_effecter_init {
114 PLDM_NO_INIT,
115 PLDM_USE_INIT_PDR,
116 PLDM_ENABLE_EFFECTER,
117 PLDM_DISABLE_EFECTER
118};
119
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530120/** @brief PLDM Platform M&C completion codes
121 */
122enum pldm_platform_completion_codes {
Sampa Misraa2fa0702019-05-31 01:28:55 -0500123 PLDM_PLATFORM_INVALID_EFFECTER_ID = 0x80,
124 PLDM_PLATFORM_INVALID_STATE_VALUE = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530125 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Sampa Misraa2fa0702019-05-31 01:28:55 -0500126 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530127};
128
Zahed Hossaind4abab12020-02-06 03:36:43 -0600129/** @brief PLDM Event types
130 */
131enum pldm_event_types {
132 PLDM_SENSOR_EVENT = 0x00,
133 PLDM_EFFECTER_EVENT = 0x01,
134 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
135 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
136 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
137 PLDM_MESSAGE_POLL_EVENT = 0x05,
138 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
139};
140
141/** @brief PLDM sensorEventClass states
142 */
143enum sensor_event_class_states {
144 PLDM_SENSOR_OP_STATE,
145 PLDM_STATE_SENSOR_STATE,
146 PLDM_NUMERIC_SENSOR_STATE
147};
148
149/** @brief PLDM sensor supported states
150 */
151enum pldm_sensor_operational_state {
152 PLDM_SENSOR_ENABLED,
153 PLDM_SENSOR_DISABLED,
154 PLDM_SENSOR_UNAVAILABLE,
155 PLDM_SENSOR_STATUSUNKOWN,
156 PLDM_SENSOR_FAILED,
157 PLDM_SENSOR_INITIALIZING,
158 PLDM_SENSOR_SHUTTINGDOWN,
159 PLDM_SENSOR_INTEST
160};
161
162/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
163 */
164enum pldm_pdr_repository_chg_event_data_format {
165 REFRESH_ENTIRE_REPOSITORY,
166 FORMAT_IS_PDR_TYPES,
167 FORMAT_IS_PDR_HANDLES
168};
169
Zahed Hossain1c861712020-03-04 08:55:19 -0600170/** @brief PLDM NumericSensorStatePresentReading data type
171 */
172enum pldm_sensor_readings_data_type {
173 PLDM_SENSOR_DATA_SIZE_UINT8,
174 PLDM_SENSOR_DATA_SIZE_SINT8,
175 PLDM_SENSOR_DATA_SIZE_UINT16,
176 PLDM_SENSOR_DATA_SIZE_SINT16,
177 PLDM_SENSOR_DATA_SIZE_UINT32,
178 PLDM_SENSOR_DATA_SIZE_SINT32
179};
180
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500181/** @struct pldm_pdr_hdr
182 *
183 * Structure representing PLDM common PDR header
184 */
185struct pldm_pdr_hdr {
186 uint32_t record_handle;
187 uint8_t version;
188 uint8_t type;
189 uint16_t record_change_num;
190 uint16_t length;
191} __attribute__((packed));
192
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500193/** @struct pldm_pdr_entity_association
194 *
195 * Structure representing PLDM Entity Association PDR
196 */
197struct pldm_pdr_entity_association {
198 uint16_t container_id;
199 uint8_t association_type;
200 pldm_entity container;
201 uint8_t num_children;
202 pldm_entity children[1];
203} __attribute__((packed));
204
Deepak Kodihallidb914672020-02-07 02:47:45 -0600205/** @struct pldm_pdr_fru_record_set
206 *
207 * Structure representing PLDM FRU record set PDR
208 */
209struct pldm_pdr_fru_record_set {
210 uint16_t terminus_handle;
211 uint16_t fru_rsi;
212 uint16_t entity_type;
213 uint16_t entity_instance_num;
214 uint16_t container_id;
215} __attribute__((packed));
216
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500217/** @struct pldm_state_effecter_pdr
218 *
219 * Structure representing PLDM state effecter PDR
220 */
221struct pldm_state_effecter_pdr {
222 struct pldm_pdr_hdr hdr;
223 uint16_t terminus_handle;
224 uint16_t effecter_id;
225 uint16_t entity_type;
226 uint16_t entity_instance;
227 uint16_t container_id;
228 uint16_t effecter_semantic_id;
229 uint8_t effecter_init;
230 bool8_t has_description_pdr;
231 uint8_t composite_effecter_count;
232 uint8_t possible_states[1];
233} __attribute__((packed));
234
235/** @struct state_effecter_possible_states
236 *
237 * Structure representing state enums for state effecter
238 */
239struct state_effecter_possible_states {
240 uint16_t state_set_id;
241 uint8_t possible_states_size;
242 bitfield8_t states[1];
243} __attribute__((packed));
244
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500245/** @struct set_effecter_state_field
246 *
247 * Structure representing a stateField in SetStateEffecterStates command */
248
249typedef struct state_field_for_state_effecter_set {
250 uint8_t set_request; //!< Whether to change the state
251 uint8_t effecter_state; //!< Expected state of the effecter
252} __attribute__((packed)) set_effecter_state_field;
253
Jolie Ku3557bad2020-03-02 16:22:57 +0800254/** @struct get_sensor_readings_field
255 *
256 * Structure representing a stateField in GetStateSensorReadings command */
257
258typedef struct state_field_for_get_state_sensor_readings {
259 uint8_t sensor_op_state; //!< The state of the sensor itself
260 uint8_t present_state; //!< Return a state value
261 uint8_t previous_state; //!< The state that the presentState was entered
262 //! from. This must be different from the
263 //! present state
264 uint8_t event_state; //!< Return a state value from a PLDM State Set
265 //! that is associated with the sensor
266} __attribute__((packed)) get_sensor_state_field;
267
Priyanga7257fdf2019-06-10 01:59:45 -0500268/** @struct PLDM_SetStateEffecterStates_Request
269 *
270 * Structure representing PLDM set state effecter states request.
271 */
272struct pldm_set_state_effecter_states_req {
273 uint16_t effecter_id;
274 uint8_t comp_effecter_count;
275 set_effecter_state_field field[8];
276} __attribute__((packed));
277
Sampa Misra7fcfb662019-05-08 13:13:53 -0500278/** @struct pldm_get_pdr_resp
279 *
280 * structure representing GetPDR response packet
281 * transfer CRC is not part of the structure and will be
282 * added at the end of last packet in multipart transfer
283 */
284struct pldm_get_pdr_resp {
285 uint8_t completion_code;
286 uint32_t next_record_handle;
287 uint32_t next_data_transfer_handle;
288 uint8_t transfer_flag;
289 uint16_t response_count;
290 uint8_t record_data[1];
291} __attribute__((packed));
292
293/** @struct pldm_get_pdr_req
294 *
295 * structure representing GetPDR request packet
296 */
297struct pldm_get_pdr_req {
298 uint32_t record_handle;
299 uint32_t data_transfer_handle;
300 uint8_t transfer_op_flag;
301 uint16_t request_count;
302 uint16_t record_change_number;
303} __attribute__((packed));
304
George Liu30b859f2020-01-07 15:03:22 +0800305/** @struct pldm_set_numeric_effecter_value_req
306 *
307 * structure representing SetNumericEffecterValue request packet
308 */
309struct pldm_set_numeric_effecter_value_req {
310 uint16_t effecter_id;
311 uint8_t effecter_data_size;
312 uint8_t effecter_value[1];
313} __attribute__((packed));
314
Jolie Ku3557bad2020-03-02 16:22:57 +0800315/** @struct pldm_get_state_sensor_readings_req
316 *
317 * Structure representing PLDM get state sensor readings request.
318 */
319struct pldm_get_state_sensor_readings_req {
320 uint16_t sensor_id;
321 bitfield8_t sensor_rearm;
322 uint8_t reserved;
323} __attribute__((packed));
324
325/** @struct pldm_get_state_sensor_readings_resp
326 *
327 * Structure representing PLDM get state sensor readings response.
328 */
329struct pldm_get_state_sensor_readings_resp {
330 uint8_t completion_code;
331 uint8_t comp_sensor_count;
332 get_sensor_state_field field[1];
333} __attribute__((packed));
334
Zahed Hossaind4abab12020-02-06 03:36:43 -0600335/** @struct pldm_sensor_event
336 *
337 * structure representing sensorEventClass
338 */
339struct pldm_sensor_event_data {
340 uint16_t sensor_id;
341 uint8_t sensor_event_class_type;
342 uint8_t event_class[1];
343} __attribute__((packed));
344
345/** @struct pldm_state_sensor_state
346 *
347 * structure representing sensorEventClass for stateSensorState
348 */
349struct pldm_sensor_event_state_sensor_state {
350 uint8_t sensor_offset;
351 uint8_t event_state;
352 uint8_t previous_event_state;
353} __attribute__((packed));
354
355/** @struct pldm_sensor_event_numeric_sensor_state
356 *
357 * structure representing sensorEventClass for stateSensorState
358 */
359struct pldm_sensor_event_numeric_sensor_state {
360 uint8_t event_state;
361 uint8_t previous_event_state;
362 uint8_t sensor_data_size;
363 uint8_t present_reading[1];
364} __attribute__((packed));
365
366/** @struct pldm_sensor_event_sensor_op_state
367 *
368 * structure representing sensorEventClass for SensorOpState
369 */
370struct pldm_sensor_event_sensor_op_state {
371 uint8_t present_op_state;
372 uint8_t previous_op_state;
373} __attribute__((packed));
374
375/** @struct pldm_platform_event_message_req
376 *
377 * structure representing PlatformEventMessage command request data
378 */
379struct pldm_platform_event_message_req {
380 uint8_t format_version;
381 uint8_t tid;
382 uint8_t event_class;
383 uint8_t event_data[1];
384} __attribute__((packed));
385
386/** @struct pldm_platform_event_message_response
387 *
388 * structure representing PlatformEventMessage command response data
389 */
390struct pldm_platform_event_message_resp {
391 uint8_t completion_code;
392 uint8_t status;
393} __attribute__((packed));
394
395/** @struct pldm_pdr_repository_chg_event_data
396 *
397 * structure representing pldmPDRRepositoryChgEvent class eventData
398 */
399struct pldm_pdr_repository_chg_event_data {
400 uint8_t event_data_format;
401 uint8_t number_of_change_records;
402 uint8_t change_records[1];
403} __attribute__((packed));
404
405/** @struct pldm_pdr_repository_chg_event_change_record_data
406 *
407 * structure representing pldmPDRRepositoryChgEvent class eventData's change
408 * record data
409 */
410struct pldm_pdr_repository_change_record_data {
411 uint8_t event_data_operation;
412 uint8_t number_of_change_entries;
413 uint32_t change_entry[1];
414} __attribute__((packed));
415
Jolie Ku6787f172020-03-19 11:15:53 +0800416/** @struct pldm_get_numeric_effecter_value_req
417 *
418 * structure representing GetNumericEffecterValue request packet
419 */
420struct pldm_get_numeric_effecter_value_req {
421 uint16_t effecter_id;
422} __attribute__((packed));
423
424/** @struct pldm_get_numeric_effecter_value_resp
425 *
426 * structure representing GetNumericEffecterValue response packet
427 */
428struct pldm_get_numeric_effecter_value_resp {
429 uint8_t completion_code;
430 uint8_t effecter_data_size;
431 uint8_t effecter_oper_state;
432 uint8_t pending_and_present_values[1];
433} __attribute__((packed));
434
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500435/* Responder */
436
George Liu30b859f2020-01-07 15:03:22 +0800437/* SetNumericEffecterValue */
438
439/** @brief Decode SetNumericEffecterValue request data
440 *
441 * @param[in] msg - Request message
442 * @param[in] payload_length - Length of request message payload
443 * @param[out] effecter_id - used to identify and access the effecter
444 * @param[out] effecter_data_size - The bit width and format of the setting
445 * value for the effecter.
446 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
447 * @param[out] effecter_value - The setting value of numeric effecter being
448 * requested.
449 * @return pldm_completion_codes
450 */
451int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
452 size_t payload_length,
453 uint16_t *effecter_id,
454 uint8_t *effecter_data_size,
455 uint8_t *effecter_value);
456
457/** @brief Create a PLDM response message for SetNumericEffecterValue
458 *
459 * @param[in] instance_id - Message's instance id
460 * @param[in] completion_code - PLDM completion code
461 * @param[out] msg - Message will be written to this
462 * @param[in] payload_length - Length of request message payload
463 * @return pldm_completion_codes
464 * @note Caller is responsible for memory alloc and dealloc of param
465 * 'msg.body.payload'
466 */
467int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
468 uint8_t completion_code,
469 struct pldm_msg *msg,
470 size_t payload_length);
471
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500472/* SetStateEffecterStates */
473
474/** @brief Create a PLDM response message for SetStateEffecterStates
475 *
476 * @param[in] instance_id - Message's instance id
477 * @param[in] completion_code - PLDM completion code
478 * @param[out] msg - Message will be written to this
479 * @return pldm_completion_codes
480 * @note Caller is responsible for memory alloc and dealloc of param
481 * 'msg.body.payload'
482 */
483
484int encode_set_state_effecter_states_resp(uint8_t instance_id,
485 uint8_t completion_code,
486 struct pldm_msg *msg);
487
488/** @brief Decode SetStateEffecterStates request data
489 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500490 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500491 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500492 * @param[out] effecter_id - used to identify and access the effecter
493 * @param[out] comp_effecter_count - number of individual sets of effecter
494 * information. Upto eight sets of state effecter info can be accessed
495 * for a given effecter.
496 * @param[out] field - each unit is an instance of the stateFileld structure
497 * that is used to set the requested state for a particular effecter
498 * within the state effecter. This field holds the starting address of
499 * the stateField values. The user is responsible to allocate the
500 * memory prior to calling this command. Since the state field count is
501 * not known in advance, the user should allocate the maximum size
502 * always, which is 8 in number.
503 * @return pldm_completion_codes
504 */
vkaverapa6575b82019-04-03 05:33:52 -0500505
Zahed Hossain223a73d2019-07-04 12:46:18 -0500506int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500507 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500508 uint16_t *effecter_id,
509 uint8_t *comp_effecter_count,
510 set_effecter_state_field *field);
511
Sampa Misra7fcfb662019-05-08 13:13:53 -0500512/* GetPDR */
513
514/** @brief Create a PLDM response message for GetPDR
515 *
516 * @param[in] instance_id - Message's instance id
517 * @param[in] completion_code - PLDM completion code
518 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
519 * the PDR Repository
520 * @param[in] next_data_transfer_hndl - A handle that identifies the next
521 * portion of the PDR data to be transferred, if any
522 * @param[in] transfer_flag - Indicates the portion of PDR data being
523 * transferred
524 * @param[in] resp_cnt - The number of recordData bytes returned in this
525 * response
526 * @param[in] record_data - PDR data bytes of length resp_cnt
527 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
528 * in the last part of a PDR being transferred
529 * @param[out] msg - Message will be written to this
530 * @return pldm_completion_codes
531 * @note Caller is responsible for memory alloc and dealloc of param
532 * 'msg.payload'
533 */
534int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
535 uint32_t next_record_hndl,
536 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
537 uint16_t resp_cnt, const uint8_t *record_data,
538 uint8_t transfer_crc, struct pldm_msg *msg);
539
540/** @brief Decode GetPDR request data
541 *
542 * @param[in] msg - Request message
543 * @param[in] payload_length - Length of request message payload
544 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
545 * @param[out] data_transfer_hndl - Handle used to identify a particular
546 * multipart PDR data transfer operation
547 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
548 * portion of transfer
549 * @param[out] request_cnt - The maximum number of record bytes requested
550 * @param[out] record_chg_num - Used to determine whether the PDR has changed
551 * while PDR transfer is going on
552 * @return pldm_completion_codes
553 */
554
555int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
556 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
557 uint8_t *transfer_op_flag, uint16_t *request_cnt,
558 uint16_t *record_chg_num);
559
Jolie Ku3557bad2020-03-02 16:22:57 +0800560/* GetStateSensorReadings */
561
562/** @brief Decode GetStateSensorReadings request data
563 *
564 * @param[in] msg - Request message
565 * @param[in] payload_length - Length of request message payload
566 * @param[out] sensor_id - used to identify and access the simple or composite
567 * sensor
568 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
569 * particular sensor within the state sensor, where bit [0] corresponds
570 * to the first state sensor (sensor offset 0) and bit [7] corresponds
571 * to the eighth sensor (sensor offset 7), sequentially.
572 * @param[out] reserved - value: 0x00
573 * @return pldm_completion_codes
574 */
575
576int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
577 size_t payload_length,
578 uint16_t *sensor_id,
579 bitfield8_t *sensor_rearm,
580 uint8_t *reserved);
581
582/** @brief Encode GetStateSensorReadings response data
583 *
584 * @param[in] instance_id - Message's instance id
585 * @param[in] completion_code - PLDM completion code
586 * @param[out] comp_sensor_count - The number of individual sets of sensor
587 * information that this command accesses
588 * @param[out] field - Each stateField is an instance of a stateField structure
589 * that is used to return the present operational state setting and the
590 * present state and event state for a particular set of sensor
591 * information contained within the state sensor
592 * @param[out] msg - Message will be written to this
593 * @return pldm_completion_codes
594 */
595
596int encode_get_state_sensor_readings_resp(uint8_t instance_id,
597 uint8_t completion_code,
598 uint8_t comp_sensor_count,
599 get_sensor_state_field *field,
600 struct pldm_msg *msg);
601
Jolie Ku6787f172020-03-19 11:15:53 +0800602/* GetNumericEffecterValue */
603
604/** @brief Decode GetNumericEffecterValue request data
605 *
606 * @param[in] msg - Request message
607 * @param[in] payload_length - Length of request message payload
608 * @param[out] effecter_id - used to identify and access the effecter
609 * @return pldm_completion_codes
610 */
611int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
612 size_t payload_length,
613 uint16_t *effecter_id);
614
615/** @brief Create a PLDM response message for GetNumericEffecterValue
616 *
617 * @param[in] instance_id - Message's instance id
618 * @param[in] completion_code - PLDM completion code
619 * @param[in] effecter_data_size - The bit width and format of the setting
620 * value for the effecter.
621 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
622 * @param[in] effecter_oper_state - The state of the effecter itself
623 * @param[in] pending_value - The pending numeric value setting of the
624 * effecter. The effecterDataSize field indicates the number of
625 * bits used for this field
626 * @param[in] present_value - The present numeric value setting of the
627 * effecter. The effecterDataSize indicates the number of bits
628 * used for this field
629 * @param[out] msg - Message will be written to this
630 * @param[in] payload_length - Length of request message payload
631 * @return pldm_completion_codes
632 * @note Caller is responsible for memory alloc and dealloc of param
633 * 'msg.payload'
634 */
635int encode_get_numeric_effecter_value_resp(
636 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
637 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
638 struct pldm_msg *msg, size_t payload_length);
639
Sampa Misra7fcfb662019-05-08 13:13:53 -0500640/* Requester */
641
George Liu820a9a52019-11-26 14:43:59 +0800642/* GetPDR */
643
644/** @brief Create a PLDM request message for GetPDR
645 *
646 * @param[in] instance_id - Message's instance id
647 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
648 * @param[in] data_transfer_hndl - Handle used to identify a particular
649 * multipart PDR data transfer operation
650 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
651 * portion of transfer
652 * @param[in] request_cnt - The maximum number of record bytes requested
653 * @param[in] record_chg_num - Used to determine whether the PDR has changed
654 * while PDR transfer is going on
655 * @param[out] msg - Message will be written to this
656 * @param[in] payload_length - Length of request message payload
657 * @return pldm_completion_codes
658 * @note Caller is responsible for memory alloc and dealloc of param
659 * 'msg.payload'
660 */
661int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
662 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
663 uint16_t request_cnt, uint16_t record_chg_num,
664 struct pldm_msg *msg, size_t payload_length);
665
666/** @brief Decode GetPDR response data
667 *
George Liu684a7162019-12-06 15:10:52 +0800668 * Note:
669 * * If the return value is not PLDM_SUCCESS, it represents a
670 * transport layer error.
671 * * If the completion_code value is not PLDM_SUCCESS, it represents a
672 * protocol layer error and all the out-parameters are invalid.
673 *
George Liu820a9a52019-11-26 14:43:59 +0800674 * @param[in] msg - Request message
675 * @param[in] payload_length - Length of request message payload
676 * @param[out] completion_code - PLDM completion code
677 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
678 * the PDR Repository
679 * @param[out] next_data_transfer_hndl - A handle that identifies the next
680 * portion of the PDR data to be transferred, if any
681 * @param[out] transfer_flag - Indicates the portion of PDR data being
682 * transferred
683 * @param[out] resp_cnt - The number of recordData bytes returned in this
684 * response
685 * @param[out] record_data - PDR data bytes of length resp_cnt
686 * @param[in] record_data_length - Length of record_data
687 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
688 * in the last part of a PDR being transferred
689 * @return pldm_completion_codes
690 */
691int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
692 uint8_t *completion_code, uint32_t *next_record_hndl,
693 uint32_t *next_data_transfer_hndl,
694 uint8_t *transfer_flag, uint16_t *resp_cnt,
695 uint8_t *record_data, size_t record_data_length,
696 uint8_t *transfer_crc);
697
Sampa Misra7fcfb662019-05-08 13:13:53 -0500698/* SetStateEffecterStates */
699
vkaverap98a2c192019-04-03 05:33:52 -0500700/** @brief Create a PLDM request message for SetStateEffecterStates
701 *
702 * @param[in] instance_id - Message's instance id
703 * @param[in] effecter_id - used to identify and access the effecter
704 * @param[in] comp_effecter_count - number of individual sets of effecter
705 * information. Upto eight sets of state effecter info can be accessed
706 * for a given effecter.
707 * @param[in] field - each unit is an instance of the stateField structure
708 * that is used to set the requested state for a particular effecter
709 * within the state effecter. This field holds the starting address of
710 * the stateField values. The user is responsible to allocate the
711 * memory prior to calling this command. The user has to allocate the
712 * field parameter as sizeof(set_effecter_state_field) *
713 * comp_effecter_count
714 * @param[out] msg - Message will be written to this
715 * @return pldm_completion_codes
716 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500717 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500718 */
719
720int encode_set_state_effecter_states_req(uint8_t instance_id,
721 uint16_t effecter_id,
722 uint8_t comp_effecter_count,
723 set_effecter_state_field *field,
724 struct pldm_msg *msg);
725
726/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800727 *
728 * Note:
729 * * If the return value is not PLDM_SUCCESS, it represents a
730 * transport layer error.
731 * * If the completion_code value is not PLDM_SUCCESS, it represents a
732 * protocol layer error and all the out-parameters are invalid.
733 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500734 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500735 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500736 * @param[out] completion_code - PLDM completion code
737 * @return pldm_completion_codes
738 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500739int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500740 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500741 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800742
743/* SetNumericEffecterValue */
744
745/** @brief Create a PLDM request message for SetNumericEffecterValue
746 *
747 * @param[in] instance_id - Message's instance id
748 * @param[in] effecter_id - used to identify and access the effecter
749 * @param[in] effecter_data_size - The bit width and format of the setting
750 * value for the effecter.
751 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
752 * @param[in] effecter_value - The setting value of numeric effecter being
753 * requested.
754 * @param[in] payload_length - Length of request message payload
755 * @param[out] msg - Message will be written to this
756 * @return pldm_completion_codes
757 * @note Caller is responsible for memory alloc and dealloc of param
758 * 'msg.payload'
759 */
760int encode_set_numeric_effecter_value_req(
761 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
762 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
763
764/** @brief Decode SetNumericEffecterValue response data
765 * @param[in] msg - Request message
766 * @param[in] payload_length - Length of response message payload
767 * @param[out] completion_code - PLDM completion code
768 * @return pldm_completion_codes
769 */
770int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
771 size_t payload_length,
772 uint8_t *completion_code);
773
Jolie Ku3557bad2020-03-02 16:22:57 +0800774/** @brief Create a PLDM request message for GetStateSensorReadings
775 *
776 * @param[in] instance_id - Message's instance id
777 * @param[in] sensor_id - used to identify and access the simple or composite
778 * sensor
779 * @param[in] sensorRearm - Each bit location in this field corresponds to a
780 * particular sensor within the state sensor, where bit [0] corresponds
781 * to the first state sensor (sensor offset 0) and bit [7] corresponds
782 * to the eighth sensor (sensor offset 7), sequentially
783 * @param[in] reserved - value: 0x00
784 * @param[out] msg - Message will be written to this
785 * @return pldm_completion_codes
786 * @note Caller is responsible for memory alloc and dealloc of param
787 * 'msg.payload'
788 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800789int encode_get_state_sensor_readings_req(uint8_t instance_id,
790 uint16_t sensor_id,
791 bitfield8_t sensor_rearm,
792 uint8_t reserved,
793 struct pldm_msg *msg);
794
795/** @brief Decode GetStateSensorReadings response data
796 *
797 * @param[in] msg - Request message
798 * @param[in] payload_length - Length of response message payload
799 * @param[out] completion_code - PLDM completion code
800 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
801 * information that this command accesses
802 * @param[out] field - Each stateField is an instance of a stateField structure
803 * that is used to return the present operational state setting and the
804 * present state and event state for a particular set of sensor
805 * information contained within the state sensor
806 * @return pldm_completion_codes
807 */
808
809int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
810 size_t payload_length,
811 uint8_t *completion_code,
812 uint8_t *comp_sensor_count,
813 get_sensor_state_field *field);
814
Zahed Hossaind4abab12020-02-06 03:36:43 -0600815/* PlatformEventMessage */
816
817/** @brief Decode PlatformEventMessage request data
818 * @param[in] msg - Request message
819 * @param[in] payload_length - Length of response message payload
820 * @param[out] format_version - Version of the event format
821 * @param[out] tid - Terminus ID for the terminus that originated the event
822 * message
823 * @param[out] event_class - The class of event being sent
824 * @param[out] event_data_offset - Offset where the event data should be read
825 * from pldm msg
826 * @return pldm_completion_codes
827 */
828int decode_platform_event_message_req(const struct pldm_msg *msg,
829 size_t payload_length,
830 uint8_t *format_version, uint8_t *tid,
831 uint8_t *event_class,
832 size_t *event_data_offset);
833
834/** @brief Encode PlatformEventMessage response data
835 * @param[in] instance_id - Message's instance id
836 * @param[in] completion_code - PLDM completion code
837 * @param[in] status - Response status of the event message command
838 * @param[out] msg - Message will be written to this
839 * @return pldm_completion_codes
840 * @note Caller is responsible for memory alloc and dealloc of param
841 * 'msg.payload'
842 */
843int encode_platform_event_message_resp(uint8_t instance_id,
844 uint8_t completion_code, uint8_t status,
845 struct pldm_msg *msg);
846
Zahed Hossain1c861712020-03-04 08:55:19 -0600847/** @brief Decode sensorEventData response data
848 *
849 * @param[in] event_data - event data from the response message
850 * @param[in] event_data_length - length of the event data
851 * @param[out] sensor_id - sensorID value of the sensor
852 * @param[out] sensor_event_class_type - Type of sensor event class
853 * @param[out] event_class_data_offset - Offset where the event class data
854 * should be read from event data
855 * @return pldm_completion_codes
856 * @note Caller is responsible for memory alloc and dealloc of param
857 * 'event_data'
858 */
859int decode_sensor_event_data(const uint8_t *event_data,
860 size_t event_data_length, uint16_t *sensor_id,
861 uint8_t *sensor_event_class_type,
862 size_t *event_class_data_offset);
863
864/** @brief Decode sensorOpState response data
865 *
866 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
867 * @param[in] sensor_data_length - Length of sensor_data
868 * @param[out] present_op_state - The sensorOperationalState value from the
869 * state change that triggered the event message
870 * @param[out] previous_op_state - The sensorOperationalState value for the
871 * state from which the present state was entered
872 * @return pldm_completion_codes
873 * @note Caller is responsible for memory alloc and dealloc of param
874 * 'sensor_data'
875 */
876int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
877 uint8_t *present_op_state,
878 uint8_t *previous_op_state);
879
880/** @brief Decode stateSensorState response data
881 *
882 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
883 * @param[in] sensor_data_length - Length of sensor_data
884 * @param[out] sensor_offset - Identifies which state sensor within a composite
885 * state sensor the event is being returned for
886 * @param[out] event_state - The event state value from the state change that
887 * triggered the event message
888 * @param[out] previous_event_state - The event state value for the state from
889 * which the present event state was entered
890 * @return pldm_completion_codes
891 * @note Caller is responsible for memory alloc and dealloc of param
892 * 'sensor_data'
893 */
894int decode_state_sensor_data(const uint8_t *sensor_data,
895 size_t sensor_data_length, uint8_t *sensor_offset,
896 uint8_t *event_state,
897 uint8_t *previous_event_state);
898
899/** @brief Decode numericSensorState response data
900 *
901 * @param[in] sensor_data - sensor_data for sensorEventClass =
902 * numericSensorState
903 * @param[in] sensor_data_length - Length of sensor_data
904 * @param[out] event_state - The eventState value from the state change that
905 * triggered the event message
906 * @param[out] previous_event_state - The eventState value for the state from
907 * which the present state was entered
908 * @param[out] sensor_data_size - The bit width and format of reading and
909 * threshold values that the sensor returns
910 * @param[out] present_reading - The present value indicated by the sensor
911 * @return pldm_completion_codes
912 * @note Caller is responsible for memory alloc and dealloc of param
913 * 'sensor_data'
914 */
915int decode_numeric_sensor_data(const uint8_t *sensor_data,
916 size_t sensor_data_length, uint8_t *event_state,
917 uint8_t *previous_event_state,
918 uint8_t *sensor_data_size,
919 uint32_t *present_reading);
920
Jolie Ku6787f172020-03-19 11:15:53 +0800921/* GetNumericEffecterValue */
922
923/** @brief Create a PLDM request message for GetNumericEffecterValue
924 *
925 * @param[in] instance_id - Message's instance id
926 * @param[in] effecter_id - used to identify and access the effecter
927 * @param[out] msg - Message will be written to this
928 * @return pldm_completion_codes
929 * @note Caller is responsible for memory alloc and dealloc of param
930 * 'msg.payload'
931 */
932int encode_get_numeric_effecter_value_req(uint8_t instance_id,
933 uint16_t effecter_id,
934 struct pldm_msg *msg);
935
936/** @brief Create a PLDM response message for GetNumericEffecterValue
937 *
938 * @param[in] msg - Request message
939 * @param[in] payload_length - Length of request message payload
940 * @param[out] completion_code - PLDM completion code
941 * @param[out] effecter_data_size - The bit width and format of the setting
942 * value for the effecter.
943 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
944 * @param[out] effecter_oper_state - The state of the effecter itself
945 * @param[out] pending_value - The pending numeric value setting of the
946 * effecter. The effecterDataSize field indicates the number of
947 * bits used for this field
948 * @param[out] present_value - The present numeric value setting of the
949 * effecter. The effecterDataSize indicates the number of bits
950 * used for this field
951 * @return pldm_completion_codes
952 */
953int decode_get_numeric_effecter_value_resp(
954 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
955 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
956 uint8_t *pending_value, uint8_t *present_value);
957
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500958#ifdef __cplusplus
959}
960#endif
961
962#endif /* PLATFORM_H */