power: make ethdev power management thread unsafe
[dpdk.git] / lib / power / rte_power_pmd_mgmt.h
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 #include <stdbool.h>
15
16 #include <rte_common.h>
17 #include <rte_byteorder.h>
18 #include <rte_log.h>
19 #include <rte_power.h>
20 #include <rte_atomic.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27  * PMD Power Management Type
28  */
29 enum rte_power_pmd_mgmt_type {
30         /** Use power-optimized monitoring to wait for incoming traffic */
31         RTE_POWER_MGMT_TYPE_MONITOR = 1,
32         /** Use power-optimized sleep to avoid busy polling */
33         RTE_POWER_MGMT_TYPE_PAUSE,
34         /** Use frequency scaling when traffic is low */
35         RTE_POWER_MGMT_TYPE_SCALE,
36 };
37
38 /**
39  * @warning
40  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
41  *
42  * Enable power management on a specified Ethernet device Rx queue and lcore.
43  *
44  * @note This function is not thread-safe.
45  *
46  * @warning This function must be called when all affected Ethernet queues are
47  *   stopped and no Rx/Tx is in progress!
48  *
49  * @param lcore_id
50  *   The lcore the Rx queue will be polled from.
51  * @param port_id
52  *   The port identifier of the Ethernet device.
53  * @param queue_id
54  *   The queue identifier of the Ethernet device.
55  * @param mode
56  *   The power management scheme to use for specified Rx queue.
57  * @return
58  *   0 on success
59  *   <0 on error
60  */
61 __rte_experimental
62 int
63 rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id,
64                 uint16_t port_id, uint16_t queue_id,
65                 enum rte_power_pmd_mgmt_type mode);
66
67 /**
68  * @warning
69  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice.
70  *
71  * Disable power management on a specified Ethernet device Rx queue and lcore.
72  *
73  * @note This function is not thread-safe.
74  *
75  * @warning This function must be called when all affected Ethernet queues are
76  *   stopped and no Rx/Tx is in progress!
77  *
78  * @param lcore_id
79  *   The lcore the Rx queue is polled from.
80  * @param port_id
81  *   The port identifier of the Ethernet device.
82  * @param queue_id
83  *   The queue identifier of the Ethernet device.
84  * @return
85  *   0 on success
86  *   <0 on error
87  */
88 __rte_experimental
89 int
90 rte_power_ethdev_pmgmt_queue_disable(unsigned int lcore_id,
91                 uint16_t port_id, uint16_t queue_id);
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif