9a309a300fee89b1cd179db2b648bca96d16051b
[dpdk.git] / lib / power / power_kvm_vm.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4
5 #ifndef _POWER_KVM_VM_H
6 #define _POWER_KVM_VM_H
7
8 /**
9  * @file
10  * RTE Power Management KVM VM
11  */
12
13 #include <rte_common.h>
14 #include <rte_byteorder.h>
15 #include <rte_log.h>
16 #include <rte_string_fns.h>
17 #include "rte_power.h"
18
19 /**
20  * Check if KVM power management is supported.
21  *
22  * @return
23  *   - 1 if supported
24  *   - 0 if unsupported
25  *   - -1 if error, with rte_errno indicating reason for error.
26  */
27 int power_kvm_vm_check_supported(void);
28
29 /**
30  * Initialize power management for a specific lcore.
31  *
32  * @param lcore_id
33  *  lcore id.
34  *
35  * @return
36  *  - 0 on success.
37  *  - Negative on error.
38  */
39 int power_kvm_vm_init(unsigned int lcore_id);
40
41 /**
42  * Exit power management on a specific lcore.
43  *
44  * @param lcore_id
45  *  lcore id.
46  *
47  * @return
48  *  - 0 on success.
49  *  - Negative on error.
50  */
51 int power_kvm_vm_exit(unsigned int lcore_id);
52
53 /**
54  * Get the available frequencies of a specific lcore.
55  * It is not currently supported for VM Power Management.
56  *
57  * @param lcore_id
58  *  lcore id.
59  * @param freqs
60  *  The buffer array to save the frequencies.
61  * @param num
62  *  The number of frequencies to get.
63  *
64  * @return
65  *  -ENOTSUP
66  */
67 uint32_t power_kvm_vm_freqs(unsigned int lcore_id, uint32_t *freqs,
68                 uint32_t num);
69
70 /**
71  * Return the current index of available frequencies of a specific lcore.
72  * It is not currently supported for VM Power Management.
73  *
74  * @param lcore_id
75  *  lcore id.
76  *
77  * @return
78  *  -ENOTSUP
79  */
80 uint32_t power_kvm_vm_get_freq(unsigned int lcore_id);
81
82 /**
83  * Set the new frequency for a specific lcore by indicating the index of
84  * available frequencies.
85  * It is not currently supported for VM Power Management.
86  *
87  * @param lcore_id
88  *  lcore id.
89  * @param index
90  *  The index of available frequencies.
91  *
92  * @return
93  *  -ENOTSUP
94  */
95 int power_kvm_vm_set_freq(unsigned int lcore_id, uint32_t index);
96
97 /**
98  * Scale up the frequency of a specific lcore. This request is forwarded to the
99  * host monitor.
100  * It should be protected outside of this function for threadsafe.
101  *
102  * @param lcore_id
103  *  lcore id.
104  *
105  * @return
106  *  - 1 on success.
107  *  - Negative on error.
108  */
109 int power_kvm_vm_freq_up(unsigned int lcore_id);
110
111 /**
112  * Scale down the frequency of a specific lcore according to the available
113  * frequencies.
114  * It should be protected outside of this function for threadsafe.
115  *
116  * @param lcore_id
117  *  lcore id.
118  *
119  * @return
120  *  - 1 on success.
121  *  - Negative on error.
122  */
123 int power_kvm_vm_freq_down(unsigned int lcore_id);
124
125 /**
126  * Scale up the frequency of a specific lcore to the highest according to the
127  * available frequencies.
128  * It should be protected outside of this function for threadsafe.
129  *
130  * @param lcore_id
131  *  lcore id.
132  *
133  * @return
134  *  - 1 on success.
135  *  - Negative on error.
136  */
137 int power_kvm_vm_freq_max(unsigned int lcore_id);
138
139 /**
140  * Scale down the frequency of a specific lcore to the lowest according to the
141  * available frequencies.
142  * It should be protected outside of this function for threadsafe.
143  *
144  * @param lcore_id
145  *  lcore id.
146  *
147  * @return
148  *  - 1 on success.
149  *  - Negative on error.
150  */
151 int power_kvm_vm_freq_min(unsigned int lcore_id);
152
153 /**
154  * It should be protected outside of this function for threadsafe.
155  *
156  * @param lcore_id
157  *  lcore id.
158  *
159  * @return
160  *  -ENOTSUP
161  */
162 int power_kvm_vm_turbo_status(unsigned int lcore_id);
163
164 /**
165  * It should be protected outside of this function for threadsafe.
166  *
167  * @param lcore_id
168  *  lcore id.
169  *
170  * @return
171  *  - 1 on success.
172  *  - Negative on error.
173  */
174 int power_kvm_vm_enable_turbo(unsigned int lcore_id);
175
176 /**
177  * It should be protected outside of this function for threadsafe.
178  *
179  * @param lcore_id
180  *  lcore id.
181  *
182  * @return
183  *  - 1 on success.
184  *  - Negative on error.
185  */
186 int power_kvm_vm_disable_turbo(unsigned int lcore_id);
187
188 /**
189  * Returns power capabilities for a specific lcore.
190  *
191  * @param lcore_id
192  *  lcore id.
193  * @param caps
194  *  pointer to rte_power_core_capabilities object.
195  *
196  * @return
197  *  - 0 on success.
198  *  - Negative on error.
199  */
200 int power_kvm_vm_get_capabilities(unsigned int lcore_id,
201                 struct rte_power_core_capabilities *caps);
202
203 #endif