From patchwork Thu Sep 21 06:32:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao1, Wei" X-Patchwork-Id: 29044 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4E9F71B027; Thu, 21 Sep 2017 08:43:28 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 383E81AEEE for ; Thu, 21 Sep 2017 08:43:23 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Sep 2017 23:43:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,424,1500966000"; d="scan'208";a="154330141" Received: from dpdk4.bj.intel.com ([172.16.182.85]) by fmsmga006.fm.intel.com with ESMTP; 20 Sep 2017 23:43:21 -0700 From: Wei Zhao To: dev@dpdk.org Cc: Wei Zhao Date: Thu, 21 Sep 2017 14:32:23 +0800 Message-Id: <1505975545-16393-2-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505975545-16393-1-git-send-email-wei.zhao1@intel.com> References: <1505715504-8797-1-git-send-email-wei.zhao1@intel.com> <1505975545-16393-1-git-send-email-wei.zhao1@intel.com> Subject: [dpdk-dev] [PATCH v4 2/4] net/i40e: add statistics protect for vf clear xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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 ?