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 849E74307F; Wed, 16 Aug 2023 12:10:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7396843255; Wed, 16 Aug 2023 12:10:17 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by mails.dpdk.org (Postfix) with ESMTP id F323140EF0 for ; Wed, 16 Aug 2023 12:10:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azx3+c9t5q3akmTSCeXqtdKAOneAKqlknGz94ilrs/ECXzYVvy6HVGGMT70ytYytxM09VbMq9kyuytwKS5rx2eB8QMpQs+LGMRsTxtJVgnv/5aoz4XiSujue64E9g8t+8mBzX5477hk83gndATWU5Ityt5Nj1oYz7F8QvqDQD4OYgwpWI0guRuZCK/6KX207gpYb46/0+hgbxFnrAaOteuIRVNzLGPA1CzJZ8p8O58QLzF3QY6w0efiB5n8F5Zj78v3zaxcZh9DxsKcOhIw0BC82V24QwJBmkIBQEfDBiuqbcuGUK14sHv20BCiwBmbQeiqhCrxCBIk/v3CifoYu8Q== 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=cM8qwMTOF7BH82qrUi/Yr8NetsjAONJ8xtZoVnI1ysg=; b=AEY4PbdeyVIWSVHxhvQVG79uCzyvR0+KAEah80iPIOUK8L9tcdX900BgUZDgTwOkbs7xPAkwqycfHJ4p7ohw2lV0JAT0eoot5RVy76XnVVPA+qH+pYhS2DwBYVQQ5gc7p3RA2w0I08TDF7gnv0ubIP1vno/eaWPnj3XihN7XJC1EvL8wtm9X0aclY+3W3J/fKAYNG9/63SxJEzst7myj9E+KkAeCCpYZa9L1pS8LwKnQWa07u+wlfX8LQRCvwXRC4q7uH/haUL2RyXVRieuNd0opUhl6aQl8ZqjDw0N6fT2PYrAcCPwmLVG9dkE8hwOR0d7d9R/jwGf8t5VZq7J4MA== 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=cM8qwMTOF7BH82qrUi/Yr8NetsjAONJ8xtZoVnI1ysg=; b=eDRF0PzScxm3VS4G9ileVzkP/bCNbVH2FIaKfK2gP5ARs7u1qqDVOa9+Dl9mn48SAi2KFWym8TPaTkY9Vi8R1+98u83x9+EtN+F9ls9dZDzz+qO+61IBa5N1EPRfg458GcfF28GfanRLqFEgbBHBEPhak1t9nFb2w5AVOUfmKcU= Received: from DM6PR11CA0031.namprd11.prod.outlook.com (2603:10b6:5:190::44) by SJ2PR12MB9163.namprd12.prod.outlook.com (2603:10b6:a03:559::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 10:10:13 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:5:190:cafe::27) by DM6PR11CA0031.outlook.office365.com (2603:10b6:5:190::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.33 via Frontend Transport; Wed, 16 Aug 2023 10:10:12 +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 CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.14 via Frontend Transport; Wed, 16 Aug 2023 10:10:12 +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.2507.27; Wed, 16 Aug 2023 05:10:11 -0500 From: Sivaprasad Tummala To: , , CC: Subject: [PATCH v2 1/2] power: refactor uncore power management interfaces Date: Wed, 16 Aug 2023 03:09:57 -0700 Message-ID: <20230816100958.1022206-1-sivaprasad.tummala@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230811102534.491000-1-sivaprasad.tummala@amd.com> References: <20230811102534.491000-1-sivaprasad.tummala@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE31:EE_|SJ2PR12MB9163:EE_ X-MS-Office365-Filtering-Correlation-Id: f50a7404-6c24-4b2b-0bb3-08db9e40fafd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KmqVlqqm0MruBlRuGDrSkRsuc0VgJ5nLe1V22RkWLIKA8PX378RHosaeuMkNHJ7oerhGcP01CAcmG9YMTedWouRGM8EtGFCsmWd1DeiBWBM/UisQcQmvx9ycOUT7BRjfHHSMB+Sc8bOXG3AScpOQwoo9e8LmwchaGQMPpId3bjxtDGC5Gec5ONs3i+BrtTiEYztEyb5f6p+Zyhzq7lbnGt1+W4FfOriEi9vQHX4XbkruRDl8/qGwmw1Noe3IiGNV7QrYKfLu/78jVGLUnNH6V/RPCqEphbzS2b5SCyAqb5bjfuGrjAPxuo2UvRfzDtTp4M6EZ/l4BgnDSXWp6yW787Q05epYjQqJFfogOIAPp3mUBkC7PuY6vlYLvZF3mPHhisHccRbWPgmm7Vx5i+v+qjGfbY1Z5v51aY+YFlI1gSR68s41eFaJOLBjEc2QQt/5nNJToJWk4E9ipan6g29So4o4S+nVVneT/iNv288zxQfTLjJ/8+AQ3p2CVuhdOxb+9ihTMdMhsRwZJ0PMcCASUyq0k+cyC+2NTpQdVdTsupswdvkwhqAaLVo2MfcFsqUKyjfaLkjMQB5bCxZntkcENKYOPqujvKZLRDiqlVsK1uRJxMFS/iO7+LSmShyLhoLDS9MGY9RarXv2NLkR0pg6AgG5onatE4rEs+HvqKO002+0zcXYHiPzv6Q5c8usm/YJ/rfE799MRqwu8aoltnmHAhnCZvr7u5B9dZCJY9ufkia4rAx6qDsqQ1jQajG/52yHn6kEjtguPsaEqBQqr3mgcTPJGhyX5H8xYcuFKo8PRGsEpUBzPSGJR9yPF9BO2bmA 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:(13230031)(4636009)(346002)(396003)(136003)(376002)(39860400002)(1800799009)(451199024)(82310400011)(186009)(46966006)(36840700001)(40470700004)(40460700003)(2906002)(83380400001)(86362001)(478600001)(40480700001)(336012)(426003)(36756003)(2616005)(7696005)(6666004)(1076003)(26005)(16526019)(5660300002)(44832011)(41300700001)(36860700001)(82740400003)(6636002)(316002)(356005)(81166007)(70206006)(70586007)(110136005)(4326008)(8676002)(8936002)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 10:10:12.8102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f50a7404-6c24-4b2b-0bb3-08db9e40fafd 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: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9163 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 currently the uncore power management implementation is vendor specific. Added new vendor agnostic uncore power interface similar to rte_power and 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 | 254 +++++++++++++++++++++++++++++++++++ 1 file changed, 254 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..e27f483eae --- /dev/null +++ b/lib/power/rte_power_uncore.h @@ -0,0 +1,254 @@ +/* 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 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 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. + * + * @return + * - The number of available index's in frequency array. + * - Negative on error. + */ +typedef int (*rte_power_uncore_get_num_freqs_t)(unsigned int pkg, unsigned int die); + +extern rte_power_uncore_get_num_freqs_t rte_power_uncore_get_num_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_dies_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 */ -- 2.34.1