power: make channel message functions public
[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 <rte_power_guest_channel.h>
12
13 /**
14  * Check if any Virtio-Serial VM end-points exist in path.
15  *
16  * @param path
17  *  The path to the serial device on the filesystem
18  *
19  * @return
20  *  - 1 if at least one potential end-point found.
21  *  - 0 if no end-points found.
22  */
23 int guest_channel_host_check_exists(const char *path);
24
25 /**
26  * Connect to the Virtio-Serial VM end-point located in path. It is
27  * thread safe for unique lcore_ids. This function must be only called once from
28  * each lcore.
29  *
30  * @param path
31  *  The path to the serial device on the filesystem
32  *
33  * @param lcore_id
34  *  lcore_id.
35  *
36  * @return
37  *  - 0 on success.
38  *  - Negative on error.
39  */
40 int guest_channel_host_connect(const char *path, unsigned int lcore_id);
41
42 /**
43  * Disconnect from an already connected Virtio-Serial Endpoint.
44  *
45  *
46  * @param lcore_id
47  *  lcore_id.
48  *
49  */
50 void guest_channel_host_disconnect(unsigned int lcore_id);
51
52 /**
53  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
54  *
55  * @param pkt
56  *  Pointer to a populated struct guest_agent_pkt
57  *
58  * @param lcore_id
59  *  lcore_id.
60  *
61  * @return
62  *  - 0 on success.
63  *  - Negative on channel not connected.
64  *  - errno on write to channel error.
65  */
66 int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);
67
68 /**
69  * Read a message contained in pkt over the Virtio-Serial
70  * from the host endpoint.
71  *
72  * @param pkt
73  *  Pointer to channel_packet or
74  *  channel_packet_freq_list struct.
75  *
76  * @param pkt_len
77  *  Size of expected data packet.
78  *
79  * @param lcore_id
80  *  lcore_id.
81  *
82  * @return
83  *  - 0 on success.
84  *  - Negative on error.
85  */
86 int power_guest_channel_read_msg(void *pkt,
87                 size_t pkt_len,
88                 unsigned int lcore_id);
89
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #endif