Skip to contentSkip to conversation

examples/vdpa: fix disabled VirtQ statistics query

PATCH In review Xueming Li 3 participants 3 messages Feb 24, 2022 – Apr 22, 2022

lore
Share & tools
lore

Xueming Li

author
#0 lore raw

PATCH 1/1 examples/vdpa: fix disabled VirtQ statistics query

Quit VirtQ statistics query instead of reporting error.

Fixes 6505865aa8ed ("examples/vdpa: add statistics show command")
---
 examples/vdpa/main.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
examples/vdpa/main.c +19 -2
index 5ab07655aed..bd66deca85c 100644
@@ -391,7 +391,9 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
 	struct rte_vdpa_device *vdev = rte_vdpa_find_device_by_name(res->bdf);
 	struct vdpa_port *vport = NULL;
 	uint32_t first, last;
+	int vq_disabled = -1;
 	int i;
+	int ret;
 
 	if (!vdev) {
 		RTE_LOG(ERR, VDPA, "Invalid device: %s.\n",
@@ -449,8 +451,20 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
 	cmdline_printf(cl, "\nDevice %s:\n", res->bdf);
 	for (; first <= last; first++) {
 		memset(vport->stats, 0, sizeof(*vport->stats) * vport->stats_n);
-		if (rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
-					vport->stats_n) <= 0) {
+		ret = rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
+						vport->stats_n);
+		if (ret == 0) {
+			/* VQ disabled. */
+			if (vq_disabled == -1)
+				vq_disabled = (int)first;
+			continue;
+		}
+		if (vq_disabled != -1) {
+			cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+				       vq_disabled, (int)first - 1);
+			vq_disabled = -1;
+		}
+		if (ret < 0) {
 			RTE_LOG(ERR, VDPA, "Failed to get vdpa queue statistics"
 				" for device %s qid %d.\n", res->bdf,
 				(int)first);
@@ -464,6 +478,9 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
 				vport->stats[i].value);
 		}
 	}
+	if (vq_disabled != -1)
+		cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+			       vq_disabled, (int)first - 1);
 }
 
 cmdline_parse_token_string_t cmd_device_stats_ =
Signature · 1 line
2.35.1
#1 lore raw

Hi Xueming,

Quoted 38 lines

-----Original Message-----
From: Xueming Li <[email protected]>
Sent: Thursday, February 24, 2022 9:24 PM
To: [email protected]
Cc: [email protected]; [email protected]; Maxime Coquelin <[email protected]>; Xia, Chenbo <[email protected]>; Matan Azrad <[email protected]>
Subject: [PATCH] examples/vdpa: fix disabled VirtQ statistics query

Quit VirtQ statistics query instead of reporting error.

Fixes 6505865aa8ed ("examples/vdpa: add statistics show command")
---
 examples/vdpa/main.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
