1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2020 Intel Corporation 3 */ 4 5 #ifndef _RTE_POWER_PMD_MGMT_H 6 #define _RTE_POWER_PMD_MGMT_H 7 8 /** 9 * @file 10 * RTE PMD Power Management 11 */ 12 13 #include <stdint.h> 14 15 #include <rte_compat.h> 16 #include <rte_log.h> 17 #include <rte_power.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * PMD Power Management Type 25 */ 26 enum rte_power_pmd_mgmt_type { 27 /** Use power-optimized monitoring to wait for incoming traffic */ 28 RTE_POWER_MGMT_TYPE_MONITOR = 1, 29 /** Use power-optimized sleep to avoid busy polling */ 30 RTE_POWER_MGMT_TYPE_PAUSE, 31 /** Use frequency scaling when traffic is low */ 32 RTE_POWER_MGMT_TYPE_SCALE, 33 }; 34 35 /** 36 * @warning 37 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 38 * 39 * Enable power management on a specified Ethernet device Rx queue and lcore. 40 * 41 * @note This function is not thread-safe. 42 * 43 * @warning This function must be called when all affected Ethernet queues are 44 * stopped and no Rx/Tx is in progress! 45 * 46 * @param lcore_id 47 * The lcore the Rx queue will be polled from. 48 * @param port_id 49 * The port identifier of the Ethernet device. 50 * @param queue_id 51 * The queue identifier of the Ethernet device. 52 * @param mode 53 * The power management scheme to use for specified Rx queue. 54 * @return 55 * 0 on success 56 * <0 on error 57 */ 58 __rte_experimental 59 int 60 rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, 61 uint16_t port_id, uint16_t queue_id, 62 enum rte_power_pmd_mgmt_type mode); 63 64 /** 65 * @warning 66 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 67 * 68 * Disable power management on a specified Ethernet device Rx queue and lcore. 69 * 70 * @note This function is not thread-safe. 71 * 72 * @warning This function must be called when all affected Ethernet queues are 73 * stopped and no Rx/Tx is in progress! 74 * 75 * @param lcore_id 76 * The lcore the Rx queue is polled from. 77 * @param port_id 78 * The port identifier of the Ethernet device. 79 * @param queue_id 80 * The queue identifier of the Ethernet device. 81 * @return 82 * 0 on success 83 * <0 on error 84 */ 85 __rte_experimental 86 int 87 rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, 88 uint16_t port_id, uint16_t queue_id); 89 90 /** 91 * @warning 92 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 93 * 94 * Set a emptypoll_max to specified value. Used to specify the number of empty 95 * polls to wait before entering sleep state. 96 * 97 * @param max 98 * The value to set emptypoll_max to. 99 */ 100 __rte_experimental 101 void 102 rte_power_pmd_mgmt_set_emptypoll_max(unsigned int max); 103 104 /** 105 * @warning 106 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 107 * 108 * Get the current value of emptypoll_max. 109 * 110 * @return 111 * The current emptypoll_max value 112 */ 113 __rte_experimental 114 unsigned int 115 rte_power_pmd_mgmt_get_emptypoll_max(void); 116 117 /** 118 * @warning 119 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 120 * 121 * Set the pause_duration. Used to adjust the pause mode callback duration. 122 * 123 * @note Duration must be greater than zero. 124 * 125 * @param duration 126 * The value to set pause_duration to. 127 * @return 128 * 0 on success 129 * <0 on error 130 */ 131 __rte_experimental 132 int 133 rte_power_pmd_mgmt_set_pause_duration(unsigned int duration); 134 135 /** 136 * @warning 137 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 138 * 139 * Get the current value of pause_duration. 140 * 141 * @return 142 * The current pause_duration value. 143 */ 144 __rte_experimental 145 unsigned int 146 rte_power_pmd_mgmt_get_pause_duration(void); 147 148 /** 149 * @warning 150 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 151 * 152 * Set the min frequency to be used for frequency scaling or zero to use defaults. 153 * 154 * @note Supported by: Pstate mode. 155 * 156 * @param lcore 157 * The ID of the lcore to set the min frequency for. 158 * @param min 159 * The value, in KiloHertz, to set the minimum frequency to. 160 * @return 161 * 0 on success 162 * <0 on error 163 */ 164 __rte_experimental 165 int 166 rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min); 167 168 /** 169 * @warning 170 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 171 * 172 * Set the max frequency to be used for frequency scaling or zero to use defaults. 173 * 174 * @note Supported by: Pstate mode. 175 * 176 * @param lcore 177 * The ID of the lcore to set the max frequency for. 178 * @param max 179 * The value, in KiloHertz, to set the maximum frequency to. 180 * If 'max' is 0, it is considered 'not set'. 181 * @return 182 * 0 on success 183 * <0 on error 184 */ 185 __rte_experimental 186 int 187 rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max); 188 189 /** 190 * @warning 191 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 192 * 193 * Get the current configured min frequency used for frequency scaling. 194 * 195 * @note Supported by: Pstate mode. 196 * 197 * @param lcore 198 * The ID of the lcore to get the min frequency for. 199 * @return 200 * 0 if no value has been configured via the 'set' API. 201 * >0 if a minimum frequency has been configured. Value is the minimum frequency 202 * , in KiloHertz, used for frequency scaling. 203 * <0 on error 204 */ 205 __rte_experimental 206 int 207 rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore); 208 209 /** 210 * @warning 211 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. 212 * 213 * Get the current configured max frequency used for frequency scaling. 214 * 215 * @note Supported by: Pstate mode. 216 * 217 * @param lcore 218 * The ID of the lcore to get the max frequency for. 219 * @return 220 * 0 if no value has been configured via the 'set' API. 221 * >0 if a maximum frequency has been configured. Value is the maximum frequency 222 * , in KiloHertz, used for frequency scaling. 223 * <0 on error 224 */ 225 __rte_experimental 226 int 227 rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore); 228 229 #ifdef __cplusplus 230 } 231 #endif 232 233 #endif 234