On 5/5/22 11:02, Chengwen Feng wrote:
This patch supports auto-filled queue xstats when telemetry stats.

Fixes: f30e69b41f94 ("ethdev: add device flag to bypass auto-filled queue 
xstats")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
  lib/ethdev/rte_ethdev.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index f26a9bac6d..76037e635b 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -5499,6 +5499,7 @@ eth_dev_handle_port_stats(const char *cmd __rte_unused,
                struct rte_tel_data *d)
  {
        struct rte_eth_stats stats;
+       struct rte_eth_dev *dev;
        int port_id, ret;
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
@@ -5507,6 +5508,7 @@ eth_dev_handle_port_stats(const char *cmd __rte_unused,
        port_id = atoi(params);
        if (!rte_eth_dev_is_valid_port(port_id))
                return -1;
+       dev = &rte_eth_devices[port_id];
ret = rte_eth_stats_get(port_id, &stats);
        if (ret < 0)
@@ -5521,11 +5523,13 @@ eth_dev_handle_port_stats(const char *cmd __rte_unused,
        ADD_DICT_STAT(stats, ierrors);
        ADD_DICT_STAT(stats, oerrors);
        ADD_DICT_STAT(stats, rx_nombuf);
-       eth_dev_add_port_queue_stats(d, stats.q_ipackets, "q_ipackets");
-       eth_dev_add_port_queue_stats(d, stats.q_opackets, "q_opackets");
-       eth_dev_add_port_queue_stats(d, stats.q_ibytes, "q_ibytes");
-       eth_dev_add_port_queue_stats(d, stats.q_obytes, "q_obytes");
-       eth_dev_add_port_queue_stats(d, stats.q_errors, "q_errors");
+       if (dev->data->dev_flags & RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS) {

I don't understand it. RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS driver
flag means that driver asks ethdev layer to autofill per-queue
*xstats* (generate names and put values) using per-queue basic
statistics.

Drivers do no set the flag if provide per-queue xstats itself
(to avoid duplication) or do not fill in per-queue basic
xstats (to avoid meaningless/misleading zeros in xstats).

So, absence of the flag does not mean that per-queue basic
statistics are not filled in and should be used as the
guard to include corresponding values in telemetry.

+               eth_dev_add_port_queue_stats(d, stats.q_ipackets, "q_ipackets");
+               eth_dev_add_port_queue_stats(d, stats.q_opackets, "q_opackets");
+               eth_dev_add_port_queue_stats(d, stats.q_ibytes, "q_ibytes");
+               eth_dev_add_port_queue_stats(d, stats.q_obytes, "q_obytes");
+               eth_dev_add_port_queue_stats(d, stats.q_errors, "q_errors");
+       }
return 0;
  }

Reply via email to