blob: 92b8b9de5c52235be55c4f146846469f807acae0 [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,
Zach Clark76728752020-03-31 10:44:09 -0500125
126 PLDM_PLATFORM_INVALID_DATA_TRANSFER_HANDLE = 0x80,
127 PLDM_PLATFORM_INVALID_TRANSFER_OPERATION_FLAG = 0x81,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530128 PLDM_PLATFORM_INVALID_RECORD_HANDLE = 0x82,
Zach Clark76728752020-03-31 10:44:09 -0500129 PLDM_PLATFORM_INVALID_RECORD_CHANGE_NUMBER = 0x83,
130 PLDM_PLATFORM_TRANSFER_TIMEOUT = 0x84,
131
Sampa Misraa2fa0702019-05-31 01:28:55 -0500132 PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE = 0x82,
Deepak Kodihalli557dfb02019-05-12 13:11:17 +0530133};
134
Zahed Hossaind4abab12020-02-06 03:36:43 -0600135/** @brief PLDM Event types
136 */
137enum pldm_event_types {
138 PLDM_SENSOR_EVENT = 0x00,
139 PLDM_EFFECTER_EVENT = 0x01,
140 PLDM_REDFISH_TASK_EXECUTED_EVENT = 0x02,
141 PLDM_REDFISH_MESSAGE_EVENT = 0x03,
142 PLDM_PDR_REPOSITORY_CHG_EVENT = 0x04,
143 PLDM_MESSAGE_POLL_EVENT = 0x05,
144 PLDM_HEARTBEAT_TIMER_ELAPSED_EVENT = 0x06
145};
146
147/** @brief PLDM sensorEventClass states
148 */
149enum sensor_event_class_states {
150 PLDM_SENSOR_OP_STATE,
151 PLDM_STATE_SENSOR_STATE,
152 PLDM_NUMERIC_SENSOR_STATE
153};
154
155/** @brief PLDM sensor supported states
156 */
157enum pldm_sensor_operational_state {
158 PLDM_SENSOR_ENABLED,
159 PLDM_SENSOR_DISABLED,
160 PLDM_SENSOR_UNAVAILABLE,
161 PLDM_SENSOR_STATUSUNKOWN,
162 PLDM_SENSOR_FAILED,
163 PLDM_SENSOR_INITIALIZING,
164 PLDM_SENSOR_SHUTTINGDOWN,
165 PLDM_SENSOR_INTEST
166};
167
168/** @brief PLDM pldmPDRRepositoryChgEvent class eventData format
169 */
170enum pldm_pdr_repository_chg_event_data_format {
171 REFRESH_ENTIRE_REPOSITORY,
172 FORMAT_IS_PDR_TYPES,
173 FORMAT_IS_PDR_HANDLES
174};
175
Zahed Hossain1c861712020-03-04 08:55:19 -0600176/** @brief PLDM NumericSensorStatePresentReading data type
177 */
178enum pldm_sensor_readings_data_type {
179 PLDM_SENSOR_DATA_SIZE_UINT8,
180 PLDM_SENSOR_DATA_SIZE_SINT8,
181 PLDM_SENSOR_DATA_SIZE_UINT16,
182 PLDM_SENSOR_DATA_SIZE_SINT16,
183 PLDM_SENSOR_DATA_SIZE_UINT32,
184 PLDM_SENSOR_DATA_SIZE_SINT32
185};
186
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500187/** @struct pldm_pdr_hdr
188 *
189 * Structure representing PLDM common PDR header
190 */
191struct pldm_pdr_hdr {
192 uint32_t record_handle;
193 uint8_t version;
194 uint8_t type;
195 uint16_t record_change_num;
196 uint16_t length;
197} __attribute__((packed));
198
Deepak Kodihalli5544ccd2020-03-15 23:36:16 -0500199/** @struct pldm_pdr_entity_association
200 *
201 * Structure representing PLDM Entity Association PDR
202 */
203struct pldm_pdr_entity_association {
204 uint16_t container_id;
205 uint8_t association_type;
206 pldm_entity container;
207 uint8_t num_children;
208 pldm_entity children[1];
209} __attribute__((packed));
210
Deepak Kodihallidb914672020-02-07 02:47:45 -0600211/** @struct pldm_pdr_fru_record_set
212 *
213 * Structure representing PLDM FRU record set PDR
214 */
215struct pldm_pdr_fru_record_set {
216 uint16_t terminus_handle;
217 uint16_t fru_rsi;
218 uint16_t entity_type;
219 uint16_t entity_instance_num;
220 uint16_t container_id;
221} __attribute__((packed));
222
Deepak Kodihallic6e8fb52019-05-02 08:35:31 -0500223/** @struct pldm_state_effecter_pdr
224 *
225 * Structure representing PLDM state effecter PDR
226 */
227struct pldm_state_effecter_pdr {
228 struct pldm_pdr_hdr hdr;
229 uint16_t terminus_handle;
230 uint16_t effecter_id;
231 uint16_t entity_type;
232 uint16_t entity_instance;
233 uint16_t container_id;
234 uint16_t effecter_semantic_id;
235 uint8_t effecter_init;
236 bool8_t has_description_pdr;
237 uint8_t composite_effecter_count;
238 uint8_t possible_states[1];
239} __attribute__((packed));
240
241/** @struct state_effecter_possible_states
242 *
243 * Structure representing state enums for state effecter
244 */
245struct state_effecter_possible_states {
246 uint16_t state_set_id;
247 uint8_t possible_states_size;
248 bitfield8_t states[1];
249} __attribute__((packed));
250
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500251/** @struct set_effecter_state_field
252 *
253 * Structure representing a stateField in SetStateEffecterStates command */
254
255typedef struct state_field_for_state_effecter_set {
256 uint8_t set_request; //!< Whether to change the state
257 uint8_t effecter_state; //!< Expected state of the effecter
258} __attribute__((packed)) set_effecter_state_field;
259
Jolie Ku3557bad2020-03-02 16:22:57 +0800260/** @struct get_sensor_readings_field
261 *
262 * Structure representing a stateField in GetStateSensorReadings command */
263
264typedef struct state_field_for_get_state_sensor_readings {
265 uint8_t sensor_op_state; //!< The state of the sensor itself
266 uint8_t present_state; //!< Return a state value
267 uint8_t previous_state; //!< The state that the presentState was entered
268 //! from. This must be different from the
269 //! present state
270 uint8_t event_state; //!< Return a state value from a PLDM State Set
271 //! that is associated with the sensor
272} __attribute__((packed)) get_sensor_state_field;
273
Priyanga7257fdf2019-06-10 01:59:45 -0500274/** @struct PLDM_SetStateEffecterStates_Request
275 *
276 * Structure representing PLDM set state effecter states request.
277 */
278struct pldm_set_state_effecter_states_req {
279 uint16_t effecter_id;
280 uint8_t comp_effecter_count;
281 set_effecter_state_field field[8];
282} __attribute__((packed));
283
Sampa Misra7fcfb662019-05-08 13:13:53 -0500284/** @struct pldm_get_pdr_resp
285 *
286 * structure representing GetPDR response packet
287 * transfer CRC is not part of the structure and will be
288 * added at the end of last packet in multipart transfer
289 */
290struct pldm_get_pdr_resp {
291 uint8_t completion_code;
292 uint32_t next_record_handle;
293 uint32_t next_data_transfer_handle;
294 uint8_t transfer_flag;
295 uint16_t response_count;
296 uint8_t record_data[1];
297} __attribute__((packed));
298
299/** @struct pldm_get_pdr_req
300 *
301 * structure representing GetPDR request packet
302 */
303struct pldm_get_pdr_req {
304 uint32_t record_handle;
305 uint32_t data_transfer_handle;
306 uint8_t transfer_op_flag;
307 uint16_t request_count;
308 uint16_t record_change_number;
309} __attribute__((packed));
310
George Liu30b859f2020-01-07 15:03:22 +0800311/** @struct pldm_set_numeric_effecter_value_req
312 *
313 * structure representing SetNumericEffecterValue request packet
314 */
315struct pldm_set_numeric_effecter_value_req {
316 uint16_t effecter_id;
317 uint8_t effecter_data_size;
318 uint8_t effecter_value[1];
319} __attribute__((packed));
320
Jolie Ku3557bad2020-03-02 16:22:57 +0800321/** @struct pldm_get_state_sensor_readings_req
322 *
323 * Structure representing PLDM get state sensor readings request.
324 */
325struct pldm_get_state_sensor_readings_req {
326 uint16_t sensor_id;
327 bitfield8_t sensor_rearm;
328 uint8_t reserved;
329} __attribute__((packed));
330
331/** @struct pldm_get_state_sensor_readings_resp
332 *
333 * Structure representing PLDM get state sensor readings response.
334 */
335struct pldm_get_state_sensor_readings_resp {
336 uint8_t completion_code;
337 uint8_t comp_sensor_count;
338 get_sensor_state_field field[1];
339} __attribute__((packed));
340
Zahed Hossaind4abab12020-02-06 03:36:43 -0600341/** @struct pldm_sensor_event
342 *
343 * structure representing sensorEventClass
344 */
345struct pldm_sensor_event_data {
346 uint16_t sensor_id;
347 uint8_t sensor_event_class_type;
348 uint8_t event_class[1];
349} __attribute__((packed));
350
351/** @struct pldm_state_sensor_state
352 *
353 * structure representing sensorEventClass for stateSensorState
354 */
355struct pldm_sensor_event_state_sensor_state {
356 uint8_t sensor_offset;
357 uint8_t event_state;
358 uint8_t previous_event_state;
359} __attribute__((packed));
360
361/** @struct pldm_sensor_event_numeric_sensor_state
362 *
363 * structure representing sensorEventClass for stateSensorState
364 */
365struct pldm_sensor_event_numeric_sensor_state {
366 uint8_t event_state;
367 uint8_t previous_event_state;
368 uint8_t sensor_data_size;
369 uint8_t present_reading[1];
370} __attribute__((packed));
371
372/** @struct pldm_sensor_event_sensor_op_state
373 *
374 * structure representing sensorEventClass for SensorOpState
375 */
376struct pldm_sensor_event_sensor_op_state {
377 uint8_t present_op_state;
378 uint8_t previous_op_state;
379} __attribute__((packed));
380
381/** @struct pldm_platform_event_message_req
382 *
383 * structure representing PlatformEventMessage command request data
384 */
385struct pldm_platform_event_message_req {
386 uint8_t format_version;
387 uint8_t tid;
388 uint8_t event_class;
389 uint8_t event_data[1];
390} __attribute__((packed));
391
392/** @struct pldm_platform_event_message_response
393 *
394 * structure representing PlatformEventMessage command response data
395 */
396struct pldm_platform_event_message_resp {
397 uint8_t completion_code;
398 uint8_t status;
399} __attribute__((packed));
400
401/** @struct pldm_pdr_repository_chg_event_data
402 *
403 * structure representing pldmPDRRepositoryChgEvent class eventData
404 */
405struct pldm_pdr_repository_chg_event_data {
406 uint8_t event_data_format;
407 uint8_t number_of_change_records;
408 uint8_t change_records[1];
409} __attribute__((packed));
410
411/** @struct pldm_pdr_repository_chg_event_change_record_data
412 *
413 * structure representing pldmPDRRepositoryChgEvent class eventData's change
414 * record data
415 */
416struct pldm_pdr_repository_change_record_data {
417 uint8_t event_data_operation;
418 uint8_t number_of_change_entries;
419 uint32_t change_entry[1];
420} __attribute__((packed));
421
Jolie Ku6787f172020-03-19 11:15:53 +0800422/** @struct pldm_get_numeric_effecter_value_req
423 *
424 * structure representing GetNumericEffecterValue request packet
425 */
426struct pldm_get_numeric_effecter_value_req {
427 uint16_t effecter_id;
428} __attribute__((packed));
429
430/** @struct pldm_get_numeric_effecter_value_resp
431 *
432 * structure representing GetNumericEffecterValue response packet
433 */
434struct pldm_get_numeric_effecter_value_resp {
435 uint8_t completion_code;
436 uint8_t effecter_data_size;
437 uint8_t effecter_oper_state;
438 uint8_t pending_and_present_values[1];
439} __attribute__((packed));
440
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500441/* Responder */
442
George Liu30b859f2020-01-07 15:03:22 +0800443/* SetNumericEffecterValue */
444
445/** @brief Decode SetNumericEffecterValue request data
446 *
447 * @param[in] msg - Request message
448 * @param[in] payload_length - Length of request message payload
449 * @param[out] effecter_id - used to identify and access the effecter
450 * @param[out] effecter_data_size - The bit width and format of the setting
451 * value for the effecter.
452 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
453 * @param[out] effecter_value - The setting value of numeric effecter being
454 * requested.
455 * @return pldm_completion_codes
456 */
457int decode_set_numeric_effecter_value_req(const struct pldm_msg *msg,
458 size_t payload_length,
459 uint16_t *effecter_id,
460 uint8_t *effecter_data_size,
461 uint8_t *effecter_value);
462
463/** @brief Create a PLDM response message for SetNumericEffecterValue
464 *
465 * @param[in] instance_id - Message's instance id
466 * @param[in] completion_code - PLDM completion code
467 * @param[out] msg - Message will be written to this
468 * @param[in] payload_length - Length of request message payload
469 * @return pldm_completion_codes
470 * @note Caller is responsible for memory alloc and dealloc of param
471 * 'msg.body.payload'
472 */
473int encode_set_numeric_effecter_value_resp(uint8_t instance_id,
474 uint8_t completion_code,
475 struct pldm_msg *msg,
476 size_t payload_length);
477
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500478/* SetStateEffecterStates */
479
480/** @brief Create a PLDM response message for SetStateEffecterStates
481 *
482 * @param[in] instance_id - Message's instance id
483 * @param[in] completion_code - PLDM completion code
484 * @param[out] msg - Message will be written to this
485 * @return pldm_completion_codes
486 * @note Caller is responsible for memory alloc and dealloc of param
487 * 'msg.body.payload'
488 */
489
490int encode_set_state_effecter_states_resp(uint8_t instance_id,
491 uint8_t completion_code,
492 struct pldm_msg *msg);
493
494/** @brief Decode SetStateEffecterStates request data
495 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500496 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500497 * @param[in] payload_length - Length of request message payload
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500498 * @param[out] effecter_id - used to identify and access the effecter
499 * @param[out] comp_effecter_count - number of individual sets of effecter
500 * information. Upto eight sets of state effecter info can be accessed
501 * for a given effecter.
502 * @param[out] field - each unit is an instance of the stateFileld structure
503 * that is used to set the requested state for a particular effecter
504 * within the state effecter. This field holds the starting address of
505 * the stateField values. The user is responsible to allocate the
506 * memory prior to calling this command. Since the state field count is
507 * not known in advance, the user should allocate the maximum size
508 * always, which is 8 in number.
509 * @return pldm_completion_codes
510 */
vkaverapa6575b82019-04-03 05:33:52 -0500511
Zahed Hossain223a73d2019-07-04 12:46:18 -0500512int decode_set_state_effecter_states_req(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500513 size_t payload_length,
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500514 uint16_t *effecter_id,
515 uint8_t *comp_effecter_count,
516 set_effecter_state_field *field);
517
Sampa Misra7fcfb662019-05-08 13:13:53 -0500518/* GetPDR */
519
520/** @brief Create a PLDM response message for GetPDR
521 *
522 * @param[in] instance_id - Message's instance id
523 * @param[in] completion_code - PLDM completion code
524 * @param[in] next_record_hndl - The recordHandle for the PDR that is next in
525 * the PDR Repository
526 * @param[in] next_data_transfer_hndl - A handle that identifies the next
527 * portion of the PDR data to be transferred, if any
528 * @param[in] transfer_flag - Indicates the portion of PDR data being
529 * transferred
530 * @param[in] resp_cnt - The number of recordData bytes returned in this
531 * response
532 * @param[in] record_data - PDR data bytes of length resp_cnt
533 * @param[in] transfer_crc - A CRC-8 for the overall PDR. This is present only
534 * in the last part of a PDR being transferred
535 * @param[out] msg - Message will be written to this
536 * @return pldm_completion_codes
537 * @note Caller is responsible for memory alloc and dealloc of param
538 * 'msg.payload'
539 */
540int encode_get_pdr_resp(uint8_t instance_id, uint8_t completion_code,
541 uint32_t next_record_hndl,
542 uint32_t next_data_transfer_hndl, uint8_t transfer_flag,
543 uint16_t resp_cnt, const uint8_t *record_data,
544 uint8_t transfer_crc, struct pldm_msg *msg);
545
546/** @brief Decode GetPDR request data
547 *
548 * @param[in] msg - Request message
549 * @param[in] payload_length - Length of request message payload
550 * @param[out] record_hndl - The recordHandle value for the PDR to be retrieved
551 * @param[out] data_transfer_hndl - Handle used to identify a particular
552 * multipart PDR data transfer operation
553 * @param[out] transfer_op_flag - Flag to indicate the first or subsequent
554 * portion of transfer
555 * @param[out] request_cnt - The maximum number of record bytes requested
556 * @param[out] record_chg_num - Used to determine whether the PDR has changed
557 * while PDR transfer is going on
558 * @return pldm_completion_codes
559 */
560
561int decode_get_pdr_req(const struct pldm_msg *msg, size_t payload_length,
562 uint32_t *record_hndl, uint32_t *data_transfer_hndl,
563 uint8_t *transfer_op_flag, uint16_t *request_cnt,
564 uint16_t *record_chg_num);
565
Jolie Ku3557bad2020-03-02 16:22:57 +0800566/* GetStateSensorReadings */
567
568/** @brief Decode GetStateSensorReadings request data
569 *
570 * @param[in] msg - Request message
571 * @param[in] payload_length - Length of request message payload
572 * @param[out] sensor_id - used to identify and access the simple or composite
573 * sensor
574 * @param[out] sensor_rearm - Each bit location in this field corresponds to a
575 * particular sensor within the state sensor, where bit [0] corresponds
576 * to the first state sensor (sensor offset 0) and bit [7] corresponds
577 * to the eighth sensor (sensor offset 7), sequentially.
578 * @param[out] reserved - value: 0x00
579 * @return pldm_completion_codes
580 */
581
582int decode_get_state_sensor_readings_req(const struct pldm_msg *msg,
583 size_t payload_length,
584 uint16_t *sensor_id,
585 bitfield8_t *sensor_rearm,
586 uint8_t *reserved);
587
588/** @brief Encode GetStateSensorReadings response data
589 *
590 * @param[in] instance_id - Message's instance id
591 * @param[in] completion_code - PLDM completion code
592 * @param[out] comp_sensor_count - The number of individual sets of sensor
593 * information that this command accesses
594 * @param[out] field - Each stateField is an instance of a stateField structure
595 * that is used to return the present operational state setting and the
596 * present state and event state for a particular set of sensor
597 * information contained within the state sensor
598 * @param[out] msg - Message will be written to this
599 * @return pldm_completion_codes
600 */
601
602int encode_get_state_sensor_readings_resp(uint8_t instance_id,
603 uint8_t completion_code,
604 uint8_t comp_sensor_count,
605 get_sensor_state_field *field,
606 struct pldm_msg *msg);
607
Jolie Ku6787f172020-03-19 11:15:53 +0800608/* GetNumericEffecterValue */
609
610/** @brief Decode GetNumericEffecterValue request data
611 *
612 * @param[in] msg - Request message
613 * @param[in] payload_length - Length of request message payload
614 * @param[out] effecter_id - used to identify and access the effecter
615 * @return pldm_completion_codes
616 */
617int decode_get_numeric_effecter_value_req(const struct pldm_msg *msg,
618 size_t payload_length,
619 uint16_t *effecter_id);
620
621/** @brief Create a PLDM response message for GetNumericEffecterValue
622 *
623 * @param[in] instance_id - Message's instance id
624 * @param[in] completion_code - PLDM completion code
625 * @param[in] effecter_data_size - The bit width and format of the setting
626 * value for the effecter.
627 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
628 * @param[in] effecter_oper_state - The state of the effecter itself
629 * @param[in] pending_value - The pending numeric value setting of the
630 * effecter. The effecterDataSize field indicates the number of
631 * bits used for this field
632 * @param[in] present_value - The present numeric value setting of the
633 * effecter. The effecterDataSize indicates the number of bits
634 * used for this field
635 * @param[out] msg - Message will be written to this
636 * @param[in] payload_length - Length of request message payload
637 * @return pldm_completion_codes
638 * @note Caller is responsible for memory alloc and dealloc of param
639 * 'msg.payload'
640 */
641int encode_get_numeric_effecter_value_resp(
642 uint8_t instance_id, uint8_t completion_code, uint8_t effecter_data_size,
643 uint8_t effecter_oper_state, uint8_t *pending_value, uint8_t *present_value,
644 struct pldm_msg *msg, size_t payload_length);
645
Sampa Misra7fcfb662019-05-08 13:13:53 -0500646/* Requester */
647
George Liu820a9a52019-11-26 14:43:59 +0800648/* GetPDR */
649
650/** @brief Create a PLDM request message for GetPDR
651 *
652 * @param[in] instance_id - Message's instance id
653 * @param[in] record_hndl - The recordHandle value for the PDR to be retrieved
654 * @param[in] data_transfer_hndl - Handle used to identify a particular
655 * multipart PDR data transfer operation
656 * @param[in] transfer_op_flag - Flag to indicate the first or subsequent
657 * portion of transfer
658 * @param[in] request_cnt - The maximum number of record bytes requested
659 * @param[in] record_chg_num - Used to determine whether the PDR has changed
660 * while PDR transfer is going on
661 * @param[out] msg - Message will be written to this
662 * @param[in] payload_length - Length of request message payload
663 * @return pldm_completion_codes
664 * @note Caller is responsible for memory alloc and dealloc of param
665 * 'msg.payload'
666 */
667int encode_get_pdr_req(uint8_t instance_id, uint32_t record_hndl,
668 uint32_t data_transfer_hndl, uint8_t transfer_op_flag,
669 uint16_t request_cnt, uint16_t record_chg_num,
670 struct pldm_msg *msg, size_t payload_length);
671
672/** @brief Decode GetPDR response data
673 *
George Liu684a7162019-12-06 15:10:52 +0800674 * Note:
675 * * If the return value is not PLDM_SUCCESS, it represents a
676 * transport layer error.
677 * * If the completion_code value is not PLDM_SUCCESS, it represents a
678 * protocol layer error and all the out-parameters are invalid.
679 *
George Liu820a9a52019-11-26 14:43:59 +0800680 * @param[in] msg - Request message
681 * @param[in] payload_length - Length of request message payload
682 * @param[out] completion_code - PLDM completion code
683 * @param[out] next_record_hndl - The recordHandle for the PDR that is next in
684 * the PDR Repository
685 * @param[out] next_data_transfer_hndl - A handle that identifies the next
686 * portion of the PDR data to be transferred, if any
687 * @param[out] transfer_flag - Indicates the portion of PDR data being
688 * transferred
689 * @param[out] resp_cnt - The number of recordData bytes returned in this
690 * response
Zach Clark3dba2bf2020-03-31 10:58:03 -0500691 * @param[out] record_data - PDR data bytes of length resp_cnt, or NULL to
692 * skip the copy and place the actual length in resp_cnt.
George Liu820a9a52019-11-26 14:43:59 +0800693 * @param[in] record_data_length - Length of record_data
694 * @param[out] transfer_crc - A CRC-8 for the overall PDR. This is present only
695 * in the last part of a PDR being transferred
696 * @return pldm_completion_codes
697 */
698int decode_get_pdr_resp(const struct pldm_msg *msg, size_t payload_length,
699 uint8_t *completion_code, uint32_t *next_record_hndl,
700 uint32_t *next_data_transfer_hndl,
701 uint8_t *transfer_flag, uint16_t *resp_cnt,
702 uint8_t *record_data, size_t record_data_length,
703 uint8_t *transfer_crc);
704
Sampa Misra7fcfb662019-05-08 13:13:53 -0500705/* SetStateEffecterStates */
706
vkaverap98a2c192019-04-03 05:33:52 -0500707/** @brief Create a PLDM request message for SetStateEffecterStates
708 *
709 * @param[in] instance_id - Message's instance id
710 * @param[in] effecter_id - used to identify and access the effecter
711 * @param[in] comp_effecter_count - number of individual sets of effecter
712 * information. Upto eight sets of state effecter info can be accessed
713 * for a given effecter.
714 * @param[in] field - each unit is an instance of the stateField structure
715 * that is used to set the requested state for a particular effecter
716 * within the state effecter. This field holds the starting address of
717 * the stateField values. The user is responsible to allocate the
718 * memory prior to calling this command. The user has to allocate the
719 * field parameter as sizeof(set_effecter_state_field) *
720 * comp_effecter_count
721 * @param[out] msg - Message will be written to this
722 * @return pldm_completion_codes
723 * @note Caller is responsible for memory alloc and dealloc of param
vkaverapa6575b82019-04-03 05:33:52 -0500724 * 'msg.payload'
vkaverap98a2c192019-04-03 05:33:52 -0500725 */
726
727int encode_set_state_effecter_states_req(uint8_t instance_id,
728 uint16_t effecter_id,
729 uint8_t comp_effecter_count,
730 set_effecter_state_field *field,
731 struct pldm_msg *msg);
732
733/** @brief Decode SetStateEffecterStates response data
George Liu684a7162019-12-06 15:10:52 +0800734 *
735 * Note:
736 * * If the return value is not PLDM_SUCCESS, it represents a
737 * transport layer error.
738 * * If the completion_code value is not PLDM_SUCCESS, it represents a
739 * protocol layer error and all the out-parameters are invalid.
740 *
Zahed Hossain223a73d2019-07-04 12:46:18 -0500741 * @param[in] msg - Request message
vkaverapa6575b82019-04-03 05:33:52 -0500742 * @param[in] payload_length - Length of response message payload
vkaverap98a2c192019-04-03 05:33:52 -0500743 * @param[out] completion_code - PLDM completion code
744 * @return pldm_completion_codes
745 */
Zahed Hossain223a73d2019-07-04 12:46:18 -0500746int decode_set_state_effecter_states_resp(const struct pldm_msg *msg,
vkaverapa6575b82019-04-03 05:33:52 -0500747 size_t payload_length,
vkaverap98a2c192019-04-03 05:33:52 -0500748 uint8_t *completion_code);
George Liu30b859f2020-01-07 15:03:22 +0800749
750/* SetNumericEffecterValue */
751
752/** @brief Create a PLDM request message for SetNumericEffecterValue
753 *
754 * @param[in] instance_id - Message's instance id
755 * @param[in] effecter_id - used to identify and access the effecter
756 * @param[in] effecter_data_size - The bit width and format of the setting
757 * value for the effecter.
758 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
759 * @param[in] effecter_value - The setting value of numeric effecter being
760 * requested.
761 * @param[in] payload_length - Length of request message payload
762 * @param[out] msg - Message will be written to this
763 * @return pldm_completion_codes
764 * @note Caller is responsible for memory alloc and dealloc of param
765 * 'msg.payload'
766 */
767int encode_set_numeric_effecter_value_req(
768 uint8_t instance_id, uint16_t effecter_id, uint8_t effecter_data_size,
769 uint8_t *effecter_value, struct pldm_msg *msg, size_t payload_length);
770
771/** @brief Decode SetNumericEffecterValue response data
772 * @param[in] msg - Request message
773 * @param[in] payload_length - Length of response message payload
774 * @param[out] completion_code - PLDM completion code
775 * @return pldm_completion_codes
776 */
777int decode_set_numeric_effecter_value_resp(const struct pldm_msg *msg,
778 size_t payload_length,
779 uint8_t *completion_code);
780
Jolie Ku3557bad2020-03-02 16:22:57 +0800781/** @brief Create a PLDM request message for GetStateSensorReadings
782 *
783 * @param[in] instance_id - Message's instance id
784 * @param[in] sensor_id - used to identify and access the simple or composite
785 * sensor
786 * @param[in] sensorRearm - Each bit location in this field corresponds to a
787 * particular sensor within the state sensor, where bit [0] corresponds
788 * to the first state sensor (sensor offset 0) and bit [7] corresponds
789 * to the eighth sensor (sensor offset 7), sequentially
790 * @param[in] reserved - value: 0x00
791 * @param[out] msg - Message will be written to this
792 * @return pldm_completion_codes
793 * @note Caller is responsible for memory alloc and dealloc of param
794 * 'msg.payload'
795 */
Jolie Ku3557bad2020-03-02 16:22:57 +0800796int encode_get_state_sensor_readings_req(uint8_t instance_id,
797 uint16_t sensor_id,
798 bitfield8_t sensor_rearm,
799 uint8_t reserved,
800 struct pldm_msg *msg);
801
802/** @brief Decode GetStateSensorReadings response data
803 *
804 * @param[in] msg - Request message
805 * @param[in] payload_length - Length of response message payload
806 * @param[out] completion_code - PLDM completion code
807 * @param[in,out] comp_sensor_count - The number of individual sets of sensor
808 * information that this command accesses
809 * @param[out] field - Each stateField is an instance of a stateField structure
810 * that is used to return the present operational state setting and the
811 * present state and event state for a particular set of sensor
812 * information contained within the state sensor
813 * @return pldm_completion_codes
814 */
815
816int decode_get_state_sensor_readings_resp(const struct pldm_msg *msg,
817 size_t payload_length,
818 uint8_t *completion_code,
819 uint8_t *comp_sensor_count,
820 get_sensor_state_field *field);
821
Zahed Hossaind4abab12020-02-06 03:36:43 -0600822/* PlatformEventMessage */
823
824/** @brief Decode PlatformEventMessage request data
825 * @param[in] msg - Request message
826 * @param[in] payload_length - Length of response message payload
827 * @param[out] format_version - Version of the event format
828 * @param[out] tid - Terminus ID for the terminus that originated the event
829 * message
830 * @param[out] event_class - The class of event being sent
831 * @param[out] event_data_offset - Offset where the event data should be read
832 * from pldm msg
833 * @return pldm_completion_codes
834 */
835int decode_platform_event_message_req(const struct pldm_msg *msg,
836 size_t payload_length,
837 uint8_t *format_version, uint8_t *tid,
838 uint8_t *event_class,
839 size_t *event_data_offset);
840
841/** @brief Encode PlatformEventMessage response data
842 * @param[in] instance_id - Message's instance id
843 * @param[in] completion_code - PLDM completion code
844 * @param[in] status - Response status of the event message command
845 * @param[out] msg - Message will be written to this
846 * @return pldm_completion_codes
847 * @note Caller is responsible for memory alloc and dealloc of param
848 * 'msg.payload'
849 */
850int encode_platform_event_message_resp(uint8_t instance_id,
851 uint8_t completion_code, uint8_t status,
852 struct pldm_msg *msg);
853
Zahed Hossain1c861712020-03-04 08:55:19 -0600854/** @brief Decode sensorEventData response data
855 *
856 * @param[in] event_data - event data from the response message
857 * @param[in] event_data_length - length of the event data
858 * @param[out] sensor_id - sensorID value of the sensor
859 * @param[out] sensor_event_class_type - Type of sensor event class
860 * @param[out] event_class_data_offset - Offset where the event class data
861 * should be read from event data
862 * @return pldm_completion_codes
863 * @note Caller is responsible for memory alloc and dealloc of param
864 * 'event_data'
865 */
866int decode_sensor_event_data(const uint8_t *event_data,
867 size_t event_data_length, uint16_t *sensor_id,
868 uint8_t *sensor_event_class_type,
869 size_t *event_class_data_offset);
870
871/** @brief Decode sensorOpState response data
872 *
873 * @param[in] sensor_data - sensor_data for sensorEventClass = sensorOpState
874 * @param[in] sensor_data_length - Length of sensor_data
875 * @param[out] present_op_state - The sensorOperationalState value from the
876 * state change that triggered the event message
877 * @param[out] previous_op_state - The sensorOperationalState value for the
878 * state from which the present state was entered
879 * @return pldm_completion_codes
880 * @note Caller is responsible for memory alloc and dealloc of param
881 * 'sensor_data'
882 */
883int decode_sensor_op_data(const uint8_t *sensor_data, size_t sensor_data_length,
884 uint8_t *present_op_state,
885 uint8_t *previous_op_state);
886
887/** @brief Decode stateSensorState response data
888 *
889 * @param[in] sensor_data - sensor_data for sensorEventClass = stateSensorState
890 * @param[in] sensor_data_length - Length of sensor_data
891 * @param[out] sensor_offset - Identifies which state sensor within a composite
892 * state sensor the event is being returned for
893 * @param[out] event_state - The event state value from the state change that
894 * triggered the event message
895 * @param[out] previous_event_state - The event state value for the state from
896 * which the present event state was entered
897 * @return pldm_completion_codes
898 * @note Caller is responsible for memory alloc and dealloc of param
899 * 'sensor_data'
900 */
901int decode_state_sensor_data(const uint8_t *sensor_data,
902 size_t sensor_data_length, uint8_t *sensor_offset,
903 uint8_t *event_state,
904 uint8_t *previous_event_state);
905
906/** @brief Decode numericSensorState response data
907 *
908 * @param[in] sensor_data - sensor_data for sensorEventClass =
909 * numericSensorState
910 * @param[in] sensor_data_length - Length of sensor_data
911 * @param[out] event_state - The eventState value from the state change that
912 * triggered the event message
913 * @param[out] previous_event_state - The eventState value for the state from
914 * which the present state was entered
915 * @param[out] sensor_data_size - The bit width and format of reading and
916 * threshold values that the sensor returns
917 * @param[out] present_reading - The present value indicated by the sensor
918 * @return pldm_completion_codes
919 * @note Caller is responsible for memory alloc and dealloc of param
920 * 'sensor_data'
921 */
922int decode_numeric_sensor_data(const uint8_t *sensor_data,
923 size_t sensor_data_length, uint8_t *event_state,
924 uint8_t *previous_event_state,
925 uint8_t *sensor_data_size,
926 uint32_t *present_reading);
927
Jolie Ku6787f172020-03-19 11:15:53 +0800928/* GetNumericEffecterValue */
929
930/** @brief Create a PLDM request message for GetNumericEffecterValue
931 *
932 * @param[in] instance_id - Message's instance id
933 * @param[in] effecter_id - used to identify and access the effecter
934 * @param[out] msg - Message will be written to this
935 * @return pldm_completion_codes
936 * @note Caller is responsible for memory alloc and dealloc of param
937 * 'msg.payload'
938 */
939int encode_get_numeric_effecter_value_req(uint8_t instance_id,
940 uint16_t effecter_id,
941 struct pldm_msg *msg);
942
943/** @brief Create a PLDM response message for GetNumericEffecterValue
944 *
945 * @param[in] msg - Request message
946 * @param[in] payload_length - Length of request message payload
947 * @param[out] completion_code - PLDM completion code
948 * @param[out] effecter_data_size - The bit width and format of the setting
949 * value for the effecter.
950 * value:{uint8,sint8,uint16,sint16,uint32,sint32}
951 * @param[out] effecter_oper_state - The state of the effecter itself
952 * @param[out] pending_value - The pending numeric value setting of the
953 * effecter. The effecterDataSize field indicates the number of
954 * bits used for this field
955 * @param[out] present_value - The present numeric value setting of the
956 * effecter. The effecterDataSize indicates the number of bits
957 * used for this field
958 * @return pldm_completion_codes
959 */
960int decode_get_numeric_effecter_value_resp(
961 const struct pldm_msg *msg, size_t payload_length, uint8_t *completion_code,
962 uint8_t *effecter_data_size, uint8_t *effecter_oper_state,
963 uint8_t *pending_value, uint8_t *present_value);
964
Sampa Misra0db1dfa2019-03-19 00:15:31 -0500965#ifdef __cplusplus
966}
967#endif
968
969#endif /* PLATFORM_H */