From patchwork Mon May 23 20:21:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 111649 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 06A4FA00C2; Mon, 23 May 2022 22:20:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AD2C542B6D; Mon, 23 May 2022 22:20:06 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 006C340156 for ; Mon, 23 May 2022 22:20:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653337205; x=1684873205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PQKJTsV0HYuc5YOAP+RnJfoOOgHiydU5KOQC2ZpgsK0=; b=UJWroS9vWtexy2tNg2eJVmm86WekApVxAxjV2nwEjrrobjtSZCKsp0p5 +2eAsPBw3156LlvzdSYYqzAfmczpicHS/VqydgGuqbQhJhVP5q+TIYNEP rv4cb6fQn31Tj/JfQhe5dAA62clsKmbDI8rKZUHE+HOu9uEPtNJxo3MP8 xmfPShvgZk4kw8KMrNaPzugisPvEG0FoFeHrDzqE/DQMcQ7ewXOU7o1vH TkwZ+GmPcAWzxeHib6lHOkznjyIlAtkmFUHI9667K5FJ3yOBhAo+Psegp 0POh4a1Wh1Jw15lBAjrdtSR677dyJPBrK2VCVosEIQkCYrmqO5iqMZ7C1 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10356"; a="273338330" X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="273338330" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2022 13:20:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,246,1647327600"; d="scan'208";a="744911327" Received: from silpixa00401122.ir.intel.com ([10.237.213.29]) by orsmga005.jf.intel.com with ESMTP; 23 May 2022 13:20:03 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: anatoly.burakov@intel.com, Kevin Laatz , David Hunt Subject: [PATCH v3 4/4] examples/l3fwd_power: add cli for configurable options Date: Mon, 23 May 2022 21:21:24 +0100 Message-Id: <20220523202124.293865-5-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220523202124.293865-1-kevin.laatz@intel.com> References: <20220419112501.1835458-1-kevin.laatz@intel.com> <20220523202124.293865-1-kevin.laatz@intel.com> MIME-Version: 1.0 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 Acked-by: Anatoly Burakov --- v2: add doc update for l3fwd-power v3: move setters out of arg parsing --- .../sample_app_ug/l3_forward_power_man.rst | 8 ++ examples/l3fwd-power/main.c | 86 ++++++++++++++++++- 2 files changed, 93 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..8f6d906200 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. Applies to --pmd-mgmt mode only. + +* --pause-duration: Set the duration of the pause callback (microseconds). Applies to --pmd-mgmt mode only. + +* --scale-freq-min: Set minimum frequency for scaling. Applies to --pmd-mgmt mode only. + +* --scale-freq-max: Set maximum frequency for scaling. Applies to --pmd-mgmt mode only. + 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..887c6eae3f 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 = 512; +static uint32_t pause_duration = 1; +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 (FREQ_MIN must be in kHz, in increments of 100MHz)\n" + " --scale-freq-max FREQ_MAX: set maximum frequency for scaling mode for" + " all application lcores (FREQ_MAX must be in kHz, in increments of 100MHz)\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-polls" +#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 @@ -1825,6 +1855,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 +2009,34 @@ 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); + } + + 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); + } + + 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); + } + + 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); + } + break; default: @@ -2801,6 +2863,28 @@ main(int argc, char **argv) } if (app_mode == APP_MODE_PMD_MGMT && !baseline_enabled) { + /* Set power_pmd_mgmt configs passed by user */ + rte_power_pmd_mgmt_set_emptypoll_max(max_empty_polls); + ret = rte_power_pmd_mgmt_set_pause_duration(pause_duration); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting pause_duration: err=%d, lcore=%d\n", + ret, lcore_id); + + ret = rte_power_pmd_mgmt_set_scaling_freq_min(lcore_id, + scale_freq_min); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting scaling freq min: err=%d, lcore=%d\n", + ret, lcore_id); + + ret = rte_power_pmd_mgmt_set_scaling_freq_max(lcore_id, + scale_freq_max); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "Error setting scaling freq max: err=%d, lcore %d\n", + ret, lcore_id); + ret = rte_power_ethdev_pmgmt_queue_enable( lcore_id, portid, queueid, pmgmt_type);