From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A54EA0526 for ; Fri, 17 Jul 2020 04:35:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 152161BED1; Fri, 17 Jul 2020 04:35:54 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 12E7C2C57; Fri, 17 Jul 2020 04:35:49 +0200 (CEST) IronPort-SDR: oP1LHpu6Eq710uvNG6uzeo+sGdmBM5LYgAYGSeLVUBN2RpFMllZEseRjhxYfViY4sdCuEoL/gZ 6JDQrqKiXq2w== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="148687583" X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="148687583" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 19:35:49 -0700 IronPort-SDR: b91NLlfJNFw7HbNFMbTa7M5dtAm7YnY+Mq5qkPX6bVjGV+RUdIuVQfeWpzXECNyM11isOB16Lg nmFhn3Ms/lng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="300430671" Received: from intel.sh.intel.com ([10.239.255.48]) by orsmga002.jf.intel.com with ESMTP; 16 Jul 2020 19:35:46 -0700 From: Junyu Jiang To: dev@dpdk.org Cc: Qi Zhang , Qiming Yang , Junyu Jiang , stable@dpdk.org Date: Fri, 17 Jul 2020 02:17:47 +0000 Message-Id: <20200717021747.52132-1-junyux.jiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200715070307.36814-1-junyux.jiang@intel.com> References: <20200715070307.36814-1-junyux.jiang@intel.com> Subject: [dpdk-stable] [PATCH v2] net/ice: fix incorrect Rx/Tx bytes statistics X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" This patch fixed the issue that rx/tx bytes overflowed on 40 bit limitation by enlarging the limitation. Fixes: a37bde56314d ("net/ice: support statistics") Cc: stable@dpdk.org Signed-off-by: Junyu Jiang --- drivers/net/ice/ice_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/net/ice/ice_ethdev.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 3534d18ca..85aa6cfe6 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -4139,6 +4139,10 @@ ice_stat_update_40(struct ice_hw *hw, static void ice_update_vsi_stats(struct ice_vsi *vsi) { + uint64_t old_rx_bytes_h = vsi->old_rx_bytes & ~ICE_40_BIT_MASK; + uint64_t old_rx_bytes_l = vsi->old_rx_bytes & ICE_40_BIT_MASK; + uint64_t old_tx_bytes_h = vsi->old_tx_bytes & ~ICE_40_BIT_MASK; + uint64_t old_tx_bytes_l = vsi->old_tx_bytes & ICE_40_BIT_MASK; struct ice_eth_stats *oes = &vsi->eth_stats_offset; struct ice_eth_stats *nes = &vsi->eth_stats; struct ice_hw *hw = ICE_VSI_TO_HW(vsi); @@ -4156,6 +4160,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi) ice_stat_update_40(hw, GLV_BPRCH(idx), GLV_BPRCL(idx), vsi->offset_loaded, &oes->rx_broadcast, &nes->rx_broadcast); + /* enlarge the limitation when rx_bytes overflowed */ + if (vsi->offset_loaded) { + if (old_rx_bytes_l > nes->rx_bytes) + old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH; + nes->rx_bytes += old_rx_bytes_h; + } + vsi->old_rx_bytes = nes->rx_bytes; /* exclude CRC bytes */ nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast + nes->rx_broadcast) * RTE_ETHER_CRC_LEN; @@ -4182,6 +4193,13 @@ ice_update_vsi_stats(struct ice_vsi *vsi) /* GLV_TDPC not supported */ ice_stat_update_32(hw, GLV_TEPC(idx), vsi->offset_loaded, &oes->tx_errors, &nes->tx_errors); + /* enlarge the limitation when tx_bytes overflowed */ + if (vsi->offset_loaded) { + if (old_tx_bytes_l > nes->tx_bytes) + old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH; + nes->tx_bytes += old_tx_bytes_h; + } + vsi->old_tx_bytes = nes->tx_bytes; vsi->offset_loaded = true; PMD_DRV_LOG(DEBUG, "************** VSI[%u] stats start **************", @@ -4206,6 +4224,10 @@ ice_update_vsi_stats(struct ice_vsi *vsi) static void ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw) { + uint64_t old_rx_bytes_h = pf->old_rx_bytes & ~ICE_40_BIT_MASK; + uint64_t old_rx_bytes_l = pf->old_rx_bytes & ICE_40_BIT_MASK; + uint64_t old_tx_bytes_h = pf->old_tx_bytes & ~ICE_40_BIT_MASK; + uint64_t old_tx_bytes_l = pf->old_tx_bytes & ICE_40_BIT_MASK; struct ice_hw_port_stats *ns = &pf->stats; /* new stats */ struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */ @@ -4229,6 +4251,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw) ice_stat_update_32(hw, PRTRPB_RDPC, pf->offset_loaded, &os->eth.rx_discards, &ns->eth.rx_discards); + /* enlarge the limitation when rx_bytes overflowed */ + if (pf->offset_loaded) { + if (old_rx_bytes_l > ns->eth.rx_bytes) + old_rx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH; + ns->eth.rx_bytes += old_rx_bytes_h; + } + pf->old_rx_bytes = ns->eth.rx_bytes; /* Workaround: CRC size should not be included in byte statistics, * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx @@ -4259,6 +4288,13 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw) GLPRT_BPTCL(hw->port_info->lport), pf->offset_loaded, &os->eth.tx_broadcast, &ns->eth.tx_broadcast); + /* enlarge the limitation when tx_bytes overflowed */ + if (pf->offset_loaded) { + if (old_tx_bytes_l > ns->eth.tx_bytes) + old_tx_bytes_h += (uint64_t)1 << ICE_40_BIT_WIDTH; + ns->eth.tx_bytes += old_tx_bytes_h; + } + pf->old_tx_bytes = ns->eth.tx_bytes; ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast + ns->eth.tx_broadcast) * RTE_ETHER_CRC_LEN; diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 2bff735ca..69fd35b47 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -248,6 +248,8 @@ struct ice_vsi { struct ice_eth_stats eth_stats_offset; struct ice_eth_stats eth_stats; bool offset_loaded; + uint64_t old_rx_bytes; + uint64_t old_tx_bytes; }; enum proto_xtr_type { @@ -391,6 +393,8 @@ struct ice_pf { struct ice_parser_list perm_parser_list; struct ice_parser_list dist_parser_list; bool init_link_up; + uint64_t old_rx_bytes; + uint64_t old_tx_bytes; }; #define ICE_MAX_QUEUE_NUM 2048 -- 2.17.1