[PATCH v1 07/15] power: add a common macro to verify lcore ID
Huisong Li
lihuisong at huawei.com
Thu Apr 16 05:06:04 CEST 2026
There are many places to verify lcore ID in power lib or driver.
So add a common macro to do this to simplify code.
Signed-off-by: Huisong Li <lihuisong at huawei.com>
---
lib/power/power_common.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/power/power_common.h b/lib/power/power_common.h
index 3f56b1103d..5f13068ad6 100644
--- a/lib/power/power_common.h
+++ b/lib/power/power_common.h
@@ -23,6 +23,13 @@ extern int rte_power_logtype;
#define POWER_DEBUG_LOG(...)
#endif
+#define RTE_POWER_VALID_LCOREID_OR_ERR_RET(lcore_id, retval) do { \
+ if (!rte_lcore_is_enabled(lcore_id)) { \
+ POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id); \
+ return retval; \
+ } \
+} while (0)
+
/* check if scaling driver matches one we want */
__rte_internal
int cpufreq_check_scaling_driver(const char *driver);
--
2.33.0
More information about the dev
mailing list