025961606c47b783422b9ae6c9cfd9442a74580a
[dpdk.git] / lib / librte_power / guest_channel.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 #ifndef _GUEST_CHANNEL_H
5 #define _GUEST_CHANNEL_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 #include <channel_commands.h>
12
13 /**
14  * Connect to the Virtio-Serial VM end-point located in path. It is
15  * thread safe for unique lcore_ids. This function must be only called once from
16  * each lcore.
17  *
18  * @param path
19  *  The path to the serial device on the filesystem
20  *
21  * @param lcore_id
22  *  lcore_id.
23  *
24  * @return
25  *  - 0 on success.
26  *  - Negative on error.
27  */
28 int guest_channel_host_connect(const char *path, unsigned int lcore_id);
29
30 /**
31  * Disconnect from an already connected Virtio-Serial Endpoint.
32  *
33  *
34  * @param lcore_id
35  *  lcore_id.
36  *
37  */
38 void guest_channel_host_disconnect(unsigned int lcore_id);
39
40 /**
41  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
42  *
43  * @param pkt
44  *  Pointer to a populated struct guest_agent_pkt
45  *
46  * @param lcore_id
47  *  lcore_id.
48  *
49  * @return
50  *  - 0 on success.
51  *  - Negative on channel not connected.
52  *  - errno on write to channel error.
53  */
54 int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);
55
56 /**
57  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
58  *
59  * @param pkt
60  *  Pointer to a populated struct channel_packet
61  *
62  * @param lcore_id
63  *  lcore_id.
64  *
65  * @return
66  *  - 0 on success.
67  *  - Negative on error.
68  */
69 int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
70                         unsigned int lcore_id);
71
72 /**
73  * Read a message contained in pkt over the Virtio-Serial
74  * from the host endpoint.
75  *
76  * @param pkt
77  *  Pointer to channel_packet or
78  *  channel_packet_freq_list struct.
79  *
80  * @param pkt_len
81  *  Size of expected data packet.
82  *
83  * @param lcore_id
84  *  lcore_id.
85  *
86  * @return
87  *  - 0 on success.
88  *  - Negative on error.
89  */
90 int power_guest_channel_read_msg(void *pkt,
91                 size_t pkt_len,
92                 unsigned int lcore_id);
93
94 /**
95  * Receive a message contained in pkt over the Virtio-Serial
96  * from the host endpoint.
97  *
98  * @param pkt
99  *  Pointer to channel_packet or
100  *  channel_packet_freq_list struct.
101  *
102  * @param pkt_len
103  *  Size of expected data packet.
104  *
105  * @param lcore_id
106  *  lcore_id.
107  *
108  * @return
109  *  - 0 on success.
110  *  - Negative on error.
111  */
112 __rte_experimental
113 int
114 rte_power_guest_channel_receive_msg(void *pkt,
115                 size_t pkt_len,
116                 unsigned int lcore_id);
117
118
119 #ifdef __cplusplus
120 }
121 #endif
122
123 #endif