numam-dpdk/lib/power/rte_power_pmd_mgmt.h
Anatoly Burakov 209fd58545 power: make ethdev power management thread unsafe
Currently, we expect that only one callback can be active at any given
moment, for a particular queue configuration, which is relatively easy
to implement in a thread-safe way. However, we're about to add support
for multiple queues per lcore, which will greatly increase the
possibility of various race conditions.

We could have used something like an RCU for this use case, but absent
of a pressing need for thread safety we'll go the easy way and just
mandate that the API's are to be called when all affected ports are
stopped, and document this limitation. This greatly simplifies the
`rte_power_monitor`-related code.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Tested-by: David Hunt <david.hunt@intel.com>
2021-07-09 21:13:13 +02:00

98 lines
2.3 KiB
C

/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2020 Intel Corporation
*/
#ifndef _RTE_POWER_PMD_MGMT_H
#define _RTE_POWER_PMD_MGMT_H
/**
* @file
* RTE PMD Power Management
*/
#include <stdint.h>
#include <stdbool.h>
#include <rte_common.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_power.h>
#include <rte_atomic.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* PMD Power Management Type
*/
enum rte_power_pmd_mgmt_type {
/** Use power-optimized monitoring to wait for incoming traffic */
RTE_POWER_MGMT_TYPE_MONITOR = 1,
/** Use power-optimized sleep to avoid busy polling */
RTE_POWER_MGMT_TYPE_PAUSE,
/** Use frequency scaling when traffic is low */
RTE_POWER_MGMT_TYPE_SCALE,
};
/**
* @warning
* @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
*
* Enable power management on a specified Ethernet device Rx queue and lcore.
*
* @note This function is not thread-safe.
*
* @warning This function must be called when all affected Ethernet queues are
* stopped and no Rx/Tx is in progress!
*
* @param lcore_id
* The lcore the Rx queue will be polled from.
* @param port_id
* The port identifier of the Ethernet device.
* @param queue_id
* The queue identifier of the Ethernet device.
* @param mode
* The power management scheme to use for specified Rx queue.
* @return
* 0 on success
* <0 on error
*/
__rte_experimental
int
rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id,
uint16_t port_id, uint16_t queue_id,
enum rte_power_pmd_mgmt_type mode);
/**
* @warning
* @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
*
* Disable power management on a specified Ethernet device Rx queue and lcore.
*
* @note This function is not thread-safe.
*
* @warning This function must be called when all affected Ethernet queues are
* stopped and no Rx/Tx is in progress!
*
* @param lcore_id
* The lcore the Rx queue is polled from.
* @param port_id
* The port identifier of the Ethernet device.
* @param queue_id
* The queue identifier of the Ethernet device.
* @return
* 0 on success
* <0 on error
*/
__rte_experimental
int
rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
uint16_t port_id, uint16_t queue_id);
#ifdef __cplusplus
}
#endif
#endif