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 A8E89A0093 for ; Tue, 19 May 2020 15:15:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A0AAF1D702; Tue, 19 May 2020 15:15:30 +0200 (CEST) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id 887391D68B for ; Tue, 19 May 2020 15:15:27 +0200 (CEST) Received: by mail-wm1-f67.google.com with SMTP id z72so3530174wmc.2 for ; Tue, 19 May 2020 06:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3MAoy88Gq3JTIo98grxjCfULQDgJoOGAVU6cwvqzP9E=; b=DspVWFDbv+N4o4uR15JzMM0trK5ld9G9serO6pcfAvGJ226joebjqdVa021vrcXELd obYsAxCLhCwhQexPxoTImu93vhucES/35ACdksfxSpbjO9/CUfRW0g6JIhtwhjVbnvSx JzftIfGolXB4lax4Jke9//Y7bLd8fcF8HIvFeFVKPDpVG6g/gaK0t/Uy/4sJSmDCdILR WQfZ8BtGHiUV7bCN0GSV+y/JQWXZ7R4sW43CI5Frux95Aw3vYbHVnorctbHyzPsM4zkW GuT7QxAKSSXUxtAf+RLnToTNv9+X80zV7Cz6MG3IOL7+qtfBon2KxL9WbmEjlzL/cUch LGGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3MAoy88Gq3JTIo98grxjCfULQDgJoOGAVU6cwvqzP9E=; b=OMcIunyMfWp4C9Ez43oMEmOrbjf9+fodhE0k0KoIoI4A0osZaJ1yLkdvHHTDsBBLJq fFyhyZ6PZVTaMOy2fPbQDeeqCWBWHiXKzgJlgm+pDlqKaEec4nDfecn+tmk9dqgwA8o6 S2MsOgqV/G89JmGHMLHYSe+Fw5jGMXl8WvUV/f7X1nuc6LBvy7aFJsjQAKt+2W2uxmHH 7dfNBwN9t11IUgBwn3KcJf8czeVkz2TxFjdegBOPYsjoiK+NkMVV5ssvlxuup7gUMaBt dwCw66iNRB89brRS7WqdA44uBRTkXZsFIWHK9MozdkSI/IiiBJCBHSwvTS+YDCIctxxp axNQ== X-Gm-Message-State: AOAM533eX+C7erhusmCDZVby+jhiODo7WqMVf53NEP7cf1bLRnFFR0D8 wjMn228fZRCeBVvrRDm3LMI= X-Google-Smtp-Source: ABdhPJw5D8b2bLWo+E2dRBDbAQbGOTDLPO72N4H0vxyCkV6ksI0SPGGUCSMV5SKuLVd77LZPrzamUg== X-Received: by 2002:a7b:cc92:: with SMTP id p18mr5662388wma.174.1589894127288; Tue, 19 May 2020 06:15:27 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 61sm8426493wrp.92.2020.05.19.06.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 06:15:26 -0700 (PDT) From: luca.boccassi@gmail.com To: "Wei Hu (Xavier)" Cc: Chengwen Feng , Ferruh Yigit , dpdk stable Date: Tue, 19 May 2020 14:05:17 +0100 Message-Id: <20200519130549.112823-182-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519130549.112823-1-luca.boccassi@gmail.com> References: <20200519125804.104349-1-luca.boccassi@gmail.com> <20200519130549.112823-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'app/testpmd: fix statistics after reset' has been queued to stable release 19.11.3 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 stable release 19.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/21/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. Thanks. Luca Boccassi --- >From 024a56857898bf3aabee0b15e9d44cb4d81776bf 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 62e547be09..42eba68b35 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -223,11 +223,26 @@ nic_stats_display(portid_t port_id) 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); } @@ -303,10 +318,19 @@ nic_xstats_clear(portid_t port_id) print_valid_ports(); return; } + 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; + } + + 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 73ef0b41d3..78bdf60fe6 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -237,7 +237,7 @@ Display the RSS hash functions and RSS hash key of a port:: 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.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-05-19 14:04:51.957781396 +0100 +++ 0182-app-testpmd-fix-statistics-after-reset.patch 2020-05-19 14:04:44.532654101 +0100 @@ -1,8 +1,10 @@ -From 9eb974221f44cf210fe5d883bdccfcb48de75fc6 Mon Sep 17 00:00:00 2001 +From 024a56857898bf3aabee0b15e9d44cb4d81776bf 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: @@ -29,7 +31,6 @@ "clear stats/xstats" command. Fixes: af75078fece3 ("first public release") -Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Wei Hu (Xavier) @@ -40,10 +41,10 @@ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index 035d336ab5..5381207cc2 100644 +index 62e547be09..42eba68b35 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c -@@ -234,11 +234,26 @@ nic_stats_display(portid_t port_id) +@@ -223,11 +223,26 @@ nic_stats_display(portid_t port_id) void nic_stats_clear(portid_t port_id) { @@ -71,7 +72,7 @@ printf("\n NIC statistics for port %d cleared\n", port_id); } -@@ -314,10 +329,19 @@ nic_xstats_clear(portid_t port_id) +@@ -303,10 +318,19 @@ nic_xstats_clear(portid_t port_id) print_valid_ports(); return; } @@ -92,7 +93,7 @@ } diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -index 19260cc2d9..581cd45ebb 100644 +index 73ef0b41d3..78bdf60fe6 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -237,7 +237,7 @@ Display the RSS hash functions and RSS hash key of a port::