accel_config: Add wq max_batch_size and max_transfer_size support
ramesh.thomas at intel.com
cover accel_config: Add wq max_batch_size and max_transfer_size support
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
This patchset adds support in accel-config and libaccel-config for wq attributes max_transfer_size and max_batch_size
Ramesh Thomas (4):
accel-config: Add new wq functions in lib
accel-config: config and json changes
accel-config: New attrs to config-wq command
accel-config: Unit tests
accfg/config.c | 34 ++++++++++--- accfg/config_attr.c | 39 ++++++++++++++- accfg/lib/libaccel-config.sym | 8 +++ accfg/lib/libaccfg.c | 46 +++++++++++++++++ accfg/lib/private.h | 2 + accfg/libaccel_config.h | 6 +++ test/dsa.c | 2 + test/dsa.h | 2 + test/libaccfg.c | 94 +++++++++++++++++++++++++++++++++++ util/json.c | 8 +++ 10 files changed, 232 insertions(+), 9 deletions(-)
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH 1/4 accel-config: Add new wq functions in lib
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Added new library functions:accfg_wq_get_max_batch_sizeaccfg_wq_get_max_transfer_sizeaccfg_wq_set_max_batch_sizeaccfg_wq_set_max_transfer_size
--- accfg/lib/libaccel-config.sym | 8 ++++++ accfg/lib/libaccfg.c | 46 +++++++++++++++++++++++++++++++++++ accfg/lib/private.h | 2 ++ accfg/libaccel_config.h | 6 +++++ 4 files changed, 62 insertions(+)
accfg/lib/libaccel-config.sym +8 -0
@@ -130,3 +130,11 @@ global: accfg_device_get_cmd_status; accfg_device_get_cmd_status_str; } LIBACCFG_5; + +LIBACCFG_7 { +global: + accfg_wq_get_max_batch_size; + accfg_wq_get_max_transfer_size; + accfg_wq_set_max_batch_size; + accfg_wq_set_max_transfer_size; +} LIBACCFG_6;
accfg/lib/libaccfg.c +46 -0
64 lines not on this page · raw message
accfg/lib/private.h +2 -0
@@ -117,6 +117,8 @@ struct accfg_wq {char *name;enum accfg_wq_type type;char *state; +unsigned int max_batch_size; +unsigned long max_transfer_size; };struct accfg_wq_uuid {
accfg/libaccel_config.h +6 -0
@@ -93,6 +93,8 @@ struct wq_parameters {unsigned int threshold;unsigned int priority;int block_on_fault; +unsigned int max_batch_size; +unsigned long max_transfer_size;const char *mode;const char *type;const char *name;
@@ -239,6 +241,8 @@ enum accfg_wq_state accfg_wq_get_state(struct accfg_wq *wq);int accfg_wq_get_cdev_minor (struct accfg_wq *wq);const char *accfg_wq_get_type_name (struct accfg_wq *wq);enum accfg_wq_type accfg_wq_get_type (struct accfg_wq *wq); +unsigned int accfg_wq_get_max_batch_size (struct accfg_wq *wq); +unsigned long accfg_wq_get_max_transfer_size (struct accfg_wq *wq);int accfg_wq_get_threshold (struct accfg_wq *wq);int accfg_wq_get_clients (struct accfg_wq *wq);int accfg_wq_is_enabled (struct accfg_wq *wq);
@@ -247,6 +251,8 @@ int accfg_wq_set_priority(struct accfg_wq *wq, int val);int accfg_wq_set_group_id (struct accfg_wq *wq,int val);int accfg_wq_set_threshold (struct accfg_wq *wq,int val);int accfg_wq_set_block_on_fault (struct accfg_wq *wq,int val); +int accfg_wq_set_max_batch_size (struct accfg_wq *wq,int val); +int accfg_wq_set_max_transfer_size (struct accfg_wq *wq,unsigned long val);int accfg_wq_set_str_mode (struct accfg_wq *wq,const char * val);int accfg_wq_set_mode (struct accfg_wq *wq,enum accfg_wq_mode mode);int accfg_wq_set_str_type (struct accfg_wq *wq,const char * val);
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH 2/4 accel-config: config and json changes
In reply to ramesh.thomas at intel.comFrom: 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
--- accfg/config.c | 34 ++++++++++++++++++++++++++-------- util/json.c | 8 ++++++++ 2 files changed, 34 insertions(+), 8 deletions(-)
accfg/config.c +26 -8
@@ -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 =
util/json.c +8 -0
@@ -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)
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH 3/4 accel-config: New attrs to config-wq command
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Added max-transfer-size and max-batch-size attrs to config-wq command.
--- accfg/config_attr.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
accfg/config_attr.c +38 -1
@@ -35,6 +35,8 @@ static struct wq_parameters wq_param = { .priority = INT_MAX, .block_on_fault = INT_MAX, .threshold = INT_MAX, + .max_batch_size = INT_MAX, + .max_transfer_size = INT_MAX, };static struct engine_parameters engine_param;
@@ -131,7 +133,8 @@ static int accel_config_parse_group_attribs(struct accfg_group *group,static int accel_config_parse_wq_attribs (struct accfg_device *device,struct accfg_wq *wq,struct wq_parameters *wq_params) { -unsigned int max_groups, max_wq_size; +unsigned int max_groups, max_wq_size, max_batch_size; +unsigned long max_transfer_size;int rc =0 ;if (wq_params->mode) {
@@ -145,6 +148,8 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device, max_groups =accfg_device_get_max_groups (device); max_wq_size =accfg_device_get_max_work_queues_size (device); + max_batch_size =accfg_device_get_max_batch_size (device); + max_transfer_size =accfg_device_get_max_transfer_size (device);if ((wq_params->wq_size > max_wq_size) && (wq_params->wq_size !=INT_MAX )) {
@@ -167,6 +172,22 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,return -EINVAL ; } +if ((wq_params->max_batch_size <1 + || wq_params->max_batch_size > max_batch_size) + && (wq_params->max_batch_size !=INT_MAX )) { +fprintf (stderr, +"valid max-batch-size should be 1 to %d\n" , max_batch_size); +return -EINVAL ; + } + +if ((wq_params->max_transfer_size <1 + || wq_params->max_transfer_size > max_transfer_size) + && (wq_params->max_transfer_size !=INT_MAX )) { +fprintf (stderr, +"valid max-transfer-size should be 1 to %ld\n" , max_transfer_size); +return -EINVAL ; + } +if (wq_params->mode) { rc =accfg_wq_set_str_mode (wq, wq_params->mode);if (rc <0 )
@@ -216,6 +237,18 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,return rc; } +if (wq_params->max_batch_size !=INT_MAX ) { + rc =accfg_wq_set_max_batch_size (wq, wq_params->max_batch_size); +if (rc <0 ) +return rc; + } + +if (wq_params->max_transfer_size !=INT_MAX ) { + rc =accfg_wq_set_max_transfer_size (wq, wq_params->max_transfer_size); +if (rc <0 ) +return rc; + } +return 0 ; }
@@ -400,6 +433,10 @@ int cmd_config_wq(int argc, const char **argv, void *ctx) "specify name by wq"),OPT_STRING ('m' ,"mode" , &wq_param.mode,"mode" ,"specify mode by wq" ), +OPT_UINTEGER ('c' ,"max-batch-size" , &wq_param.max_batch_size, +"specify max-batch-size used by wq" ), +OPT_U64 ('x' ,"max-transfer-size" , &wq_param.max_transfer_size, +"specify max-transfer-size used by wq" ), OPT_END(), };
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH 4/4 accel-config: Unit tests
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Config test for lowest, max and middle values Config test with invalid values of 0 and greater than device max_batch_size/max_transfer_size
--- test/dsa.c | 2 ++ test/dsa.h | 2 ++ test/libaccfg.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+)
test/dsa.c +2 -0
@@ -177,6 +177,8 @@ int dsa_alloc(struct dsa_context *ctx, int shared) ctx->wq_size =accfg_wq_get_size (ctx->wq); ctx->wq_idx =accfg_wq_get_id (ctx->wq); ctx->bof =accfg_wq_get_block_on_fault (ctx->wq); + ctx->wq_max_batch_size =accfg_wq_get_max_batch_size (ctx->wq); + ctx->wq_max_xfer_size =accfg_wq_get_max_transfer_size (ctx->wq); ctx->max_batch_size =accfg_device_get_max_batch_size (dev); ctx->max_xfer_size =accfg_device_get_max_transfer_size (dev);
test/dsa.h +2 -0
@@ -83,6 +83,8 @@ struct dsa_context {int wq_size;int dedicated;int bof; +unsigned int wq_max_batch_size; +unsigned long wq_max_xfer_size;int is_batch;union {
test/libaccfg.c +94 -0
164 lines not on this page · raw message
Signature · 1 line
2.26.2
Dave Jiang
Reviewed-by on the v1 seriesQuoted 4 lines · ramesh.thomas(a)intel.com
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
This patchset adds support in accel-config and libaccel-config for wq attributes
max_transfer_sizeandmax_batch_size
Quoted 19 lines
Ramesh Thomas (4):
accel-config: Add new wq functions in lib
accel-config: config and json changes
accel-config: New attrs to config-wq command
accel-config: Unit testsaccfg/config.c | 34 ++++++++++--- accfg/config_attr.c | 39 ++++++++++++++- accfg/lib/libaccel-config.sym | 8 +++ accfg/lib/libaccfg.c | 46 +++++++++++++++++ accfg/lib/private.h | 2 + accfg/libaccel_config.h | 6 +++ test/dsa.c | 2 + test/dsa.h | 2 + test/libaccfg.c | 94 +++++++++++++++++++++++++++++++++++ util/json.c | 8 +++ 10 files changed, 232 insertions(+), 9 deletions(-)