199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2020 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_POWER_PMD_MGMT_H 699a2dd95SBruce Richardson #define _RTE_POWER_PMD_MGMT_H 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson /** 999a2dd95SBruce Richardson * @file 1099a2dd95SBruce Richardson * RTE PMD Power Management 1199a2dd95SBruce Richardson */ 1299a2dd95SBruce Richardson 1399a2dd95SBruce Richardson #include <stdint.h> 1499a2dd95SBruce Richardson 1599a2dd95SBruce Richardson #include <rte_log.h> 16*f30a1bbdSSivaprasad Tummala #include <rte_power_cpufreq.h> 1799a2dd95SBruce Richardson 1899a2dd95SBruce Richardson #ifdef __cplusplus 1999a2dd95SBruce Richardson extern "C" { 2099a2dd95SBruce Richardson #endif 2199a2dd95SBruce Richardson 2299a2dd95SBruce Richardson /** 2399a2dd95SBruce Richardson * PMD Power Management Type 2499a2dd95SBruce Richardson */ 2599a2dd95SBruce Richardson enum rte_power_pmd_mgmt_type { 2699a2dd95SBruce Richardson /** Use power-optimized monitoring to wait for incoming traffic */ 2799a2dd95SBruce Richardson RTE_POWER_MGMT_TYPE_MONITOR = 1, 2899a2dd95SBruce Richardson /** Use power-optimized sleep to avoid busy polling */ 2999a2dd95SBruce Richardson RTE_POWER_MGMT_TYPE_PAUSE, 3099a2dd95SBruce Richardson /** Use frequency scaling when traffic is low */ 3199a2dd95SBruce Richardson RTE_POWER_MGMT_TYPE_SCALE, 3299a2dd95SBruce Richardson }; 3399a2dd95SBruce Richardson 3499a2dd95SBruce Richardson /** 3599a2dd95SBruce Richardson * Enable power management on a specified Ethernet device Rx queue and lcore. 3699a2dd95SBruce Richardson * 3799a2dd95SBruce Richardson * @note This function is not thread-safe. 3899a2dd95SBruce Richardson * 39209fd585SAnatoly Burakov * @warning This function must be called when all affected Ethernet queues are 40209fd585SAnatoly Burakov * stopped and no Rx/Tx is in progress! 41209fd585SAnatoly Burakov * 4299a2dd95SBruce Richardson * @param lcore_id 4399a2dd95SBruce Richardson * The lcore the Rx queue will be polled from. 4499a2dd95SBruce Richardson * @param port_id 4599a2dd95SBruce Richardson * The port identifier of the Ethernet device. 4699a2dd95SBruce Richardson * @param queue_id 4799a2dd95SBruce Richardson * The queue identifier of the Ethernet device. 4899a2dd95SBruce Richardson * @param mode 4999a2dd95SBruce Richardson * The power management scheme to use for specified Rx queue. 5099a2dd95SBruce Richardson * @return 5199a2dd95SBruce Richardson * 0 on success 5299a2dd95SBruce Richardson * <0 on error 5399a2dd95SBruce Richardson */ 5499a2dd95SBruce Richardson int 5599a2dd95SBruce Richardson rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, 5699a2dd95SBruce Richardson uint16_t port_id, uint16_t queue_id, 5799a2dd95SBruce Richardson enum rte_power_pmd_mgmt_type mode); 5899a2dd95SBruce Richardson 5999a2dd95SBruce Richardson /** 6099a2dd95SBruce Richardson * Disable power management on a specified Ethernet device Rx queue and lcore. 6199a2dd95SBruce Richardson * 6299a2dd95SBruce Richardson * @note This function is not thread-safe. 6399a2dd95SBruce Richardson * 64209fd585SAnatoly Burakov * @warning This function must be called when all affected Ethernet queues are 65209fd585SAnatoly Burakov * stopped and no Rx/Tx is in progress! 66209fd585SAnatoly Burakov * 6799a2dd95SBruce Richardson * @param lcore_id 6899a2dd95SBruce Richardson * The lcore the Rx queue is polled from. 6999a2dd95SBruce Richardson * @param port_id 7099a2dd95SBruce Richardson * The port identifier of the Ethernet device. 7199a2dd95SBruce Richardson * @param queue_id 7299a2dd95SBruce Richardson * The queue identifier of the Ethernet device. 7399a2dd95SBruce Richardson * @return 7499a2dd95SBruce Richardson * 0 on success 7599a2dd95SBruce Richardson * <0 on error 7699a2dd95SBruce Richardson */ 7799a2dd95SBruce Richardson int 7899a2dd95SBruce Richardson rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id, 7999a2dd95SBruce Richardson uint16_t port_id, uint16_t queue_id); 8099a2dd95SBruce Richardson 819e9e945bSKevin Laatz /** 829e9e945bSKevin Laatz * Set a emptypoll_max to specified value. Used to specify the number of empty 839e9e945bSKevin Laatz * polls to wait before entering sleep state. 849e9e945bSKevin Laatz * 859e9e945bSKevin Laatz * @param max 869e9e945bSKevin Laatz * The value to set emptypoll_max to. 879e9e945bSKevin Laatz */ 889e9e945bSKevin Laatz void 899e9e945bSKevin Laatz rte_power_pmd_mgmt_set_emptypoll_max(unsigned int max); 909e9e945bSKevin Laatz 919e9e945bSKevin Laatz /** 929e9e945bSKevin Laatz * Get the current value of emptypoll_max. 939e9e945bSKevin Laatz * 949e9e945bSKevin Laatz * @return 959e9e945bSKevin Laatz * The current emptypoll_max value 969e9e945bSKevin Laatz */ 979e9e945bSKevin Laatz unsigned int 989e9e945bSKevin Laatz rte_power_pmd_mgmt_get_emptypoll_max(void); 999e9e945bSKevin Laatz 1004a8fbc28SKevin Laatz /** 1014a8fbc28SKevin Laatz * Set the pause_duration. Used to adjust the pause mode callback duration. 1024a8fbc28SKevin Laatz * 1034a8fbc28SKevin Laatz * @note Duration must be greater than zero. 1044a8fbc28SKevin Laatz * 1054a8fbc28SKevin Laatz * @param duration 1064a8fbc28SKevin Laatz * The value to set pause_duration to. 1074a8fbc28SKevin Laatz * @return 1084a8fbc28SKevin Laatz * 0 on success 1094a8fbc28SKevin Laatz * <0 on error 1104a8fbc28SKevin Laatz */ 1114a8fbc28SKevin Laatz int 1124a8fbc28SKevin Laatz rte_power_pmd_mgmt_set_pause_duration(unsigned int duration); 1134a8fbc28SKevin Laatz 1144a8fbc28SKevin Laatz /** 1154a8fbc28SKevin Laatz * Get the current value of pause_duration. 1164a8fbc28SKevin Laatz * 1174a8fbc28SKevin Laatz * @return 1184a8fbc28SKevin Laatz * The current pause_duration value. 1194a8fbc28SKevin Laatz */ 1204a8fbc28SKevin Laatz unsigned int 1214a8fbc28SKevin Laatz rte_power_pmd_mgmt_get_pause_duration(void); 1224a8fbc28SKevin Laatz 12342651168SKevin Laatz /** 12442651168SKevin Laatz * Set the min frequency to be used for frequency scaling or zero to use defaults. 12542651168SKevin Laatz * 12642651168SKevin Laatz * @note Supported by: Pstate mode. 12742651168SKevin Laatz * 12842651168SKevin Laatz * @param lcore 12942651168SKevin Laatz * The ID of the lcore to set the min frequency for. 13042651168SKevin Laatz * @param min 13142651168SKevin Laatz * The value, in KiloHertz, to set the minimum frequency to. 13242651168SKevin Laatz * @return 13342651168SKevin Laatz * 0 on success 13442651168SKevin Laatz * <0 on error 13542651168SKevin Laatz */ 13642651168SKevin Laatz int 13742651168SKevin Laatz rte_power_pmd_mgmt_set_scaling_freq_min(unsigned int lcore, unsigned int min); 13842651168SKevin Laatz 13942651168SKevin Laatz /** 14042651168SKevin Laatz * Set the max frequency to be used for frequency scaling or zero to use defaults. 14142651168SKevin Laatz * 14242651168SKevin Laatz * @note Supported by: Pstate mode. 14342651168SKevin Laatz * 14442651168SKevin Laatz * @param lcore 14542651168SKevin Laatz * The ID of the lcore to set the max frequency for. 14642651168SKevin Laatz * @param max 14742651168SKevin Laatz * The value, in KiloHertz, to set the maximum frequency to. 14842651168SKevin Laatz * If 'max' is 0, it is considered 'not set'. 14942651168SKevin Laatz * @return 15042651168SKevin Laatz * 0 on success 15142651168SKevin Laatz * <0 on error 15242651168SKevin Laatz */ 15342651168SKevin Laatz int 15442651168SKevin Laatz rte_power_pmd_mgmt_set_scaling_freq_max(unsigned int lcore, unsigned int max); 15542651168SKevin Laatz 15642651168SKevin Laatz /** 15742651168SKevin Laatz * Get the current configured min frequency used for frequency scaling. 15842651168SKevin Laatz * 15942651168SKevin Laatz * @note Supported by: Pstate mode. 16042651168SKevin Laatz * 16142651168SKevin Laatz * @param lcore 16242651168SKevin Laatz * The ID of the lcore to get the min frequency for. 16342651168SKevin Laatz * @return 16442651168SKevin Laatz * 0 if no value has been configured via the 'set' API. 16542651168SKevin Laatz * >0 if a minimum frequency has been configured. Value is the minimum frequency 16642651168SKevin Laatz * , in KiloHertz, used for frequency scaling. 16742651168SKevin Laatz * <0 on error 16842651168SKevin Laatz */ 16942651168SKevin Laatz int 17042651168SKevin Laatz rte_power_pmd_mgmt_get_scaling_freq_min(unsigned int lcore); 17142651168SKevin Laatz 17242651168SKevin Laatz /** 17342651168SKevin Laatz * Get the current configured max frequency used for frequency scaling. 17442651168SKevin Laatz * 17542651168SKevin Laatz * @note Supported by: Pstate mode. 17642651168SKevin Laatz * 17742651168SKevin Laatz * @param lcore 17842651168SKevin Laatz * The ID of the lcore to get the max frequency for. 17942651168SKevin Laatz * @return 18042651168SKevin Laatz * 0 if no value has been configured via the 'set' API. 18142651168SKevin Laatz * >0 if a maximum frequency has been configured. Value is the maximum frequency 18242651168SKevin Laatz * , in KiloHertz, used for frequency scaling. 18342651168SKevin Laatz * <0 on error 18442651168SKevin Laatz */ 18542651168SKevin Laatz int 18642651168SKevin Laatz rte_power_pmd_mgmt_get_scaling_freq_max(unsigned int lcore); 18742651168SKevin Laatz 18899a2dd95SBruce Richardson #ifdef __cplusplus 18999a2dd95SBruce Richardson } 19099a2dd95SBruce Richardson #endif 19199a2dd95SBruce Richardson 19299a2dd95SBruce Richardson #endif 193