The number of xstats may be large, after the hide zero parameter to
hide zero only non-zero values can be displayed.

So display xstats with hide zero:
    dpdk-proc-info --proc-type=secondary -- --xstats
and without hide zero:
    dpdk-proc-info --proc-type=secondary -- --xstats=hide_zero

Signed-off-by: Dengdui Huang <huangdeng...@huawei.com>
Acked-by: Chengwen Feng <fengcheng...@huawei.com>
---
 app/proc-info/main.c           | 20 ++++++++++++++------
 doc/guides/tools/proc_info.rst |  7 ++++---
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index e1272164b1..cc0f71c229 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -61,6 +61,7 @@ static unsigned long enabled_port_mask;
 static uint32_t enable_stats;
 /* Enable xstats. */
 static uint32_t enable_xstats;
+static bool xstats_hide_zero = false;
 /* Enable collectd format */
 static uint32_t enable_collectd_format;
 /* FD to send collectd format messages to STDOUT */
@@ -162,8 +163,8 @@ proc_info_usage(const char *prgname)
                "  -m to display DPDK memory zones, segments and TAILQ 
information\n"
                "  -p PORTMASK: hexadecimal bitmask of ports to retrieve stats 
for\n"
                "  --stats: to display port statistics, enabled by default\n"
-               "  --xstats: to display extended port statistics, disabled by "
-                       "default\n"
+               "  --xstats[=hide_zero]: to display extended port statistics, 
disabled by default, "
+                       "support hide zero.\n"
 #ifdef RTE_LIB_METRICS
                "  --metrics: to display derived metrics of the ports, disabled 
by "
                        "default\n"
@@ -425,7 +426,7 @@ proc_info_parse_args(int argc, char **argv)
        static struct option long_option[] = {
                {"stats", 0, NULL, 0},
                {"stats-reset", 0, NULL, 0},
-               {"xstats", 0, NULL, 0},
+               {"xstats", optional_argument, NULL, 0},
 #ifdef RTE_LIB_METRICS
                {"metrics", 0, NULL, 0},
 #endif
@@ -476,12 +477,17 @@ proc_info_parse_args(int argc, char **argv)
                case 0:
                        /* Print stats */
                        if (!strncmp(long_option[option_index].name, "stats",
-                                       MAX_LONG_OPT_SZ))
+                                       MAX_LONG_OPT_SZ)) {
                                enable_stats = 1;
                        /* Print xstats */
-                       else if (!strncmp(long_option[option_index].name, 
"xstats",
-                                       MAX_LONG_OPT_SZ))
+                       } else if (!strncmp(long_option[option_index].name, 
"xstats",
+                                       MAX_LONG_OPT_SZ)) {
                                enable_xstats = 1;
+                               if (optarg != NULL && !strncmp(optarg, 
"hide_zero",
+                                   MAX_LONG_OPT_SZ))
+                                       xstats_hide_zero = true;
+
+                       }
 #ifdef RTE_LIB_METRICS
                        else if (!strncmp(long_option[option_index].name,
                                        "metrics",
@@ -850,6 +856,8 @@ nic_xstats_display(uint16_t port_id)
        }
 
        for (i = 0; i < len; i++) {
+               if (xstats_hide_zero && values[i] == 0)
+                       continue;
                if (enable_collectd_format) {
                        char counter_type[MAX_STRING_LEN];
                        char buf[MAX_STRING_LEN];
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index bb483afbce..e623d71785 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -17,7 +17,7 @@ The application has a number of command line options:
 
 .. code-block:: console
 
-   ./<build_dir>/app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats |
+   ./<build_dir>/app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | 
--xstats[=hide_zero] |
    --stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto |
    --show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
    --show-port-private | --version | --firmware-version | --show-rss-reta |
@@ -34,9 +34,10 @@ Parameters
 The stats parameter controls the printing of generic port statistics. If no
 port mask is specified stats are printed for all DPDK ports.
 
-**--xstats**
+**--xstats[=hide_zero]**
 The xstats parameter controls the printing of extended port statistics. If no
-port mask is specified xstats are printed for all DPDK ports.
+port mask is specified xstats are printed for all DPDK ports. Specifying the
+hide_zero value to display xstats with hide zero.
 
 **--stats-reset**
 The stats-reset parameter controls the resetting of generic port statistics. If
-- 
2.33.0

Reply via email to