From patchwork Tue Apr 19 11:24:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Laatz X-Patchwork-Id: 109889 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 CD6BFA00BE; Tue, 19 Apr 2022 13:25:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5276C427ED; Tue, 19 Apr 2022 13:25:26 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id DA99C4068E for ; Tue, 19 Apr 2022 13:25:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650367522; x=1681903522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YSTr/7iLNoQgmXLjsqJLKMoXOEti/dG70Gvz35qcyNE=; b=dVnFr5h01Izx8c8zgALt548+yjGwijZnsW55EVKLsSiYSY5lB3+ejxD2 mra3I5r44/7nDIWwEN1m8nK1oA2WdYmJfldfDb98MQmOICl3IHeIXe3WO a9v4DKD9LNMrVq405LWcKzxyXBXPwJNnBSDSbktEgUnPW2tcBVYUxW1wB Fai6XHXSAAXwtVruEmN5vaegxetDjJQIhMP5Pm3iL7t9BknTa/lMk9XmI xftEHhjIPe7we9A5pJBueYL5AZEi6XlLB9F0c6eDqGklPWDMcYIbgT+Pt tisKWr+vgsL2nmTwajl8jtcAjqE7ZWtL3Fy+NEGykheQ3J9MAMpzFb2eg Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10321"; a="262600087" X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="262600087" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 04:25:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,272,1643702400"; d="scan'208";a="727032512" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by orsmga005.jf.intel.com with ESMTP; 19 Apr 2022 04:25:09 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: Kevin Laatz , David Hunt , Ray Kinsella Subject: [PATCH v2 2/4] lib/power: add get and set API for pause duration Date: Tue, 19 Apr 2022 12:24:59 +0100 Message-Id: <20220419112501.1835458-3-kevin.laatz@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220419112501.1835458-1-kevin.laatz@intel.com> References: <20220408140847.1319312-1-kevin.laatz@intel.com> <20220419112501.1835458-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 new get/set API for configuring 'pause_duration' which used to adjust the pause mode callback duration. Signed-off-by: Kevin Laatz Acked-by: Ray Kinsella Acked-by: Anatoly Burakov --- lib/power/rte_power_pmd_mgmt.c | 26 ++++++++++++++++++++++++-- lib/power/rte_power_pmd_mgmt.h | 31 +++++++++++++++++++++++++++++++ lib/power/version.map | 2 ++ 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lib/power/rte_power_pmd_mgmt.c b/lib/power/rte_power_pmd_mgmt.c index dfb7ca9187..ab92a93aa0 100644 --- a/lib/power/rte_power_pmd_mgmt.c +++ b/lib/power/rte_power_pmd_mgmt.c @@ -12,6 +12,7 @@ #include "rte_power_pmd_mgmt.h" unsigned int emptypoll_max; +unsigned int pause_duration; /* store some internal state */ static struct pmd_conf_data { @@ -315,6 +316,7 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, struct queue_list_entry *queue_conf = arg; struct pmd_core_cfg *lcore_conf; const bool empty = nb_rx == 0; + uint32_t pause_duration = rte_power_pmd_mgmt_get_pause_duration(); lcore_conf = &lcore_cfgs[lcore]; @@ -334,11 +336,11 @@ clb_pause(uint16_t port_id __rte_unused, uint16_t qidx __rte_unused, if (global_data.intrinsics_support.power_pause) { const uint64_t cur = rte_rdtsc(); const uint64_t wait_tsc = - cur + global_data.tsc_per_us; + cur + global_data.tsc_per_us * pause_duration; rte_power_pause(wait_tsc); } else { uint64_t i; - for (i = 0; i < global_data.pause_per_us; i++) + for (i = 0; i < global_data.pause_per_us * pause_duration; i++) rte_pause(); } } @@ -673,6 +675,25 @@ rte_power_pmd_mgmt_get_emptypoll_max(void) return emptypoll_max; } +int +rte_power_pmd_mgmt_set_pause_duration(unsigned int duration) +{ + if (duration == 0) { + printf("Pause duration must be greater than 0, value unchanged\n"); + rte_errno = EINVAL; + return -1; + } + pause_duration = duration; + + return 0; +} + +unsigned int +rte_power_pmd_mgmt_get_pause_duration(void) +{ + return pause_duration; +} + RTE_INIT(rte_power_ethdev_pmgmt_init) { size_t i; @@ -684,4 +705,5 @@ RTE_INIT(rte_power_ethdev_pmgmt_init) { /* initialize config defaults */ emptypoll_max = 512; + pause_duration = 1; } diff --git a/lib/power/rte_power_pmd_mgmt.h b/lib/power/rte_power_pmd_mgmt.h index d5a94f8187..18a9c3abb5 100644 --- a/lib/power/rte_power_pmd_mgmt.h +++ b/lib/power/rte_power_pmd_mgmt.h @@ -117,6 +117,37 @@ __rte_experimental unsigned int rte_power_pmd_mgmt_get_emptypoll_max(void); +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. + * + * Set the pause_duration. Used to adjust the pause mode callback duration. + * + * @note Duration must be greater than zero. + * + * @param duration + * The value to set pause_duration to. + * @return + * 0 on success + * <0 on error + */ +__rte_experimental +int +rte_power_pmd_mgmt_set_pause_duration(unsigned int duration); + +/** + * @warning + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice. + * + * Get the current value of pause_duration. + * + * @return + * The current pause_duration value. + */ +__rte_experimental +unsigned int +rte_power_pmd_mgmt_get_pause_duration(void); + #ifdef __cplusplus } #endif diff --git a/lib/power/version.map b/lib/power/version.map index 812843c3f3..4673b719f9 100644 --- a/lib/power/version.map +++ b/lib/power/version.map @@ -41,5 +41,7 @@ EXPERIMENTAL { # added in 22.07 rte_power_pmd_mgmt_get_emptypoll_max; + rte_power_pmd_mgmt_get_pause_duration; rte_power_pmd_mgmt_set_emptypoll_max; + rte_power_pmd_mgmt_set_pause_duration; };