blob: 700c3e6870232c27d47e220593fbd8cae9342246 [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
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* OEM_IBM_HOST_H */