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