From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Zhao Subject: [PATCH v3 2/3] net/i40e: add statistics protect for vf clear xstats Date: Mon, 18 Sep 2017 14:18:23 +0800 Message-ID: <1505715504-8797-2-git-send-email-wei.zhao1@intel.com> References: <20170829022806.68101-1-wei.zhao1@intel.com> <1505715504-8797-1-git-send-email-wei.zhao1@intel.com> Cc: Wei Zhao To: dev@dpdk.org Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id CFAF8DE3 for ; Mon, 18 Sep 2017 08:29:20 +0200 (CEST) In-Reply-To: <1505715504-8797-1-git-send-email-wei.zhao1@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The diff_pkts_rx and diff_pkts_tx statistic data will be wrong when the first time after clear xstats command if there is no protect. Signed-off-by: Wei Zhao --- app/test-pmd/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ca83eef..e8e311c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -203,8 +203,10 @@ nic_stats_display(portid_t port_id) if (diff_cycles > 0) diff_cycles = prev_cycles[port_id] - diff_cycles; - diff_pkts_rx = stats.ipackets - prev_pkts_rx[port_id]; - diff_pkts_tx = stats.opackets - prev_pkts_tx[port_id]; + diff_pkts_rx = (stats.ipackets > prev_pkts_rx[port_id]) ? + (stats.ipackets - prev_pkts_rx[port_id]) : 0; + diff_pkts_tx = (stats.opackets > prev_pkts_tx[port_id]) ? + (stats.opackets - prev_pkts_tx[port_id]) : 0; prev_pkts_rx[port_id] = stats.ipackets; prev_pkts_tx[port_id] = stats.opackets; mpps_rx = diff_cycles > 0 ? -- 2.9.3