DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/test:add NIC parameter exception handling
@ 2023-07-13  5:17 Kaisen You
  0 siblings, 0 replies; only message in thread
From: Kaisen You @ 2023-07-13  5:17 UTC (permalink / raw)
  To: dev; +Cc: qiming.yang, yidingx.zhou, Kaisen You, stable

Add NIC exception parameter handling to dpdk_test process,
program exits when carrying unbound vfio NIC parameters.

Fixes: 50247fe03fe0 ("test/timer: exercise new APIs in secondary process")
Cc: stable@dpdk.org

Signed-off-by: Kaisen You <kaisenx.you@intel.com>
---
 app/test/test.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/app/test/test.c b/app/test/test.c
index fb073ff795..c927adba81 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -20,6 +20,7 @@ extern cmdline_parse_ctx_t main_ctx[];
 #endif
 
 #include <rte_memory.h>
+#include <rte_ethdev.h>
 #include <rte_eal.h>
 #include <rte_cycles.h>
 #include <rte_log.h>
@@ -111,6 +112,9 @@ main(int argc, char **argv)
 	char *tests[argc]; /* store an array of tests to run */
 	int test_count = 0;
 	int i;
+	uint16_t count;
+	uint16_t port_id;
+	uint16_t nb_ports;
 #endif
 	char *extra_args;
 	int ret;
@@ -157,6 +161,20 @@ main(int argc, char **argv)
 
 	prgname = argv[0];
 
+	count = 0;
+	RTE_ETH_FOREACH_DEV(port_id) {
+		count++;
+	}
+	nb_ports = count;
+	if (nb_ports == 0) {
+		if (rte_errno == EBUSY)
+			printf("Requested device cannot be used: %d\n", rte_errno);
+		else
+			printf("No probed ethernet devices: %d\n", rte_errno);
+		ret = 0;
+		goto out;
+	}
+
 #ifdef RTE_LIB_TIMER
 	ret = rte_timer_subsystem_init();
 	if (ret < 0 && ret != -EALREADY) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-13  5:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13  5:17 [PATCH] app/test:add NIC parameter exception handling Kaisen You

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).