New upstream version 18.02
[deb_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  * @param lcore_id
21  *  lcore_id.
22  *
23  * @return
24  *  - 0 on success.
25  *  - Negative on error.
26  */
27 int guest_channel_host_connect(const char *path, unsigned int lcore_id);
28
29 /**
30  * Disconnect from an already connected Virtio-Serial Endpoint.
31  *
32  *
33  * @param lcore_id
34  *  lcore_id.
35  *
36  */
37 void guest_channel_host_disconnect(unsigned int lcore_id);
38
39 /**
40  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
41  *
42  * @param pkt
43  *  Pointer to a populated struct guest_agent_pkt
44  *
45  * @param lcore_id
46  *  lcore_id.
47  *
48  * @return
49  *  - 0 on success.
50  *  - Negative on channel not connected.
51  *  - errno on write to channel error.
52  */
53 int guest_channel_send_msg(struct channel_packet *pkt, unsigned int lcore_id);
54
55 /**
56  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
57  *
58  * @param pkt
59  *  Pointer to a populated struct channel_packet
60  *
61  * @param lcore_id
62  *  lcore_id.
63  *
64  * @return
65  *  - 0 on success.
66  *  - Negative on error.
67  */
68 int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
69                         unsigned int lcore_id);
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif