accel-config: Add mdev support
ramesh.thomas at intel.com
v3 cover accel-config: Add mdev support
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Implements vfio mdev support for wqs. This implementation uses wqs internally and user does not need to attach wqs. Mdevs are stored and listed in the context of devices.
Initially 2 types of mdevs, 1dwq and 1swq are supported. 1swq uses shared wq type while 1dwq uses dedicaed wq.
Implements both library and command interfaces.
Added improvements in test case management and clears up stale state after test failures.
Added support for "locked" wq state.
Added unit tests and man pages.
Added support for new kernel ver 5.10 driver changes.
Ramesh Thomas (14):
accel-config: Add mdev path to device context
accel-config: Create mdev structures and load mdevs into device
context
accel-config: Add lib functions to list mdevs and retrieve mdev
properties
accel-config: Add mdev json support
accel-config: Implement create and remove mdev library API
accel-config: Add mdev create and remove commands
accel-config: Improve management of test cases
accel-config: Unit tests for mdev support
accel-config: Add wq locked state support
accel-config: Add documentation for wq options
accel-config: Add documentation for mdev commands
accel-config: Clear conditions blocking unit test after failure
accel-config: Support new driver changes in kernel ver 5.10
accel-config: Remove unloading of driver at end
.../accfg/accel-config-config-wq.txt | 15 + .../accfg/accel-config-create-mdev.txt | 32 +- .../accfg/accel-config-remove-mdev.txt | 26 +- accfg/config.c | 5 +- accfg/enable.c | 4 +- accfg/lib/libaccel-config.sym | 11 + accfg/lib/libaccfg.c | 223 +++++++++++++- accfg/lib/private.h | 9 + accfg/libaccel_config.h | 28 +- accfg/mdev.c | 123 +++++++- test/libaccfg.c | 279 +++++++++++++++--- util/json.c | 44 ++- 12 files changed, 733 insertions(+), 66 deletions(-)
Signature · 7 lines
v2: Split documentation batch into wq-config and mdev create/remove v3: Add support for new driver changes in kernel ver 5.10 2.26.2
ramesh.thomas at intel.com
PATCH v3 1/14 accel-config: Add mdev path to device context
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
/sys/class/mdev_bus/<bdf> is used often to access mdevs associated with the device. Generate and store in device so it need not be constructed everytime.
--- accfg/lib/libaccfg.c | 17 +++++++++++++++++ accfg/lib/private.h | 1 + 2 files changed, 18 insertions(+)
accfg/lib/libaccfg.c +17 -0
@@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device, struct list_head *head)list_del_from (head, &device->list);free (device->device_path);free (device->device_buf); +free (device->mdev_path);free (device); }
@@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_prchar *path;int dfd;int rc; +char *p; path =calloc (1 ,strlen (ctl_base) +MAX_PARAM_LEN );if (!path) {
@@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr goto err_dev_path; } + device->mdev_path =strdup (device->device_path); +if (!device->mdev_path) { +err (ctx,"strdup of device_path failed\n" ); + goto err_dev_path; + } + +if (asprintf (&p,"%s/%s" ,MDEV_BUS , +basename (dirname (device->mdev_path))) <0 ) { +err (ctx,"device mdev_path allocation failed\n" ); + goto err_dev_path; + } +free (device->mdev_path); + device->mdev_path = p; + device->device_buf =calloc (1 ,strlen (device->device_path) +MAX_PARAM_LEN );if (!device->device_buf) {
@@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr err_dev_path: err_read:free (device->device_buf); +free (device->mdev_path);free (device); err_device:free (path);
accfg/lib/private.h +1 -0
@@ -30,6 +30,7 @@ struct accfg_device {struct list_node list;int group_init;char *device_path; +char *mdev_path;char *device_buf;char *device_type_str;enum accfg_device_type type;
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 2/14 accel-config: Create mdev structures and load mdevs into device context
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Lays the foundation for the mdev implementation
- Create private and exported structures for mdev types and mdev list
- Create routines to scan and classify mdevs in sysfs
- Store mdev details in device contexts during init
--- accfg/lib/libaccfg.c | 81 +++++++++++++++++++++++++++++++++++++++++ accfg/lib/private.h | 8 ++++ accfg/libaccel_config.h | 7 ++++ 3 files changed, 96 insertions(+)
accfg/lib/libaccfg.c +81 -0
@@ -43,6 +43,12 @@ ACCFG_EXPORT char *accfg_basenames[] = {NULL }; +ACCFG_EXPORT char *accfg_mdev_basenames[] = { + [ACCFG_MDEV_TYPE_1_DWQ ] ="1dwq" , + [ACCFG_MDEV_TYPE_1_SWQ ] ="1swq" , +NULL +}; +enum {ACCFG_CMD_STATUS_MAX =0x45 , };
@@ -407,6 +413,77 @@ static int device_parse_type(struct accfg_device *device)return 0 ; } +static int mdev_str_to_type (char *mdev_type_str) +{ +char **b; +char *s; +int l, i; + + s =strchr (mdev_type_str,'-' ); +if (!s) + s = mdev_type_str; +else + s++; + l = (int ) (strchrnul (s,'-' ) - s); + +for (b = accfg_mdev_basenames, i =0 ; *b !=NULL ; b++, i++) +if (!strncmp (*b, s, l)) +return i; + +return ACCFG_MDEV_TYPE_UNKNOWN ; +} + +static int add_device_mdevs (struct accfg_ctx *ctx,struct accfg_device *dev) +{ +struct accfg_device_mdev *dev_mdev; +uuid_t uu; +struct dirent **d; +char *f, *mdev_type_str; +char p[PATH_MAX ]; +char mdev_path[PATH_MAX ]; +int n, n1, rc =0 ; + + n1 = n =scandir (dev->mdev_path, &d,NULL , alphasort); +if (n <0 ) { +err (ctx,"scandir failed\n" ); +return -ENOENT ; + } + +while (n--) { + f = &d[n]->d_name[0 ]; +if (*f =='.' ||uuid_parse (f, uu)) +continue ; +sprintf (p,"%s/%s/mdev_type" , dev->mdev_path, f); +if (!realpath (p, mdev_path)) +continue ; + dev_mdev =calloc (1 , +sizeof (struct accfg_device_mdev )); +if (!dev_mdev) { +err (ctx,"allocation failed\n" ); + rc = -ENOMEM ; + goto exit_add_mdev; + } +uuid_copy (dev_mdev->uuid, uu); + mdev_type_str =strrchr (mdev_path,'/' ) +1 ; + dev_mdev->device = dev; + dev_mdev->type =mdev_str_to_type (mdev_type_str); +if (dev_mdev->type ==ACCFG_MDEV_TYPE_UNKNOWN ) { +err (ctx,"mdev type error\n" ); +free (dev_mdev); + rc = -EINVAL ; + goto exit_add_mdev; + } +list_add_tail (&dev->mdev_list, &dev_mdev->list); + } + +exit_add_mdev: +while (n1--) +free (d[n1]); +free (d); + +return rc; +} +static void *add_device (void *parent,int id,const char *ctl_base,char *dev_prefix) {struct accfg_ctx *ctx = parent;
@@ -439,6 +516,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_prlist_head_init (&device->groups);list_head_init (&device->wqs);list_head_init (&device->engines); +list_head_init (&device->mdev_list); device->ctx = ctx; device->id = id;
@@ -501,6 +579,9 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_prlist_add_tail (&ctx->devices, &device->list);free (path); +if (add_device_mdevs (ctx, device)) + goto err_dev_path; +return device; err_dev_path:
accfg/lib/private.h +8 -0
@@ -35,6 +35,7 @@ struct accfg_device {char *device_type_str;enum accfg_device_type type;size_t buf_len; +struct list_head mdev_list;/* Device Attributes */ struct accfg_error errors;
@@ -56,6 +57,13 @@ struct accfg_device {char *pasid_enabled; }; +struct accfg_device_mdev { +struct accfg_device *device; +uuid_t uuid; +enum accfg_mdev_type type; +struct list_node list; +}; +struct accfg_group {struct accfg_device *device;int id;
accfg/libaccel_config.h +7 -0
@@ -67,6 +67,12 @@ enum accfg_control_flag { ACCFG_WQ_DISABLE, }; +enum accfg_mdev_type { +ACCFG_MDEV_TYPE_1_DWQ , +ACCFG_MDEV_TYPE_1_SWQ , +ACCFG_MDEV_TYPE_UNKNOWN , +}; +/* no need to save device error */ struct accfg_error {uint64_t val[4 ];
@@ -78,6 +84,7 @@ struct dev_parameters { };extern char *accfg_basenames[]; +extern char *accfg_mdev_basenames[];struct group_parameters {unsigned int tokens_reserved;
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 3/14 accel-config: Add lib functions to list mdevs and retrieve mdev properties
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Create library functions for querrying mdev details
- Functions to retrieve first and next mdev in list
- Macro to iterate mdev list
- Functions to retrieve mdev uuid and type
--- accfg/lib/libaccel-config.sym | 9 +++++++++ accfg/lib/libaccfg.c | 22 ++++++++++++++++++++++ accfg/libaccel_config.h | 11 +++++++++++ 3 files changed, 42 insertions(+)
accfg/lib/libaccel-config.sym +9 -0
@@ -133,3 +133,12 @@ global: accfg_wq_set_max_batch_size; accfg_wq_set_max_transfer_size; } LIBACCFG_6; + +LIBACCFG_8 { +global: + accfg_device_first_mdev; + accfg_device_next_mdev; + accfg_mdev_get_uuid; + accfg_mdev_get_type; + accfg_mdev_basenames; +} LIBACCFG_7;
accfg/lib/libaccfg.c +22 -0
@@ -957,6 +957,28 @@ static void engines_init(struct accfg_device *device) add_engine); } +ACCFG_EXPORT struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device) +{ + return list_top(&device->mdev_list, struct accfg_device_mdev, list); +} + +ACCFG_EXPORT struct accfg_device_mdev *accfg_device_next_mdev(struct accfg_device_mdev *mdev) +{ +struct accfg_device *device = mdev->device; + +return list_next (&device->mdev_list, mdev, list); +} + +ACCFG_EXPORT void accfg_mdev_get_uuid(struct accfg_device_mdev *mdev, uuid_t uuid) +{ +uuid_copy (uuid, mdev->uuid); +} + +ACCFG_EXPORT enum accfg_mdev_type accfg_mdev_get_type(struct accfg_device_mdev *mdev) +{ +return mdev->type; +} +/** * accfg_device_get_first - retrieve first device in the system * @ctx: context established by accfg_new
accfg/libaccel_config.h +11 -0
@@ -184,6 +184,17 @@ int accfg_device_is_active(struct accfg_device *device);int accfg_device_get_cmd_status (struct accfg_device *device);const char *accfg_device_get_cmd_status_str (struct accfg_device *device); +struct accfg_device_mdev ; +struct accfg_device_mdev *accfg_device_first_mdev (struct accfg_device *device); +struct accfg_device_mdev *accfg_device_next_mdev (struct accfg_device_mdev *mdev); +void accfg_mdev_get_uuid (struct accfg_device_mdev *mdev,uuid_t uuid); +enum accfg_mdev_type accfg_mdev_get_type (struct accfg_device_mdev *mdev); + +#define accfg_device_mdev_foreach (device, mdev) \ + for (mdev = accfg_device_first_mdev(device); \ + mdev != NULL; \ + mdev = accfg_device_next_mdev(mdev)) +/* libaccfg function for group */ struct accfg_group ;struct accfg_group *accfg_group_get_first (struct accfg_device *device);
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 4/14 accel-config: Add mdev json support
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Load the mdevs stored in device contexts into json objects as array of mdev structures containing uuid and types
"list" command will list the mdevs structures under each device
--- util/json.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
util/json.c +38 -0
@@ -153,6 +153,12 @@ struct json_object *util_device_to_json(struct accfg_device *device,unsigned long ulong_val;unsigned long long ullong_val;bool new_bool; +struct accfg_device_mdev *mdev; +struct json_object *json_uuid; +struct json_object *json_mtype; +char uuid_string[UUID_STR_LEN ]; +int mdev_found =0 ; +struct json_object *json_mdev;if (!jdevice)return NULL ;
@@ -339,6 +345,38 @@ struct json_object *util_device_to_json(struct accfg_device *device, goto err;json_object_object_add (jdevice,"clients" , jobj); + jobj =json_object_new_array (); + accfg_device_mdev_foreach(device, mdev) { +uuid_t uuid; +const char *mdev_type; + +accfg_mdev_get_uuid (mdev, uuid); +uuid_unparse (uuid, uuid_string); + json_uuid =json_object_new_string (uuid_string); +if (!json_uuid) +break ; + mdev_type = accfg_mdev_basenames[accfg_mdev_get_type (mdev)]; + json_mtype =json_object_new_string (mdev_type); +if (!json_mtype) { +json_object_put (json_uuid); +break ; + } + json_mdev =json_object_new_object (); +if (!json_mdev) { +json_object_put (json_uuid); +json_object_put (json_mtype); +break ; + } +json_object_object_add (json_mdev,"uuid" , json_uuid); +json_object_object_add (json_mdev,"type" , json_mtype); +json_object_array_add (jobj, json_mdev); + mdev_found++; + } +if (mdev_found) +json_object_object_add (jdevice,"mdevs" , jobj); +else +json_object_put (jobj); +free (error);return jdevice; err:
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 5/14 accel-config: Implement create and remove mdev library API
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Adds accfg_create_mdev and accfg_remove_mdev library functions.
--- accfg/lib/libaccel-config.sym | 2 + accfg/lib/libaccfg.c | 104 ++++++++++++++++++++++++++++++++++ accfg/libaccel_config.h | 3 + 3 files changed, 109 insertions(+)
accfg/lib/libaccel-config.sym +2 -0
@@ -141,4 +141,6 @@ global: accfg_mdev_get_uuid; accfg_mdev_get_type; accfg_mdev_basenames; + accfg_create_mdev; + accfg_remove_mdev; } LIBACCFG_7;
accfg/lib/libaccfg.c +104 -0
110 lines not on this page · raw message
accfg/libaccel_config.h +3 -0
@@ -189,6 +189,9 @@ struct accfg_device_mdev *accfg_device_first_mdev(struct accfg_device *device);struct accfg_device_mdev *accfg_device_next_mdev (struct accfg_device_mdev *mdev);void accfg_mdev_get_uuid (struct accfg_device_mdev *mdev,uuid_t uuid);enum accfg_mdev_type accfg_mdev_get_type (struct accfg_device_mdev *mdev); +int accfg_create_mdev (struct accfg_device *device,enum accfg_mdev_type type, +uuid_t uuid); +int accfg_remove_mdev (struct accfg_device *device,uuid_t uuid);#define accfg_device_mdev_foreach (device, mdev) \ for (mdev = accfg_device_first_mdev(device); \
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 6/14 accel-config: Add mdev create and remove commands
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Implements following commands -
accel-config create-mdev <device-name> [<mdev-type>|<options>] accel-config remove-mdev <device-name> [<uuid>|<options>]
--- accfg/mdev.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-)
accfg/mdev.c +122 -1
@@ -21,12 +21,133 @@#include <sys/stat.h> #include <accfg.h> +static int opt_called; +static struct accfg_device *device; + +static int opt_cb_create_mdev (const struct option *opt,const char *arg,int unset) +{ +char **m; + +if (opt->short_name !='l' ) +return -1 ; + +printf ("Available mdev types:\n" ); +for (m = accfg_mdev_basenames; *m; m++) +printf ("\t%s\n" , *m); + + opt_called = true; + +return 0 ; +} + +static int opt_cb_remove_mdev (const struct option *opt,const char *arg,int unset) +{ +uuid_t uuid; +char uuid_str[UUID_STR_LEN ]; +struct accfg_device_mdev *mdev; +enum accfg_mdev_type type; + +if (opt->short_name !='l' ) +return -1 ; + +printf ("Available mdevs:\n" ); + accfg_device_mdev_foreach(device, mdev) { +accfg_mdev_get_uuid (mdev, uuid); + type =accfg_mdev_get_type (mdev); +uuid_unparse (uuid, uuid_str); +printf ("\tuuid:%s, type:%s\n" , uuid_str, + accfg_mdev_basenames[type]); + } + opt_called = true; + +return 0 ; +} +int cmd_create_mdev (int argc,const char **argv,void *ctx) { +char **m; +int rc, t; +uuid_t uuid; +char uuid_str[UUID_STR_LEN ]; + +const struct option options[] = { +OPT_CALLBACK_NOOPT ('l' ,"list-mdev-types" ,NULL ,NULL , +"will list available mdev types" , opt_cb_create_mdev), +OPT_END (), + }; + +const char *const u[] = { +"accfg create-mdev <device name> [<mdev type>|<options>]" , +NULL + }; + +if (argc <3 ) +usage_with_options (u, options); + + device =accfg_ctx_device_get_by_name (ctx, argv[1 ]); +if (!device) { +fprintf (stderr,"Enter a valid device to create mdev\n" ); +usage_with_options (u, options); + } + + argc =parse_options (argc, argv, options, u,0 ); +if (opt_called) +return 0 ; + +for (m = accfg_mdev_basenames, t =0 ; *m; m++, t++) +if (!strcmp (argv[1 ], *m)) +break ; +if (!*m) { +fprintf (stderr,"Invalid mdev type\n" ); +usage_with_options (u, options); + } + + rc =accfg_create_mdev (device, t, uuid); +if (rc <0 ) +return rc; + +uuid_unparse (uuid, uuid_str); +printf ("Created mdev wth uuid: %s\n" , uuid_str); +return 0 ; }int cmd_remove_mdev (int argc,const char **argv,void *ctx) { -return 0 ; +int rc; +uuid_t uuid; + +const struct option options[] = { +OPT_CALLBACK_NOOPT ('l' ,"list-mdevs" ,NULL ,NULL , +"will list available mdevs" , opt_cb_remove_mdev), +OPT_END (), + }; + +const char *const u[] = { +"accfg remove-mdev <device name> [<uuid>|<options>]" , +"Pass null uuid to remove all mdevs" , +NULL + }; + +if (argc <3 ) +usage_with_options (u, options); + + device =accfg_ctx_device_get_by_name (ctx, argv[1 ]); +if (!device) { +fprintf (stderr,"Enter a valid device to remove mdev\n" ); +usage_with_options (u, options); + } + + argc =parse_options (argc, argv, options, u,0 ); +if (opt_called) +return 0 ; + +if (uuid_parse (argv[1 ], uuid) <0 ) { +fprintf (stderr,"Invalid uuid\n" ); +usage_with_options (u, options); + } + + rc =accfg_remove_mdev (device, uuid); + +return rc; }
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 7/14 accel-config: Improve management of test cases
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Created structure to store test func and description. Array of this structure will be used to print test case description and results. This removes the need to name tests with serial numbers. Invidual tests can be enabled/disabled by setting a flag.
--- test/libaccfg.c | 66 ++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 26 deletions(-)
test/libaccfg.c +40 -26
@@ -766,7 +766,7 @@ static int wq_bounds_test(struct accfg_ctx *ctx, const char *dev_name) }/* test the set and get libaccfg functions for all components in dsa0 */ -static int do_test0 (struct accfg_ctx *ctx) +static int test_config (struct accfg_ctx *ctx) {int rc =0 ;
@@ -781,22 +781,18 @@ static int do_test0(struct accfg_ctx *ctx)/* get configuration to see if match */ rc =check_config (ctx,"dsa0" ); -if (rc !=0 ) { -fprintf (stderr,"test 0: test the set and get libaccfg functions for components failed\n" ); +if (rc !=0 )return rc; - } rc =device_test_reset (ctx,"dsa0" );if (rc !=0 )return rc; -fprintf (stderr,"test 0: test the set and get libaccfg functions for components passed successfully\n" ); -return 0 ; }/* set large wq to exceed max total size in dsa */ -static int do_test1 (struct accfg_ctx *ctx) +static int test_max_wq_size (struct accfg_ctx *ctx) {int rc =0 ;
@@ -805,21 +801,18 @@ static int do_test1(struct accfg_ctx *ctx)return rc; rc =set_exceed_config (ctx,"dsa1" ); -if (rc !=0 ) { -fprintf (stderr,"test 1: set large wq to exceed max total size in dsa failed\n" ); +if (rc !=0 )return rc; - } rc =device_test_reset (ctx,"dsa1" );if (rc !=0 )return rc; -fprintf (stderr,"test 1: set large wq to exceed max total size in dsa passed successfully\n" ); -return 0 ; +return 0 ; }/* test the boundary conditions for wq max_batch_size and max_transfer_size */ -static int do_test2 (struct accfg_ctx *ctx) +static int test_wq_boundary_conditions (struct accfg_ctx *ctx) {int rc =0 ;
@@ -828,24 +821,39 @@ static int do_test2(struct accfg_ctx *ctx)return rc; rc =wq_bounds_test (ctx,"dsa0" ); -if (rc !=0 ) { -fprintf (stderr,"test 2: wq boundary conditions test failed\n" ); +if (rc !=0 )return rc; - } rc =device_test_reset (ctx,"dsa0" );if (rc !=0 )return rc; -fprintf (stderr,"test 2: wq boundary conditions test passed successfully\n" ); -return 0 ; +return 0 ; }typedef int (*do_test_fn )(struct accfg_ctx *ctx); -static do_test_fn do_test[] = { - do_test0, - do_test1, - do_test2, +struct _test_case { +do_test_fn test_fn; +char *desc; +bool enabled; +}; + +static struct _test_case test_cases[] = { + { + .test_fn = test_config, + .desc ="set and get configurations" , + .enabled = true, + }, + { + .test_fn = test_max_wq_size, + .desc ="max wq size" , + .enabled = true, + }, + { + .test_fn = test_wq_boundary_conditions, + .desc ="wq boundary conditions" , + .enabled = true, + }, }; static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
@@ -914,15 +922,21 @@ int test_libaccfg(int loglevel, struct accfg_test *test, } } -for (i =0 ; i <ARRAY_SIZE (do_test); i++) { - err = do_test[i](ctx); +for (i =0 ; i <ARRAY_SIZE (test_cases); i++) { +if (!test_cases[i].enabled) { +fprintf (stderr,"\naccfg-test%d *disabled*\n" , i); +continue ; + } +printf ("\nRunning accfg-test%d: %s\n" , i, test_cases[i].desc); + err = test_cases[i].test_fn (ctx);if (err <0 ) { -fprintf (stderr,"accfg-test%d failed: %d\n" , i, err); +fprintf (stderr,"accfg-test%d *failed*: %d\n" , i, err);break ; } +printf ("accfg-test%d passed!\n" , i); } -if (i >=ARRAY_SIZE (do_test)) +if (i >=ARRAY_SIZE (test_cases)) result =EXIT_SUCCESS ;kmod_module_remove_module (mod,0 );
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 8/14 accel-config: Unit tests for mdev support
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Tests for create/remove mdev 1swq amd 1dwq
--- test/libaccfg.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 157 insertions(+), 1 deletion(-)
test/libaccfg.c +157 -1
@@ -492,7 +492,6 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)if (wq_state ==ACCFG_WQ_DISABLED || wq_state ==ACCFG_WQ_QUIESCING ) { -fprintf (stderr,"%s is disabled already\n" ,accfg_wq_get_devname (wq));continue ; }
@@ -762,6 +761,15 @@ static int wq_bounds_test(struct accfg_ctx *ctx, const char *dev_name)return rc; } +/* reset to valid values for following tests */ + wq00_param.max_batch_size =1 ; + wq00_param.max_transfer_size =1 ; + rc =config_wq (ctx,0 ,0 , wq00_param, dev_name); +if (rc !=0 ) { +fprintf (stderr,"config wq wq0.0 failed\n" ); +return rc; + } +return 0 ; }
@@ -831,6 +839,144 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx)return 0 ; } +static int mdev_test (struct accfg_ctx *ctx,const char *dev_name, +char *mdev_type_str,int num_mdevs) +{ +struct accfg_device *device; +enum accfg_mdev_type type; +int rc, i; +char **m; +uuid_t uuid; + + device =accfg_ctx_device_get_by_name (ctx, dev_name); +if (!device) { +fprintf (stderr,"Device %s not found\n" , dev_name); +return -EINVAL ; + } + +for (m = accfg_mdev_basenames, type =0 ; *m; m++, type++) +if (!strcmp (*m, mdev_type_str)) +break ; + +if (!*m) { +fprintf (stderr,"Invalid mdev type\n" ); +return -EINVAL ; + } + +for (i =0 ; i < num_mdevs; i++) { + rc =accfg_create_mdev (device, type, uuid); +if (rc) { +fprintf (stderr,"mdev creation failed\n" ); +return rc; + } + } + +/* Remove all mdevs */ +uuid_clear (uuid); + rc =accfg_remove_mdev (device, uuid); +if (rc) { +fprintf (stderr,"mdev removal failed\n" ); +return rc; + } + +return rc; +} + +static int enable_wq (struct accfg_ctx *ctx,const char *dev_name,int wq_id) +{ +struct accfg_device *device; +struct accfg_wq *wq; +int rc; + + device =accfg_ctx_device_get_by_name (ctx, dev_name); +if (!device) { +fprintf (stderr,"Device %s not found\n" , dev_name); +return -EINVAL ; + } +if (!accfg_device_is_active (device)) { + rc =accfg_device_enable (device); +if (rc <0 ) { +fprintf (stderr,"device enable of %s failed\n" , + dev_name); +return rc; + } + } + + wq =accfg_device_wq_get_by_id (device, wq_id); +if (!wq) { +fprintf (stderr,"wq with id %d not found for device %s\n" , + wq_id, dev_name); +return -EINVAL ; + } + +if (accfg_wq_get_state (wq) ==ACCFG_WQ_ENABLED ) +return 0 ; + +return accfg_wq_enable (wq); +} + +/* test 1swq type mdev creation and removal */ +static int test_mdev_1swq (struct accfg_ctx *ctx) +{ +int rc =0 ; + + rc =device_test_reset (ctx,"dsa0" ); +if (rc) +return rc; + + rc =set_config (ctx,"dsa0" ); +if (rc !=0 ) +return rc; + + rc =enable_wq (ctx,"dsa0" ,2 ); +if (rc) { +fprintf (stderr,"enable wq wq0.2 failed" ); +return rc; + } + +/* create and remove 5 1swq mdevs */ + rc =mdev_test (ctx,"dsa0" ,"1swq" ,5 ); +if (rc) +return rc; + + rc =device_test_reset (ctx,"dsa0" ); +if (rc) +return rc; + +return 0 ; +} + +/* test 1dwq type mdev creation and removal */ +static int test_mdev_1dwq (struct accfg_ctx *ctx) +{ +int rc =0 ; + + rc =device_test_reset (ctx,"dsa0" ); +if (rc) +return rc; + + rc =set_config (ctx,"dsa0" ); +if (rc !=0 ) +return rc; + + rc =enable_wq (ctx,"dsa0" ,3 ); +if (rc) { +fprintf (stderr,"enable wq wq0.3 failed" ); +return rc; + } + +/* create and remove 1 1dwq mdev */ + rc =mdev_test (ctx,"dsa0" ,"1dwq" ,1 ); +if (rc) +return rc; + + rc =device_test_reset (ctx,"dsa0" ); +if (rc) +return rc; + +return 0 ; +} +typedef int (*do_test_fn )(struct accfg_ctx *ctx);struct _test_case {do_test_fn test_fn;
@@ -854,6 +1000,16 @@ static struct _test_case test_cases[] = { .desc = "wq boundary conditions", .enabled = true, }, + { + .test_fn = test_mdev_1swq, + .desc = "1swq type mdev creation and removal", + .enabled = true, + }, + { + .test_fn = test_mdev_1dwq, + .desc = "1dwq type mdev creation and removal", + .enabled = true, + }, }; static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 9/14 accel-config: Add wq locked state support
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Add support to the "locked" wq state. Read and save state to be used in wq state identification querries and listing of wq details. It is treated same as enabled state.
--- accfg/config.c | 5 +++-- accfg/enable.c | 4 ++-- accfg/lib/libaccfg.c | 4 +++- accfg/libaccel_config.h | 7 ++++--- test/libaccfg.c | 12 ++++++++---- util/json.c | 6 +++++- 6 files changed, 25 insertions(+), 13 deletions(-)
accfg/config.c +3 -2
@@ -474,7 +474,7 @@ static int configure_json_value(struct accfg_ctx *ctx,if (!wq)return -ENOENT ; wq_state =accfg_wq_get_state (wq); -if (wq_state ==ACCFG_WQ_ENABLED ) { +if (wq_state ==ACCFG_WQ_ENABLED || wq_state ==ACCFG_WQ_LOCKED ) {fprintf (stderr,"%s is active, will skip...\n" , parsed_string);return 0 ; }
@@ -539,7 +539,8 @@ static int configure_json_value(struct accfg_ctx *ctx, key);return rc; } - }else if (wq && wq_state !=ACCFG_WQ_ENABLED ) { + }else if (wq && wq_state !=ACCFG_WQ_ENABLED && + wq_state !=ACCFG_WQ_LOCKED ) { rc =wq_json_set_val (wq, jobj, key);if (rc <0 ) { fprintf(stderr, "wq set %s value failed\n",
accfg/enable.c +2 -2
@@ -201,9 +201,9 @@ static int action_enable_wq(struct accfg_wq *wq, const char *wq_name) {enum accfg_wq_state wq_state =accfg_wq_get_state (wq); -if (wq_state ==ACCFG_WQ_ENABLED ) { +if (wq_state ==ACCFG_WQ_ENABLED || wq_state ==ACCFG_WQ_LOCKED ) {fprintf (stderr, -"%s is in enabled mode already, skipping...\n" , +"%s is in enabled or locked mode, skipping...\n" , wq_name);return -ENXIO ; }else if (wq_state ==ACCFG_WQ_QUIESCING ) {
accfg/lib/libaccfg.c +3 -1
@@ -1942,7 +1942,7 @@ static int accfg_wq_control(struct accfg_wq *wq, enum accfg_control_flag flag,/* verify state */ if (!accfg_wq_state_expected (wq, flag)) { -err (ctx,"WQ not in expected state." ); +err (ctx,"WQ not in expected state\n" );return -ENXIO ; }
@@ -1988,6 +1988,8 @@ ACCFG_EXPORT enum accfg_wq_state accfg_wq_get_state(struct accfg_wq *wq)return ACCFG_WQ_ENABLED ; else if (strcmp(read_state, "quiescing") == 0) return ACCFG_WQ_QUIESCING; + else if (strcmp(read_state, "locked") == 0) + return ACCFG_WQ_LOCKED;return ACCFG_WQ_UNKNOWN ; }
accfg/libaccel_config.h +4 -3
@@ -48,9 +48,10 @@ enum accfg_wq_mode { };enum accfg_wq_state { -ACCFG_WQ_DISABLED =0 , -ACCFG_WQ_ENABLED =1 , -ACCFG_WQ_QUIESCING =2 , +ACCFG_WQ_DISABLED , +ACCFG_WQ_ENABLED , +ACCFG_WQ_QUIESCING , +ACCFG_WQ_LOCKED ,ACCFG_WQ_UNKNOWN =-1 , };
test/libaccfg.c +8 -4
@@ -334,8 +334,10 @@ static int config_wq(struct accfg_ctx *ctx, int dev_id, int wq_id,/* check if wq is disabled before configuration */ wstate =accfg_wq_get_state (wq); -if (wstate ==ACCFG_WQ_ENABLED ) { -fprintf (stderr,"wq%d in %s is in enabled mode and can not be configured\n" , wq_id, dev_name); +if (wstate ==ACCFG_WQ_ENABLED || wstate ==ACCFG_WQ_LOCKED ) { +fprintf (stderr, +"wq%d in %s is in enabled or locked mode and cannot be configured\n" , + wq_id, dev_name);continue ; }
@@ -497,7 +499,7 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name) rc =accfg_wq_disable (wq, true);if (rc <0 ) { -fprintf (stderr,"wq under %s disabled failed\n" , dev_name); +fprintf (stderr,"wq under %s disable failed\n" , dev_name);return rc; } }
@@ -886,6 +888,7 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id) {struct accfg_device *device;struct accfg_wq *wq; +enum accfg_wq_state wq_state;int rc; device =accfg_ctx_device_get_by_name (ctx, dev_name);
@@ -909,7 +912,8 @@ static int enable_wq(struct accfg_ctx *ctx, const char *dev_name, int wq_id)return -EINVAL ; } -if (accfg_wq_get_state (wq) ==ACCFG_WQ_ENABLED ) + wq_state =accfg_wq_get_state (wq); +if (wq_state ==ACCFG_WQ_ENABLED || wq_state ==ACCFG_WQ_LOCKED )return 0 ;return accfg_wq_enable (wq);
util/json.c +5 -1
@@ -400,7 +400,8 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq, wq_state =accfg_wq_get_state (wq);/* Don't display idle wqs */ -if (wq_state !=ACCFG_WQ_ENABLED && !(flags &UTIL_JSON_IDLE )) +if (wq_state !=ACCFG_WQ_ENABLED && wq_state !=ACCFG_WQ_LOCKED && + !(flags &UTIL_JSON_IDLE )) goto err; jobj =json_object_new_string (accfg_wq_get_devname (wq));
@@ -477,6 +478,9 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,case ACCFG_WQ_QUIESCING : jobj =json_object_new_string ("quiescing" );break ; +case ACCFG_WQ_LOCKED : + jobj =json_object_new_string ("locked" ); +break ;case ACCFG_WQ_UNKNOWN :default : jobj =json_object_new_string ("unknown" );
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 10/14 accel-config: Add documentation for wq options
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Add man pages for config-wq options max_batch_size and max_transfer_size
--- Documentation/accfg/accel-config-config-wq.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/accfg/accel-config-config-wq.txt +15 -0
@@ -64,4 +64,19 @@ OPTIONS configure the mode for the wq. The wq mode can be set as "dedicated" or "shared". +-c:: +--max-batch-size:: + specify the max batch size used by a work queue. The value should be + between 1 and the device maximum batch size found in the + max_batch_size attribute under device. If the value is not a power + of 2, it will be rounded up to the next power of 2. + +-x:: +--max-transfer-size:: + specify the max transfer size used by a work queue. The value should be + between 1 and the device maximum transfer size found in the + max_transfer_size attribute under device. If the value is not a power + of 2, it will be rounded up to the next power of 2. + + include::../copyright.txt[]
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 11/14 accel-config: Add documentation for mdev commands
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Add manual pages for create-mdev and remove-mdev commands
--- .../accfg/accel-config-create-mdev.txt | 32 +++++++++++++------ .../accfg/accel-config-remove-mdev.txt | 26 +++++++++++---- 2 files changed, 42 insertions(+), 16 deletions(-)
Documentation/accfg/accel-config-create-mdev.txt +23 -9
@@ -5,21 +5,35 @@ accel-config-create-mdev(1) NAME ---- -accel-config-create-mdev - create mdev to a specified workqueue by generating a -random uuid and writing to workqueue sysfs. The workqueue has to be enabled -before running this command and it has to be configured as "mdev" type. If the -workqueue type is shared, this command can be issued multiple times. If the -workqueue is dedicated, only one uuid is allowed to be created. If this command -is issued to a dedicated wq with uuid already existing, it will trigger -operation not permitted error. +accel-config-create-mdev - create mdev to enabled workqueues of devices. +A uuid is generated which is associated with the mdev and will be stored in +/sys/class/mdev_bus under the device pcie bdf id. Creation of mdevs require +enabled workqueues. For mdevs of the shared type, at least one shared +mode workqueue needs to be enabled. Each dedicated type mdev require one +dedicated mode workqueue to be enabled. Creation of dedicated type mdevs +would set the state of workqueue used as "locked". Creation of shared +type mdevs do not alter the state of workqueues. SYNOPSIS -------- [verse] -'accel-config create-mdev' <device name>/<workqueue name> +'accel-config create-mdev <device-name> [<mdev-type>|<options>]' EXAMPLE ------- -accel-config create-mdev dsa0/wq0.0 +accel-config create-mdev dsa0 1dwq + +accel-config create-mdev dsa0 -l +---- +Available mdev types: + 1dwq + 1swq +---- + +OPTIONS +-------- +-l:: +--list-mdev-types:: + list the available mdev types include::../copyright.txt[]
Documentation/accfg/accel-config-remove-mdev.txt +19 -7
@@ -5,22 +5,34 @@ accel-config-remove-mdev(1) NAME ---- -accel-config-remove-mdev - clear the uuid from a workqueue uuid list. If not uuid is -specified, then entire uuid list in this workqueue will be removed. +accel-config-remove-mdev - remove mdev of a device associated with +the passed uuid. Passing a null uuid will remove all mdevs of the +device. SYNOPSIS -------- [verse] -'accel-config remove-mdev' <device name>/<workqueue name> [<options>] +'accel-config remove-mdev <device-name> [<uuid>|<options>]' EXAMPLE ------- -accel-config remove-mdev dsa0/wq0.0 --uuid=0f34f0ed-6f67-4086-a4b7-8e1ecf077dce +accel-config remove-mdev dsa0 0f34f0ed-6f67-4086-a4b7-8e1ecf077dce +accel-config remove-mdev dsa0 00000000-0000-0000-0000-000000000000 + +accel-config remove-mdev dsa0 -l +---- +Available mdevs: + uuid:edc13abf-cbf4-4de8-bf01-0dc864c54290, type:1dwq + uuid:7e776dce-a80b-4da8-9b13-d0483bff678f, type:1swq + uuid:45174189-1b18-4270-9f02-30cadbd4b1a4, type:1swq + uuid:3c53af36-be6f-405f-9ebf-d556e0735943, type:1swq + uuid:131a1337-4c32-48a0-97a7-0aac053f383c, type:1swq +---- OPTIONS ------- --u:: ---uuid=:: - remove this specific uuid from uuid list in the specified workqueue. +-l:: +--list-mdevs:: + list available mdevs of device include::../copyright.txt[]
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 12/14 accel-config: Clear conditions blocking unit test after failure
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
Not disabling components and resetting driver blocks future tests. This change force closes mdevs, wqs, devices and resets the driver. Also at start loads driver if it was not.
--- test/libaccfg.c | 53 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 13 deletions(-)
test/libaccfg.c +40 -13
@@ -475,12 +475,14 @@ static int check_engine(struct accfg_ctx *ctx, int dev_id, int engine_id,return 0 ; } -static int device_test_reset (struct accfg_ctx *ctx,const char *dev_name) +static int device_test_reset (struct accfg_ctx *ctx,const char *dev_name, +bool forced) {int rc =0 ;struct accfg_device *device;struct accfg_wq *wq;enum accfg_wq_state wq_state; +uuid_t uuid; device =accfg_ctx_device_get_by_name (ctx, dev_name);if (!device)
@@ -488,6 +490,15 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name)/* make sure device is disabled before configuration */ if (accfg_device_is_active (device)) { + +/* Remove all mdevs */ +uuid_clear (uuid); + rc =accfg_remove_mdev (device, uuid); +if (rc && !forced) { +fprintf (stderr,"mdev removal failed\n" ); +return rc; + } +/* make sure each wq is disabled */ accfg_wq_foreach(device, wq) { wq_state =accfg_wq_get_state (wq);
@@ -498,14 +509,14 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name) } rc =accfg_wq_disable (wq, true); -if (rc <0 ) { +if (rc <0 && !forced) {fprintf (stderr,"wq under %s disable failed\n" , dev_name);return rc; } } rc =accfg_device_disable (device, true);if (rc <0 ) { -fprintf (stderr,"%s should be disabled before config but failed\n" , dev_name); +fprintf (stderr,"%s disabling failed\n" , dev_name);return rc; } }
@@ -514,6 +525,17 @@ static int device_test_reset(struct accfg_ctx *ctx, const char *dev_name) } +static void test_cleanup (struct accfg_ctx *ctx) +{ +struct accfg_device *device; + + accfg_device_foreach(ctx, device) { +const char *dev_name =accfg_device_get_devname (device); + +device_test_reset (ctx, dev_name, true); + } +} +static int set_config (struct accfg_ctx *ctx,const char *dev_name) {int rc =0 ;
@@ -780,7 +802,7 @@ static int test_config(struct accfg_ctx *ctx) {int rc =0 ; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc !=0 )return rc;
@@ -794,7 +816,7 @@ static int test_config(struct accfg_ctx *ctx)if (rc !=0 )return rc; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc !=0 )return rc;
@@ -806,7 +828,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx) {int rc =0 ; - rc =device_test_reset (ctx,"dsa1" ); + rc =device_test_reset (ctx,"dsa1" , false);if (rc !=0 )return rc;
@@ -814,7 +836,7 @@ static int test_max_wq_size(struct accfg_ctx *ctx)if (rc !=0 )return rc; - rc =device_test_reset (ctx,"dsa1" ); + rc =device_test_reset (ctx,"dsa1" , false);if (rc !=0 )return rc;
@@ -826,7 +848,7 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx) {int rc =0 ; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc !=0 )return rc;
@@ -834,7 +856,7 @@ static int test_wq_boundary_conditions(struct accfg_ctx *ctx)if (rc !=0 )return rc; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc !=0 )return rc;
@@ -924,7 +946,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx) {int rc =0 ; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc)return rc;
@@ -943,7 +965,7 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)if (rc)return rc; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc)return rc;
@@ -955,7 +977,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx) {int rc =0 ; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc)return rc;
@@ -974,7 +996,7 @@ static int test_mdev_1dwq(struct accfg_ctx *ctx)if (rc)return rc; - rc =device_test_reset (ctx,"dsa0" ); + rc =device_test_reset (ctx,"dsa0" , false);if (rc)return rc;
@@ -1037,6 +1059,9 @@ static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module **mod, } rc =kmod_module_get_initstate (*mod); +if (rc == -ENOENT ) + rc =kmod_module_probe_insert_module (*mod,0 ,NULL ,NULL ,NULL , +NULL );return rc; }
@@ -1098,6 +1123,8 @@ int test_libaccfg(int loglevel, struct accfg_test *test,if (i >=ARRAY_SIZE (test_cases)) result =EXIT_SUCCESS ; +else +test_cleanup (ctx);kmod_module_remove_module (mod,0 );kmod_module_probe_insert_module (mod,0 ,NULL ,NULL ,NULL ,NULL );
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 13/14 accel-config: Support new driver changes in kernel ver 5.10
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
New driver ver 1.0 in kernl 5.10 has changed the format of mdev type name. Add changes in library to read the new type names while scanning for and creation of mdevs.
--- accfg/lib/libaccfg.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
accfg/lib/libaccfg.c +7 -12
@@ -416,18 +416,10 @@ static int device_parse_type(struct accfg_device *device)static int mdev_str_to_type (char *mdev_type_str) {char **b; -char *s; -int l, i; - - s =strchr (mdev_type_str,'-' ); -if (!s) - s = mdev_type_str; -else - s++; - l = (int ) (strchrnul (s,'-' ) - s); +int i;for (b = accfg_mdev_basenames, i =0 ; *b !=NULL ; b++, i++) -if (!strncmp (*b, s, l)) +if (strstr (mdev_type_str, *b))return i;return ACCFG_MDEV_TYPE_UNKNOWN ;
@@ -1002,6 +994,7 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,struct accfg_device_mdev *mdev;char uuid_str[UUID_STR_LEN ];char mdev_path[PATH_MAX ]; +unsigned int version;int rc;if (type >=ACCFG_MDEV_TYPE_UNKNOWN || type <0 )
@@ -1016,8 +1009,10 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device, mdev->type = type;uuid_unparse (mdev->uuid, uuid_str); -sprintf (mdev_path,"%s/%s/idxd-%s/create" , device->mdev_path, -MDEV_POSTFIX , accfg_mdev_basenames[type]); + version = device->version >>8 ; +sprintf (mdev_path,"%s/%s/idxd-%s-%s-v%d/create" , device->mdev_path, +MDEV_POSTFIX , device->device_type_str, + accfg_mdev_basenames[type], version); rc =sysfs_write_attr (ctx, mdev_path, uuid_str);if (rc <0 ) {err (ctx,"create mdev failed %d\n" , rc);
Signature · 1 line
2.26.2
ramesh.thomas at intel.com
PATCH v3 14/14 accel-config: Remove unloading of driver at end
In reply to ramesh.thomas at intel.comFrom: Ramesh Thomas <ramesh.thomas(a)intel.com>
New idxd driver in kernel ver 5.10 cannot be unloaded without unloading idxd_mdev driver. idxd_mdev drivers gets loaded and need not be unloaded after the test. Remove unloading and reloding of idxd to avoid error message during idxd driver unload failure.
--- test/libaccfg.c | 2 -- 1 file changed, 2 deletions(-)
test/libaccfg.c +0 -2
@@ -1126,8 +1126,6 @@ int test_libaccfg(int loglevel, struct accfg_test *test,else test_cleanup (ctx); -kmod_module_remove_module (mod,0 ); -kmod_module_probe_insert_module (mod,0 ,NULL ,NULL ,NULL ,NULL );kmod_unref (kmod_ctx);return result;
Signature · 1 line
2.26.2
Thomas
Please disregard v3 patchset. I will send a new patchset adding support for new changes in kernel ver 5.10 idxd and idxd_mdev drivers.
Quoted 62 lines · ramesh.thomas(a)intel.com
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Implements vfio mdev support for wqs. This implementation uses wqs internally and user does not need to attach wqs. Mdevs are stored and listed in the context of devices.
Initially 2 types of mdevs, 1dwq and 1swq are supported. 1swq uses shared wq type while 1dwq uses dedicaed wq.
Implements both library and command interfaces.
Added improvements in test case management and clears up stale state after test failures.
Added support for "locked" wq state.
Added unit tests and man pages.
Added support for new kernel ver 5.10 driver changes.
Ramesh Thomas (14):
accel-config: Add mdev path to device context
accel-config: Create mdev structures and load mdevs into device
context
accel-config: Add lib functions to list mdevs and retrieve mdev
properties
accel-config: Add mdev json support
accel-config: Implement create and remove mdev library API
accel-config: Add mdev create and remove commands
accel-config: Improve management of test cases
accel-config: Unit tests for mdev support
accel-config: Add wq locked state support
accel-config: Add documentation for wq options
accel-config: Add documentation for mdev commands
accel-config: Clear conditions blocking unit test after failure
accel-config: Support new driver changes in kernel ver 5.10
accel-config: Remove unloading of driver at end.../accfg/accel-config-config-wq.txt | 15 + .../accfg/accel-config-create-mdev.txt | 32 +- .../accfg/accel-config-remove-mdev.txt | 26 +- accfg/config.c | 5 +- accfg/enable.c | 4 +- accfg/lib/libaccel-config.sym | 11 + accfg/lib/libaccfg.c | 223 +++++++++++++- accfg/lib/private.h | 9 + accfg/libaccel_config.h | 28 +- accfg/mdev.c | 123 +++++++- test/libaccfg.c | 279 +++++++++++++++--- util/json.c | 44 ++- 12 files changed, 733 insertions(+), 66 deletions(-)Signature · 7 lines
v2: Split documentation batch into wq-config and mdev create/remove v3: Add support for new driver changes in kernel ver 5.10 2.26.2