From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0626E591E for ; Mon, 9 Nov 2015 15:55:09 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 09 Nov 2015 06:55:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,266,1444719600"; d="scan'208";a="846731154" Received: from sie-lab-212-222.ir.intel.com (HELO silpixa00366884.ir.intel.com) ([10.237.212.222]) by fmsmga002.fm.intel.com with ESMTP; 09 Nov 2015 06:55:06 -0800 From: Harry van Haaren To: helin.zhang@intel.com Date: Mon, 9 Nov 2015 14:55:04 +0000 Message-Id: <1447080904-27512-1-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 1.9.1 Cc: dev@dpdk.org, shemming@brocade.com Subject: [dpdk-dev] [PATCH] ixgbe: fix crc-strip enable changing rx 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: Mon, 09 Nov 2015 14:55:10 -0000 Fix a consistency issue in ixgbe, that when CRC stripping is enabled, the CRC bytes are not added to the rx total byte count. When CRC strip is disabled, these bytes are counted. This patch reads the CRC strip register, and when enabled adds 4 bytes to the total bytes recieved counter for each received packet. E-mail discussion thread available: http://dpdk.org/ml/archives/dev/2015-March/015685.html To reproduce, run testpmd with no flags and with --crc-strip, sending a single packet, and notice that the RX byte counter is 4 bytes smaller when CRC stripping is enabled. Fixes: 29a05247ebad ("ixgbe: configure CRC stripping behaviour of PF") Reported-by: Stephen Hemminger Suggested-by: Konstantin Ananyev Signed-off-by: Harry van Haaren --- doc/guides/rel_notes/release_2_2.rst | 6 ++++++ drivers/net/ixgbe/ixgbe_ethdev.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 59dda59..6bab51b 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -134,6 +134,12 @@ Drivers VF needs the PF interrupt support initialized even if not started. +* **ixgbe: Fixed CRC strip enable influencing RX byte counters.** + + A workaround has been put in place to ensure consistent presentation + of total RX bytes. The CRC bytes are now always included in RX bytes, + providing consistency between RX and TX bytes. + * **i40e: Fixed base driver allocation when not using first numa node.** Fixed i40e issue that occurred when a DPDK application didn't initialize diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 0b0bbcf..b311ffb 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2361,6 +2361,13 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw, struct ixgbe_hw_stats hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC); hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC); + /* Workaround for RX byte count not including CRC bytes when CRC + * strip is enabled. Multiply rx_total_packets by CRC size and add + * to adjust rx_bytes to the correct value + */ + if (IXGBE_READ_REG(hw, IXGBE_HLREG0) & IXGBE_HLREG0_RXCRCSTRP) + *total_qbrc += (*total_qprc * 4); + /* Note that gprc counts missed packets */ hw_stats->gprc += IXGBE_READ_REG(hw, IXGBE_GPRC); -- 1.9.1