From: ramesh.thomas at intel.com
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH v1 2/4] accel-config: config and json changes
Date: Wed, 28 Oct 2020 12:54:50 -0400 [thread overview]
Message-ID: <20201028165452.86013-3-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20201028165452.86013-1-ramesh.thomas@intel.com
[-- 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
reply other threads:[~2020-10-28 16:54 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=20201028165452.86013-3-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.