numam-dpdk/lib/librte_power/rte_power_pmd_mgmt.h
Liang Ma 682a645438 power: add ethdev power management
Add a simple on/off switch that will enable saving power when no
packets are arriving. It is based on counting the number of empty
polls and, when the number reaches a certain threshold, entering an
architecture-defined optimized power state that will either wait
until a TSC timestamp expires, or when packets arrive.

This API mandates a core-to-single-queue mapping (that is, multiple
queued per device are supported, but they have to be polled on different
cores).

This design is using PMD RX callbacks.

1. UMWAIT/UMONITOR:

   When a certain threshold of empty polls is reached, the core will go
   into a power optimized sleep while waiting on an address of next RX
   descriptor to be written to.

2. TPAUSE/Pause instruction

   This method uses the pause (or TPAUSE, if available) instruction to
   avoid busy polling.

3. Frequency scaling
   Reuse existing DPDK power library to scale up/down core frequency
   depending on traffic volume.

Signed-off-by: Liang Ma <liang.j.ma@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
2021-01-29 15:29:48 +01:00

92 lines
2.0 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.
*
* @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.
*
* @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