From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 66467A00BE; Tue, 19 Apr 2022 13:25:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C604427E9; Tue, 19 Apr 2022 13:25:25 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id B3D7740687 for ; Tue, 19 Apr 2022 13:25:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650367521; x=1681903521; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UNwZShoT+mrkV8ax9lUYYwsyQvzrtyZUX+b8nY8bFNc=; b=LrFIgtIOk/0gvwww8+yLfkRxPEG0Yg9VpIFDMBTPyv7VjZMydvxu5SIX 9xSIE6IKKauavGdeJ0th2GzFTmhxvod3fVC56B69JyPwZY/u/plzkiifv 4lhUVGHEz8ockzKv/Ej1genD+Ogcq1fmUqxn8DARTo2NdFj7/KeJ8G0OZ eqnlpQMY9LwWt+1UKLrzyEzJFj7qyU+rxw8sJuX6T6EHyQZG2IGtu98NL 7Ffs5w4Kz0Iqh0QYzPCdf0n+Hw9bhVoHiXJez+ha80ZfpTGhoRZlbyFfc mN/itLnup4kSvZp/yWVnRmqi4nFF+yP6ryAc6W0CRpvbeFGaUZjgPtgbz g==; X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="262600091" X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="262600091" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 04:25:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="727032526" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by orsmga005.jf.intel.com with ESMTP; 19 Apr 2022 04:25:13 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , David Hunt Subject: [PATCH v2 4/4] examples/l3fwd_power: add cli for configurable options Date: Tue, 19 Apr 2022 12:25:01 +0100 Message-Id: <20220419112501.1835458-5-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220419112501.1835458-1-kevin.laatz@intel.com> References: <20220408140847.1319312-1-kevin.laatz@intel.com> <20220419112501.1835458-1-kevin.laatz@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add CLI options to l3fwd_power to utilize the new power APIs introduced in this patchset. These CLI options allow the user to configure the heuritstics made available through the new API via the l3fwd_power application options. Signed-off-by: Kevin Laatz --- v2: add doc update for l3fwd-power --- .../sample_app_ug/l3_forward_power_man.rst | 8 ++ examples/l3fwd-power/main.c | 75 ++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/doc/guides/sample_app_ug/l3_forward_power_man.rst b/doc/guides/sample_app_ug/l3_forward_power_man.rst index 2e350c45f1..b26f11a220 100644 --- a/doc/guides/sample_app_ug/l3_forward_power_man.rst +++ b/doc/guides/sample_app_ug/l3_forward_power_man.rst @@ -109,6 +109,14 @@ where, * --pmd-mgmt: PMD power management mode. +* --max-empty-polls : Number of empty polls to wait before entering sleep state. + +* --pause-duration: Set the duration of the pause callback (microseconds). + +* --scale-freq-min: Set minimum frequency for scaling. + +* --scale-freq-max: Set maximum frequency for scaling. + See :doc:`l3_forward` for details. The L3fwd-power example reuses the L3fwd command line options. diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index 20e5b59af9..ec2a71f02f 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -265,6 +265,10 @@ static struct rte_eth_conf port_conf = { }; static uint32_t max_pkt_len; +static uint32_t max_empty_polls; +static uint32_t pause_duration; +static uint32_t scale_freq_min; +static uint32_t scale_freq_max; static struct rte_mempool * pktmbuf_pool[NB_SOCKETS]; @@ -1626,10 +1630,32 @@ print_usage(const char *prgname) " empty polls, full polls, and core busyness to telemetry\n" " --interrupt-only: enable interrupt-only mode\n" " --pmd-mgmt MODE: enable PMD power management mode. " - "Currently supported modes: baseline, monitor, pause, scale\n", + "Currently supported modes: baseline, monitor, pause, scale\n" + " --max-empty-polls MAX_EMPTY_POLLS: number of empty polls to" + " wait before entering sleep state\n" + " --pause_duration DURATION: set the duration, in microseconds," + " of the pause callback\n" + " --scale-freq-min FREQ_MIN: set minimum frequency for scaling" + " mode for all application lcores\n" + " --scale_freq_max FREQ_MAX: set maximum frequency for scaling" + " mode for all application lcores\n", prgname); } +static int +parse_int(const char *opt) +{ + char *end = NULL; + unsigned long val; + + /* parse integer string */ + val = strtoul(opt, &end, 10); + if ((opt[0] == '\0') || (end == NULL) || (*end != '\0')) + return -1; + + return val; +} + static int parse_max_pkt_len(const char *pktlen) { char *end = NULL; @@ -1803,6 +1829,10 @@ parse_ep_config(const char *q_arg) #define CMD_LINE_OPT_TELEMETRY "telemetry" #define CMD_LINE_OPT_PMD_MGMT "pmd-mgmt" #define CMD_LINE_OPT_MAX_PKT_LEN "max-pkt-len" +#define CMD_LINE_OPT_MAX_EMPTY_POLLS "max-empty-poll" +#define CMD_LINE_OPT_PAUSE_DURATION "pause-duration" +#define CMD_LINE_OPT_SCALE_FREQ_MIN "scale-freq-min" +#define CMD_LINE_OPT_SCALE_FREQ_MAX "scale-freq-max" /* Parse the argument given in the command line of the application */ static int @@ -1812,6 +1842,7 @@ parse_args(int argc, char **argv) char **argvopt; int option_index; uint32_t limit; + int i; char *prgname = argv[0]; static struct option lgopts[] = { {"config", 1, 0, 0}, @@ -1825,6 +1856,10 @@ parse_args(int argc, char **argv) {CMD_LINE_OPT_TELEMETRY, 0, 0, 0}, {CMD_LINE_OPT_INTERRUPT_ONLY, 0, 0, 0}, {CMD_LINE_OPT_PMD_MGMT, 1, 0, 0}, + {CMD_LINE_OPT_MAX_EMPTY_POLLS, 1, 0, 0}, + {CMD_LINE_OPT_PAUSE_DURATION, 1, 0, 0}, + {CMD_LINE_OPT_SCALE_FREQ_MIN, 1, 0, 0}, + {CMD_LINE_OPT_SCALE_FREQ_MAX, 1, 0, 0}, {NULL, 0, 0, 0} }; @@ -1975,6 +2010,44 @@ parse_args(int argc, char **argv) parse_ptype = 1; } + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_MAX_EMPTY_POLLS, + sizeof(CMD_LINE_OPT_MAX_EMPTY_POLLS))) { + printf("Maximum empty polls configured\n"); + max_empty_polls = parse_int(optarg); + rte_power_pmd_mgmt_set_emptypoll_max(max_empty_polls); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_PAUSE_DURATION, + sizeof(CMD_LINE_OPT_PAUSE_DURATION))) { + printf("Pause duration configured\n"); + pause_duration = parse_int(optarg); + rte_power_pmd_mgmt_set_pause_duration(pause_duration); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_SCALE_FREQ_MIN, + sizeof(CMD_LINE_OPT_SCALE_FREQ_MIN))) { + printf("Scaling frequency minimum configured\n"); + scale_freq_min = parse_int(optarg); + for (i = 0; i < RTE_MAX_LCORE; i++) + if (rte_lcore_is_enabled(i)) + rte_power_pmd_mgmt_set_scaling_freq_min(i, + scale_freq_min); + } + + if (!strncmp(lgopts[option_index].name, + CMD_LINE_OPT_SCALE_FREQ_MAX, + sizeof(CMD_LINE_OPT_SCALE_FREQ_MAX))) { + printf("Scaling frequency maximum configured\n"); + scale_freq_max = parse_int(optarg); + for (i = 0; i < RTE_MAX_LCORE; i++) + if (rte_lcore_is_enabled(i)) + rte_power_pmd_mgmt_set_scaling_freq_max(i, + scale_freq_max); + } + break; default: -- 2.31.1