examples/vdpa/main.c +2 -0
index 5ab07655aed..bd66deca85c 100644
@@ -391,7 +391,9 @@ static void cmd_device_stats_parsed(void *parsed_result,
 struct cmdline *cl,
 	struct rte_vdpa_device *vdev = rte_vdpa_find_device_by_name(res->bdf);
 	struct vdpa_port *vport = NULL;
 	uint32_t first, last;
+	int vq_disabled = -1;
 	int i;
+	int ret;
 
 	if (!vdev) {
examples/vdpa/main.c +0 -0
 		RTE_LOG(ERR, VDPA, "Invalid device: %s.\n",
@@ -449,8 +451,20 @@ static void cmd_device_stats_parsed(void *parsed_result,
 struct cmdline *cl,
 	cmdline_printf(cl, "\nDevice %s:\n", res->bdf);
 	for (; first <= last; first++) {

examples/vdpa/main.c static void cmd_device_stats_parsed(void *parsed_result, · line 461

Quoted 10 lines
examples/vdpa/main.c +7 -2
 		memset(vport->stats, 0, sizeof(*vport->stats) * vport->stats_n);
-		if (rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
-					vport->stats_n) <= 0) {
+		ret = rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
+						vport->stats_n);
+		if (ret == 0) {
+			/* VQ disabled. */
+			if (vq_disabled == -1)
+				vq_disabled = (int)first;
+			continue;

I am not sure. Does ret == 0 mean VQ is disabled in this API? Because I don't see anything special described in API doxygen about return value equals zero.

examples/vdpa/main.c static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl, · line 464

Quoted 4 lines
examples/vdpa/main.c +4 -0
+		}
+		if (vq_disabled != -1) {
+			cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+				       vq_disabled, (int)first - 1);

Let's check if vq_disabled == first - 1 to make different log. I will feel strange if I see log like 'Virq 2-2 disabled'.

Thanks,
Chenbo

Quoted 19 lines
examples/vdpa/main.c +3 -0
+			vq_disabled = -1;
+		}
+		if (ret < 0) {
 			RTE_LOG(ERR, VDPA, "Failed to get vdpa queue statistics"
 				" for device %s qid %d.\n", res->bdf,
examples/vdpa/main.c +3 -0
 				(int)first);
@@ -464,6 +478,9 @@ static void cmd_device_stats_parsed(void *parsed_result,
 struct cmdline *cl,
 				vport->stats[i].value);
 		}
 	}
+	if (vq_disabled != -1)
+		cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+			       vq_disabled, (int)first - 1);
 }
 

cmdline_parse_token_string_t cmd_device_stats_ =
--
2.35.1

#2 lore raw
In reply to Xueming Li

"examples/vdpa: fix disabled virtqueue statistics query"

Quoted 48 lines · Xueming Li

Quit VirtQ statistics query instead of reporting error.

Fixes 6505865aa8ed ("examples/vdpa: add statistics show command")
---
  examples/vdpa/main.c | 21 +++++++++++++++++++--
  1 file changed, 19 insertions(+), 2 deletions(-)
examples/vdpa/main.c +16 -2
index 5ab07655aed..bd66deca85c 100644
@@ -391,7 +391,9 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
  	struct rte_vdpa_device *vdev = rte_vdpa_find_device_by_name(res->bdf);
  	struct vdpa_port *vport = NULL;
  	uint32_t first, last;
+	int vq_disabled = -1;
  	int i;
+	int ret;
 
  	if (!vdev) {
  		RTE_LOG(ERR, VDPA, "Invalid device: %s.\n",
@@ -449,8 +451,20 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
  	cmdline_printf(cl, "\nDevice %s:\n", res->bdf);
  	for (; first <= last; first++) {
  		memset(vport->stats, 0, sizeof(*vport->stats) * vport->stats_n);
-		if (rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
-					vport->stats_n) <= 0) {
+		ret = rte_vdpa_get_stats(vport->dev, (int)first, vport->stats,
+						vport->stats_n);
+		if (ret == 0) {
+			/* VQ disabled. */
+			if (vq_disabled == -1)
+				vq_disabled = (int)first;
+			continue;
+		}
+		if (vq_disabled != -1) {
+			cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+				       vq_disabled, (int)first - 1);
+			vq_disabled = -1;
+		}
+		if (ret < 0) {
  			RTE_LOG(ERR, VDPA, "Failed to get vdpa queue statistics"
  				" for device %s qid %d.\n", res->bdf,
  				(int)first);

examples/vdpa/main.c static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl, · line 486

Quoted 9 lines
examples/vdpa/main.c +3 -0
@@ -464,6 +478,9 @@ static void cmd_device_stats_parsed(void *parsed_result, struct cmdline *cl,
  				vport->stats[i].value);
  		}
  	}
+	if (vq_disabled != -1)
+		cmdline_printf(cl, "\tVirtq %d - %d disabled\n",
+			       vq_disabled, (int)first - 1);
  }
 
  cmdline_parse_token_string_t cmd_device_stats_ =

It is not clear to me how it is going to look like, could you paste some logs?