From: Ramesh Thomas <ramesh.thomas at intel.com>
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH 1/4] accel-config: Add "enable" option to load-config command
Date: Tue, 07 Dec 2021 19:51:49 -0500 [thread overview]
Message-ID: <20211208005152.220518-2-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20211208005152.220518-1-ramesh.thomas@intel.com
[-- Attachment #1: Type: text/plain, Size: 3464 bytes --]
Add an option to enable devices and wqs while configuring devices using
the load-config command. This is a convenience feature so user does not
need to manually enable the newly configured devices and wqs. The option
is -e, enable=true
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/config.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/accfg/config.c b/accfg/config.c
index b0ab701..91a71e3 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -21,8 +21,16 @@
#include <accfg.h>
static bool verbose;
+static bool enable;
static struct util_filter_params util_param;
+static LIST_HEAD(activate_dev_list);
+static LIST_HEAD(activate_wq_list);
+struct activate_dev {
+ void *dev;
+ struct list_node list;
+};
+
static struct config {
bool devices;
bool groups;
@@ -417,6 +425,57 @@ static int engine_json_set_val(struct accfg_engine *engine,
return -ENOENT;
}
+/*
+ * Add configured devices and wqs to activation list
+ */
+static int add_to_activation_list(struct list_head *activate_list, void *dev)
+{
+ struct activate_dev *act_dev;
+
+ act_dev = calloc(1, sizeof(struct activate_dev));
+ if (!act_dev) {
+ fprintf(stderr, "Error allocating memory for activation list\n");
+ return -ENOMEM;
+ }
+ act_dev->dev = dev;
+ list_add(activate_list, &act_dev->list);
+
+ return 0;
+}
+
+/*
+ * Enable devices in activation list
+ */
+static int activate_devices(void)
+{
+ struct activate_dev *iter, *next;
+ int rc;
+
+ list_for_each_safe(&activate_dev_list, iter, next, list) {
+ printf("Enabling device %s\n",
+ accfg_device_get_devname(iter->dev));
+ rc = accfg_device_enable(iter->dev);
+ if (rc) {
+ fprintf(stderr, "Error enabling device\n");
+ return rc;
+ }
+
+ free(iter);
+ }
+
+ list_for_each_safe(&activate_wq_list, iter, next, list) {
+ printf("Enabling wq %s\n", accfg_wq_get_devname(iter->dev));
+ rc = accfg_wq_enable(iter->dev);
+ if (rc) {
+ fprintf(stderr, "Error enabling wq\n");
+ return rc;
+ }
+ free(iter);
+ }
+
+ return 0;
+}
+
/*
* Configuring the value corresponding to integer and strings
*/
@@ -471,6 +530,12 @@ static int configure_json_value(struct accfg_ctx *ctx,
wq = NULL;
engine = NULL;
group = NULL;
+
+ if (enable) {
+ rc = add_to_activation_list(&activate_dev_list, dev);
+ if (rc)
+ return rc;
+ }
break;
}
accel_type = accfg_basenames[i];
@@ -500,6 +565,12 @@ static int configure_json_value(struct accfg_ctx *ctx,
dev = NULL;
engine = NULL;
group = NULL;
+
+ if (enable) {
+ rc = add_to_activation_list(&activate_wq_list, wq);
+ if (rc)
+ return rc;
+ }
}
if (strstr(parsed_string, "engine") != NULL) {
@@ -1004,6 +1075,8 @@ int cmd_config(int argc, const char **argv, void *ctx)
"override the default config"),
OPT_BOOLEAN('v', "verbose", &verbose,
"emit extra debug messages to stderr"),
+ OPT_BOOLEAN('e', "enable", &enable,
+ "enable configured devices and wqs"),
OPT_END(),
};
const char *const u[] = {
@@ -1049,5 +1122,9 @@ int cmd_config(int argc, const char **argv, void *ctx)
fprintf(stderr, "Parse json and set device fail: %d\n", rc);
free_containers(&cfa);
+
+ if (enable && !rc)
+ rc = activate_devices();
+
return rc;
}
--
2.26.3
reply other threads:[~2021-12-08 0:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208005152.220518-2-ramesh.thomas@intel.com \
--to=accel-config@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.