[v3,08/10] ethdev: support auto-filled flag when telemetry stats

Message ID 20220505080233.12737-9-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series bugfix for ethdev telemetry |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chengwen Feng May 5, 2022, 8:02 a.m. UTC
  This patch supports auto-filled queue xstats when telemetry stats.

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

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

Comments

Andrew Rybchenko May 12, 2022, 10:26 a.m. UTC | #1
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: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@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;
>   }
  

Patch

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) {
+		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;
 }