[v4,3/4] power: add power monitor support check

Message ID 20221111102039.3567666-4-feifei.wang2@arm.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Enable PMD power management on Arm |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Feifei Wang Nov. 11, 2022, 10:20 a.m. UTC
  On ARM, WFE instruction, which is used to power monitor, has no timeout
wake-up mechanism, and if users want to exit power monitor actively, the
main lcore is needed to send SEV instruction to wake up other lcores.

So it is necessary to ensure the main lcore does not enter the
power-monitor state. To solve this, main core support check on ARM is
added.

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 lib/power/rte_power_pmd_mgmt.c | 12 ++++++++++++
 lib/power/rte_power_pmd_mgmt.h |  1 +
 2 files changed, 13 insertions(+)
  

Patch

diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c
index ca1840387c..3f3478b2c1 100644
--- a/lib/power/rte_power_pmd_mgmt.c
+++ b/lib/power/rte_power_pmd_mgmt.c
@@ -490,6 +490,18 @@  rte_power_ethdev_pmgmt_queue_enable(unsigned int lcore_id, uint16_t port_id,
 	rte_rx_callback_fn clb;
 	int ret;
 
+#if defined(RTE_ARCH_ARM64)
+	/* Ensure the main lcore does not enter the power-monitor state,
+	 * so that it can be used to wake up other lcores on ARM.
+	 * This is due to WFE instruction has no timeout wake-up mechanism,
+	 * and if users want to exit actively, the main lcore is needed
+	 * to send SEV instruction to wake up other lcores.
+	 */
+	if (lcore_id == rte_get_main_lcore() &&
+			mode == RTE_POWER_MGMT_TYPE_MONITOR)
+		return EPERM;
+#endif
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
 	if (queue_id >= RTE_MAX_QUEUES_PER_PORT || lcore_id >= RTE_MAX_LCORE) {
diff --git a/lib/power/rte_power_pmd_mgmt.h b/lib/power/rte_power_pmd_mgmt.h
index 7ae6ef2d32..b1a0989b88 100644
--- a/lib/power/rte_power_pmd_mgmt.h
+++ b/lib/power/rte_power_pmd_mgmt.h
@@ -52,6 +52,7 @@  enum rte_power_pmd_mgmt_type {
  *   The power management scheme to use for specified Rx queue.
  * @return
  *   0 on success
+ *   EPERM main core cannot be supported on ARM
  *   <0 on error
  */
 __rte_experimental