From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8460683234462125143==" MIME-Version: 1.0 From: Jiang, Dave Subject: [Accel-config] Re: [PATCH v1] accel-config: Remove uuid type mdev support Date: Tue, 17 Nov 2020 15:34:04 +0000 Message-ID: <902ea9348f78418fb3ffcce3b652e3d1@intel.com> In-Reply-To: 20201117022313.165407-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============8460683234462125143== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: ramesh.thomas(a)intel.com > Sent: Monday, November 16, 2020 7:23 PM > To: accel-config(a)lists.01.org > Cc: Thomas, Ramesh ; Luck, Tony > ; Jiang, Dave > Subject: [PATCH v1] accel-config: Remove uuid type mdev support > = > From: Ramesh Thomas > = > mdev implementation will be redesigned to support new mdev types added > by driver. Current implementation of wq based uuid type mdev > implementation is obsolete for now and is removed here. > = > Signed-off-by: Ramesh Thomas Reviewed-by: Dave Jiang > --- > accfg/lib/libaccel-config.sym | 5 - > accfg/lib/libaccfg.c | 322 +--------------------------------- > accfg/lib/private.h | 8 - > accfg/libaccel_config.h | 13 +- > accfg/mdev.c | 160 ----------------- > test/README.md | 39 ---- > test/libaccfg.c | 192 +------------------- > util/json.c | 23 +-- > 8 files changed, 8 insertions(+), 754 deletions(-) > = > diff --git a/accfg/lib/libaccel-config.sym b/accfg/lib/libaccel-config.sy= m index > 9768d42..471e06a 100644 > --- a/accfg/lib/libaccel-config.sym > +++ b/accfg/lib/libaccel-config.sym > @@ -59,8 +59,6 @@ LIBACCFG_1 { > accfg_device_wq_get_by_id; > accfg_wq_get_first; > accfg_wq_get_next; > - accfg_wq_first_uuid; > - accfg_wq_next_uuid; > accfg_wq_get_ctx; > accfg_wq_get_device; > accfg_wq_get_group; > @@ -76,7 +74,6 @@ LIBACCFG_1 { > accfg_wq_get_cdev_minor; > accfg_wq_get_type; > accfg_wq_get_threshold; > - accfg_wq_get_uuid; > accfg_wq_set_size; > accfg_wq_set_priority; > accfg_wq_set_group_id; > @@ -89,8 +86,6 @@ LIBACCFG_1 { > accfg_wq_disable; > accfg_wq_priority_boundary; > accfg_wq_size_boundary; > - accfg_wq_create_mdev; > - accfg_wq_remove_mdev; > accfg_engine_get_first; > accfg_engine_get_next; > accfg_engine_get_ctx; > diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index d55a246..7= 0553f7 > 100644 > --- a/accfg/lib/libaccfg.c > +++ b/accfg/lib/libaccfg.c > @@ -513,8 +513,6 @@ static int wq_parse_type(struct accfg_wq *wq, char > *wq_type) > wq->type =3D ACCFG_WQT_KERNEL; > else if (strcmp(ptype, "user") =3D=3D 0) > wq->type =3D ACCFG_WQT_USER; > - else if (strcmp(ptype, "mdev") =3D=3D 0) > - wq->type =3D ACCFG_WQT_MDEV; > else > wq->type =3D ACCFG_WQT_NONE; > = > @@ -523,52 +521,6 @@ static int wq_parse_type(struct accfg_wq *wq, char > *wq_type) > return 0; > } > = > -static int uuid_entry_add(struct accfg_ctx *ctx, struct accfg_wq *wq, int > dfd) -{ > - struct accfg_wq_uuid *wq_uuid; > - char *read_uuid =3D NULL; > - FILE *uuid_fd; > - ssize_t nread; > - size_t len =3D 0; > - int fd; > - > - /* pull uuid entry and add the uuid in sysfs */ > - fd =3D openat(dfd, "uuid", O_RDONLY); > - if (fd =3D=3D -1) > - return -errno; > - > - uuid_fd =3D fdopen(fd, "r"); > - if (!uuid_fd) { > - err(ctx, "fopen of uuid path for wq failed: %s\n", > - strerror(errno)); > - close(fd); > - return -errno; > - } > - > - while ((nread =3D getline(&read_uuid, > - &len, uuid_fd) !=3D -1)) { > - /* add '\0' to terminate the read_uuid */ > - read_uuid[UUID_STR_LEN - 1] =3D '\0'; > - wq_uuid =3D calloc(1, sizeof(struct accfg_wq_uuid)); > - if (!wq_uuid) { > - err(ctx, "allocation of wq_uuid failed\n"); > - close(fd); > - return -ENOMEM; > - } > - > - if (uuid_parse(read_uuid, wq_uuid->uuid) !=3D 0) { > - err(ctx, "uuid_parse failed: %s\n", > - strerror(errno)); > - close(fd); > - free(wq_uuid); > - return -ENOMEM; > - } > - list_add_tail(&wq->uuid_list, &wq_uuid->list); > - } > - > - return 0; > -} > - > static void *add_wq(void *parent, int id, const char *wq_base, > char *dev_prefix) > { > @@ -579,7 +531,7 @@ static void *add_wq(void *parent, int id, const char > *wq_base, > char *path; > char *wq_base_string; > unsigned long device_id, wq_id; > - int dfd, ret =3D 0; > + int dfd; > char *wq_type; > = > if (!device) > @@ -605,7 +557,6 @@ static void *add_wq(void *parent, int id, const char > *wq_base, > return NULL; > } > = > - list_head_init(&wq->uuid_list); > wq_base_string =3D strdup(wq_base); > if (!wq_base_string) { > err(ctx, "conversion of wq_base_string failed\n"); @@ - > 639,13 +590,6 @@ static void *add_wq(void *parent, int id, const char > *wq_base, > wq_parse_type(wq, wq_type); > free(wq_type); > = > - /* parse uuid only in mdeve wq type */ > - if (wq->type =3D=3D ACCFG_WQT_MDEV) { > - ret =3D uuid_entry_add(ctx, wq, dfd); > - if (ret < 0) > - goto err_wq; > - } > - > close(dfd); > wq->wq_path =3D strdup(wq_base); > if (!wq->wq_path) { > @@ -1944,10 +1888,6 @@ ACCFG_EXPORT int accfg_wq_set_str_##field( \ > return -errno; \ > } \ > } \ > - if (!strcmp(#field, "mode") && !list_empty(&wq->uuid_list)) { \ > - err(ctx, "change wq mode in mdev is not allowed\n"); \ > - return -errno; \ > - } \ > if (sysfs_write_attr(ctx, path, buf) < 0) { \ > err(ctx, "%s: write failed: %s\n", \ > accfg_wq_get_devname(wq), \ > @@ -2025,266 +1965,6 @@ ACCFG_EXPORT int accfg_wq_set_mode(struct > accfg_wq *wq, > return accfg_wq_set_str_mode(wq, > accfg_wq_mode_str[wq_mode]); } > = > -static char *accfg_wq_get_pcie_path(struct accfg_wq *wq) -{ > - char *buf, *dup_string; > - struct accfg_device *dev =3D accfg_wq_get_device(wq); > - struct accfg_ctx *ctx =3D accfg_wq_get_ctx(wq); > - > - dup_string =3D strdup(dev->device_path); > - if (!dup_string) { > - err(ctx, "duplicating device path failed\n"); > - return NULL; > - } > - > - buf =3D basename(dirname(dup_string)); > - buf =3D strdup(buf); > - if (!buf) { > - err(ctx, "duplicate basename failed\n"); > - return NULL; > - } > - > - free(dup_string); > - > - return buf; > -} > - > -ACCFG_EXPORT uuid_t *accfg_wq_first_uuid(struct accfg_wq *wq) -{ > - struct accfg_wq_uuid *wq_uuid; > - > - wq_uuid =3D list_top(&wq->uuid_list, struct accfg_wq_uuid, list); > - wq->iter =3D wq_uuid; > - > - return (uuid_t *)wq_uuid->uuid; > -} > - > -ACCFG_EXPORT uuid_t *accfg_wq_next_uuid(struct accfg_wq *wq) -{ > - struct accfg_wq_uuid *wq_uuid; > - > - if (!wq->iter) > - return NULL; > - wq_uuid =3D list_next(&wq->uuid_list, wq->iter, list); > - if (!wq_uuid) > - return NULL; > - wq->iter =3D wq_uuid; > - > - return (uuid_t *)wq_uuid->uuid; > -} > - > -ACCFG_EXPORT int accfg_wq_create_mdev(struct accfg_wq *wq, uuid_t > uuid) -{ > - char *pcie_path; > - char *mdev_create_path; > - char *wq_uuid_path; > - struct accfg_ctx *ctx =3D accfg_wq_get_ctx(wq); > - struct accfg_wq_uuid *wq_uuid, *entry, *next; > - char uuid_string[UUID_STR_LEN]; > - int rc =3D 0; > - > - uuid_clear(uuid); > - wq_uuid =3D calloc(1, sizeof(struct accfg_wq_uuid)); > - if (!wq_uuid) { > - err(ctx, "allocation of wq_uuid failed\n"); > - return -ENOMEM; > - } > - > - /* generate uuid */ > - uuid_generate(wq_uuid->uuid); > - > - /* extract pcie path name by parsing symbolic link */ > - pcie_path =3D accfg_wq_get_pcie_path(wq); > - if (!pcie_path) { > - err(ctx, "getting pcie path failed\n"); > - free(wq_uuid); > - return -ENOMEM; > - } > - > - /* create mdev via sysfs using uuid */ > - mdev_create_path =3D malloc(PATH_MAX); > - if (!mdev_create_path) { > - err(ctx, "malloc of mdev_create_path failed\n"); > - rc =3D -ENOMEM; > - goto create_err; > - } > - > - wq_uuid_path =3D malloc(PATH_MAX); > - if (!wq_uuid_path) { > - err(ctx, "malloc of wq_uuid_path failed\n"); > - rc =3D -ENOMEM; > - goto wq_err; > - } > - > - /* convert uuid into string format */ > - uuid_unparse(wq_uuid->uuid, uuid_string); > - > - list_for_each_safe(&wq->uuid_list, entry, next, list) { > - if (uuid_compare(wq_uuid->uuid, entry->uuid) =3D=3D 0) { > - err(ctx, "uuid %s already exists for wq %s\n", > - uuid_string, > - accfg_wq_get_devname(wq)); > - rc =3D -EINVAL; > - goto out_err; > - } > - } > - > - /* add uuid onto linked list if it does not exist */ > - list_add_tail(&wq->uuid_list, &wq_uuid->list); > - > - /* write uuid to wq/uuid */ > - if (sprintf(wq_uuid_path, "%s/%s", wq->wq_path, "uuid") < 0) { > - err(ctx, "create wq_uuid_path failed with %s\n", > - strerror(errno)); > - rc =3D -errno; > - goto out_err; > - } > - > - rc =3D sysfs_write_attr(ctx, wq_uuid_path, uuid_string); > - if (rc < 0) { > - err(ctx, "write uuid into wq/uuid failed: %d\n", rc); > - goto out_err; > - } > - > - /* create mdev via sysfs using uuid */ > - if (sprintf(mdev_create_path, "%s/%s/%s/idxd-wq/create", > MDEV_BUS, pcie_path, > - MDEV_POSTFIX) < 0) { > - err(ctx, "create mdev_create_path failed with %s\n", > - strerror(errno)); > - rc =3D -errno; > - goto out_err; > - } > - > - rc =3D sysfs_write_attr(ctx, mdev_create_path, uuid_string); > - if (rc < 0) { > - err(ctx, "create mdev failed %d\n", rc); > - goto out_err; > - } > - > - uuid_copy(uuid, wq_uuid->uuid); > - free(wq_uuid_path); > - free(pcie_path); > - free(mdev_create_path); > - return 0; > - out_err: > - free(wq_uuid_path); > - wq_err: > - free(mdev_create_path); > - create_err: > - free(pcie_path); > - > - free(wq_uuid); > - return rc; > -} > - > -static int accfg_wq_uuid_remove(struct accfg_wq *wq, uuid_t uuid) -{ > - struct accfg_ctx *ctx =3D accfg_wq_get_ctx(wq); > - char *wq_uuid_path; > - char *mdev_remove_path; > - char uuid_str[UUID_STR_LEN]; > - int rc =3D 0; > - > - uuid_unparse(uuid, uuid_str); > - > - /* write 1 into /remove to remove it */ > - mdev_remove_path =3D malloc(PATH_MAX); > - if (!mdev_remove_path) { > - err(ctx, "malloc of mdev_remove_path failed\n"); > - return -ENOMEM; > - } > - > - if (sprintf(mdev_remove_path, "%s/%s/%s", > - MDEV_PREFIX, uuid_str, "remove") < 0) { > - err(ctx, "mdev_remove_path creation failed with %s\n", > - strerror(errno)); > - free(mdev_remove_path); > - rc =3D -errno; > - goto err_remove_path; > - } > - > - rc =3D sysfs_write_attr(ctx, mdev_remove_path, "1"); > - if (rc < 0) { > - err(ctx, "remove mdev when write 1 failed with %d\n", rc); > - goto err_remove_path; > - } > - > - /* write same uuid into sysfs to remove it */ > - wq_uuid_path =3D malloc(PATH_MAX); > - if (!wq_uuid_path) { > - err(ctx, "malloc of wq_uuid_path failed\n"); > - rc =3D -ENOMEM; > - goto err_remove_path; > - } > - > - /* write uuid to wq/uuid */ > - if (sprintf(wq_uuid_path, "%s/%s", wq->wq_path, "uuid") < 0) { > - err(ctx, "remove wq_uuid_path failed with %s\n", > - strerror(errno)); > - rc =3D -errno; > - goto err_uuid_path; > - } > - > - rc =3D sysfs_write_attr(ctx, wq_uuid_path, uuid_str); > - if (rc < 0) { > - err(ctx, "write uuid into wq/uuid failed with %d\n", rc); > - goto err_uuid_path; > - } > - > - err_uuid_path: > - free(wq_uuid_path); > - err_remove_path: > - free(mdev_remove_path); > - > - return rc; > -} > - > -ACCFG_EXPORT int accfg_wq_remove_mdev(struct accfg_wq *wq, uuid_t > uuid) -{ > - struct accfg_wq_uuid *entry, *next; > - struct accfg_ctx *ctx =3D accfg_wq_get_ctx(wq); > - uuid_t uuid_zero; > - int rc; > - > - /* generate null uuid */ > - uuid_generate(uuid_zero); > - uuid_clear(uuid_zero); > - > - /* If user writes null, erase entire list. */ > - if (uuid_compare(uuid, uuid_zero) =3D=3D 0) { > - list_for_each_safe(&wq->uuid_list, entry, next, list) { > - rc =3D accfg_wq_uuid_remove(wq, entry->uuid); > - if (rc !=3D 0) { > - err(ctx, "remove uuid failed: %d\n", rc); > - return rc; > - } > - > - list_del(&entry->list); > - free(entry); > - wq->uuids--; > - } > - return 0; > - } > - > - /* If uuid already exists, remove the old uuid. */ > - list_for_each_safe(&wq->uuid_list, entry, next, list) { > - if (uuid_compare(uuid, entry->uuid) =3D=3D 0) { > - list_del(&entry->list); > - wq->uuids--; > - rc =3D accfg_wq_uuid_remove(wq, entry->uuid); > - free(entry); > - if (rc !=3D 0) { > - err(ctx, "remove uuid failed: %d\n", rc); > - return rc; > - } > - return 0; > - } > - } > - > - err(ctx, "could not find matched uuid\n"); > - return -EINVAL; > -} > - > ACCFG_EXPORT struct accfg_engine *accfg_engine_get_first( > struct accfg_device *device) > { > diff --git a/accfg/lib/private.h b/accfg/lib/private.h index 399c601..f38= ff23 > 100644 > --- a/accfg/lib/private.h > +++ b/accfg/lib/private.h > @@ -97,8 +97,6 @@ struct accfg_wq { > struct accfg_device *device; > struct accfg_group *group; > struct list_node list; > - struct list_head uuid_list; > - struct accfg_wq_uuid *iter; > char *wq_path; > char *wq_buf; > int id, buf_len; > @@ -111,7 +109,6 @@ struct accfg_wq { > int priority; > int block_on_fault; > int cdev_minor; > - int uuids; > unsigned int threshold; > char *mode; > char *name; > @@ -121,11 +118,6 @@ struct accfg_wq { > unsigned long max_transfer_size; > }; > = > -struct accfg_wq_uuid { > - uuid_t uuid; > - struct list_node list; > -}; > - > #define ACCFG_EXPORT __attribute__ ((visibility("default"))) > = > /** > diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h index > 706b371..392188e 100644 > --- a/accfg/libaccel_config.h > +++ b/accfg/libaccel_config.h > @@ -56,8 +56,7 @@ enum accfg_wq_state { > enum accfg_wq_type { > ACCFG_WQT_NONE =3D 0, > ACCFG_WQT_KERNEL, > - ACCFG_WQT_USER, > - ACCFG_WQT_MDEV, > + ACCFG_WQT_USER > }; > = > enum accfg_control_flag { > @@ -98,7 +97,6 @@ struct wq_parameters { > const char *mode; > const char *type; > const char *name; > - const char *uuid_str; > }; > = > struct engine_parameters { > @@ -210,8 +208,6 @@ int accfg_group_set_traffic_class_b(struct > accfg_group *group, int val); struct accfg_wq; struct accfg_wq > *accfg_wq_get_first(struct accfg_device *device); struct accfg_wq > *accfg_wq_get_next(struct accfg_wq *wq); -uuid_t > *accfg_wq_first_uuid(struct accfg_wq *wq); -uuid_t > *accfg_wq_next_uuid(struct accfg_wq *wq); > = > = > #define accfg_wq_foreach(device, wq) \ > @@ -219,11 +215,6 @@ uuid_t *accfg_wq_next_uuid(struct accfg_wq *wq); > wq !=3D NULL; \ > wq =3D accfg_wq_get_next(wq)) > = > -#define accfg_wq_uuid_foreach(wq, uuid) \ > - for (uuid =3D accfg_wq_first_uuid(wq); \ > - uuid !=3D NULL; \ > - uuid =3D accfg_wq_next_uuid(wq)) > - > struct accfg_ctx *accfg_wq_get_ctx(struct accfg_wq *wq); struct > accfg_device *accfg_wq_get_device(struct accfg_wq *wq); struct > accfg_group *accfg_wq_get_group(struct accfg_wq *wq); @@ -261,8 +252,6 > @@ 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); int accfg_wq_size_boundary(struct accfg_device *device, int > wq_num); -int accfg_wq_create_mdev(struct accfg_wq *wq, uuid_t uuid); - > int accfg_wq_remove_mdev(struct accfg_wq *wq, uuid_t uuid); > = > /* libaccfg function for engine */ > struct accfg_engine; > diff --git a/accfg/mdev.c b/accfg/mdev.c index 0744a46..56c5c68 100644 > --- a/accfg/mdev.c > +++ b/accfg/mdev.c > @@ -21,172 +21,12 @@ > #include > #include > = > -static struct wq_parameters wq_param; > - > int cmd_create_mdev(int argc, const char **argv, void *ctx) { > - int i =3D 0; > - unsigned int dev_id =3D 0, wq_id =3D 0; > - const char *const u[] =3D { > - "accfg create-mdev ", > - NULL > - }; > - uuid_t uuid; > - char uuid_str[UUID_STR_LEN]; > - > - argc =3D parse_options(argc, argv, NULL, u, 0); > - > - if (argc =3D=3D 0) > - fprintf(stderr, "specify a wq name to create mdev\n"); > - > - for (i =3D 0; i < argc; i++) { > - struct accfg_device *device; > - struct accfg_wq *wq; > - char dev_name[MAX_DEV_LEN], > wq_name[MAX_DEV_LEN]; > - enum accfg_wq_state wq_state; > - int rc =3D 0; > - > - /* walk through wq */ > - if (strstr(argv[i], "wq") !=3D NULL) { > - if (sscanf(argv[i], "%[^/]/wq%u.%u", > - dev_name, &dev_id, &wq_id) !=3D 3) { > - fprintf(stderr, "'%s' is not a valid wq name\n", > - argv[i]); > - return -EINVAL; > - } > - } > - > - if (!accfg_device_type_validate(dev_name)) > - return -EINVAL; > - > - rc =3D sprintf(wq_name, "wq%u.%u", dev_id, wq_id); > - if (rc < 0) > - return rc; > - > - accfg_device_foreach(ctx, device) { > - if (!util_device_filter(device, dev_name)) > - continue; > - > - accfg_wq_foreach(device, wq) { > - if (!util_wq_filter(wq, wq_name)) > - continue; > - > - wq_state =3D accfg_wq_get_state(wq); > - if (wq_state =3D=3D ACCFG_WQ_DISABLED > - || wq_state =3D=3D > ACCFG_WQ_QUIESCING) { > - fprintf(stderr, > - "wq in wrong mode: %d\n", > - wq_state); > - return -ENXIO; > - } > - > - rc =3D accfg_wq_create_mdev(wq, uuid); > - if (rc !=3D 0) > - return rc; > - uuid_unparse(uuid, uuid_str); > - printf("%s attached to %s\n", > - uuid_str, > - > accfg_wq_get_devname(wq)); > - } > - } > - } > - > return 0; > } > = > int cmd_remove_mdev(int argc, const char **argv, void *ctx) { > - int i =3D 0; > - unsigned int dev_id =3D 0, wq_id =3D 0; > - > - const struct option options[] =3D { > - OPT_STRING('u', "uuid", &wq_param.uuid_str, "uuid", > - "specify uuid to be removed"), > - OPT_END(), > - }; > - > - const char *const u[] =3D { > - "accfg remove-mdev / [] > to remove single uuid", > - "accfg remove-mdev / to removel > all uuid for this wq", > - NULL > - }; > - > - argc =3D parse_options(argc, argv, options, u, 0); > - > - if (argc =3D=3D 0) > - fprintf(stderr, "specify a wq name to clear uuid\n"); > - else { > - for (i =3D 0; i < argc; i++) { > - if (strcmp(argv[i], "all") =3D=3D 0) { > - argv[0] =3D "all"; > - argc =3D 1; > - break; > - } > - } > - } > - > - for (i =3D 0; i < argc; i++) { > - struct accfg_device *device; > - struct accfg_wq *wq; > - char dev_name[MAX_DEV_LEN], > wq_name[MAX_DEV_LEN]; > - uuid_t uuid, uuid_zero; > - enum accfg_wq_state wq_state; > - int rc =3D 0; > - > - /* walk through wq */ > - if (strstr(argv[i], "wq") !=3D NULL) { > - if (sscanf(argv[i], "%[^/]/wq%u.%u", > - dev_name, &dev_id, &wq_id) !=3D 3) { > - fprintf(stderr, > - "'%s' is not a valid wq name\n", > - argv[i]); > - return -EINVAL; > - } > - } > - > - if (!accfg_device_type_validate(dev_name)) > - return -EINVAL; > - > - rc =3D sprintf(wq_name, "wq%u.%u", dev_id, wq_id); > - if (rc < 0) > - return rc; > - > - accfg_device_foreach(ctx, device) { > - if (!util_device_filter(device, dev_name)) > - continue; > - > - accfg_wq_foreach(device, wq) { > - if (!util_wq_filter(wq, wq_name)) > - continue; > - > - wq_state =3D accfg_wq_get_state(wq); > - if (wq_state =3D=3D ACCFG_WQ_DISABLED > - || wq_state =3D=3D > ACCFG_WQ_QUIESCING) { > - fprintf(stderr, > - "wq in wrong mode: %d\n", > - wq_state); > - return -ENXIO; > - } > - > - if (wq_param.uuid_str) { > - uuid_parse(wq_param.uuid_str, > - uuid); > - rc =3D accfg_wq_remove_mdev(wq, > - uuid); > - if (rc !=3D 0) > - return rc; > - } else { > - /* generate null uuid */ > - uuid_generate(uuid_zero); > - uuid_clear(uuid_zero); > - rc =3D accfg_wq_remove_mdev(wq, > - uuid_zero); > - if (rc !=3D 0) > - return rc; > - } > - } > - } > - } > - > return 0; > } > diff --git a/test/README.md b/test/README.md index c5b783b..6e88098 > 100644 > --- a/test/README.md > +++ b/test/README.md > @@ -63,45 +63,6 @@ configure wq1.2 > configure wq1.3 > configure wq1.4 > test 1: set large wq to exceed max total size in dsa passed successfully= -wq > not enabled -uuid 7a0dca6f-02fe-4cd3-a7ee-9a767883dc08 successfully > attached to wq0.2 -uuid d6a87782-8736-4166-aba3-c6580269f186 successfully > attached to wq0.2 -uuid 4d0758a3-7ff1-42ec-9979-ba046a1f5722 successfully > attached to wq0.2 -uuid c0aa9cd2-3d9d-4cf9-a085-f5bb0f1e9fe0 successfully > attached to wq0.2 -uuid 57a5e7a6-cd7d-4fdb-b764-dc0b5fceb047 successfully > attached to wq0.2 -successfully removed the saved uuid c0aa9cd2-3d9d-4cf9- > a085-f5bb0f1e9fe0 in wq -successfully removed the rest uuid in shared wq > -wq0.0 is disabled already > -wq0.1 is disabled already > -wq0.3 is disabled already > -wq0.4 is disabled already > -wq0.5 is disabled already > -wq0.6 is disabled already > -wq0.7 is disabled already > -test 2: test the create-mdev and remove-mdev on shared wq passed > successfully -configure device 0 -configure group0.0 -configure wq0.0 - > configure engine0.0 -configure engine0.1 -configure group0.1 -configure > wq0.1 -configure wq0.2 -configure wq0.3 -configure engine0.2 -configure > engine0.3 -wq not enabled -uuid 97fc3e6a-9cb3-46d7-93e6-7b64ebb0d0dd > successfully attached to wq0.3 -successfully removed the saved uuid > 97fc3e6a-9cb3-46d7-93e6-7b64ebb0d0dd in wq > -wq0.0 is disabled already > -wq0.1 is disabled already > -wq0.2 is disabled already > -wq0.3 is disabled already > -wq0.4 is disabled already > -wq0.5 is disabled already > -wq0.6 is disabled already > -wq0.7 is disabled already > -test 3: test the create-mdev and remove-mdev on dedicated wq passed > successfully > test-libaccfg: PASS > SUCCESS! > ``` > diff --git a/test/libaccfg.c b/test/libaccfg.c index 5f4cb31..aef877a 100= 644 > --- a/test/libaccfg.c > +++ b/test/libaccfg.c > @@ -109,7 +109,7 @@ static struct wq_parameters wq02_param =3D { > .max_batch_size =3D (1 << 8), > .max_transfer_size =3D (1l << 30), > .mode =3D "shared", > - .type =3D "mdev", > + .type =3D "user", > .name =3D "guest1" > }; > = > @@ -121,7 +121,7 @@ static struct wq_parameters wq03_param =3D { > .max_batch_size =3D (1 << 9), > .max_transfer_size =3D (1l << 31), > .mode =3D "dedicated", > - .type =3D "mdev", > + .type =3D "user", > .name =3D "guest2" > = > }; > @@ -765,123 +765,6 @@ static int wq_bounds_test(struct accfg_ctx *ctx, > const char *dev_name) > return 0; > } > = > -static int test_enable_wq(struct accfg_device *device, struct accfg_wq > *wq) -{ > - int rc =3D 0; > - enum accfg_wq_state wq_state; > - const char *wq_name; > - > - if (!accfg_device_is_active(device)) { > - rc =3D accfg_device_enable(device); > - if (rc < 0) { > - fprintf(stderr, "device_enable failed\n"); > - return rc; > - } > - } > - > - wq_state =3D accfg_wq_get_state(wq); > - wq_name =3D accfg_wq_get_devname(wq); > - > - if (wq_state =3D=3D ACCFG_WQ_ENABLED) { > - fprintf(stderr, "wq %s is already enabled\n", wq_name); > - return rc; > - } > - > - rc =3D accfg_wq_enable(wq); > - if (rc < 0) { > - fprintf(stderr, "wq_enable of %s failed", wq_name); > - return rc; > - } > - > - return 0; > -} > - > -static int mdev_test(struct accfg_ctx *ctx, struct accfg_device *device, > - struct accfg_wq *wq) > -{ > - enum accfg_wq_mode wq_mode; > - int rc, i =3D 0, iterations =3D 1; > - uuid_t uuid, uuid_zero, saved_uuid; > - char uuid_str[UUID_STR_LEN]; > - > - wq_mode =3D accfg_wq_get_mode(wq); > - if (wq_mode !=3D ACCFG_WQ_SHARED && wq_mode !=3D > ACCFG_WQ_DEDICATED) > - return -ENXIO; > - > - if (wq_mode =3D=3D ACCFG_WQ_SHARED) > - iterations =3D 5; > - > - /* For shared wq, we can create multiple uuid */ > - for (i =3D 0; i < iterations; i++) { > - rc =3D accfg_wq_create_mdev(wq, uuid); > - if (rc !=3D 0) > - return rc; > - > - if (i =3D=3D 3 || wq_mode =3D=3D ACCFG_WQ_DEDICATED) > - uuid_copy(saved_uuid, uuid); > - > - uuid_unparse(uuid, uuid_str); > - printf("uuid %s successfully attached to %s\n", uuid_str, > - accfg_wq_get_devname(wq)); > - } > - > - /* Remove the saved uuid first */ > - rc =3D accfg_wq_remove_mdev(wq, saved_uuid); > - if (rc !=3D 0) > - return rc; > - > - uuid_unparse(saved_uuid, uuid_str); > - printf("successfully removed the saved uuid %s in wq\n", uuid_str); > - > - /* Remove all rest of the uuid */ > - if (wq_mode =3D=3D ACCFG_WQ_SHARED) { > - uuid_clear(uuid_zero); > - rc =3D accfg_wq_remove_mdev(wq, uuid_zero); > - if (rc !=3D 0) > - return rc; > - printf("successfully removed the rest uuid in shared wq\n"); > - } > - > - return 0; > -} > - > -static int dsa_mdev_test(struct accfg_ctx *ctx, const char *wq_name, > - const char *dev_name) > -{ > - int rc; > - struct accfg_device *device; > - struct accfg_wq *wq; > - enum accfg_wq_state wq_state; > - > - accfg_device_foreach(ctx, device) { > - if (strcmp(accfg_device_get_devname(device), dev_name)) > - continue; > - > - if (!accfg_device_type_validate(dev_name)) > - return -EINVAL; > - > - accfg_wq_foreach(device, wq) { > - if (strcmp(accfg_wq_get_devname(wq), wq_name)) > - continue; > - > - wq_state =3D accfg_wq_get_state(wq); > - if (wq_state =3D=3D ACCFG_WQ_DISABLED > - || wq_state =3D=3D > ACCFG_WQ_QUIESCING) > - fprintf(stderr, "wq not enabled\n"); > - > - rc =3D test_enable_wq(device, wq); > - if (rc !=3D 0) > - return rc; > - > - rc =3D mdev_test(ctx, device, wq); > - if (rc < 0) > - return rc; > - } > - } > - > - return 0; > -} > - > /* test the set and get libaccfg functions for all components in dsa0 */= static > int do_test0(struct accfg_ctx *ctx) { @@ -935,71 +818,8 @@ static int > do_test1(struct accfg_ctx *ctx) > return 0; > } > = > -/* test the create-mdev and remove-mdev on shared wq */ -static int > do_test2(struct accfg_ctx *ctx) -{ > - int rc =3D 0; > - > - rc =3D device_test_reset(ctx, "dsa0"); > - if (rc !=3D 0) > - return rc; > - > - rc =3D config_device(ctx, 0, device0_param, "dsa0"); > - if (rc !=3D 0) { > - fprintf(stderr, "config device dsa0 failed\n"); > - return rc; > - } > - > - rc =3D config_wq(ctx, 0, 2, wq02_param, "dsa0"); > - if (rc !=3D 0) { > - fprintf(stderr, "config wq wq0.2 failed\n"); > - return rc; > - } > - > - rc =3D dsa_mdev_test(ctx, "wq0.2", "dsa0"); > - if (rc !=3D 0) { > - fprintf(stderr, "test 2: test the create-mdev and remove- > mdev on shared wq failed\n"); > - return rc; > - } > - > - rc =3D device_test_reset(ctx, "dsa0"); > - if (rc !=3D 0) > - return rc; > - > - fprintf(stderr, "test 2: test the create-mdev and remove-mdev on > shared wq passed successfully\n"); > - return 0; > -} > - > -/* test the create-mdev and remove-mdev on dedicated wq */ -static int > do_test3(struct accfg_ctx *ctx) -{ > - int rc =3D 0; > - > - rc =3D device_test_reset(ctx, "dsa0"); > - if (rc !=3D 0) > - return rc; > - > - /* set configuration of each attribute */ > - rc =3D set_config(ctx, "dsa0"); > - if (rc !=3D 0) > - return rc; > - > - rc =3D dsa_mdev_test(ctx, "wq0.3", "dsa0"); > - if (rc !=3D 0) { > - fprintf(stderr, "test 3: test the create-mdev and remove- > mdev on dedicated wq failed\n"); > - return rc; > - } > - > - rc =3D device_test_reset(ctx, "dsa0"); > - if (rc !=3D 0) > - return rc; > - > - fprintf(stderr, "test 3: test the create-mdev and remove-mdev on > dedicated wq passed successfully\n"); > - return 0; > -} > - > /* test the boundary conditions for wq max_batch_size and > max_transfer_size */ -static int do_test4(struct accfg_ctx *ctx) > +static int do_test2(struct accfg_ctx *ctx) > { > int rc =3D 0; > = > @@ -1009,7 +829,7 @@ static int do_test4(struct accfg_ctx *ctx) > = > rc =3D wq_bounds_test(ctx, "dsa0"); > if (rc !=3D 0) { > - fprintf(stderr, "test 4: wq boundary conditions test > failed\n"); > + fprintf(stderr, "test 2: wq boundary conditions test > failed\n"); > return rc; > } > = > @@ -1017,7 +837,7 @@ static int do_test4(struct accfg_ctx *ctx) > if (rc !=3D 0) > return rc; > = > - fprintf(stderr, "test 4: wq boundary conditions test passed > successfully\n"); > + fprintf(stderr, "test 2: wq boundary conditions test passed > +successfully\n"); > return 0; > } > = > @@ -1025,9 +845,7 @@ typedef int (*do_test_fn)(struct accfg_ctx *ctx); > static do_test_fn do_test[] =3D { > do_test0, > do_test1, > - do_test4, > do_test2, > - do_test3 > }; > = > static int idxd_kmod_init(struct kmod_ctx **ctx, struct kmod_module > **mod, diff --git a/util/json.c b/util/json.c index c858fc3..3bf8950 1006= 44 > --- a/util/json.c > +++ b/util/json.c > @@ -20,8 +20,7 @@ > static const char *wq_type_str[] =3D { > "none", > "kernel", > - "user", > - "mdev" > + "user" > }; > = > /* adapted from mdadm::human_size_brief() */ @@ -354,9 +353,6 @@ > struct json_object *util_wq_to_json(struct accfg_wq *wq, > unsigned long size =3D ULLONG_MAX; > enum accfg_wq_mode wq_mode; > enum accfg_wq_state wq_state; > - const uuid_t *wq_uuid; > - struct json_object *json_uuid; > - char uuid_string[UUID_STR_LEN]; > int int_val; > = > if (!jaccfg) > @@ -430,7 +426,6 @@ struct json_object *util_wq_to_json(struct accfg_wq > *wq, > json_object_object_add(jaccfg, "threshold", jobj); > = > if (!(flags & UTIL_JSON_SAVE)) { > - int uuid_found =3D 0; > = > switch (wq_state) { > case ACCFG_WQ_DISABLED: > @@ -450,22 +445,6 @@ struct json_object *util_wq_to_json(struct > accfg_wq *wq, > if (jobj) > json_object_object_add(jaccfg, "state", jobj); > = > - /* UUID can't be programmed through config file */ > - jobj =3D json_object_new_array(); > - accfg_wq_uuid_foreach(wq, wq_uuid) { > - uuid_unparse(*wq_uuid, uuid_string); > - json_uuid =3D json_object_new_string(uuid_string); > - if (json_uuid) > - json_object_array_add(jobj, json_uuid); > - else > - break; > - uuid_found++; > - } > - if (uuid_found) > - json_object_object_add(jaccfg, "uuid", jobj); > - else > - json_object_put(jobj); > - > jobj =3D json_object_new_int(accfg_wq_get_clients(wq)); > if (jobj) > json_object_object_add(jaccfg, "clients", jobj); > -- > 2.26.2 --===============8460683234462125143==--