1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
5 #ifndef _RTE_POWER_INTRINSIC_H_
6 #define _RTE_POWER_INTRINSIC_H_
10 #include <rte_compat.h>
11 #include <rte_spinlock.h>
15 * Advanced power management operations.
17 * This file define APIs for advanced power management,
18 * which are architecture-dependent.
21 struct rte_power_monitor_cond {
22 volatile void *addr; /**< Address to monitor for changes */
23 uint64_t val; /**< If the `mask` is non-zero, location pointed
24 * to by `addr` will be read and compared
27 uint64_t mask; /**< 64-bit mask to extract value read from `addr` */
28 uint8_t size; /**< Data size (in bytes) that will be used to compare
29 * expected value (`val`) with data read from the
30 * monitored memory location (`addr`). Can be 1, 2,
31 * 4, or 8. Supplying any other value will result in
38 * @b EXPERIMENTAL: this API may change without prior notice
40 * Monitor specific address for changes. This will cause the CPU to enter an
41 * architecture-defined optimized power state until either the specified
42 * memory address is written to, a certain TSC timestamp is reached, or other
43 * reasons cause the CPU to wake up.
45 * Additionally, an `expected` 64-bit value and 64-bit mask are provided. If
46 * mask is non-zero, the current value pointed to by the `p` pointer will be
47 * checked against the expected value, and if they match, the entering of
48 * optimized power state may be aborted.
50 * @warning It is responsibility of the user to check if this function is
51 * supported at runtime using `rte_cpu_get_intrinsics_support()` API call.
54 * The monitoring condition structure.
55 * @param tsc_timestamp
56 * Maximum TSC timestamp to wait for. Note that the wait behavior is
57 * architecture-dependent.
61 * -EINVAL on invalid parameters
62 * -ENOTSUP if unsupported
65 int rte_power_monitor(const struct rte_power_monitor_cond *pmc,
66 const uint64_t tsc_timestamp);
70 * @b EXPERIMENTAL: this API may change without prior notice
72 * Wake up a specific lcore that is in a power optimized state and is monitoring
75 * @note This function will *not* wake up a core that is in a power optimized
76 * state due to calling `rte_power_pause`.
79 * Lcore ID of a sleeping thread.
82 int rte_power_monitor_wakeup(const unsigned int lcore_id);
86 * @b EXPERIMENTAL: this API may change without prior notice
88 * Enter an architecture-defined optimized power state until a certain TSC
89 * timestamp is reached.
91 * @warning It is responsibility of the user to check if this function is
92 * supported at runtime using `rte_cpu_get_intrinsics_support()` API call.
94 * @param tsc_timestamp
95 * Maximum TSC timestamp to wait for. Note that the wait behavior is
96 * architecture-dependent.
100 * -EINVAL on invalid parameters
101 * -ENOTSUP if unsupported
104 int rte_power_pause(const uint64_t tsc_timestamp);
106 #endif /* _RTE_POWER_INTRINSIC_H_ */