All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v1 2/4] accel-config: config and json changes
@ 2020-10-28 16:54 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2020-10-28 16:54 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Added support for fields with long values in wq_table
Added support for new attributes in json interface

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config.c | 34 ++++++++++++++++++++++++++--------
 util/json.c    |  8 ++++++++
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/accfg/config.c b/accfg/config.c
index d9cdcaa..3887873 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -47,6 +47,7 @@ struct device_set_table {
 struct wq_set_table {
 	char *name;
 	int (*set_int_func)(struct accfg_wq *wq, int val);
+	int (*set_long_func)(struct accfg_wq *wq, unsigned long val);
 	int (*set_str_func)(struct accfg_wq *wq, const char *val);
 	bool (*is_writable)(struct accfg_wq *wq, int val);
 };
@@ -89,14 +90,16 @@ static const struct group_set_table group_table[] = {
 static bool is_wq_threshold_writable(struct accfg_wq *wq, int val);
 
 static const struct wq_set_table wq_table[] = {
-	{ "size", accfg_wq_set_size, NULL, NULL },
-	{ "priority", accfg_wq_set_priority, NULL, NULL },
-	{ "group_id", accfg_wq_set_group_id, NULL, NULL },
-	{ "block_on_fault", accfg_wq_set_block_on_fault, NULL, NULL },
-	{ "type", NULL, accfg_wq_set_str_type, NULL },
-	{ "name", NULL, accfg_wq_set_str_name, NULL },
-	{ "mode", NULL, accfg_wq_set_str_mode, NULL },
-	{ "threshold", accfg_wq_set_threshold, NULL,
+	{ "size", accfg_wq_set_size, NULL, NULL, NULL },
+	{ "priority", accfg_wq_set_priority, NULL, NULL, NULL },
+	{ "group_id", accfg_wq_set_group_id, NULL, NULL, NULL },
+	{ "block_on_fault", accfg_wq_set_block_on_fault, NULL, NULL, NULL },
+	{ "type", NULL, NULL, accfg_wq_set_str_type, NULL },
+	{ "name", NULL, NULL, accfg_wq_set_str_name, NULL },
+	{ "mode", NULL, NULL, accfg_wq_set_str_mode, NULL },
+	{ "max_batch_size", accfg_wq_set_max_batch_size, NULL, NULL, NULL },
+	{ "max_transfer_size", NULL, accfg_wq_set_max_transfer_size, NULL, NULL },
+	{ "threshold", accfg_wq_set_threshold, NULL, NULL,
 		is_wq_threshold_writable },
 };
 
@@ -254,6 +257,21 @@ static int wq_json_set_val(struct accfg_wq *wq, json_object *jobj, char *key)
 				if (rc != 0)
 					return rc;
 
+				return 0;
+			} else if (wq_table[i].set_long_func) {
+				unsigned long val = json_object_get_int64(jobj);
+
+				if ((val == 0) && (errno == EINVAL))
+					return -errno;
+
+				if (wq_table[i].is_writable &&
+					!wq_table[i].is_writable(wq, val))
+					return 0;
+
+				rc = wq_table[i].set_long_func(wq, val);
+				if (rc != 0)
+					return rc;
+
 				return 0;
 			} else if (wq_table[i].set_str_func) {
 				const char *val =
diff --git a/util/json.c b/util/json.c
index 3260c69..c858fc3 100644
--- a/util/json.c
+++ b/util/json.c
@@ -403,6 +403,14 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 	if (jobj)
 		json_object_object_add(jaccfg, "block_on_fault", jobj);
 
+	jobj = json_object_new_int(accfg_wq_get_max_batch_size(wq));
+	if (jobj)
+		json_object_object_add(jaccfg, "max_batch_size", jobj);
+
+	jobj = json_object_new_int64(accfg_wq_get_max_transfer_size(wq));
+	if (jobj)
+		json_object_object_add(jaccfg, "max_transfer_size", jobj);
+
 	if (!(flags & UTIL_JSON_SAVE)) {
 		jobj = json_object_new_int(accfg_wq_get_cdev_minor(wq));
 		if (jobj)
-- 
2.26.2

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

only message in thread, other threads:[~2020-10-28 16:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-28 16:54 [Accel-config] [PATCH v1 2/4] accel-config: config and json changes ramesh.thomas

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.