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 4A923A0540 for ; Wed, 15 Jul 2020 09:26:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1226F1BFEB; Wed, 15 Jul 2020 09:26:52 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 372B81BF80; Wed, 15 Jul 2020 09:26:49 +0200 (CEST) IronPort-SDR: OUa1P4VvXXXbnthqonw+DIr70jvDHx9JMwUwhEmyUs+38jju/WtrgtITlAnz9cZj2B5VSrqhiq UnM+f5VK2GVg== X-IronPort-AV: E=McAfee;i="6000,8403,9682"; a="210643313" X-IronPort-AV: E=Sophos;i="5.75,354,1589266800"; d="scan'208";a="210643313" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2020 00:26:48 -0700 IronPort-SDR: DgwhCZDbFaUaCvAnNyEPr9B0d+bmOEiG6Mm9FqETX3VQE7P9LnkCq6IfFg0DlxKE4PkPIfDwTp UWAXS6oY7wRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,354,1589266800"; d="scan'208";a="299798558" Received: from intel.sh.intel.com ([10.239.255.48]) by orsmga002.jf.intel.com with ESMTP; 15 Jul 2020 00:26:46 -0700 From: Junyu Jiang To: dev@dpdk.org Cc: Qi Zhang , Qiming Yang , Junyu Jiang , stable@dpdk.org Date: Wed, 15 Jul 2020 07:03:06 +0000 Message-Id: <20200715070307.36814-2-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 1/2] net/ice: fix incorrect Rx 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_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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 3534d18ca..d92b6ffa1 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -4143,6 +4143,10 @@ ice_update_vsi_stats(struct ice_vsi *vsi) struct ice_eth_stats *nes = &vsi->eth_stats; struct ice_hw *hw = ICE_VSI_TO_HW(vsi); int idx = rte_le_to_cpu_16(vsi->vsi_id); + uint64_t old_rx_bytes = nes->rx_bytes; + + old_rx_bytes += (nes->rx_unicast + nes->rx_multicast + + nes->rx_broadcast) * RTE_ETHER_CRC_LEN; ice_stat_update_40(hw, GLV_GORCH(idx), GLV_GORCL(idx), vsi->offset_loaded, &oes->rx_bytes, @@ -4156,6 +4160,9 @@ 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 (old_rx_bytes > nes->rx_bytes && vsi->offset_loaded) + nes->rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH; /* exclude CRC bytes */ nes->rx_bytes -= (nes->rx_unicast + nes->rx_multicast + nes->rx_broadcast) * RTE_ETHER_CRC_LEN; @@ -4208,6 +4215,10 @@ ice_read_stats_registers(struct ice_pf *pf, struct ice_hw *hw) { struct ice_hw_port_stats *ns = &pf->stats; /* new stats */ struct ice_hw_port_stats *os = &pf->stats_offset; /* old stats */ + uint64_t old_rx_bytes = ns->eth.rx_bytes; + + old_rx_bytes += (ns->eth.rx_unicast + ns->eth.rx_multicast + + ns->eth.rx_broadcast) * RTE_ETHER_CRC_LEN; /* Get statistics of struct ice_eth_stats */ ice_stat_update_40(hw, GLPRT_GORCH(hw->port_info->lport), @@ -4229,6 +4240,9 @@ 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 (old_rx_bytes > ns->eth.rx_bytes && pf->offset_loaded) + ns->eth.rx_bytes += (uint64_t)1 << ICE_40_BIT_WIDTH; /* Workaround: CRC size should not be included in byte statistics, * so subtract RTE_ETHER_CRC_LEN from the byte counter for each rx -- 2.17.1