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 C8D4D43BF7; Tue, 27 Feb 2024 17:18:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B3D9042EA2; Tue, 27 Feb 2024 17:18:33 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2040.outbound.protection.outlook.com [40.107.223.40]) by mails.dpdk.org (Postfix) with ESMTP id 699C9410EE for ; Tue, 27 Feb 2024 17:18:31 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gbTltBWmNEa91LPXmJ5lHd8IGtSWxyg7bJC0v2eTi2C0md7MizNgowS3oiHh+NTw/StAgx9wMO3bldRx3pV6SLvgHg08Sav3pfD0JOIp9W5qURnFYhtZXUzf1aXJWQyd3A7CpZpKo2WK1y6Rlc4wsjWaeOYmMQDiF+DsbVe+cP4Ye01v9sXezT4em/cJYNT3Zi/qRfxBVENypzrGYozpLnfzBD4bjWQDLXbjtVJ4AzhQZcuRThM5DTpMxqHzKu+1jlM9X4T5F3364b3Hqtd3LVERdFMTSbMFoWPok8xuSS6tZtx1VIMYHnb/93UtbiwQr67X4T4l6fS/GB0mFJKnJQ== 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=AuayitXnHjECmep429sbkgoJmCa1+glv0qu5lfJ+UN8=; b=niYuHY4TmAfDhak4ax7ArpStac89y3ScsrD/Z9JGlZMlOZevgXoQn87MpSJttnlT2hBaWG5B75STxQq+Gw3jXAoGcjF3o2Zqnlv5p+4E9LgjXpaj6KIxWfxr/qk7jz91IOwfle0ldmTmR0H8PTuIllhbE50Z9cKHRbUJ75Bj/W8mG/PT5Uht2GH/73iOJdcbgEdc8270lKcVvTfJWKKzDnI4z1vj7VOWd9js056i9x4h7WdF7MvZYptYjdJ5RLuNHVoMfX/MMqpixpXJUKdUide0pN7bTI8nVeIQ/cb+0sbF9ZWIL/BiJWzYuSxbXZFMz6wSGo1nm5DO4LtCeHRKuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AuayitXnHjECmep429sbkgoJmCa1+glv0qu5lfJ+UN8=; b=ZJguEmsYpafuj3ywwV/0owhN6X9Vej76aMhgIVk67mcnfQohFTSNnDkiXH+wcfbVtVhIRx3v+He5yANUB7Mdu+Go/VMrO5/GBRvLBLaJk3dQ2z5uGZNZQn9KeGKXzNtR5HaF+jTslxa2+5wUEELwOyY1acsadx2QFQREZHodrBw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by LV8PR12MB9155.namprd12.prod.outlook.com (2603:10b6:408:183::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Tue, 27 Feb 2024 16:18:28 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3ec7:6339:1c14:c529]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3ec7:6339:1c14:c529%5]) with mapi id 15.20.7316.035; Tue, 27 Feb 2024 16:18:28 +0000 Message-ID: Date: Tue, 27 Feb 2024 16:18:23 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/2] power: refactor core power management library To: Sivaprasad Tummala , david.hunt@intel.com, anatoly.burakov@intel.com, jerinj@marvell.com, radu.nicolau@intel.com, gakhil@marvell.com, cristian.dumitrescu@intel.com, konstantin.ananyev@huawei.com Cc: dev@dpdk.org References: <20240220153326.6236-1-sivaprasad.tummala@amd.com> <20240220153326.6236-3-sivaprasad.tummala@amd.com> Content-Language: en-US From: Ferruh Yigit Autocrypt: addr=ferruh.yigit@amd.com; keydata= xsFNBGJDD3EBEAC/M7Tk/DfQSmP1K96vyzdhfSBzlCaGtcxNXorq4fALruqVsD3oi0yfyEz9 4YN8x7py0o9EL8ZdpOX0skc0AMCDAaw033uWhCn0GLMeGRKUbfOAPvL6ecSDvGD7CJIO9j0J eZUvasBgPdM/435PEr9DmC6Ggzdzt8IuG4PoLi5jpFSfcqxZFCCxLUDEo/w0nuguk2FTuYJg B2zEZ4JTBZrw7hIHiFh8D8hr6YA6a5uTofq1tr+l048lbtdFUl8TR0aIExVzE4Z8qKZlcE+9 RQaewjK5Al1jLE4sHdmd3GN+IvgDF3D/fLsi25SKJDeGSdeHkOmaX0qGeM4WKIfU6iARRCiQ N3AmBIxZ/A7UXBKLaOyZ+/i3sE6Wb53nrO4i8+0K2Qwyh6LjTeiJAIjYKN43ppxz3DaI+QwQ vI+uyHr4Gg0Da9EPPz/YyKauSeOZCfCB5gIfICO0j6x0SCl8uQ2nLpjxcZkf0gjcwUzP3h+S 3x6NfDji9YEij0zczW/dcSpGgZ6vsFpPrtnP9ZXy6J53yp0kJtOJoOlkEFFdU2yCZnCDseum CoudmGLZVvS0/DzHDJejq+3kK3FDGktZBOxZIIpal+nFqS7lVgOZc4+huVv3jyhzoAUOEyXA XK5j6o7g8STUY+z33QNnHpdLvecMwuzmvqy0jR54yAbZ64mB9QARAQABzSNGZXJydWggWWln aXQgPGZlcnJ1aC55aWdpdEBhbWQuY29tPsLBlwQTAQgAQQIbAwULCQgHAgYVCgkICwIEFgID AQIeAQIXgAIZARYh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ZUMTzME5PFCXJIZ83qkZQ795MTe2YScp9dIV7fsS5tpDwIs7BZNVM1l3NAdK+DLHqNxKuyO 8Zk= In-Reply-To: <20240220153326.6236-3-sivaprasad.tummala@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0047.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ac::14) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|LV8PR12MB9155:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f829ca6-41c5-4792-35c3-08dc37afbba6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PUoDloE2mEA5fhrTIg8a3vJDgTXYs0zvWWDtmmehgcEDSqDVMPUWTEw0ALTol1+lRo9f57r+P+BPZwLd0lRkGR5XbgntxKw66tbR+XaH5XUIabJGjpPOxbGfKBrJ6EqZOzNIniteTiqJsMxyswbOWbZowQyRM+3IHX2Stm+oVuxWBF2Toa92t+AreAdJy9oQqbFeAP7R0opbIlprpoVk5BEFNy84FKPY1CtjaO4JzG8iHUVjkDWXkZmLWh0jMm9NUelhgX/lRZH9Dnu/DVDNB8h3A2IjTVr8nDFTA70DyH53GY1Hwsn/Xv1MF20M7kkhRZPgl1nKpXCbhvkY1sI72XW/kJhrYpw8lZNbdef3pH9tvAD7lZcHG/mTfaPA9JNsAVIl2uKjAZD2NKnhy8ZTpSqEPZU0ALfcQV5Y57unavcNG44zbjQpqUk+KhUMeQz+kW841H25pRymRUoYZo7fwFtZu7ZaLvRl7UXPPaiSXuIY8DEx+qOD2v1Nim9NAIon9afyMlnJcbDN4JfQdJL1g8s0zoiNn8+LcaHKFLfe9hgKA+5+ofaewAeS1T7ZRGWvAXocw2DPp647gNyII5G6afc3JgqGyvojV3HZ0k53yrnEQBsNLx6dUqgSd0t+iCfDW7zUmm1bTQEQMM3iSIPTaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N0JyWnRSZ1hXbjdWbHJVWTJDYzNqSEQ4TkZVVk9JbFU3ZHR3c2c0K0cyMG40?= =?utf-8?B?bXdzeC94bG5DTWh5b3JveCswOXg2L2U0cnRIZXpPU2lIbDJUTEFSL2w4YUNv?= =?utf-8?B?ODBQQ0RJLzNJN0wzZ2svZmNGU2R4Z0hjcUYxNUFWbFZwbVJzb2R0L0RQeVdj?= =?utf-8?B?eVZYQ3hKYWxpUkl0YWtFallEL2gxZ0ZWQURmd0hXUlUvbHZMMkk4UGNjQVZN?= =?utf-8?B?WkZKYmRpdVRKMm5UT3ZsVStIV3FUb0RJaWY1SGduUVgzU2duVi93S0NhMDlh?= =?utf-8?B?MXlhLzhMQnozL2FOWVA5VFlncUxiQ1RIcmNJMXI3QitUbXNLY25EbFIwWDhB?= =?utf-8?B?VzVnYTBBaHpUV1FGMitzcHBZK1hRUW9SUk96eWltWGl5bnlMNUVtWmZxdXNV?= =?utf-8?B?UXg1TC90eWVWdjQzUTBWZG9IeFFHMGN1MWRmVzhNYkQxTFg4ZUpqam1yNGxy?= =?utf-8?B?ZkZZV2hML0xTOHpPUGVZamdJN3llNHM2d2Z6OXd2eC9rK3p6VDJRM2YrVE1Y?= =?utf-8?B?WlVQTW5oR1Rub0lOM3VTWkJCQTRZb1lkNGYrdGF4WVYzbkJPai9YRjZzMGds?= =?utf-8?B?OU5udk5lY0pZd1FwUk1DOGREK3hpcFIwYmJFSnRQWFZiR2tIK21IMmFMbUNR?= =?utf-8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hHRi9h?= =?utf-8?B?YjJIZkpHbFFvNkpreVM1NmJvNHdrbWJ5YnFONnlmMkl0d0FEOEoxTHVqYUIz?= =?utf-8?B?bGFjZkxBRVIySmd2cGNySGxhU1NLZUdpT1JVOVBMaFJwVXM4Snc1aDdXSTBu?= =?utf-8?B?U0oxYnBuZHNpVC95b3Y3c2ttQVdtYnh0MkpFdkdnTWM1UjNLeU84aFBnR29N?= =?utf-8?B?dENxRGlub1cxaWhzMjRMMVFkUjFEa2h2YXNSWE1rT0laNFBzcnpQWU1yK0hB?= =?utf-8?B?eGpwaWlJTVBlQWJoZU1kSFY3Q2NsRUdMbmZ5am1GTFFvWUw4MlpmbTBYbXhD?= =?utf-8?B?UFpMd3VSTHBLRmZBV21zRWZMR2NwWVRGNWM5aUlDY1FtU3k2aytOS2hyTWRw?= =?utf-8?B?UmxSb2p4dHJJdkVrdEZMaCtWSHZWNUhiQTRnVzM3VEVGVmlXOUNQaHJoZDl2?= =?utf-8?B?YklXMTJVUGJ4L3BhdUdGYnVNUUI5RElRSlY5K1hkVE1FZFdQb0g4OFRJVWpl?= =?utf-8?B?UmtEbTFvM01uVmJ2V3FMMHNDMWJpalVEL0F0eVJDZ05icmRoTHRjWUhucWlh?= =?utf-8?Q?qh5vE+xjzTkUWp6tfkfvPaxfF?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f829ca6-41c5-4792-35c3-08dc37afbba6 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 16:18:28.7955 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lfNMW9nOCY0am1n1/9RiU0FMcpMWGMesu8YdhYHat+VYDhbNKBsePzN8Q4L7ttPk X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9155 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 On 2/20/2024 3:33 PM, Sivaprasad Tummala wrote: > This patch introduces a comprehensive refactor to the core power > management library. The primary focus is on improving modularity > and organization by relocating specific driver implementations > from the 'lib/power' directory to dedicated directories within > 'drivers/power/core/*'. The adjustment of meson.build files > enables the selective activation of individual drivers. > > These changes contribute to a significant enhancement in code > organization, providing a clearer structure for driver implementations. > The refactor aims to improve overall code clarity and boost > maintainability. Additionally, it establishes a foundation for > future development, allowing for more focused work on individual > drivers and seamless integration of forthcoming enhancements. > > Signed-off-by: Sivaprasad Tummala > +1 to refactor, thanks for the work. There are multiple power implementations but all are managed withing the power library, it is good idea to extract different implementations as drivers. <...> > diff --git a/drivers/power/core/acpi/meson.build b/drivers/power/core/acpi/meson.build > new file mode 100644 > index 0000000000..d10ec8ee94 > --- /dev/null > +++ b/drivers/power/core/acpi/meson.build > @@ -0,0 +1,8 @@ > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2024 AMD Limited > It should be as following, same for all: Copyright (C) 2024, Advanced Micro Devices, Inc. > + > +sources = files('power_acpi_cpufreq.c') > + > +headers = files('power_acpi_cpufreq.h') > In meson, 'headers' variable is used to install the header, this is required for the case user needs to include the header but I guess that is not the case for power libraries. Can you please check if the 'header' variable in meson is required? <...> > @@ -577,3 +577,22 @@ int power_acpi_get_capabilities(unsigned int lcore_id, > > return 0; > } > + > +static struct rte_power_ops acpi_ops = { > + .init = power_acpi_cpufreq_init, > + .exit = power_acpi_cpufreq_exit, > + .check_env_support = power_acpi_cpufreq_check_supported, > + .get_avail_freqs = power_acpi_cpufreq_freqs, > + .get_freq = power_acpi_cpufreq_get_freq, > + .set_freq = power_acpi_cpufreq_set_freq, > + .freq_down = power_acpi_cpufreq_freq_down, > + .freq_up = power_acpi_cpufreq_freq_up, > + .freq_max = power_acpi_cpufreq_freq_max, > + .freq_min = power_acpi_cpufreq_freq_min, > + .turbo_status = power_acpi_turbo_status, > + .enable_turbo = power_acpi_enable_turbo, > + .disable_turbo = power_acpi_disable_turbo, > + .get_caps = power_acpi_get_capabilities > +}; > + With current usage of the ops struct, I guess all can be "static const". <...> > diff --git a/drivers/power/core/kvm-vm/meson.build b/drivers/power/core/kvm-vm/meson.build > new file mode 100644 > index 0000000000..3150c6674b > --- /dev/null > +++ b/drivers/power/core/kvm-vm/meson.build > @@ -0,0 +1,20 @@ > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(C) 2024 AMD Limited. > +# > + > +if not is_linux > + build = false > + reason = 'only supported on Linux' > + subdir_done() > +endif > Before refactoring, in lib/power was supported only for Linux, I assume this means all existing power libraries supported only for Linux. If so above check can be added to all drivers. <...> > +/* register the ops struct in rte_power_ops, return 0 on success. */ > +int > +rte_power_register_ops(const struct rte_power_ops *op) > +{ > + struct rte_power_ops *ops; > + > + if (op->env >= PM_ENV_MAX) { > + POWER_LOG(ERR, "Unsupported power management environment\n"); > + return -EINVAL; > + } > + > + if (op->status != 0) { > + POWER_LOG(ERR, "Power management env[%d] ops registered already\n", > + op->env); > + return -EINVAL; > + } > + > + if (!op->init || !op->exit || !op->check_env_support || > + !op->get_avail_freqs || !op->get_freq || !op->set_freq || > + !op->freq_up || !op->freq_down || !op->freq_max || > + !op->freq_min || !op->turbo_status || !op->enable_turbo || > + !op->disable_turbo || !op->get_caps) { > + POWER_LOG(ERR, "Missing callbacks while registering power ops\n"); > + return -EINVAL; > + } > + > + ops = &rte_power_ops[op->env]; > I don't see all drivers set 'op->env', This 'rte_power_register_ops()' function copies ops from driver proved struct to library global 'rte_power_ops[]' array, it can be possible to store ops pointer provided by driver, instead of copying it. And it can be possible to link the ops in this function, instead of putting them to specific index, as only one ops can be active in a given time, it can be possible to store active ops pointer in a global variable which removes the need to have index accessible array for ops. <...> > @@ -177,59 +138,76 @@ int > rte_power_init(unsigned int lcore_id) > { > int ret = -1; > + struct rte_power_ops *ops; > > - switch (global_default_env) { > - case PM_ENV_ACPI_CPUFREQ: > - return power_acpi_cpufreq_init(lcore_id); > - case PM_ENV_KVM_VM: > - return power_kvm_vm_init(lcore_id); > - case PM_ENV_PSTATE_CPUFREQ: > - return power_pstate_cpufreq_init(lcore_id); > - case PM_ENV_CPPC_CPUFREQ: > - return power_cppc_cpufreq_init(lcore_id); > - case PM_ENV_AMD_PSTATE_CPUFREQ: > - return power_amd_pstate_cpufreq_init(lcore_id); > - default: > - POWER_LOG(INFO, "Env isn't set yet!"); > + if (global_default_env != PM_ENV_NOT_SET) { > + ops = &rte_power_ops[global_default_env]; > + if (!ops->status) { > + POWER_LOG(ERR, "Power management env[%d] not" > + " supported\n", global_default_env); > + goto out; > + } > + return ops->init(lcore_id); > } > + POWER_LOG(INFO, POWER, "Env isn't set yet!\n"); > > /* Auto detect Environment */ > - POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management..."); > - ret = power_acpi_cpufreq_init(lcore_id); > - if (ret == 0) { > - rte_power_set_env(PM_ENV_ACPI_CPUFREQ); > - goto out; > + POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq" > + " power management...\n"); > Shouldn't break the log, can break the line by keeping message whole: POWER_LOG(INFO, "Attempting to initialise ACPI cpufreq power management..."); <...> > @@ -21,7 +22,7 @@ extern "C" { > /* Power Management Environment State */ > enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM, > PM_ENV_PSTATE_CPUFREQ, PM_ENV_CPPC_CPUFREQ, > - PM_ENV_AMD_PSTATE_CPUFREQ}; > + PM_ENV_AMD_PSTATE_CPUFREQ, PM_ENV_MAX}; > Syntax. Can we have enum item per line? > /** > * Check if a specific power management environment type is supported on a > @@ -66,6 +67,97 @@ void rte_power_unset_env(void); > */ > enum power_management_env rte_power_get_env(void); > > +typedef int (*rte_power_cpufreq_init_t)(unsigned int lcore_id); > +typedef int (*rte_power_cpufreq_exit_t)(unsigned int lcore_id); > +typedef int (*rte_power_check_env_support_t)(void); > + > +typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs, > + uint32_t num); > +typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id); > +typedef int (*rte_power_set_freq_t)(unsigned int lcore_id, uint32_t index); > +typedef int (*rte_power_freq_change_t)(unsigned int lcore_id); > + > I guess above is not required for users, what do you think to create a driver header file and move these to driver header file? <...> > + > +/** > + * Macro to statically register the ops of a cpufreq driver. > + */ > +#define RTE_POWER_REGISTER_OPS(ops) \ > + (RTE_INIT(power_hdlr_init_##ops) \ > + { \ > + rte_power_register_ops(&ops); \ > + }) > is () required around RTE_INIT() > + > +/** > + * @internal Get the power ops struct from its index. > + * > + * @param ops_index > + * The index of the ops struct in the ops struct table. > + * @return > + * The pointer to the ops struct in the table if registered. > + */ > +struct rte_power_ops * > +rte_power_get_ops(int ops_index); > + > /** > * Initialize power management for a specific lcore. If rte_power_set_env() has > * not been called then an auto-detect of the environment will start and > @@ -108,10 +200,14 @@ int rte_power_exit(unsigned int lcore_id); > * @return > * The number of available frequencies. > */ > -typedef uint32_t (*rte_power_freqs_t)(unsigned int lcore_id, uint32_t *freqs, > - uint32_t num); > +static inline uint32_t > +rte_power_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t n) > +{ > + struct rte_power_ops *ops; > > -extern rte_power_freqs_t rte_power_freqs; > + ops = rte_power_get_ops(rte_power_get_env()); > + return ops->get_avail_freqs(lcore_id, freqs, n); > +} > Why not proper functions but "static inline functions"? > > /** > * Return the current index of available frequencies of a specific lcore. > @@ -124,9 +220,14 @@ extern rte_power_freqs_t rte_power_freqs; > * @return > * The current index of available frequencies. > */ > -typedef uint32_t (*rte_power_get_freq_t)(unsigned int lcore_id); > +static inline uint32_t > +rte_power_get_freq(unsigned int lcore_id) > +{ > + struct rte_power_ops *ops; > > -extern rte_power_get_freq_t rte_power_get_freq; > + ops = rte_power_get_ops(rte_power_get_env()); > As 'rte_power_get_env()' already returns a global variable, why not set a global ops pointer and directly access to them, is above abstraction providing any benefit?