Content-Type: multipart/mixed; boundary="===============0025602294942758891==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 4/4] accel-config: Unit tests Date: Wed, 28 Oct 2020 12:54:52 -0400 Message-ID: <20201028165452.86013-5-ramesh.thomas@intel.com> In-Reply-To: 20201028165452.86013-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============0025602294942758891== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas 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 Signed-off-by: Ramesh Thomas --- test/dsa.c | 2 ++ test/dsa.h | 2 ++ test/libaccfg.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/test/dsa.c b/test/dsa.c index d0db87c..70eda30 100644 --- a/test/dsa.c +++ b/test/dsa.c @@ -177,6 +177,8 @@ int dsa_alloc(struct dsa_context *ctx, int shared) ctx->wq_size =3D accfg_wq_get_size(ctx->wq); ctx->wq_idx =3D accfg_wq_get_id(ctx->wq); ctx->bof =3D accfg_wq_get_block_on_fault(ctx->wq); + ctx->wq_max_batch_size =3D accfg_wq_get_max_batch_size(ctx->wq); + ctx->wq_max_xfer_size =3D accfg_wq_get_max_transfer_size(ctx->wq); = ctx->max_batch_size =3D accfg_device_get_max_batch_size(dev); ctx->max_xfer_size =3D accfg_device_get_max_transfer_size(dev); diff --git a/test/dsa.h b/test/dsa.h index 5f6dd7c..b99ec44 100644 --- a/test/dsa.h +++ b/test/dsa.h @@ -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 { diff --git a/test/libaccfg.c b/test/libaccfg.c index 635c023..5f4cb31 100644 --- a/test/libaccfg.c +++ b/test/libaccfg.c @@ -80,6 +80,8 @@ static struct wq_parameters wq00_param =3D { .priority =3D 10, .block_on_fault =3D 1, .threshold =3D 15, + .max_batch_size =3D 1, + .max_transfer_size =3D 1, .mode =3D "shared", .type =3D "user", .name =3D "myapp1" @@ -90,6 +92,8 @@ static struct wq_parameters wq01_param =3D { .wq_size =3D 8, .priority =3D 10, .block_on_fault =3D 0, + .max_batch_size =3D (1 << 4), + .max_transfer_size =3D (1l << 16), .mode =3D "dedicated", .type =3D "user", .name =3D "myapp2" @@ -102,6 +106,8 @@ static struct wq_parameters wq02_param =3D { .priority =3D 10, .block_on_fault =3D 1, .threshold =3D 8, + .max_batch_size =3D (1 << 8), + .max_transfer_size =3D (1l << 30), .mode =3D "shared", .type =3D "mdev", .name =3D "guest1" @@ -112,6 +118,8 @@ static struct wq_parameters wq03_param =3D { .wq_size =3D 7, .priority =3D 10, .block_on_fault =3D 0, + .max_batch_size =3D (1 << 9), + .max_transfer_size =3D (1l << 31), .mode =3D "dedicated", .type =3D "mdev", .name =3D "guest2" @@ -126,6 +134,8 @@ static struct wq_parameters wq12_param =3D { .priority =3D 15, .block_on_fault =3D 1, .threshold =3D 50, + .max_batch_size =3D 1, + .max_transfer_size =3D 1, .mode =3D "shared", .type =3D "user", .name =3D "myapp3" @@ -137,6 +147,8 @@ static struct wq_parameters wq13_param =3D { .priority =3D 15, .block_on_fault =3D 1, .threshold =3D 50, + .max_batch_size =3D 1, + .max_transfer_size =3D 1, .mode =3D "shared", .type =3D "user", .name =3D "myapp3" @@ -148,6 +160,8 @@ static struct wq_parameters wq14_param =3D { .priority =3D 15, .block_on_fault =3D 1, .threshold =3D 50, + .max_batch_size =3D 1, + .max_transfer_size =3D 1, .mode =3D "shared", .type =3D "user", .name =3D "myapp3" @@ -332,6 +346,8 @@ static int config_wq(struct accfg_ctx *ctx, int dev_id,= int wq_id, accfg_wq_set_group_id(wq, wq_param.group_id); accfg_wq_set_priority(wq, wq_param.priority); accfg_wq_set_block_on_fault(wq, wq_param.block_on_fault); + accfg_wq_set_max_batch_size(wq, wq_param.max_batch_size); + accfg_wq_set_max_transfer_size(wq, wq_param.max_transfer_size); if (wq_param.threshold) accfg_wq_set_threshold(wq, wq_param.threshold); } @@ -379,6 +395,16 @@ static int check_wq(struct accfg_ctx *ctx, int dev_id,= int wq_id, fprintf(stderr, "check_wq failed on threshold\n"); return -EINVAL; } + if (wq_param.max_batch_size !=3D + accfg_wq_get_max_batch_size(wq)) { + fprintf(stderr, "%s failed on max_batch_size\n", __func__); + return -EINVAL; + } + if (wq_param.max_transfer_size !=3D + accfg_wq_get_max_transfer_size(wq)) { + fprintf(stderr, "%s failed on max_transfer_size\n", __func__); + return -EINVAL; + } if (strcmp(wq_param.name, accfg_wq_get_type_name(wq)) !=3D 0) { fprintf(stderr, "check wq failed on wq name\n"); return -EINVAL; @@ -695,6 +721,50 @@ static int set_exceed_config(struct accfg_ctx *ctx, co= nst char *dev_name) return 0; } = +static int wq_bounds_test(struct accfg_ctx *ctx, const char *dev_name) +{ + struct accfg_device *device; + int rc =3D 0; + + printf("configure device 0, group 0.0, wq0.0 for bounds test\n"); + rc =3D config_device(ctx, 0, device0_param, dev_name); + if (rc !=3D 0) { + fprintf(stderr, "config device %s failed\n", dev_name); + return rc; + } + + device =3D accfg_ctx_device_get_by_name(ctx, dev_name); + if (!device) + return -EINVAL; + + rc =3D config_group(ctx, 0, 0, group00_param, dev_name); + if (rc !=3D 0) { + fprintf(stderr, "config group group0.0 failed\n"); + return rc; + } + + /* should not be 0 */ + wq00_param.max_batch_size =3D 0; + wq00_param.max_transfer_size =3D 0; + rc =3D config_wq(ctx, 0, 0, wq00_param, dev_name); + if (rc !=3D 0) { + fprintf(stderr, "config wq wq0.0 failed\n"); + return rc; + } + /* should not be greater device max_batch_size/max_transfer_size */ + wq00_param.max_batch_size =3D + (accfg_device_get_max_batch_size(device) << 1); + wq00_param.max_transfer_size =3D + (accfg_device_get_max_transfer_size(device) << 1); + rc =3D config_wq(ctx, 0, 0, wq00_param, dev_name); + if (rc !=3D 0) { + fprintf(stderr, "config wq wq0.0 failed\n"); + return rc; + } + + return 0; +} + static int test_enable_wq(struct accfg_device *device, struct accfg_wq *wq) { int rc =3D 0; @@ -928,10 +998,34 @@ static int do_test3(struct accfg_ctx *ctx) return 0; } = +/* test the boundary conditions for wq max_batch_size and max_transfer_siz= e */ +static int do_test4(struct accfg_ctx *ctx) +{ + int rc =3D 0; + + rc =3D device_test_reset(ctx, "dsa0"); + if (rc !=3D 0) + return rc; + + rc =3D wq_bounds_test(ctx, "dsa0"); + if (rc !=3D 0) { + fprintf(stderr, "test 4: wq boundary conditions test failed\n"); + return rc; + } + + rc =3D device_test_reset(ctx, "dsa0"); + if (rc !=3D 0) + return rc; + + fprintf(stderr, "test 4: wq boundary conditions test passed successfully\= n"); + return 0; +} + 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 }; -- = 2.26.2 --===============0025602294942758891==--