blob: 71273350cb9d1f75a996706cbb47441c56870ac6 [file] [log] [blame]
Rashmica Guptac1b66f42022-12-09 16:24:45 +11001#ifndef TRANSPORT_PLDM_H
2#define TRANSPORT_PLDM_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "libpldm/base.h"
9#include "libpldm/pldm.h"
10#include <stddef.h>
11
12struct 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 Jeffery5aa765a2023-05-24 16:09:16 +093021 * @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 Guptac1b66f42022-12-09 16:24:45 +110026 * @return pldm_requester_rc_t (errno may be set)
27 */
28pldm_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 */
52pldm_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 */
81pldm_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 *
Thu Nguyenb01fb1c2023-05-28 09:16:46 +070090 * pldm_transport_send_recv() will discard messages received on the underlying transport instance
91 * that are not a response that matches the request. Do not use this function if you're attempting
92 * to use the transport instance asynchronously, as this discard behaviour will affect other
93 * responses that you may care about.
94 *
Rashmica Guptac1b66f42022-12-09 16:24:45 +110095 * @pre The pldm transport instance must be initialised; otherwise,
96 * PLDM_REQUESTER_INVALID_SETUP is returned. If the transport requires a
97 * TID to transport specific identifier mapping, this must already be set
98 * up.
99 *
100 * @param[in] ctx - pldm transport instance with a registered transport
101 * @param[in] tid - destination PLDM TID
102 * @param[in] pldm_req_msg - caller owned pointer to PLDM request msg or async
103 * notification. If NULL, PLDM_REQUESTER_INVALID_SETUP is returned.
104 * @param[in] req_msg_len - size of PLDM request msg. If this is less than the
105 * minimum size of a PLDM msg PLDM_REQUESTER_NOT_REQ_MSG is returned.
106 * Otherwise, if this is not the correct length of the PLDM msg,
107 * behaviour is undefined.
108 * @param[out] pldm_resp_msg - *pldm_resp_msg will point to PLDM response msg if
109 * return code is PLDM_REQUESTER_SUCCESS; otherwise, NULL. On
110 * success this function allocates memory, caller to
111 * free(*pldm_resp_msg).
112 * @param[out] resp_msg_len - caller owned pointer that will be made to point to
113 * the size of the PLDM response msg. If NULL,
114 * PLDM_REQUESTER_INVALID_SETUP is returned.
115 *
116 * @return pldm_requester_rc_t (errno may be set)
117 */
118pldm_requester_rc_t
119pldm_transport_send_recv_msg(struct pldm_transport *transport, pldm_tid_t tid,
120 const void *pldm_req_msg, size_t req_msg_len,
121 void **pldm_resp_msg, size_t *resp_msg_len);
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* TRANSPORT_PLDM_H */