Add support for wq driver_name attribute
Ramesh Thomas
cover Add support for wq driver_name attribute
A new attribute called "driver_name" is added to wqs which can be configured by user with the driver name to bind. Add support in accel-config to update, validate and use this attribute. It can be updated using config-wq command or using a configuration file.
Since older drivers would not have this attribute, to be backward compatible the code checks for the presence of the attribute. If not found it will fall through to use the predefined driver names in code.
Ramesh Thomas (6):
accel-config: Add driver_name attribute to wq context
accel-config: Add driver_name option to config_wq command
accel-config: Add driver_name to json configuration data
accel-config: Update copy of idxd.h with kernel changes
accel-config: Use driver_name attr for binding
accel-config: Update config-wq documentation with driver_name option
.../accfg/accel-config-config-wq.txt | 5 ++++ accfg/config.c | 1 + accfg/config_attr.c | 14 +++++++++ accfg/idxd.h | 3 ++ accfg/lib/libaccel-config.sym | 7 +++++ accfg/lib/libaccfg.c | 30 +++++++++++++++++++ accfg/lib/private.h | 1 + accfg/libaccel_config.h | 4 +++ util/json.c | 6 ++++ 9 files changed, 71 insertions(+)
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 1/6 accel-config: Add driver_name attribute to wq context
Add a driver_name memember to wq context structure and API to set it. It will be initialized with the value stored in sysfs. A NULL will be stored if driver_name attribute is not present.
--- accfg/lib/libaccel-config.sym | 7 +++++++ accfg/lib/libaccfg.c | 24 ++++++++++++++++++++++++ accfg/lib/private.h | 1 + accfg/libaccel_config.h | 3 +++ 4 files changed, 35 insertions(+)
accfg/lib/libaccel-config.sym +7 -0
@@ -179,3 +179,10 @@ global: accfg_group_set_read_buffers_allowed; accfg_group_set_use_read_buffer_limit; } LIBACCFG_11; + +LIBACCFG_13 { +global: + accfg_wq_set_str_driver_name; + accfg_wq_get_driver_name; + accfg_wq_driver_name_validate; +} LIBACCFG_12;
accfg/lib/libaccfg.c +24 -0
@@ -827,6 +827,7 @@ static void *add_wq(void *parent, int id, const char *wq_base, wq->cdev_minor =accfg_get_param_long (ctx, dfd,"cdev_minor" ); wq_type =accfg_get_param_str (ctx, dfd,"type" ); wq->name =accfg_get_param_str (ctx, dfd,"name" ); + wq->driver_name =accfg_get_param_str (ctx, dfd,"driver_name" ); wq->threshold =accfg_get_param_long (ctx, dfd,"threshold" ); wq->max_batch_size =accfg_get_param_long (ctx, dfd,"max_batch_size" ); wq->max_transfer_size =accfg_get_param_long (ctx, dfd,"max_transfer_size" );
@@ -2062,6 +2063,28 @@ ACCFG_EXPORT const char *accfg_wq_get_type_name(struct accfg_wq *wq)return wq->name; } +ACCFG_EXPORT const char *accfg_wq_get_driver_name(struct accfg_wq *wq) +{ +return wq->driver_name; +} + +ACCFG_EXPORT int accfg_wq_driver_name_validate(struct accfg_wq *wq, +const char *drv_name) +{ +int rc =0 ; +char *path =NULL ; +struct accfg_device *device =accfg_wq_get_device (wq); + + rc =get_driver_bind_path (device->bus_type_str, wq->driver_name, &path); +if (rc <0 ) +return 0 ; + + rc =access (path,F_OK ); +free (path); + +return !rc; +} + ACCFG_EXPORT uint64_t accfg_wq_get_size(struct accfg_wq *wq) {return wq->size;
@@ -2454,6 +2477,7 @@ ACCFG_EXPORT int accfg_wq_set_str_##field( \ accfg_wq_set_str_field(wq, val, mode) accfg_wq_set_str_field(wq, val, name) +accfg_wq_set_str_field(wq, val, driver_name)static int wq_parse_type (struct accfg_wq *wq,char *wq_type);
accfg/lib/private.h +1 -0
@@ -121,6 +121,7 @@ struct accfg_wq {unsigned int threshold;char *mode;char *name; +char *driver_name;enum accfg_wq_type type;char *state;unsigned int max_batch_size;
accfg/libaccel_config.h +3 -0
@@ -293,6 +293,8 @@ int accfg_wq_get_block_on_fault(struct accfg_wq *wq);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); +const char *accfg_wq_get_driver_name (struct accfg_wq *wq); +int accfg_wq_driver_name_validate (struct accfg_wq *wq,const char *drv_name);enum accfg_wq_type accfg_wq_get_type (struct accfg_wq *wq);unsigned int accfg_wq_get_max_batch_size (struct accfg_wq *wq);uint64_t accfg_wq_get_max_transfer_size (struct accfg_wq *wq);
@@ -313,6 +315,7 @@ 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);int accfg_wq_set_str_name (struct accfg_wq *wq,const char *val); +int accfg_wq_set_str_driver_name (struct accfg_wq *wq,const char *val);int accfg_wq_enable (struct accfg_wq *wq);int accfg_wq_disable (struct accfg_wq *wq,bool force);int accfg_wq_priority_boundary (struct accfg_wq *wq);
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 2/6 accel-config: Add driver_name option to config_wq command
In reply to Ramesh ThomasAdd an option to config_wq command to update driver_name attribute.
--- accfg/config_attr.c | 14 ++++++++++++++ accfg/libaccel_config.h | 1 + 2 files changed, 15 insertions(+)
accfg/config_attr.c +14 -0
@@ -226,6 +226,18 @@ static int accel_config_parse_wq_attribs(struct accfg_device *device,return rc; } +if (wq_params->driver_name) { +if (!accfg_wq_driver_name_validate (wq, wq_params->driver_name)) { +fprintf (stderr,"Invalid driver name \"%s\"\n" , + wq_params->driver_name); +return -ENOENT ; + + } + rc =accfg_wq_set_str_driver_name (wq, wq_params->driver_name); +if (rc <0 ) +return rc; + } +if (wq_params->wq_size !=INT_MAX ) { rc =accfg_wq_set_size (wq, wq_params->wq_size);if (rc <0 )
@@ -428,6 +440,8 @@ int cmd_config_wq(int argc, const char **argv, void *ctx) "specify type by wq"),OPT_STRING ('n' ,"name" , &wq_param.name,"name" ,"specify name by wq" ), +OPT_STRING ('d' ,"driver-name" , &wq_param.driver_name, +"driver name" ,"specify wq driver name" ),OPT_STRING ('m' ,"mode" , &wq_param.mode,"mode" ,"specify mode by wq" ), OPT_UINTEGER('c', "max-batch-size", &wq_param.max_batch_size,
accfg/libaccel_config.h +1 -0
@@ -120,6 +120,7 @@ struct wq_parameters {const char *mode;const char *type;const char *name; +const char *driver_name; };struct engine_parameters {
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 3/6 accel-config: Add driver_name to json configuration data
In reply to Ramesh ThomasUpdate json load, save and list configuration data with driver_name attribute.
--- accfg/config.c | 1 + util/json.c | 6 ++++++ 2 files changed, 7 insertions(+)
accfg/config.c +1 -0
@@ -115,6 +115,7 @@ static const struct wq_set_table wq_table[] = { { "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 }, + { "driver_name", NULL, NULL, accfg_wq_set_str_driver_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 },
util/json.c +6 -0
@@ -453,6 +453,12 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,if (jobj)json_object_object_add (jaccfg,"name" , jobj); +if (accfg_wq_get_driver_name (wq)) { + jobj =json_object_new_string (accfg_wq_get_driver_name (wq)); +if (jobj) +json_object_object_add (jaccfg,"driver_name" , jobj); + } + jobj =json_object_new_int (accfg_wq_get_threshold (wq));if (jobj)json_object_object_add (jaccfg,"threshold" , jobj);
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 4/6 accel-config: Update copy of idxd.h with kernel changes
In reply to Ramesh ThomasUpdate local copy of kernel idxd.h with newly defined error codes.
--- accfg/idxd.h | 3 +++ 1 file changed, 3 insertions(+)
accfg/idxd.h +3 -0
@@ -24,6 +24,9 @@ enum idxd_scmd_stat {IDXD_SCMD_WQ_NO_SWQ_SUPPORT =0x800c0000 ,IDXD_SCMD_WQ_NONE_CONFIGURED =0x800d0000 ,IDXD_SCMD_WQ_NO_SIZE =0x800e0000 , +IDXD_SCMD_WQ_NO_PRIV =0x800f0000 , +IDXD_SCMD_WQ_IRQ_ERR =0x80100000 , + IDXD_SCMD_WQ_NO_DRV_NAME = 0x80200000, };#define IDXD_SCMD_SOFTERR_MASK 0x80000000
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 5/6 accel-config: Use driver_name attr for binding
In reply to Ramesh ThomasUse wq driver_name attribute if present get the driver name for binding.
--- accfg/lib/libaccfg.c | 6 ++++++ 1 file changed, 6 insertions(+)
accfg/lib/libaccfg.c +6 -0
@@ -2193,9 +2193,15 @@ static int accfg_wq_control(struct accfg_wq *wq, enum accfg_control_flag flag,if (flag ==ACCFG_WQ_ENABLE ) { rc =get_driver_bind_path (device->bus_type_str, + wq->driver_name ? wq->driver_name :IDXD_WQ_DEVICE_PORTAL (device, wq), &path);if (rc <0 )return rc; +if (wq->driver_name &&access (path,F_OK )) { +fprintf (stderr,"Invalid wq driver name \"%s\"\n" , + wq->driver_name); +return -ENOENT ; + } }else if (flag ==ACCFG_WQ_DISABLE ) {int clients;
Signature · 1 line
2.31.1
Ramesh Thomas
PATCH 6/6 accel-config: Update config-wq documentation with driver_name option
In reply to Ramesh ThomasUpdate documentation of config-wq command with driver_name option details.
--- Documentation/accfg/accel-config-config-wq.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/accfg/accel-config-config-wq.txt +5 -0
@@ -65,6 +65,11 @@ OPTIONS Typically it is used for identifying the wq in some unique way. A possible suggestion would be using a uuid string. +-d:: +--driver-name:: + specify the name of the driver to bind. This should be one of the valid + wq drivers found in /sys/bus/dsa/drivers + -m:: --mode:: configure the mode for the wq. The wq mode can be set as "dedicated" or
Signature · 1 line
2.31.1
Dave Jiang
Reviewed-by on the v1 seriesQuoted 17 lines · Ramesh Thomas
A new attribute called "
driver_name" is added to wqs which can be configured by user with the driver name to bind. Add support in accel-config to update, validate and use this attribute. It can be updated using config-wq command or using a configuration file.Since older drivers would not have this attribute, to be backward compatible the code checks for the presence of the attribute. If not found it will fall through to use the predefined driver names in code.
Ramesh Thomas (6):
accel-config: Adddriver_nameattribute to wq context
accel-config: Adddriver_nameoption toconfig_wqcommand
accel-config: Adddriver_nameto json configuration data
accel-config: Update copy ofidxd.hwith kernel changes
accel-config: Usedriver_nameattr for binding
accel-config: Update config-wq documentation withdriver_nameoption
Quoted 10 lines
.../accfg/accel-config-config-wq.txt | 5 ++++ accfg/config.c | 1 + accfg/config_attr.c | 14 +++++++++ accfg/idxd.h | 3 ++ accfg/lib/libaccel-config.sym | 7 +++++ accfg/lib/libaccfg.c | 30 +++++++++++++++++++ accfg/lib/private.h | 1 + accfg/libaccel_config.h | 4 +++ util/json.c | 6 ++++ 9 files changed, 71 insertions(+)
for the series.