Thread (70 messages) 70 messages, 8 authors, 2019-01-28

Re: [PATCH 3/3] app/testpmd: changed example to parse options from cfg file

From: Wu, Jingjing <hidden>
Date: 2017-06-20 02:13:41

+
+#ifdef RTE_LIBRTE_CFGFILE
+/* Load config file path from command line */ static char *
+cfgfile_load_path(int argc, char **argv) {
+	int i;
+
+	for (i = 0; i < argc; i++) {
+		if (!strcmp("--cfgfile-path", argv[i])) {
+			if (i < argc)
+				return strdup(argv[i+1]);
+		}
+	}
+	return 0;
+}
+#endif
+
It is a little confused. Is the cfgfile-path is application's argument or EAL's?
Where is it supposed to be located?
 int
 main(int argc, char** argv)
 {
 	int  diag;
 	uint8_t port_id;
+	struct rte_cfgfile *cfg = NULL;
+	char *config_file = NULL;

 	signal(SIGINT, signal_handler);
 	signal(SIGTERM, signal_handler);

+#ifdef RTE_LIBRTE_CFGFILE
+	/* load --cfgfile-path argument from argv */
+	config_file = cfgfile_load_path(argc, argv);
+
+	if (config_file) {
+		printf("Info: found cfgfile-path \"%s\"\n", config_file);
+	} else {
+		printf("Info: not found cfgfile-path parameter "
+				"(searching for cfgfile "
+				"in default directory)\n");
+		config_file = strdup("config.ini");
+	}
+	cfg = rte_cfgfile_load(config_file, CFG_FLAG_EMPTY_VALUES);
+	if (cfg == NULL)
+		printf("Info: Valid cfgfile not found\n");
+	rte_eal_configure(cfg);
+#endif
+
Does it mean if RTE_LIBRTE_CFGFILE is defined, then the arguments are passed by
Cfgfile, if no cfgfile will use config.ini by default? How about the legacy command lines?
I think even cfgfile is good, we still need to keep the command line way.
quoted hunk ↗ jump to hunk
 	diag = rte_eal_init(argc, argv);
 	if (diag < 0)
 		rte_panic("Cannot init EAL\n");
@@ -2289,7 +2329,16 @@ uint8_t port_is_bonding_slave(portid_t slave_pid)
 	argc -= diag;
 	argv += diag;
 	if (argc > 1)
-		launch_args_parse(argc, argv);
+		launch_args_parse(argc, argv, cfg);
+
The argc and argv have been overwritten by cfgfile, right? Does it make sense to
Pass cfg to  launch_args_parse?


And you also need to update the testpmd doc to describe this new use.

Thanks
Jingjing
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help