blob: ed121ae0e77ca25b5f00bf58e7bdf5f288159458 [file] [log] [blame]
George Liu9008d282020-03-12 11:20:35 +08001#ifndef OEM_IBM_HOST_H
2#define OEM_IBM_HOST_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "base.h"
12
13/* Maximum size for request */
14#define PLDM_GET_ALERT_STATUS_REQ_BYTES 1
15
16/* Response lengths are inclusive of completion code */
17#define PLDM_GET_ALERT_STATUS_RESP_BYTES 9
18
19enum pldm_host_commands {
20 PLDM_HOST_GET_ALERT_STATUS = 0xF0 // Custom oem cmd
21};
22
23/** @brief PLDM Command specific codes
24 */
25enum pldm_host_completion_codes { PLDM_HOST_UNSUPPORTED_FORMAT_VERSION = 0x81 };
26
27/** @struct pldm_get_alert_states_resp
28 *
29 * Structure representing GetAlertStatus response packet
30 */
31struct pldm_get_alert_status_resp {
32 uint8_t completion_code;
33 uint32_t rack_entry;
34 uint32_t pri_cec_node;
35} __attribute__((packed));
36
37/* Requester */
38
39/* GetAlertStatus */
40
41/** @brief Create a PLDM request message for GetAlertStatus
42 *
43 * @param[in] instance_id - Message's instance id
44 * @param[in] version_id - The command/response format. 0x00 for this format
45 * @param[out] msg - Message will be written to this
46 * @param[in] payload_length - Length of request message payload
47 * @return pldm_completion_codes
48 * @note Caller is responsible for memory alloc and dealloc of param
49 * 'msg.payload'
50 */
51int encode_get_alert_status_req(uint8_t instance_id, uint8_t version_id,
52 struct pldm_msg *msg, size_t payload_length);
53
54/** @brief Decode GetAlertStatus response data
55 *
56 * Note:
57 * * If the return value is not PLDM_SUCCESS, it represents a
58 * transport layer error.
59 * * If the completion_code value is not PLDM_SUCCESS, it represents a
60 * protocol layer error and all the out-parameters are invalid.
61 *
62 * @param[in] msg - Request message
63 * @param[in] payload_length - Length of request message payload
64 * @param[out] completion_code - PLDM completion code
65 * @param[out] rack_entry - Enclosure ID, Alert Status, Flags, Config ID
66 * @param[out] pri_cec_node - Enclosure ID, Alert Status, Flags, Config ID
67 * @return pldm_completion_codes
68 */
69int decode_get_alert_status_resp(const struct pldm_msg *msg,
70 size_t payload_length,
71 uint8_t *completion_code, uint32_t *rack_entry,
72 uint32_t *pri_cec_node);
73
George Liu81caca52020-03-12 12:14:11 +080074/* Responder */
75
76/* GetAlertStatus */
77
78/** @brief Decode GetAlertStatus request data
79 *
80 * @param[in] msg - Request message
81 * @param[in] payload_length - Length of request message payload
82 * @param[out] version_id - the command/response format. 0x00 for this format
83 * @return pldm_completion_codes
84 */
85int decode_get_alert_status_req(const struct pldm_msg *msg,
86 size_t payload_length, uint8_t *version_id);
87
88/** @brief Create a PLDM OEM response message for GetAlertStatus
89 *
90 * @param[in] instance_id - Message's instance id
91 * @param[in] completion_code - PLDM completion code
92 * @param[in] rack_entry - Enclosure ID, Alert Status, Flags, Config ID
93 * @param[in] pri_cec_node - Enclosure ID, Alert Status, Flags, Config ID
94 * @param[out] msg - Message will be written to this
95 * @param[in] payload_length - Length of request message payload
96 * @return pldm_completion_codes
97 * @note Caller is responsible for memory alloc and dealloc of param
98 * 'msg.body.payload'
99 */
100int encode_get_alert_status_resp(uint8_t instance_id, uint8_t completion_code,
101 uint32_t rack_entry, uint32_t pri_cec_node,
102 struct pldm_msg *msg, size_t payload_length);
103
George Liu9008d282020-03-12 11:20:35 +0800104#ifdef __cplusplus
105}
106#endif
107
108#endif /* OEM_IBM_HOST_H */