From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 236258D99 for ; Wed, 18 Nov 2015 11:48:31 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 18 Nov 2015 02:48:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,312,1444719600"; d="scan'208";a="688363540" Received: from sie-lab-212-222.ir.intel.com (HELO silpixa00366884.ir.intel.com) ([10.237.212.222]) by orsmga003.jf.intel.com with ESMTP; 18 Nov 2015 02:48:30 -0800 From: Harry van Haaren To: dev@dpdk.org Date: Wed, 18 Nov 2015 10:48:09 +0000 Message-Id: <1447843689-32315-4-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447843689-32315-1-git-send-email-harry.van.haaren@intel.com> References: <1447670117-17723-1-git-send-email-harry.van.haaren@intel.com> <1447843689-32315-1-git-send-email-harry.van.haaren@intel.com> Cc: shemming@brocade.com Subject: [dpdk-dev] [PATCH v2 3/3] i40e: fix rx/tx size mismatch, remove crc bytes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2015 10:48:32 -0000 This patch removes the crc bytes from byte counter statistics. Doing so fixes a bug that CRC bytes were included on TX but not on RX, causing mismatch of bytes recieved / sent. Fixes: 9aace75fc82e ("i40e: fix statistics") Reported-by: Weichun Chen Signed-off-by: Harry van Haaren --- drivers/net/i40e/i40e_ethdev.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 2c51a0b..6cf99dc 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1870,6 +1870,7 @@ i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw) unsigned int i; struct i40e_hw_port_stats *ns = &pf->stats; /* new stats */ struct i40e_hw_port_stats *os = &pf->stats_offset; /* old stats */ + /* Get statistics of struct i40e_eth_stats */ i40e_stat_update_48(hw, I40E_GLPRT_GORCH(hw->port), I40E_GLPRT_GORCL(hw->port), @@ -1887,6 +1888,12 @@ i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw) I40E_GLPRT_BPRCL(hw->port), pf->offset_loaded, &os->eth.rx_broadcast, &ns->eth.rx_broadcast); + /* Workaround: CRC size should not be included in byte statistics, + * so subtract ETHER_CRC_LEN from the byte counter for each rx packet. + */ + ns->eth.rx_bytes -= (ns->eth.rx_unicast + ns->eth.rx_multicast + + ns->eth.rx_broadcast) * ETHER_CRC_LEN; + i40e_stat_update_32(hw, I40E_GLPRT_RDPC(hw->port), pf->offset_loaded, &os->eth.rx_discards, &ns->eth.rx_discards); @@ -1912,6 +1919,8 @@ i40e_read_stats_registers(struct i40e_pf *pf, struct i40e_hw *hw) I40E_GLPRT_BPTCL(hw->port), pf->offset_loaded, &os->eth.tx_broadcast, &ns->eth.tx_broadcast); + ns->eth.tx_bytes -= (ns->eth.tx_unicast + ns->eth.tx_multicast + + ns->eth.tx_broadcast) * ETHER_CRC_LEN; /* GLPRT_TEPC not supported */ /* additional port specific stats */ @@ -2069,8 +2078,8 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->opackets = pf->main_vsi->eth_stats.tx_unicast + pf->main_vsi->eth_stats.tx_multicast + pf->main_vsi->eth_stats.tx_broadcast; - stats->ibytes = pf->main_vsi->eth_stats.rx_bytes; - stats->obytes = pf->main_vsi->eth_stats.tx_bytes; + stats->ibytes = ns->eth.rx_bytes; + stats->obytes = ns->eth.tx_bytes; stats->oerrors = ns->eth.tx_errors + pf->main_vsi->eth_stats.tx_errors; stats->imcasts = pf->main_vsi->eth_stats.rx_multicast; -- 1.9.1