[Accel-config] [PATCH 5/7] accel-config: Add "-n <wq_name>" to specify WQ name for disabling WQs

Fenghua Yu <[email protected]> Tue, 1 Aug 2023 14:52:30 -0700
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
Default configured WQs are named as "user-wq" by default and can be
re-named in default config file. To disable the default configured
WQs that are re-named, add a new option "-n <wq_name>" to specify WQ
name for disabling WQs.

Signed-off-by: Fenghua Yu <[email protected]>
Reviewed-by: Ramesh Thomas <[email protected]>
---
 accfg/config.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/accfg/config.c b/accfg/config.c
index 771aa6c..82b71a8 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -39,6 +39,7 @@ static struct config {
 	bool engines;
 	bool wqs;
 	const char *config_file;
+	const char *user_default_wq_name;
 	char *buf;
 } config;
 
@@ -1579,12 +1580,17 @@ void config_default_disable(void *ctx)
 	char *user_default_wq_name;
 	struct accfg_device *dev;
 
-	user_default_wq_name = strdup(CONFIG_DEFAULT_WQ_NAME);
+	if (config.user_default_wq_name)
+		user_default_wq_name = strdup(config.user_default_wq_name);
+	else
+		user_default_wq_name = strdup(CONFIG_DEFAULT_WQ_NAME);
 	if (!user_default_wq_name) {
 		fprintf(stderr, "strdup user default wq name failed\n");
 		return;
 	}
 
+	printf("disable WQs named as %s\n", user_default_wq_name);
+
 	accfg_device_foreach(ctx, dev) {
 		enum accfg_device_state dev_state;
 		enum accfg_wq_state wq_state;
@@ -1633,6 +1639,8 @@ int cmd_config_default(int argc, const char **argv, void *ctx)
 			     "override the default config"),
 		OPT_BOOLEAN('d', "disable", &disable,
 			    "disable configured default devices and wqs"),
+		OPT_STRING('n', "name", &config.user_default_wq_name, "user default wq name",
+			   "specify user default wq name. Default \"user_default_wq\""),
 		OPT_BOOLEAN('v', "verbose", &verbose,
 			    "emit extra debug messages to stderr"),
 		OPT_END(),
-- 
2.31.1