From patchwork Mon Nov 9 10:22:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 8791 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D7DD35424; Mon, 9 Nov 2015 11:22:40 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id A9BC23979 for ; Mon, 9 Nov 2015 11:22:38 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 09 Nov 2015 02:22:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,265,1444719600"; d="scan'208";a="681290764" 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; 09 Nov 2015 02:22:36 -0800 From: Harry van Haaren To: dev@dpdk.org Date: Mon, 9 Nov 2015 10:22:22 +0000 Message-Id: <1447064542-12078-1-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447063990-1021-1-git-send-email-harry.van.haaren@intel.com> References: <1447063990-1021-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v3] i40e: fix resetting of stats 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch fixes a bug where only some of the statistics were being reset when calling rte_eth_stats_reset() or rte_eth_xstats_reset(). As both the stats reset and xstats reset do the same, refactor away the duplicated function. This patch marks the VSI to update its offset, causing the stats be look like they are reset. Fixes: 9aace75fc82e ("i40e: fix statistics") Signed-off-by: Harry van Haaren Acked-by: Maryam Tahhan --- v4: Add previous ack, remove uneccessary function prototype v3: Refactor away function, fixing stats and xstats reset v2: Remove commented code drivers/net/i40e/i40e_ethdev.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index a39bd28..5e707d1 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -288,7 +288,6 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev, static int i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats, unsigned n); static void i40e_dev_stats_reset(struct rte_eth_dev *dev); -static void i40e_dev_xstats_reset(struct rte_eth_dev *dev); static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev, uint16_t queue_id, uint8_t stat_idx, @@ -426,7 +425,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = { .stats_get = i40e_dev_stats_get, .xstats_get = i40e_dev_xstats_get, .stats_reset = i40e_dev_stats_reset, - .xstats_reset = i40e_dev_xstats_reset, + .xstats_reset = i40e_dev_stats_reset, .queue_stats_mapping_set = i40e_dev_queue_stats_mapping_set, .dev_infos_get = i40e_dev_info_get, .vlan_filter_set = i40e_vlan_filter_set, @@ -2124,19 +2123,20 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) PMD_DRV_LOG(DEBUG, "***************** PF stats end ********************"); } +/* Reset the statistics */ static void -i40e_dev_xstats_reset(struct rte_eth_dev *dev) +i40e_dev_stats_reset(struct rte_eth_dev *dev) { struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct i40e_hw_port_stats *hw_stats = &pf->stats; - /* The hw registers are cleared on read */ + /* Mark PF and VSI stats to update the offset, aka "reset" */ pf->offset_loaded = false; - i40e_read_stats_registers(pf, hw); + if (pf->main_vsi) + pf->main_vsi->offset_loaded = false; - /* reset software counters */ - memset(hw_stats, 0, sizeof(*hw_stats)); + /* read the stats, reading current register values into offset */ + i40e_read_stats_registers(pf, hw); } static int @@ -2216,16 +2216,6 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats, return I40E_NB_XSTATS; } -/* Reset the statistics */ -static void -i40e_dev_stats_reset(struct rte_eth_dev *dev) -{ - struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); - - /* It results in reloading the start point of each counter */ - pf->offset_loaded = false; -} - static int i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,