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