xref: /dpdk/drivers/power/kvm_vm/guest_channel.h (revision 6f987b594fa6751b49769755fe1d1bf9f9d15ac4)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef GUEST_CHANNEL_H
6 #define GUEST_CHANNEL_H
7 
8 /**
9  * Check if any Virtio-Serial VM end-points exist in path.
10  *
11  * @param path
12  *  The path to the serial device on the filesystem
13  *
14  * @return
15  *  - 1 if at least one potential end-point found.
16  *  - 0 if no end-points found.
17  */
18 int guest_channel_host_check_exists(const char *path);
19 
20 /**
21  * Connect to the Virtio-Serial VM end-point located in path. It is
22  * thread safe for unique lcore_ids. This function must be only called once from
23  * each lcore.
24  *
25  * @param path
26  *  The path to the serial device on the filesystem
27  *
28  * @param lcore_id
29  *  lcore_id.
30  *
31  * @return
32  *  - 0 on success.
33  *  - Negative on error.
34  */
35 int guest_channel_host_connect(const char *path, unsigned int lcore_id);
36 
37 /**
38  * Disconnect from an already connected Virtio-Serial Endpoint.
39  *
40  *
41  * @param lcore_id
42  *  lcore_id.
43  */
44 void guest_channel_host_disconnect(unsigned int lcore_id);
45 
46 /**
47  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
48  *
49  * @param pkt
50  *  Pointer to a populated struct guest_agent_pkt
51  *
52  * @param lcore_id
53  *  lcore_id.
54  *
55  * @return
56  *  - 0 on success.
57  *  - Negative on channel not connected.
58  *  - errno on write to channel error.
59  */
60 int guest_channel_send_msg(struct rte_power_channel_packet *pkt,
61 		unsigned int lcore_id);
62 
63 /**
64  * Read a message contained in pkt over the Virtio-Serial
65  * from the host endpoint.
66  *
67  * @param pkt
68  *  Pointer to rte_power_channel_packet or
69  *  rte_power_channel_packet_freq_list struct.
70  *
71  * @param pkt_len
72  *  Size of expected data packet.
73  *
74  * @param lcore_id
75  *  lcore_id.
76  *
77  * @return
78  *  - 0 on success.
79  *  - Negative on error.
80  */
81 int power_guest_channel_read_msg(void *pkt,
82 		size_t pkt_len,
83 		unsigned int lcore_id);
84 
85 #endif /* GUEST_CHANNEL_H */
86