diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 035d336ab5..5381207cc2 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -234,11 +234,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); } @@ -314,10 +329,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 19260cc2d9..581cd45ebb 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)