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 DF816A0542; Tue, 6 Sep 2022 12:51:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9ABBD40143; Tue, 6 Sep 2022 12:51:50 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id B4B81400D6 for ; Tue, 6 Sep 2022 12:51:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662461508; x=1693997508; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=QO8OcdnZolJKE6CYXN8N8m8eXIFYaFddnX7XzJ/SROg=; b=horNo4dHJVa5Fv1mZs2RQqAWJnlzunP5aJhrWat5vFUa9zW+jDCN2YGn qEo6Qb+30Q09+r5IMADty6NXmMoY5z4kFuCIkx4qdin7JyNDTkxsOMCTN fyweCUmha7lwIFISJYJ3SZ2ZH+n8lI9B8iw7WBHro2mbzz6rHYGxRU6EH wXzHegXWWyf77DtN0YDsBam3E9uHDyAj8nOBUxt0fDQ2W4C+vv+7VOxR2 vna+BaYBO/NRfdDAkxXXhsZz31olMLvCbEVoaid2iEvo42ikghZJ3KBpy AqeHZFc2ckIkj3ScgkLL6ceT+GLf5TgNM2TE2dMjn7ax/STHleOumcyMe A==; X-IronPort-AV: E=McAfee;i="6500,9779,10461"; a="294148058" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="294148058" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 03:51:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="565051496" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga003.jf.intel.com with ESMTP; 06 Sep 2022 03:51:45 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Sep 2022 03:51:45 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 6 Sep 2022 03:51:44 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 6 Sep 2022 03:51:44 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 6 Sep 2022 03:51:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S4KMNXrRbOQBpUVY0Y2/HzzMaiP7/YZHwqWE0Y+MTfeUVLZTUfX2RtuhlroaC5+e8CFG4U7WfcZG3JMYrWc+2oioeILlnKnPhTDENorq9v8JKcNQhTeqmQLrllwgja+Xn3Vc8fsip4FqwuFpmbnG1iRY6W7Ionc0Q78I4B6ldivKdGYHiXd1qaeeMpATwiQNbH+rR8LmD2zb8xXQbvf2GLyL5lze8y3YA0Z/wKqnn7sVG6GF80oonZBFOEOd2qz9eKpWytBk2J5nydEyIsnWF2ckfbhMBfAjuWxZW04n+pH1i8r3DxWJeUxxbaZKx+A9JwoOPqcjGYhtwOFgR1O5Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8liAitPbteoMLb5yxMv/HF1r85GBB18/nCU4ZWazFyc=; b=fJ9Ev/ff+B08n3zNGaqTzq53iOVGaIJQwC2Fuks5adqZfEsc3P+ZqsyzzLwvdFvKBHtaC2GNrQQuPVQzEG4Q50cZcZ6jTBgkLf5RNqd6SQTVRnzqAmIyPf6yibgn3hJkXjnqymYy1OYH30uXPD3rQBzzKTKCrc9Dr+tmfHCImN6dpXefcxRRSM0ERSgfoUpBm0KuKS6VAaNkyyxXymeTne4IkKuwBnGD7pmzF2OCOyCBCca1PEBkFH3QNahEQTnKZwaehJ+jB2/wIHCgbpJMSC8iJOltf3ttd1jOWIL/O9Dzn3cPxZk2626FPqDxOgPyt2Hj+W144jSDyK+Zjp3uww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BYAPR11MB3799.namprd11.prod.outlook.com (2603:10b6:a03:fb::19) by MWHPR11MB1822.namprd11.prod.outlook.com (2603:10b6:300:111::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Tue, 6 Sep 2022 10:51:42 +0000 Received: from BYAPR11MB3799.namprd11.prod.outlook.com ([fe80::4959:604c:ca50:38b5]) by BYAPR11MB3799.namprd11.prod.outlook.com ([fe80::4959:604c:ca50:38b5%5]) with mapi id 15.20.5588.017; Tue, 6 Sep 2022 10:51:42 +0000 Message-ID: Date: Tue, 6 Sep 2022 11:51:37 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v2 3/3] l3fwd-power: add option to call uncore API Content-Language: en-US To: Tadhg Kearney , CC: , References: <20220713140706.4143705-1-tadhg.kearney@intel.com> <20220713140706.4143705-4-tadhg.kearney@intel.com> From: "Hunt, David" In-Reply-To: <20220713140706.4143705-4-tadhg.kearney@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PR3P250CA0016.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:57::21) To BYAPR11MB3799.namprd11.prod.outlook.com (2603:10b6:a03:fb::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 342ff29d-d859-4b09-3d72-08da8ff5c8bc X-MS-TrafficTypeDiagnostic: MWHPR11MB1822:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PBpze4FtKu6hgCvassFdjuPgXoxmJm/12Nd7338VOTiXXjBuwPLCCV5Va+47QQ5byx+jtGkLwA5FvAQrnR0nJfj5AwhmtfBQuH0/UeRNKL3Po9pndYnAG8Bd/RK2l+fnhR3Rl2F/OLMdN8tN78TT6xEAjBeHoNsJr/Vhc+/Mi6OZB4NyhuSaHVDEDCgcGrgpFPd2jNt61ZzmlEhRbtTrl6Z+8uaw6Ymhe8/rozXNsJwYHGnULUdpl0cLWyn1YoIQFSBHxxGLAL4m2vQq4Gtatlnt76Nqj9q0q7w3JsVgCOyBuzZkLLZapH4MCHg90Z3opbpJnOFXGpdQ1p1bGstivyo2ovzxPmqLJqDmFJutx0bzsGdS2YtVfa4llvzaUv5vhCeZhk9gkkalhE7jBu3s/k8zkztT2UGbpk199XLRywQXLa+/gG5fc+LvCQ43I/Jloq0ppqMTE54OlUGOO1z3sCKKvpkStjhRVh8hhLjdUuG6N6FbMtA1mGglTkDM6Hja1Uw2vtu+xZrTVSozcaLLE0kqg2vPeBnSAkr5tZJQpH/7EgDcc0bsQI3UwNKq5Cowto0CYSkk02++jjsSF5jo+XvkrM6GamEjuk8cWGTLQhtdsJ/JFxc9W1Fr602JCvlNj1HLzNLubulHG4OAXFDB4PrbiHH+waR2mVVIUJhUCCZV1kubv43mEERcBPYFy/+CHVY9P4xhOCp+bcbqr/d4EF/kxb7496CPCLtC9gJPdXXXT3clxfjJQjuMAL8WOKuMidKV5uyRLC5GcIngxEraPCw45/1Xc21ActQ9idUXY6hIBATR7pdClNdTUc8TkHA5 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3799.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(366004)(346002)(136003)(376002)(396003)(39860400002)(6486002)(41300700001)(478600001)(316002)(186003)(2616005)(82960400001)(38100700002)(83380400001)(6506007)(53546011)(107886003)(26005)(6512007)(2906002)(6666004)(36756003)(8936002)(5660300002)(30864003)(31686004)(86362001)(8676002)(66946007)(66476007)(31696002)(4326008)(66556008)(32563001)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RElLazVaT1Y4MzBJYnAzbXUrZCtYWklVaDE0QzJJSm5HYW42M1c5Y09LcnNk?= =?utf-8?B?VzFPZHBCVUpCN29IVVVZaUowaFd2U2I0ODdHVUd1cjZaU3lwVk5uNGs2dHdI?= =?utf-8?B?MXFYSVVXa0thbzI3bndrTTJncXB5WWRybUwwUi9FeFUxWG1HSitRSjN0Uk02?= =?utf-8?B?ditxY1NNM0xlaHdxTFdqUFlNTlhFQmRPeXRsTWtGYjlvSGsxUVpSdkZvaDUv?= =?utf-8?B?Y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xNLzExUWdp?= =?utf-8?B?SVRQWGs5WU9HVk1qYTlxN29adWJvNHhKd2xzVjZkd3U2ZjBCWHU3dWVxSTRz?= =?utf-8?Q?HHt9Fat0z7V+RNM+DUkod+1uH?= X-MS-Exchange-CrossTenant-Network-Message-Id: 342ff29d-d859-4b09-3d72-08da8ff5c8bc X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3799.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2022 10:51:42.6697 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Cf3B9toysJqh7pt8oQio8qPwM3hu0uEcG8EFDk23PGya9ua8JsVg1q2UTNzZZvmJwrYEnZCjhF9nLnrMMgYSBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1822 X-OriginatorOrg: intel.com 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 Hi Tadhg, On 13/07/2022 15:07, Tadhg Kearney wrote: > Add option for setting uncore frequency min/max/index, through uncore api. > This will be set for each package and die on the SKU. On exit, uncore > frequency will be reverted back to previous frequency. > > Signed-off-by: Tadhg Kearney > --- > .../sample_app_ug/l3_forward_power_man.rst | 28 +++ > examples/l3fwd-power/main.c | 190 ++++++++++++++++-- > 2 files changed, 202 insertions(+), 16 deletions(-) > > 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 8f6d906200..1e452140a1 100644 > --- a/doc/guides/sample_app_ug/l3_forward_power_man.rst > +++ b/doc/guides/sample_app_ug/l3_forward_power_man.rst > @@ -97,6 +97,12 @@ where, > * -P: Sets all ports to promiscuous mode so that packets are accepted regardless of the packet's Ethernet MAC destination address. > Without this option, only packets with the Ethernet MAC destination address set to the Ethernet address of the port are accepted. > > +* -u: optional, sets uncore frequency to minimum value. > + > +* -U: optional, sets uncore frequency to maximum value. > + > +* -i (frequency index): optional, sets uncore frequency to frequency index value, by setting min and max values to be the same. > + > * --config (port,queue,lcore)[,(port,queue,lcore)]: determines which queues from which ports are mapped to which cores. > > * --max-pkt-len: optional, maximum packet length in decimal (64-9600) > @@ -364,3 +370,25 @@ in the DPDK Programmer's Guide for more details on PMD power management. > .. code-block:: console > > .//examples/dpdk-l3fwd-power -l 1-3 -- -p 0x0f --config="(0,0,2),(0,1,3)" --pmd-mgmt=scale > + > +Setting Uncore Values > +--------------------- > + > +Uncore frequency can be adjusted through manipulating related sysfs entries to adjust the minimum and maximum uncore values. > +This will be set for each package and die on the SKU. Three options are available for setting uncore frequency: > + > +``-u`` > + This will set uncore to minimum frequency possible. > + > +``-U`` > + This will set uncore to maximum frequency possible. > + > +``-i`` > + This will allow you to set the specific uncore frequency index that you want, by setting > + minimum and maximum values to be the same. Frequency index's are set 100000Hz apart from > + maximum to minimum. > + Frequency index values are in descending order, ie, index 0 is maximum frequency index. > + > +.. code-block:: console > + > + .//examples/dpdk-l3fwd-power -l 1-3 -- -p 0x0f --config="(0,0,2),(0,1,3)" -i 1 > diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c > index 887c6eae3f..5f74e29e3a 100644 > --- a/examples/l3fwd-power/main.c > +++ b/examples/l3fwd-power/main.c > @@ -15,6 +15,8 @@ > #include > #include > #include > +#include > +#include > > #include > #include > @@ -47,6 +49,7 @@ > #include > #include > #include > +#include > > #include "perf_core.h" > #include "main.h" > @@ -71,6 +74,7 @@ > > #ifndef APP_LOOKUP_METHOD > #define APP_LOOKUP_METHOD APP_LOOKUP_LPM > + > #endif > > #if (APP_LOOKUP_METHOD == APP_LOOKUP_EXACT_MATCH) > @@ -83,7 +87,7 @@ > > #ifndef IPv6_BYTES > #define IPv6_BYTES_FMT "%02x%02x:%02x%02x:%02x%02x:%02x%02x:"\ > - "%02x%02x:%02x%02x:%02x%02x:%02x%02x" > + "%02x%02x:%02x%02x:%02x%02x:%02x%02x" > #define IPv6_BYTES(addr) \ > addr[0], addr[1], addr[2], addr[3], \ > addr[4], addr[5], addr[6], addr[7], \ > @@ -134,9 +138,14 @@ > > #define NUM_TELSTATS RTE_DIM(telstats_strings) > > +#define UNCORE_FREQUENCY_DIR "/sys/devices/system/cpu/intel_uncore_frequency" > + > static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; > static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; > > +/* Max number of nodes times dies available on uncore */ > +#define MAX_DIE_NODES (RTE_MAX_NUMA_DIE * RTE_MAX_NUMA_NODES) > + > /* ethernet addresses of ports */ > static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; > > @@ -145,6 +154,8 @@ static rte_spinlock_t locks[RTE_MAX_ETHPORTS]; > > /* mask of enabled ports */ > static uint32_t enabled_port_mask = 0; > +/* if uncore frequency was enabled without errors */ > +static int enabled_uncore; > /* Ports set in promiscuous mode off by default. */ > static int promiscuous_on = 0; > /* NUMA is enabled by default. */ > @@ -165,6 +176,13 @@ struct telstats_name { > char name[RTE_ETH_XSTATS_NAME_SIZE]; > }; > > +struct uncore_info { > + unsigned int pkg; > + unsigned int die; > +}; > + > +struct uncore_info ui[MAX_DIE_NODES]; > + > /* telemetry stats to be reported */ > const struct telstats_name telstats_strings[] = { > {"empty_poll"}, > @@ -557,9 +575,9 @@ static void > print_ipv6_key(struct ipv6_5tuple key) > { > printf( "IP dst = " IPv6_BYTES_FMT ", IP src = " IPv6_BYTES_FMT ", " > - "port dst = %d, port src = %d, proto = %d\n", > - IPv6_BYTES(key.ip_dst), IPv6_BYTES(key.ip_src), > - key.port_dst, key.port_src, key.proto); > + "port dst = %d, port src = %d, proto = %d\n", > + IPv6_BYTES(key.ip_dst), IPv6_BYTES(key.ip_src), > + key.port_dst, key.port_src, key.proto); > } > > static inline uint16_t > @@ -674,9 +692,9 @@ parse_ptype_one(struct rte_mbuf *m) > > static uint16_t > cb_parse_ptype(uint16_t port __rte_unused, uint16_t queue __rte_unused, > - struct rte_mbuf *pkts[], uint16_t nb_pkts, > - uint16_t max_pkts __rte_unused, > - void *user_param __rte_unused) > + struct rte_mbuf *pkts[], uint16_t nb_pkts, > + uint16_t max_pkts __rte_unused, > + void *user_param __rte_unused) > { > unsigned int i; > > @@ -797,8 +815,8 @@ power_idle_heuristic(uint32_t zero_rx_packet_count) > > static inline enum freq_scale_hint_t > power_freq_scaleup_heuristic(unsigned lcore_id, > - uint16_t port_id, > - uint16_t queue_id) > + uint16_t port_id, > + uint16_t queue_id) > { > uint32_t rxq_count = rte_eth_rx_queue_count(port_id, queue_id); > /** > @@ -1051,7 +1069,7 @@ static int main_intr_loop(__rte_unused void *dummy) > * less as possible. > */ > for (i = 1, > - lcore_idle_hint = qconf->rx_queue_list[0].idle_hint; > + lcore_idle_hint = qconf->rx_queue_list[0].idle_hint; > i < qconf->n_rx_queue; ++i) { > rx_queue = &(qconf->rx_queue_list[i]); > if (rx_queue->idle_hint < lcore_idle_hint) > @@ -1616,6 +1634,9 @@ print_usage(const char *prgname) > " [--max-pkt-len PKTLEN]\n" > " -p PORTMASK: hexadecimal bitmask of ports to configure\n" > " -P: enable promiscuous mode\n" > + " -u: set min frequency for uncore\n" > + " -U: set max frequency for uncore\n" > + " -i (frequency index): set frequency index for uncore\n" > " --config (port,queue,lcore): rx queues configuration\n" > " --high-perf-cores CORELIST: list of high performance cores\n" > " --perf-config: similar as config, cores specified as indices" > @@ -1672,6 +1693,112 @@ static int parse_max_pkt_len(const char *pktlen) > return len; > } > > +static int > +parse_uncore_dir(void) > +{ > + DIR *d; > + struct dirent *dir; > + char pkg[3], die[3]; > + unsigned int count = 0; > + static const char filter[] = "*freq_khz*"; > + > + d = opendir(UNCORE_FREQUENCY_DIR); > + if (!d) { > + RTE_LOG(ERR, EAL, "Unable to open uncore frequency directory"); > + return -1; > + } > + > + else { > + /* Loop through every file name in uncore frequency dir extracting > + * pkg + die numbers from file names. > + */ > + while ((dir = readdir(d)) != NULL) { > + if (fnmatch(filter, dir->d_name, 0) > 0) { > + /* Extract pkg + die numbers from string 'package_XX_die_XX' */ > + sprintf(pkg, "%c%c", dir->d_name[8], dir->d_name[9]); > + sprintf(die, "%c%c", dir->d_name[15], dir->d_name[16]); > + ui[count].pkg = atoi(pkg); > + ui[count].die = atoi(die); Prefer to use safer function strtol(). Also, I feel that we should move the sysfs accesses into the new set of API functions as well. Currently it feels like most of it is in the library, but this part is left in the sample app. How about a couple of new APIs to get the max pkg and max die? Could be rte_power_uncore_get_num_pkgs() and rte_power_uncore_get_num_dies(pkg)? That way all the sysfs accesses are hidden. > + count++; > + } > + } > + closedir(d); > + } > + return(count); > +} > + > +static int > +parse_uncore_min_max(const char *choice) > +{ > + int ret = 0, total_files, i; > + unsigned int die, pkg; > + total_files = parse_uncore_dir(); > + > + if (total_files < 1) > + return -1; > + > + for (i = 0; i < total_files; i++) { > + die = ui[i].die; > + pkg = ui[i].pkg; > + rte_power_uncore_init(pkg, die); > + if (!strncmp(choice, "max", 3)) { > + ret = rte_power_uncore_freq_max(pkg, die); > + if (ret == -1) > + RTE_LOG(INFO, L3FWD_POWER, "Unable to set max uncore value for pkg %02u die %02u\n"\ > + , pkg, die); > + } > + > + else if (!strncmp(choice, "min", 3)) { > + ret = rte_power_uncore_freq_min(pkg, die); > + if (ret == -1) { > + RTE_LOG(INFO, L3FWD_POWER, "Unable to set min uncore value for pkg %02u die %02u\n"\ > + , pkg, die); > + return ret; > + } > + } else { > + RTE_LOG(INFO, L3FWD_POWER, "Uncore choice provided invalid\n"); > + return -1; > + } > + } > + > + RTE_LOG(INFO, L3FWD_POWER, "Successfully set max/min uncore frequency.\n"); > + return ret; > +} > + > +static int > +parse_uncore_index(const char *choice) > +{ > + int ret = 0, total_files, i; > + unsigned int die, pkg; > + total_files = parse_uncore_dir(); > + > + if (total_files < 1) > + return -1; > + > + for (i = 0; i < total_files; i++) { > + die = ui[i].die; > + pkg = ui[i].pkg; > + rte_power_uncore_init(pkg, die); > + > + int frequency_index = atoi(choice); Again, prefer to use strtol(). > + int freq_array_len = rte_power_uncore_get_num_freqs(pkg, die); > + if (frequency_index > freq_array_len) { > + RTE_LOG(INFO, L3FWD_POWER, \ > + "Frequency index given out of range, please choose a value from 0 to %d.\n" \ > + , freq_array_len); > + return -1; > + } > + ret = rte_power_set_uncore_freq(pkg, die, frequency_index); > + if (ret == -1) { > + RTE_LOG(INFO, L3FWD_POWER, \ > + "Unable to set uncore index value for pkg %02u die %02u\n", pkg, die); > + return ret; > + } > + } > + RTE_LOG(INFO, L3FWD_POWER, "Successfully set freq index for uncore\n"); > + return ret; > +} > + > static int > parse_portmask(const char *portmask) > { > @@ -1861,10 +1988,12 @@ parse_args(int argc, char **argv) > {CMD_LINE_OPT_SCALE_FREQ_MAX, 1, 0, 0}, > {NULL, 0, 0, 0} > }; > + const char *min = "min"; > + const char *max = "max"; > > argvopt = argv; > > - while ((opt = getopt_long(argc, argvopt, "p:l:m:h:P", > + while ((opt = getopt_long(argc, argvopt, "p:l:m:h:P:u U i:", > lgopts, &option_index)) != EOF) { > > switch (opt) { > @@ -1893,6 +2022,30 @@ parse_args(int argc, char **argv) > limit = parse_max_pkt_len(optarg); > freq_tlb[HGH] = limit; > break; > + case 'u': > + enabled_uncore = parse_uncore_min_max(min); > + if (enabled_uncore < 0) { > + printf("Unable to reach min uncore value\n"); > + print_usage(prgname); > + return -1; > + } > + break; > + case 'U': > + enabled_uncore = parse_uncore_min_max(max); > + if (enabled_uncore < 0) { > + printf("Unable to reach max uncore value\n"); > + print_usage(prgname); > + return -1; > + } > + break; > + case 'i': > + enabled_uncore = parse_uncore_index(optarg); > + if (enabled_uncore < 0) { > + printf("Unable to reach uncore index value\n"); > + print_usage(prgname); > + return -1; > + } > + break; > /* long options */ > case 0: > if (!strncmp(lgopts[option_index].name, "config", 6)) { > @@ -2003,8 +2156,8 @@ parse_args(int argc, char **argv) > } > > if (!strncmp(lgopts[option_index].name, > - CMD_LINE_OPT_PARSE_PTYPE, > - sizeof(CMD_LINE_OPT_PARSE_PTYPE))) { > + CMD_LINE_OPT_PARSE_PTYPE, > + sizeof(CMD_LINE_OPT_PARSE_PTYPE))) { > printf("soft parse-ptype is enabled\n"); > parse_ptype = 1; > } > @@ -2262,7 +2415,7 @@ check_all_ports_link_status(uint32_t port_mask) > rte_eth_link_to_str(link_status_text, > sizeof(link_status_text), &link); > printf("Port %d %s\n", portid, > - link_status_text); > + link_status_text); > continue; > } > /* clear all_ports_up flag if any link down */ > @@ -2365,6 +2518,8 @@ static int > deinit_power_library(void) > { > unsigned int lcore_id; > + int i, total_files; > + total_files = parse_uncore_dir(); > int ret = 0; > > RTE_LCORE_FOREACH(lcore_id) { > @@ -2377,6 +2532,9 @@ deinit_power_library(void) > return ret; > } > } > + > + for (i = 0; i < total_files; i++) > + rte_power_uncore_exit(ui[i].pkg, ui[i].die); > return ret; > } > > @@ -2734,7 +2892,7 @@ main(int argc, char **argv) > "err=%d, port=%d\n", ret, portid); > > ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd, > - &nb_txd); > + &nb_txd); > if (ret < 0) > rte_exit(EXIT_FAILURE, > "Cannot adjust number of descriptors: err=%d, port=%d\n", > @@ -2791,7 +2949,7 @@ main(int argc, char **argv) > txconf = &dev_info.default_txconf; > txconf->offloads = local_port_conf.txmode.offloads; > ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd, > - socketid, txconf); > + socketid, txconf); > if (ret < 0) > rte_exit(EXIT_FAILURE, > "rte_eth_tx_queue_setup: err=%d, "