From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7101644227354049279==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 2/4] accel-config: config and json changes Date: Wed, 28 Oct 2020 12:54:50 -0400 Message-ID: <20201028165452.86013-3-ramesh.thomas@intel.com> In-Reply-To: 20201028165452.86013-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============7101644227354049279== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Added support for fields with long values in wq_table Added support for new attributes in json interface Signed-off-by: Ramesh Thomas --- 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[] =3D { static bool is_wq_threshold_writable(struct accfg_wq *wq, int val); = static const struct wq_set_table wq_table[] =3D { - { "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_o= bject *jobj, char *key) if (rc !=3D 0) return rc; = + return 0; + } else if (wq_table[i].set_long_func) { + unsigned long val =3D json_object_get_int64(jobj); + + if ((val =3D=3D 0) && (errno =3D=3D EINVAL)) + return -errno; + + if (wq_table[i].is_writable && + !wq_table[i].is_writable(wq, val)) + return 0; + + rc =3D wq_table[i].set_long_func(wq, val); + if (rc !=3D 0) + return rc; + return 0; } else if (wq_table[i].set_str_func) { const char *val =3D 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 *w= q, if (jobj) json_object_object_add(jaccfg, "block_on_fault", jobj); = + jobj =3D json_object_new_int(accfg_wq_get_max_batch_size(wq)); + if (jobj) + json_object_object_add(jaccfg, "max_batch_size", jobj); + + jobj =3D 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 =3D json_object_new_int(accfg_wq_get_cdev_minor(wq)); if (jobj) -- = 2.26.2 --===============7101644227354049279==--