1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2 #ifndef LIBPLDM_AF_MCTP_H
3 #define LIBPLDM_AF_MCTP_H
4 
5 #include <libpldm/base.h>
6 #include <libpldm/pldm.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 struct pldm_transport_af_mctp;
13 struct sockaddr_mctp;
14 
15 /* Init the transport backend */
16 int pldm_transport_af_mctp_init(struct pldm_transport_af_mctp **ctx);
17 
18 /* Destroy the transport backend */
19 void pldm_transport_af_mctp_destroy(struct pldm_transport_af_mctp *ctx);
20 
21 /* Get the core pldm transport struct */
22 struct pldm_transport *
23 pldm_transport_af_mctp_core(struct pldm_transport_af_mctp *ctx);
24 
25 #ifdef PLDM_HAS_POLL
26 struct pollfd;
27 /* Init pollfd for async calls */
28 int pldm_transport_af_mctp_init_pollfd(struct pldm_transport *t,
29 				       struct pollfd *pollfd);
30 #endif
31 
32 /* Inserts a TID-to-EID mapping into the transport's device map */
33 int pldm_transport_af_mctp_map_tid(struct pldm_transport_af_mctp *ctx,
34 				   pldm_tid_t tid, mctp_eid_t eid);
35 
36 /* Removes a TID-to-EID mapping from the transport's device map */
37 int pldm_transport_af_mctp_unmap_tid(struct pldm_transport_af_mctp *ctx,
38 				     pldm_tid_t tid, mctp_eid_t eid);
39 
40 /**
41  * @brief Allow the transport to receive requests from remote endpoints
42  *
43  * @param[in] transport - The transport instance on which to listen for requests
44  * @param[in] smctp - The configuration provided to bind(2). NULL may be passed,
45  *		      in which case the transport is bound to all available
46  *		      interfaces on the system's default network. If NULL is
47  *		      passed then len must be zero.
48  * @param[in] len - The size of the object pointed to by the smctp argument. If
49  *		    smctp is NULL then len must be zero.
50  *
51  * @return PLDM_REQUESTER_SUCCESS on success, or a negative error code on
52  * failure.
53  */
54 int pldm_transport_af_mctp_bind(struct pldm_transport_af_mctp *transport,
55 				const struct sockaddr_mctp *smctp, size_t len);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif /* LIBPLDM_AF_MCTP*/
62