From patchwork Wed May 3 17:03:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sivaprasad Tummala X-Patchwork-Id: 126676 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 EFC0442A51; Wed, 3 May 2023 19:04:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6C9341144; Wed, 3 May 2023 19:04:09 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) by mails.dpdk.org (Postfix) with ESMTP id 62947410F9 for ; Wed, 3 May 2023 19:04:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wi4LdPOL6V3QUfudGwB5JObb9p2DPD09Og2MOhbBjVkZztr/OjfjQ6dG4ttD8Q0L8g2NWDbPHPl2OaREKOlBuSNg0JVMma+q0coHArihnqD+TCM8KPiilDX4NahafcSkQusKFT/5+oyY2oehYJKCPK2BD4Gtz2Lk4i+z0FU4V2hI9vlzJqhm2YtEKI7KyeCGALam6A7RRAfX6icKAhu1SQ2qNlq+3cr0L6EUU22sXndfb1d1YjQ1O3TiddM4UMFzKai7W4Z113euZ2YWWY3iNbkEroVAciob6utr0t4MTWOkJmY9+g/UmasGD7ZCNUmj3dK7WspM0276qkBMyovLYw== 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=3onPbz/MN589nec+1zNnsU4yXlZrecpRcAH8reJ8n5M=; b=AyGTNX7qASFXSOYjAT0rfIrr0M7L1/S9VBFVucZb62gBpeP6ARo8mbOD8YmDIhmBYpn/MG9WOeynOOUpr4iT+Qrkfh+hoxOpWhp41zd+4K2ZcpnLvIyU3gA+5q4JINnS/XA65a6npgPZz+CBnKlX20Q+t385cXW1S6PO8LdA+H7Ry1RmqfWvX40fJdlElgNEbJfCZujggi7bvnqp53boNg1/C4PqSPGKVbLgwNC36kobt+udytFfB49UCjH5izM7GM8JrIjuK69v992rQhUtYBg+d/+a+0ktT0WlCM776ov1DCGsfquSnezi7G2OLyF8RjJqluZLQJI1OWLyxTVoqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=3onPbz/MN589nec+1zNnsU4yXlZrecpRcAH8reJ8n5M=; b=Qc8txw0Sc5jPa9vU4/zCordH9IqQB7GOW3z4Daxa0OyolVKgEFHruZU6k/phhlRrUNTx0ddwQoneVhECRXdrTkbwTuVICMlX1XQ4vZXRhm7Mi2r2ZM7zPP5MiEaEaWy113so9dnAFn7rI0y4U3wXyURXhALf7f7Y0a51K3d+eMs= Received: from DM6PR07CA0056.namprd07.prod.outlook.com (2603:10b6:5:74::33) by SN7PR12MB8169.namprd12.prod.outlook.com (2603:10b6:806:32f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.31; Wed, 3 May 2023 17:04:06 +0000 Received: from DM6NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::55) by DM6PR07CA0056.outlook.office365.com (2603:10b6:5:74::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22 via Frontend Transport; Wed, 3 May 2023 17:04:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT018.mail.protection.outlook.com (10.13.172.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6363.21 via Frontend Transport; Wed, 3 May 2023 17:04:04 +0000 Received: from telco-siena.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 3 May 2023 12:04:03 -0500 From: Sivaprasad Tummala To: CC: , , , Sivaprasad Tummala Subject: [RFC PATCH] power: refactor uncore power management interfaces Date: Wed, 3 May 2023 10:03:49 -0700 Message-ID: <20230503170349.740528-1-sivaprasad.tummala@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT018:EE_|SN7PR12MB8169:EE_ X-MS-Office365-Filtering-Correlation-Id: ff8a0cd3-0314-4250-e22a-08db4bf86689 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xhjPc0+4vx3j2Ap51INJqO13njJe/L0+xsR5t9qSdGvnwJkVgI5gMfv/ugojl9LtJcLkK1nkXaQ297ZS5Wbq/thCg3SiNBXTFGpbQU5xC8RaU1JoKTrbKKDljKBIE+A9Z1wzKB2uCTvasRknsTnEQThZF6ZPMKlys/Qc3bL2TsLPrZ7U9anMd/+b+CkhBA3rn5ng/oWwrMQe2OKpZt+DOpxUc24q6WdSxE8eWFfHPOeC9PSyLj46DrkwJSoxOPPiaOe9TLm+fN+LH/uq0FvIYbWuUILDsN7+QQdGANZKGxgsxT5QDX99GXFcF1xpbOJPG4g+wSzP4c44HqKO77ioWLheyt/1y7wv8xwrWGtnc5L7i4DrdxHl8AiTPnfGSjVGqw+Fy9dt3n/0Rgkal1Dob8p8JW/sm5KvziUMHsntF9tM5qyGs+ycEpyaLPi8hvShRfB+N6Ewjti7kpD19+v5rX25PI4WZ3n1wcCi7/DPNAcV4X453ccZClcS6Csac7wk8aXAZZUB3qexFfIvdVVkQ+lmibq9+ulBv22Nj8O4nJDD1A6bUAG+B05LSNYgzOZdaTf0d3bX5QKnTPE9n8zT2d0RBDQePU+6BCNmWfmuh5UL7c0P/JREsauF+fnAzZCLnXsNpNSonZ3Idu6aIYhrPqEcuqGsNnjsPak1BALRSg4mZ9dH/C9xePaN7IpxBW9nbhmW+6foqqMXzNKRSDmCz63hy0/EznjNbHO5iLG1F6Q= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(40470700004)(46966006)(36840700001)(7696005)(6666004)(36860700001)(47076005)(426003)(83380400001)(336012)(6916009)(2906002)(40480700001)(1076003)(26005)(16526019)(186003)(2616005)(478600001)(82310400005)(36756003)(54906003)(81166007)(41300700001)(70586007)(70206006)(82740400003)(356005)(316002)(8936002)(8676002)(40460700003)(86362001)(4326008)(5660300002)(44832011)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2023 17:04:04.6560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff8a0cd3-0314-4250-e22a-08db4bf86689 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8169 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 From: Sivaprasad Tummala currently the uncore power management implementation is vendor specific. Added new vendor agnostic uncore power interface similar to rte_power and subsequently will rename specific implementations ("rte_power_intel_uncore") to "power_intel_uncore" along with functions. Signed-off-by: Sivaprasad Tummala --- lib/power/rte_power_uncore.h | 234 +++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 lib/power/rte_power_uncore.h diff --git a/lib/power/rte_power_uncore.h b/lib/power/rte_power_uncore.h new file mode 100644 index 0000000000..196fb9ec01 --- /dev/null +++ b/lib/power/rte_power_uncore.h @@ -0,0 +1,234 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Intel Corporation + * Copyright(c) 2023 AMD Corporation + */ + +#ifndef RTE_POWER_UNCORE_H +#define RTE_POWER_UNCORE_H + +/** + * @file + * RTE Uncore Frequency Management + */ + +#include +#include "rte_power.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Uncore Power Management Environment */ +enum uncore_power_mgmt_env { UNCORE_PM_ENV_NOT_SET, + UNCORE_PM_ENV_INTEL_UNCORE, UNCORE_PM_ENV_AMD_HSMP}; + +/** + * Initialize uncore frequency management for specific die on a package. + * It will get the available frequencies and prepare to set new die frequencies. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * - 0 on success. + * - Negative on error. + */ +__rte_experimental +int +rte_power_uncore_init(unsigned int pkg, unsigned int die); + +/** + * Exit uncore frequency management on a specific die on a package. + * It will restore uncore min and* max values to previous values + * before initialization of API. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * - 0 on success. + * - Negative on error. + */ +__rte_experimental +int +rte_power_uncore_exit(unsigned int pkg, unsigned int die); + +/** + * Return the current index of available frequencies of a specific die on a package. + * It should be protected outside of this function for threadsafe. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * The current index of available frequencies. + * If error, it will return 'RTE_POWER_INVALID_FREQ_INDEX = (~0)'. + */ +typedef uint32_t (*rte_power_get_uncore_freq_t)(unsigned int pkg, unsigned int die); + +extern rte_power_get_uncore_freq_t rte_power_get_uncore_freq; + +/** + * Set minimum and maximum uncore frequency for specified die on a package + * to specified index value. + * It should be protected outside of this function for threadsafe. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * @param index + * The index of available frequencies. + * + * @return + * - 1 on success with frequency changed. + * - 0 on success without frequency changed. + * - Negative on error. + */ +typedef int (*rte_power_set_uncore_freq_t)(unsigned int pkg, unsigned int die, uint32_t index); + +extern rte_power_set_uncore_freq_t rte_power_set_uncore_freq; + +/** + * Function pointer definition for generic frequency change functions. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * - 1 on success with frequency changed. + * - 0 on success without frequency changed. + * - Negative on error. + */ +typedef int (*rte_power_uncore_freq_change_t)(unsigned int pkg, unsigned int die); + +/** + * Set minimum and maximum uncore frequency for specified die on a package + * to maximum value according to the available frequencies. + * It should be protected outside of this function for threadsafe. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * - 1 on success with frequency changed. + * - 0 on success without frequency changed. + * - Negative on error. + */ +extern rte_power_uncore_freq_change_t rte_power_uncore_freq_max; + +/** + * Set minimum and maximum uncore frequency for specified die on a package + * to minimum value according to the available frequencies. + * It should be protected outside of this function for threadsafe. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * + * @return + * - 1 on success with frequency changed. + * - 0 on success without frequency changed. + * - Negative on error. + */ +extern rte_power_uncore_freq_change_t rte_power_uncore_freq_min; + +/** + * Return the list length of available frequencies in the index array. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * @param die + * Die number. + * Each package can have several dies connected together via the uncore mesh. + * @param freqs + * The buffer array to save the frequencies. + * @param num + * The number of frequencies to get. + * + * @return + * - The number of available index's in frequency array. + * - Negative on error. + */ +typedef int (*rte_power_uncore_freqs_t)(unsigned int pkg, unsigned int die, + uint32_t *freqs, uint32_t num); + +extern rte_power_uncore_freqs_t rte_power_uncore_freqs; + +/** + * Return the number of packages (CPUs) on a system + * by parsing the uncore sysfs directory. + * + * This function should NOT be called in the fast path. + * + * @return + * - Zero on error. + * - Number of package on system on success. + */ +typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(void); + +extern rte_power_uncore_get_num_pkgs_t rte_power_uncore_get_num_pkgs; + +/** + * Return the number of dies for pakckages (CPUs) specified + * from parsing the uncore sysfs directory. + * + * This function should NOT be called in the fast path. + * + * @param pkg + * Package number. + * Each physical CPU in a system is referred to as a package. + * + * @return + * - Zero on error. + * - Number of dies for package on sucecss. + */ +typedef unsigned int (*rte_power_uncore_get_num_pkgs_t)(unsigned int pkg); + +extern rte_power_uncore_get_num_dies_t rte_power_uncore_get_num_dies; + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_POWER_UNCORE_H */