From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 286C8A0518; Fri, 19 Jun 2020 12:54:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF74A1BEE7; Fri, 19 Jun 2020 12:54:11 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 626811B9B7 for ; Fri, 19 Jun 2020 12:54:08 +0200 (CEST) IronPort-SDR: Iv2vVOtrdUjXrJM/AWRznsEE2PFGSePlGZY34yrVBGuGsDUQoT1rrwo1vNw2ucEapjYnEXbSiv zBv4Yotm+V1Q== X-IronPort-AV: E=McAfee;i="6000,8403,9656"; a="131318786" X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="131318786" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2020 03:54:08 -0700 IronPort-SDR: Y9EWuaK74sifGX8mU9JY0gj+9aZvOWDRvrVc9+hI61/q1P57L4COp3ctNPLIwLfJVDY0oiHOI/ AL09/3tz+GWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,255,1589266800"; d="scan'208";a="263347993" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by orsmga007.jf.intel.com with ESMTP; 19 Jun 2020 03:54:06 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , reshma.pattan@intel.com, hkalra@marvell.com, jerinjacobk@gmail.com, yinan.wang@intel.com Date: Fri, 19 Jun 2020 11:53:55 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 7/7] l3fwd-power: add auto-selection of default mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, the application does support running without the power library being initialized, but it has to be specifically requested. On platforms without support for frequency scaling using the power library, we can just enable interrupt-only mode by default. Signed-off-by: Anatoly Burakov Suggested-by: Jerin Jacob Tested-by: Harman Kalra --- examples/l3fwd-power/main.c | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 51acbfd87d..6a4a27984b 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -2412,6 +2412,42 @@ launch_timer(unsigned int lcore_id) return 0; } +static int +autodetect_mode(void) +{ + RTE_LOG(NOTICE, L3FWD_POWER, "Operating mode not specified, probing frequency scaling support...\n"); + + /* + * Empty poll and telemetry modes have to be specifically requested to + * be enabled, but we can auto-detect between interrupt mode with or + * without frequency scaling. Both ACPI and pstate can be used. + */ + if (rte_power_check_env_supported(PM_ENV_ACPI_CPUFREQ)) + return APP_MODE_LEGACY; + if (rte_power_check_env_supported(PM_ENV_PSTATE_CPUFREQ)) + return APP_MODE_LEGACY; + + RTE_LOG(NOTICE, L3FWD_POWER, "Frequency scaling not supported, selecting interrupt-only mode\n"); + + return APP_MODE_INTERRUPT; +} + +static const char * +mode_to_str(enum appmode mode) +{ + switch (mode) { + case APP_MODE_LEGACY: + return "legacy"; + case APP_MODE_EMPTY_POLL: + return "empty poll"; + case APP_MODE_TELEMETRY: + return "telemetry"; + case APP_MODE_INTERRUPT: + return "interrupt-only"; + default: + return "invalid"; + } +} int main(int argc, char **argv) @@ -2449,7 +2485,10 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n"); if (app_mode == APP_MODE_DEFAULT) - app_mode = APP_MODE_LEGACY; + app_mode = autodetect_mode(); + + RTE_LOG(INFO, L3FWD_POWER, "Selected operation mode: %s\n", + mode_to_str(app_mode)); /* only legacy and empty poll mode rely on power library */ if ((app_mode == APP_MODE_LEGACY || app_mode == APP_MODE_EMPTY_POLL) && -- 2.17.1