[PATCH v3 3/3] app/test-pipeline: add dev close operation

Feifei Wang feifei.wang2 at arm.com
Tue Sep 12 08:39:03 CEST 2023


For test-pipeline, there is dev start operation, but when thread need to
exit, there is no dev close operation. This is not safe, to fix this,
add dev close operation.

Signed-off-by: Feifei Wang <feifei.wang2 at arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
---
 app/test-pipeline/main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/app/test-pipeline/main.c b/app/test-pipeline/main.c
index 8633933fd9..73f6d31f82 100644
--- a/app/test-pipeline/main.c
+++ b/app/test-pipeline/main.c
@@ -55,6 +55,7 @@ int
 main(int argc, char **argv)
 {
 	uint32_t lcore;
+	uint32_t i;
 	int ret;
 
 	/* Init EAL */
@@ -85,6 +86,24 @@ main(int argc, char **argv)
 			return -1;
 	}
 
+	/*Close ports */
+	for (i = 0; i < app.n_ports; i++) {
+		uint16_t port;
+		int ret;
+
+		port = app.ports[i];
+		printf("Closing port %d...", port);
+		ret = rte_eth_dev_stop(port);
+		if (ret != 0)
+			printf("rte_eth_dev_stop: err=%d, port=%u\n",
+					 ret, port);
+		rte_eth_dev_close(port);
+		printf("Done\n");
+	}
+
+	/* Clean up the EAL */
+	rte_eal_cleanup();
+
 	return 0;
 }
 
-- 
2.25.1



More information about the dev mailing list