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 | * |
Andrew Jeffery | 5aa765a | 2023-05-24 16:09:16 +0930 | [diff] [blame] | 21 | * @param[in] transport - Wait until this transport instance is ready |
| 22 | * @param[in] timeout - Wait for readiness for up to timeout milliseconds. |
| 23 | * Specifying a timeout value of zero yields an immediate return. |
| 24 | * Specifying a negative value means an indefinite timeout. |
| 25 | * |
Rashmica Gupta | c1b66f4 | 2022-12-09 16:24:45 +1100 | [diff] [blame] | 26 | * @return pldm_requester_rc_t (errno may be set) |
| 27 | */ |
| 28 | pldm_requester_rc_t pldm_transport_poll(struct pldm_transport *transport, |
| 29 | int timeout); |
| 30 | |
| 31 | /** |
| 32 | * @brief Asynchronously send a PLDM message. Control is immediately returned to |
| 33 | * the caller. |
| 34 | * |
| 35 | * @pre The pldm transport instance must be initialised; otherwise, |
| 36 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 37 | * TID to transport specific identifier mapping, this must already be set |
| 38 | * up. |
| 39 | * |
| 40 | * @param[in] ctx - pldm transport instance |
| 41 | * @param[in] tid - destination PLDM TID |
| 42 | * @param[in] pldm_req_msg - caller owned pointer to PLDM request msg or async |
| 43 | * notification. If this is NULL, PLDM_REQUESTER_INVALID_SETUP is |
| 44 | * returned. |
| 45 | * @param[in] req_msg_len - size of PLDM request msg. If this is less than the |
| 46 | * minimum size of a PLDM msg PLDM_REQUESTER_NOT_REQ_MSG is returned. |
| 47 | * Otherwise, if this is not the correct length of the PLDM msg, |
| 48 | * behaviour is undefined. |
| 49 | * |
| 50 | * @return pldm_requester_rc_t (errno may be set) |
| 51 | */ |
| 52 | pldm_requester_rc_t pldm_transport_send_msg(struct pldm_transport *transport, |
| 53 | pldm_tid_t tid, |
| 54 | const void *pldm_req_msg, |
| 55 | size_t req_msg_len); |
| 56 | |
| 57 | /** |
| 58 | * @brief Asynchronously get a PLDM response message for the given TID |
| 59 | * regardless of instance ID. Control is immediately returned to the |
| 60 | * caller. |
| 61 | * |
| 62 | * @pre The pldm transport instance must be initialised; otherwise, |
| 63 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 64 | * TID to transport specific identifier mapping, this must already be set |
| 65 | * up. |
| 66 | * |
| 67 | * @param[in] ctx - pldm transport instance |
| 68 | * @param[in] tid - destination PLDM TID |
| 69 | * @param[out] pldm_resp_msg - *pldm_resp_msg will point to PLDM response msg if |
| 70 | * return code is PLDM_REQUESTER_SUCCESS; otherwise, NULL. On |
| 71 | * success this function allocates memory, caller to |
| 72 | * free(*pldm_resp_msg). |
| 73 | * @param[out] resp_msg_len - caller owned pointer that will be made to point to |
| 74 | * the size of the PLDM response msg. If NULL, |
| 75 | * PLDM_REQUESTER_INVALID_SETUP is returned. |
| 76 | * |
| 77 | * @return pldm_requester_rc_t (errno may be set). Failure is returned if no |
| 78 | * PLDM response messages are available. |
| 79 | * |
| 80 | */ |
| 81 | pldm_requester_rc_t pldm_transport_recv_msg(struct pldm_transport *transport, |
| 82 | pldm_tid_t tid, |
| 83 | void **pldm_resp_msg, |
| 84 | size_t *resp_msg_len); |
| 85 | |
| 86 | /** |
| 87 | * @brief Synchronously send a PLDM request and receive the response. Control is |
| 88 | * returned to the caller once the response is received. |
| 89 | * |
| 90 | * @pre The pldm transport instance must be initialised; otherwise, |
| 91 | * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a |
| 92 | * TID to transport specific identifier mapping, this must already be set |
| 93 | * up. |
| 94 | * |
| 95 | * @param[in] ctx - pldm transport instance with a registered transport |
| 96 | * @param[in] tid - destination PLDM TID |
| 97 | * @param[in] pldm_req_msg - caller owned pointer to PLDM request msg or async |
| 98 | * notification. If NULL, PLDM_REQUESTER_INVALID_SETUP is returned. |
| 99 | * @param[in] req_msg_len - size of PLDM request msg. If this is less than the |
| 100 | * minimum size of a PLDM msg PLDM_REQUESTER_NOT_REQ_MSG is returned. |
| 101 | * Otherwise, if this is not the correct length of the PLDM msg, |
| 102 | * behaviour is undefined. |
| 103 | * @param[out] pldm_resp_msg - *pldm_resp_msg will point to PLDM response msg if |
| 104 | * return code is PLDM_REQUESTER_SUCCESS; otherwise, NULL. On |
| 105 | * success this function allocates memory, caller to |
| 106 | * free(*pldm_resp_msg). |
| 107 | * @param[out] resp_msg_len - caller owned pointer that will be made to point to |
| 108 | * the size of the PLDM response msg. If NULL, |
| 109 | * PLDM_REQUESTER_INVALID_SETUP is returned. |
| 110 | * |
| 111 | * @return pldm_requester_rc_t (errno may be set) |
| 112 | */ |
| 113 | pldm_requester_rc_t |
| 114 | pldm_transport_send_recv_msg(struct pldm_transport *transport, pldm_tid_t tid, |
| 115 | const void *pldm_req_msg, size_t req_msg_len, |
| 116 | void **pldm_resp_msg, size_t *resp_msg_len); |
| 117 | |
| 118 | #ifdef __cplusplus |
| 119 | } |
| 120 | #endif |
| 121 | |
| 122 | #endif /* TRANSPORT_PLDM_H */ |