power: add environment capability probing
[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  * 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  * Send a message contained in pkt over the Virtio-Serial to the host endpoint.
70  *
71  * @param pkt
72  *  Pointer to a populated struct channel_packet
73  *
74  * @param lcore_id
75  *  lcore_id.
76  *
77  * @return
78  *  - 0 on success.
79  *  - Negative on error.
80  */
81 int rte_power_guest_channel_send_msg(struct channel_packet *pkt,
82                         unsigned int lcore_id);
83
84 /**
85  * Read a message contained in pkt over the Virtio-Serial
86  * from the host endpoint.
87  *
88  * @param pkt
89  *  Pointer to channel_packet or
90  *  channel_packet_freq_list struct.
91  *
92  * @param pkt_len
93  *  Size of expected data packet.
94  *
95  * @param lcore_id
96  *  lcore_id.
97  *
98  * @return
99  *  - 0 on success.
100  *  - Negative on error.
101  */
102 int power_guest_channel_read_msg(void *pkt,
103                 size_t pkt_len,
104                 unsigned int lcore_id);
105
106 /**
107  * Receive a message contained in pkt over the Virtio-Serial
108  * from the host endpoint.
109  *
110  * @param pkt
111  *  Pointer to channel_packet or
112  *  channel_packet_freq_list struct.
113  *
114  * @param pkt_len
115  *  Size of expected data packet.
116  *
117  * @param lcore_id
118  *  lcore_id.
119  *
120  * @return
121  *  - 0 on success.
122  *  - Negative on error.
123  */
124 __rte_experimental
125 int
126 rte_power_guest_channel_receive_msg(void *pkt,
127                 size_t pkt_len,
128                 unsigned int lcore_id);
129
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif