From patchwork Mon Dec 2 07:49:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaolong Ye X-Patchwork-Id: 63474 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3AF7EA04B5; Mon, 2 Dec 2019 09:05:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 23F1D1C0C2; Mon, 2 Dec 2019 08:59:08 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 167221C044 for ; Mon, 2 Dec 2019 08:58:54 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Dec 2019 23:58:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,268,1571727600"; d="scan'208";a="207993609" Received: from dpdk_yexl_af_xdp.sh.intel.com ([10.67.119.186]) by fmsmga008.fm.intel.com with ESMTP; 01 Dec 2019 23:58:53 -0800 From: Xiaolong Ye To: Beilei Xing , Qi Zhang Cc: dev@dpdk.org, Xiaolong Ye , Aleksandr Loktionov Date: Mon, 2 Dec 2019 15:49:12 +0800 Message-Id: <20191202074935.97629-47-xiaolong.ye@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191202074935.97629-1-xiaolong.ye@intel.com> References: <20191202074935.97629-1-xiaolong.ye@intel.com> Subject: [dpdk-dev] [PATCH 46/69] net/i40e/base: implement lpi statistics read from registers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 1g i40e_aq_run_phy_activity() reports lpi statistics always as 0. If phy is connected on 1g now the i40e_aq_run_phy_activity() call is skipped and lpi statistics reading is done via direct I40E_PRTPM_TLPIC,I40E_PRTPM_RLPIC registers read. Added new return parameter to i40e_get_lpi_counters() because registers are clean after read and especial if(is_clean) branch to handle statistics increment such case also. Signed-off-by: Aleksandr Loktionov Reviewed-by: Piotr Kwapulinski Reviewed-by: Pietruszewski Piotr Reviewed-by: Michael Alice Signed-off-by: Xiaolong Ye --- drivers/net/i40e/base/i40e_common.c | 40 +++++++++++++++----------- drivers/net/i40e/base/i40e_prototype.h | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/net/i40e/base/i40e_common.c b/drivers/net/i40e/base/i40e_common.c index 6ae598c95..8763c0e65 100644 --- a/drivers/net/i40e/base/i40e_common.c +++ b/drivers/net/i40e/base/i40e_common.c @@ -7173,21 +7173,25 @@ enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw, * @hw: pointer to the hw struct * @tx_counter: pointer to memory for TX LPI counter * @rx_counter: pointer to memory for RX LPI counter + * @is_clear: returns true if counters are clear after read * * Read Low Power Idle (LPI) mode counters from Energy Efficient * Ethernet (EEE) statistics. **/ enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw, - u32 *tx_counter, u32 *rx_counter) + u32 *tx_counter, u32 *rx_counter, + bool *is_clear) { #ifdef CARLSVILLE_HW /* only X710-T*L requires special handling of counters * for other devices we just read the MAC registers */ - if (hw->device_id == I40E_DEV_ID_10G_BASE_T_BC) { + if (hw->device_id == I40E_DEV_ID_10G_BASE_T_BC && + hw->phy.link_info.link_speed != I40E_LINK_SPEED_1GB) { enum i40e_status_code retval; u32 cmd_status; + *is_clear = false; retval = i40e_aq_run_phy_activity(hw, I40E_AQ_RUN_PHY_ACT_ID_USR_DFND, I40E_AQ_RUN_PHY_ACT_DNL_OPCODE_GET_EEE_STAT, @@ -7200,6 +7204,7 @@ enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw, } #endif /* CARLSVILLE_HW */ + *is_clear = true; *tx_counter = rd32(hw, I40E_PRTPM_TLPIC); *rx_counter = rd32(hw, I40E_PRTPM_RLPIC); @@ -7225,25 +7230,28 @@ enum i40e_status_code i40e_lpi_stat_update(struct i40e_hw *hw, { enum i40e_status_code retval; u32 tx_counter, rx_counter; + bool is_clear; - retval = i40e_get_lpi_counters(hw, &tx_counter, &rx_counter); + retval = i40e_get_lpi_counters(hw, &tx_counter, &rx_counter, &is_clear); if (retval) goto err; - if (!offset_loaded) { - *tx_offset = tx_counter; - *rx_offset = rx_counter; - } - - if (tx_counter >= *tx_offset) - *tx_stat = (u32)(tx_counter - *tx_offset); - else - *tx_stat = (u32)((tx_counter + BIT_ULL(32)) - *tx_offset); + if (is_clear) { + *tx_stat += tx_counter; + *rx_stat += rx_counter; + } else { + if (!offset_loaded) { + *tx_offset = tx_counter; + *rx_offset = rx_counter; + } - if (rx_counter >= *rx_offset) - *rx_stat = (u32)(rx_counter - *rx_offset); - else - *rx_stat = (u32)((rx_counter + BIT_ULL(32)) - *rx_offset); + *tx_stat = (tx_counter >= *tx_offset) ? + (u32)(tx_counter - *tx_offset) : + (u32)((tx_counter + BIT_ULL(32)) - *tx_offset); + *rx_stat = (rx_counter >= *rx_offset) ? + (u32)(rx_counter - *rx_offset) : + (u32)((rx_counter + BIT_ULL(32)) - *rx_offset); + } err: return retval; } diff --git a/drivers/net/i40e/base/i40e_prototype.h b/drivers/net/i40e/base/i40e_prototype.h index 975fbd3ca..86e320da8 100644 --- a/drivers/net/i40e/base/i40e_prototype.h +++ b/drivers/net/i40e/base/i40e_prototype.h @@ -77,7 +77,7 @@ enum i40e_status_code i40e_blink_phy_link_led(struct i40e_hw *hw, enum i40e_status_code i40e_get_phy_lpi_status(struct i40e_hw *hw, struct i40e_hw_port_stats *stats); enum i40e_status_code i40e_get_lpi_counters(struct i40e_hw *hw, u32 *tx_counter, - u32 *rx_counter); + u32 *rx_counter, bool *is_clear); enum i40e_status_code i40e_lpi_stat_update(struct i40e_hw *hw, bool offset_loaded, u64 *tx_offset, u64 *tx_stat, u64 *rx_offset,