Rashmica Gupta | c1b66f4 | 2022-12-09 16:24:45 +1100 | [diff] [blame^] | 1 | #ifndef TRANSPORT_PLDM_H |
| 2 | #define TRANSPORT_PLDM_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include "libpldm/base.h" |
| 9 | #include "libpldm/pldm.h" |
| 10 | #include <stddef.h> |
| 11 | |
| 12 | struct pldm_transport; |
| 13 | |
| 14 | /** |
| 15 | * @brief Waits for a PLDM event. |
| 16 | * |
| 17 | * @pre The pldm transport instance must be initialised; otherwise, |
| 18 | * PLDM_REQUESTER_INVALID_SETUP is returned. This should be called after |
| 19 | * pldm_transport_send_msg has been called. |
| 20 | * |
| 21 | * @return pldm_requester_rc_t (errno may be set) |
| 22 | */ |
| 23 | pldm_requester_rc_t pldm_transport_poll(struct pldm_transport *transport, |
| 24 | int timeout); |
| 25 | |
| 26 | /** |
| 27 | * @brief Asynchronously send a PLDM message. Control is immediately returned to |
| 28 | * the caller. |
| 29 | * |
| 30 | * @pre The pldm transport instance must be initialised; otherwise, |
| 31 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 32 | * TID to transport specific identifier mapping, this must already be set |
| 33 | * up. |
| 34 | * |
| 35 | * @param[in] ctx - pldm transport instance |
| 36 | * @param[in] tid - destination PLDM TID |
| 37 | * @param[in] pldm_req_msg - caller owned pointer to PLDM request msg or async |
| 38 | * notification. If this is NULL, PLDM_REQUESTER_INVALID_SETUP is |
| 39 | * returned. |
| 40 | * @param[in] req_msg_len - size of PLDM request msg. If this is less than the |
| 41 | * minimum size of a PLDM msg PLDM_REQUESTER_NOT_REQ_MSG is returned. |
| 42 | * Otherwise, if this is not the correct length of the PLDM msg, |
| 43 | * behaviour is undefined. |
| 44 | * |
| 45 | * @return pldm_requester_rc_t (errno may be set) |
| 46 | */ |
| 47 | pldm_requester_rc_t pldm_transport_send_msg(struct pldm_transport *transport, |
| 48 | pldm_tid_t tid, |
| 49 | const void *pldm_req_msg, |
| 50 | size_t req_msg_len); |
| 51 | |
| 52 | /** |
| 53 | * @brief Asynchronously get a PLDM response message for the given TID |
| 54 | * regardless of instance ID. Control is immediately returned to the |
| 55 | * caller. |
| 56 | * |
| 57 | * @pre The pldm transport instance must be initialised; otherwise, |
| 58 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 59 | * TID to transport specific identifier mapping, this must already be set |
| 60 | * up. |
| 61 | * |
| 62 | * @param[in] ctx - pldm transport instance |
| 63 | * @param[in] tid - destination PLDM TID |
| 64 | * @param[out] pldm_resp_msg - *pldm_resp_msg will point to PLDM response msg if |
| 65 | * return code is PLDM_REQUESTER_SUCCESS; otherwise, NULL. On |
| 66 | * success this function allocates memory, caller to |
| 67 | * free(*pldm_resp_msg). |
| 68 | * @param[out] resp_msg_len - caller owned pointer that will be made to point to |
| 69 | * the size of the PLDM response msg. If NULL, |
| 70 | * PLDM_REQUESTER_INVALID_SETUP is returned. |
| 71 | * |
| 72 | * @return pldm_requester_rc_t (errno may be set). Failure is returned if no |
| 73 | * PLDM response messages are available. |
| 74 | * |
| 75 | */ |
| 76 | pldm_requester_rc_t pldm_transport_recv_msg(struct pldm_transport *transport, |
| 77 | pldm_tid_t tid, |
| 78 | void **pldm_resp_msg, |
| 79 | size_t *resp_msg_len); |
| 80 | |
| 81 | /** |
| 82 | * @brief Synchronously send a PLDM request and receive the response. Control is |
| 83 | * returned to the caller once the response is received. |
| 84 | * |
| 85 | * @pre The pldm transport instance must be initialised; otherwise, |
| 86 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 87 | * TID to transport specific identifier mapping, this must already be set |
| 88 | * up. |
| 89 | * |
| 90 | * @param[in] ctx - pldm transport instance with a registered transport |
| 91 | * @param[in] tid - destination PLDM TID |
| 92 | * @param[in] pldm_req_msg - caller owned pointer to PLDM request msg or async |
| 93 | * notification. If NULL, PLDM_REQUESTER_INVALID_SETUP is returned. |
| 94 | * @param[in] req_msg_len - size of PLDM request msg. If this is less than the |
| 95 | * minimum size of a PLDM msg PLDM_REQUESTER_NOT_REQ_MSG is returned. |
| 96 | * Otherwise, if this is not the correct length of the PLDM msg, |
| 97 | * behaviour is undefined. |
| 98 | * @param[out] pldm_resp_msg - *pldm_resp_msg will point to PLDM response msg if |
| 99 | * return code is PLDM_REQUESTER_SUCCESS; otherwise, NULL. On |
| 100 | * success this function allocates memory, caller to |
| 101 | * free(*pldm_resp_msg). |
| 102 | * @param[out] resp_msg_len - caller owned pointer that will be made to point to |
| 103 | * the size of the PLDM response msg. If NULL, |
| 104 | * PLDM_REQUESTER_INVALID_SETUP is returned. |
| 105 | * |
| 106 | * @return pldm_requester_rc_t (errno may be set) |
| 107 | */ |
| 108 | pldm_requester_rc_t |
| 109 | pldm_transport_send_recv_msg(struct pldm_transport *transport, pldm_tid_t tid, |
| 110 | const void *pldm_req_msg, size_t req_msg_len, |
| 111 | void **pldm_resp_msg, size_t *resp_msg_len); |
| 112 | |
| 113 | #ifdef __cplusplus |
| 114 | } |
| 115 | #endif |
| 116 | |
| 117 | #endif /* TRANSPORT_PLDM_H */ |