From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8744A04F2 for ; Fri, 5 Jun 2020 20:27:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 778E71D55E; Fri, 5 Jun 2020 20:27:03 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 009481D52C for ; Fri, 5 Jun 2020 20:27:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591381621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrGYLt6CMPewBtTE3lS822w5RlHppYkurbnGRtjMQG8=; b=VmDQcNE91fOStUa3uPhAKPCjFeskmQSi2IyeT1uT+N5E7guYl9xyADW2cNqa3PXO2W4yCI 4zT3j3WMHSc1vOP7GdqeWkOW31sWra/gB+anAKnJewIy20NnDrtADntCVJPDzXZQNdatpN Hpuk3pwA5obu2M9Ue+AALdFidDlxeeY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-yPRYuwh-MOC0PLofSIkqHQ-1; Fri, 05 Jun 2020 14:26:58 -0400 X-MC-Unique: yPRYuwh-MOC0PLofSIkqHQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC70388EF1A; Fri, 5 Jun 2020 18:26:51 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7C426199D; Fri, 5 Jun 2020 18:26:50 +0000 (UTC) From: Kevin Traynor To: "Wei Hu (Xavier)" Cc: Chengwen Feng , Ferruh Yigit , dpdk stable Date: Fri, 5 Jun 2020 19:24:30 +0100 Message-Id: <20200605182525.22483-33-ktraynor@redhat.com> In-Reply-To: <20200605182525.22483-1-ktraynor@redhat.com> References: <20200605182525.22483-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'app/testpmd: fix statistics after reset' has been queued to LTS release 18.11.9 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 06/10/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/9478a1a301d359e05f271cd5295cf392fa124517 Thanks. Kevin. --- >From 9478a1a301d359e05f271cd5295cf392fa124517 Mon Sep 17 00:00:00 2001 From: "Wei Hu (Xavier)" Date: Tue, 28 Apr 2020 19:50:45 +0800 Subject: [PATCH] app/testpmd: fix statistics after reset [ upstream commit 9eb974221f44cf210fe5d883bdccfcb48de75fc6 ] Currently, when running start/clear stats&xstats/stop command many times based on testpmd application, there are incorrect forward Rx/Tx-packets stats as below: ---------------------- Forward statistics for port 0 -------------- RX-packets: 18446744073709544808 RX-dropped: 0 TX-packets: 18446744073709536616 TX-dropped: 0 -------------------------------------------------------------------- The root cause as below: 1. The struct rte_port of testpmd.h has a member variable "struct rte_eth_stats stats" to store the last port statistics. 2. When running start command, it execute cmd_start_parsed -> start_packet_forwarding -> fwd_stats_reset, which call rte_eth_stats_get API function to save current port statistics. 3. When running stop command, it execute fwd_stats_display, which call rte_eth_stats_get to get current port statistics, and then minus last port statistics. 4. If we run clear stats or xstats after start command, then run stop, it may display above incorrect stats because the current Rx/Tx-packets is lower than the last saved RX/TX-packets(uint64_t overflow). This patch fixes it by clearing last port statistics when executing "clear stats/xstats" command. Fixes: af75078fece3 ("first public release") Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) Reviewed-by: Ferruh Yigit --- app/test-pmd/config.c | 26 ++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 6e9a2042c2..0e5d77159d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -205,9 +205,24 @@ void nic_stats_clear(portid_t port_id) { + int ret; + if (port_id_is_invalid(port_id, ENABLED_WARN)) { print_valid_ports(); return; } - rte_eth_stats_reset(port_id); + + ret = rte_eth_stats_reset(port_id); + if (ret != 0) { + printf("%s: Error: failed to reset stats (port %u): %s", + __func__, port_id, strerror(ret)); + return; + } + + ret = rte_eth_stats_get(port_id, &ports[port_id].stats); + if (ret != 0) { + printf("%s: Error: failed to get stats (port %u): %s", + __func__, port_id, strerror(ret)); + return; + } printf("\n NIC statistics for port %d cleared\n", port_id); } @@ -279,4 +294,6 @@ void nic_xstats_clear(portid_t port_id) { + int ret; + if (port_id_is_invalid(port_id, ENABLED_WARN)) { print_valid_ports(); @@ -284,4 +301,11 @@ nic_xstats_clear(portid_t port_id) } rte_eth_xstats_reset(port_id); + + ret = rte_eth_stats_get(port_id, &ports[port_id].stats); + if (ret != 0) { + printf("%s: Error: failed to get stats (port %u): %s", + __func__, port_id, strerror(ret)); + return; + } } diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index c327d1f4df..0d71e20c64 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -239,5 +239,5 @@ clear port ~~~~~~~~~~ -Clear the port statistics for a given port or for all ports:: +Clear the port statistics and forward engine statistics for a given port or for all ports:: testpmd> clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all) -- 2.21.3 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-06-05 19:20:52.664416455 +0100 +++ 0033-app-testpmd-fix-statistics-after-reset.patch 2020-06-05 19:20:50.771041699 +0100 @@ -1 +1 @@ -From 9eb974221f44cf210fe5d883bdccfcb48de75fc6 Mon Sep 17 00:00:00 2001 +From 9478a1a301d359e05f271cd5295cf392fa124517 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 9eb974221f44cf210fe5d883bdccfcb48de75fc6 ] + @@ -32 +33,0 @@ -Cc: stable@dpdk.org @@ -43 +44 @@ -index 035d336ab5..5381207cc2 100644 +index 6e9a2042c2..0e5d77159d 100644 @@ -46 +47 @@ -@@ -235,9 +235,24 @@ void +@@ -205,9 +205,24 @@ void @@ -72,3 +73,4 @@ -@@ -315,8 +330,17 @@ nic_xstats_clear(portid_t port_id) - return; - } +@@ -279,4 +294,6 @@ void + nic_xstats_clear(portid_t port_id) + { ++ int ret; @@ -76,6 +78,5 @@ - ret = rte_eth_xstats_reset(port_id); - if (ret != 0) { - printf("%s: Error: failed to reset xstats (port %u): %s", - __func__, port_id, strerror(ret)); -+ return; -+ } + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); +@@ -284,4 +301,11 @@ nic_xstats_clear(portid_t port_id) + } + rte_eth_xstats_reset(port_id); @@ -88 +89 @@ - } ++ } @@ -89,0 +91 @@ + @@ -91 +93 @@ -index 19260cc2d9..581cd45ebb 100644 +index c327d1f4df..0d71e20c64 100644 @@ -94 +96 @@ -@@ -238,5 +238,5 @@ clear port +@@ -239,5 +239,5 @@ clear port