Content-Type: multipart/mixed; boundary="===============1073713940477915397==" MIME-Version: 1.0 From: Dave Jiang Subject: [Accel-config] Re: [PATCH v1 2/3] accel-config/test: Add source code of operation CRC64 Date: Thu, 28 Apr 2022 09:08:16 -0700 Message-ID: <2e8eb7a8-170c-f3ef-7d9a-d6db5719ef12@intel.com> In-Reply-To: 20220428095607.551960-3-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============1073713940477915397== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 4/28/2022 2:56 AM, Li Zhang wrote: > Add source code of operation CRC64 into IAA test. Do we want to convert all the IAX to IAA since this is new code? > > Signed-off-by: Li Zhang > Reviewed-by: Dave Jiang > --- > test/iaa.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++- > test/iaa.h | 7 ++- > test/iaa_prep.c | 12 ++++ > test/iaa_test.c | 70 +++++++++++++++++++++ > 4 files changed, 244 insertions(+), 3 deletions(-) > > diff --git a/test/iaa.c b/test/iaa.c > index 639d82f..f5c2f71 100644 > --- a/test/iaa.c > +++ b/test/iaa.c > @@ -16,6 +16,48 @@ > #include > #include "accel_test.h" > #include "iaa.h" > +#include "algorithms/iaa_crc64.h" > + > +static int init_crc64(struct task *tsk, int tflags, int opcode, unsigned= long src1_xfer_size) > +{ > + tsk->pattern =3D 0x98765432abcdef01; > + tsk->opcode =3D opcode; > + tsk->test_flags =3D tflags; > + tsk->xfer_size =3D src1_xfer_size; > + > + tsk->src1 =3D malloc(src1_xfer_size); > + if (!tsk->src1) > + return -ENOMEM; > + memset_pattern(tsk->src1, tsk->pattern, src1_xfer_size); > + tsk->iax_crc64_poly =3D IAX_CRC64_POLYNOMIAL; > + > + return ACCTEST_STATUS_OK; > +} > + > +/* this function is re-used by batch task */ > +int init_task(struct task *tsk, int tflags, int opcode, unsigned long sr= c1_xfer_size) > +{ > + int rc =3D 0; > + > + dbg("initilizing single task %#lx\n", tsk); > + > + /* allocate memory: src1*/ > + switch (opcode) { > + case IAX_OPCODE_CRC64: /* intentionally empty */ > + rc =3D init_crc64(tsk, tflags, opcode, src1_xfer_size); > + break; > + } > + > + if (rc !=3D ACCTEST_STATUS_OK) { > + err("init: opcode %d data failed\n", opcode); > + return rc; > + } > + > + dbg("Mem allocated: s1 %#lx s2 %#lx d %#lx\n", > + tsk->src1, tsk->src2, tsk->dst1); > + > + return ACCTEST_STATUS_OK; > +} > = > static int iax_wait_noop(struct acctest_context *ctx, struct task *tsk) > { > @@ -61,15 +103,127 @@ int iax_noop_multi_task_nodes(struct acctest_contex= t *ctx) > return ret; > } > = > +static int iax_wait_crc64(struct acctest_context *ctx, struct task *tsk) > +{ > + struct completion_record *comp =3D tsk->comp; > + int rc; > + > + rc =3D acctest_wait_on_desc_timeout(comp, ctx, ms_timeout); > + if (rc < 0) { > + err("crc64 desc timeout\n"); > + return ACCTEST_STATUS_TIMEOUT; > + } > + > + return ACCTEST_STATUS_OK; > +} > + > +int iax_crc64_multi_task_nodes(struct acctest_context *ctx) > +{ > + struct task_node *tsk_node =3D ctx->multi_task_node; > + int ret =3D ACCTEST_STATUS_OK; > + > + while (tsk_node) { > + tsk_node->tsk->dflags |=3D (IDXD_OP_FLAG_CRAV | IDXD_OP_FLAG_RCR); > + if ((tsk_node->tsk->test_flags & TEST_FLAGS_BOF) && ctx->bof) > + tsk_node->tsk->dflags |=3D IDXD_OP_FLAG_BOF; > + > + iax_prep_crc64(tsk_node->tsk); > + tsk_node =3D tsk_node->next; > + } > + > + info("Submitted all crc64 jobs\n"); > + tsk_node =3D ctx->multi_task_node; > + while (tsk_node) { > + acctest_desc_submit(ctx, tsk_node->tsk->desc); > + tsk_node =3D tsk_node->next; > + } > + > + tsk_node =3D ctx->multi_task_node; > + while (tsk_node) { > + ret =3D iax_wait_crc64(ctx, tsk_node->tsk); > + if (ret !=3D ACCTEST_STATUS_OK) > + info("Desc: %p failed with ret: %d\n", > + tsk_node->tsk->desc, tsk_node->tsk->comp->status); > + tsk_node =3D tsk_node->next; > + } > + > + return ret; > +} > + > /* mismatch_expected: expect mismatched buffer with success status 0x1 = */ > int iax_task_result_verify(struct task *tsk, int mismatch_expected) > { > + int ret =3D ACCTEST_STATUS_OK; > + > info("verifying task result for %#lx\n", tsk); > = > if (tsk->comp->status !=3D IAX_COMP_SUCCESS) > return tsk->comp->status; > = > - info("test with op %d passed\n", tsk->opcode); > + switch (tsk->opcode) { > + case IAX_OPCODE_CRC64: > + ret =3D task_result_verify_crc64(tsk, mismatch_expected); > + } > = > - return ACCTEST_STATUS_OK; > + if (ret =3D=3D ACCTEST_STATUS_OK) > + info("test with op %d passed\n", tsk->opcode); > + > + return ret; > +} > + > +int iax_task_result_verify_task_nodes(struct acctest_context *ctx, int m= ismatch_expected) > +{ > + struct task_node *tsk_node =3D ctx->multi_task_node; > + int ret =3D ACCTEST_STATUS_OK; > + > + while (tsk_node) { > + ret =3D iax_task_result_verify(tsk_node->tsk, mismatch_expected); > + if (ret !=3D ACCTEST_STATUS_OK) { > + err("memory result verify failed %d\n", ret); > + return ret; > + } > + tsk_node =3D tsk_node->next; > + } > + > + return ret; > +} > + > +int task_result_verify_crc64(struct task *tsk, int mismatch_expected) > +{ > + int rc; > + uint64_t crc; > + > + if (mismatch_expected) > + warn("invalid arg mismatch_expected for %d\n", tsk->opcode); > + > + if (tsk->iax_crc64_flags =3D=3D IAX_CRC64_EXTRA_FLAGS_BIT_ORDER) { > + crc =3D iax_calculate_crc64(tsk->iax_crc64_poly, tsk->src1, > + tsk->xfer_size, 1, 0); > + } else if (tsk->iax_crc64_flags =3D=3D IAX_CRC64_EXTRA_FLAGS_INVERT_CRC= ) { > + crc =3D iax_calculate_crc64(tsk->iax_crc64_poly, tsk->src1, > + tsk->xfer_size, 0, 1); > + } else { > + err("Unsupported extra flags %#x\n", tsk->iax_crc64_flags); > + return -EINVAL; > + } > + > + rc =3D memcmp((void *)(&tsk->comp->crc64_result), (void *)(&crc), sizeo= f(uint64_t)); > + > + if (!mismatch_expected) { > + if (rc) { > + err("crc64 mismatch, memcmp rc %d\n", rc); > + err("expected crc=3D0x%llX, actual crc=3D0x%llX\n", > + crc, tsk->comp->crc64_result); > + return -ENXIO; > + } > + return ACCTEST_STATUS_OK; > + } > + > + /* mismatch_expected */ > + if (rc) { > + info("expected mismatch in crc 0x%llX\n", tsk->comp->crc64_result); > + return ACCTEST_STATUS_OK; > + } > + > + return -ENXIO; > } > diff --git a/test/iaa.h b/test/iaa.h > index 0560d2c..e0bbad2 100644 > --- a/test/iaa.h > +++ b/test/iaa.h > @@ -7,10 +7,15 @@ > #include "accel_test.h" > #include "accfg_test.h" > = > -int iax_noop_multi_task_nodes(struct acctest_context *ctx); > +int init_task(struct task *tsk, int tflags, int opcode, unsigned long sr= c1_xfer_size); > = > +int iax_noop_multi_task_nodes(struct acctest_context *ctx); > +int iax_crc64_multi_task_nodes(struct acctest_context *ctx); > void iax_prep_noop(struct task *tsk); > +void iax_prep_crc64(struct task *tsk); > = > int iax_task_result_verify(struct task *tsk, int mismatch_expected); > +int iax_task_result_verify_task_nodes(struct acctest_context *ctx, int m= ismatch_expected); > +int task_result_verify_crc64(struct task *tsk, int mismatch_expected); > = > #endif > diff --git a/test/iaa_prep.c b/test/iaa_prep.c > index f7f8712..8522353 100644 > --- a/test/iaa_prep.c > +++ b/test/iaa_prep.c > @@ -19,3 +19,15 @@ void iax_prep_noop(struct task *tsk) > tsk->desc->completion_addr =3D (uint64_t)(tsk->comp); > tsk->comp->status =3D 0; > } > + > +void iax_prep_crc64(struct task *tsk) > +{ > + info("preparing descriptor for memcpy\n"); > + > + acctest_prep_desc_common(tsk->desc, tsk->opcode, 0, > + (uint64_t)(tsk->src1), tsk->xfer_size, tsk->dflags); > + tsk->desc->completion_addr =3D (uint64_t)(tsk->comp); > + tsk->desc->iax_crc64_flags =3D tsk->iax_crc64_flags; > + tsk->desc->iax_crc64_poly =3D tsk->iax_crc64_poly; > + tsk->comp->status =3D 0; > +} > diff --git a/test/iaa_test.c b/test/iaa_test.c > index b398378..cd16949 100644 > --- a/test/iaa_test.c > +++ b/test/iaa_test.c > @@ -18,6 +18,7 @@ static void usage(void) > "-f ; 0x1: block-on-fault\n" > " ; 0x4: reserved\n" > " ; 0x8: prefault buffers\n" > + "-e ; specified by each opcpde\n" > "-o ; opcode, same value as in IAX spec\n" > "-d ; wq device such as iax1/wq1.0\n" > "-n ;descriptor count to submit\n" > @@ -74,6 +75,65 @@ static int test_noop(struct acctest_context *ctx, int = tflags, int num_desc) > return rc; > } > = > +static int test_crc64(struct acctest_context *ctx, size_t buf_size, int = tflags, > + int extra_flags, uint32_t opcode, int num_desc) > +{ > + struct task_node *tsk_node; > + int rc =3D ACCTEST_STATUS_OK; > + int itr =3D num_desc, i =3D 0, range =3D 0; > + > + info("testcrc64: opcode %d len %#lx tflags %#x num_desc %ld extra_flags= %#lx\n", > + opcode, buf_size, tflags, num_desc, extra_flags); > + > + ctx->is_batch =3D 0; > + > + if (ctx->dedicated =3D=3D ACCFG_WQ_SHARED) > + range =3D ctx->threshold; > + else > + range =3D ctx->wq_size; > + > + while (itr > 0 && rc =3D=3D ACCTEST_STATUS_OK) { > + i =3D (itr < range) ? itr : range; > + /* Allocate memory to all the task nodes, desc, completion record*/ > + rc =3D acctest_alloc_multiple_tasks(ctx, i); > + if (rc !=3D ACCTEST_STATUS_OK) > + return rc; > + > + /* allocate memory to src and dest buffers and fill in the desc for al= l the nodes*/ > + tsk_node =3D ctx->multi_task_node; > + while (tsk_node) { > + tsk_node->tsk->iax_crc64_flags =3D extra_flags; > + > + rc =3D init_task(tsk_node->tsk, tflags, opcode, buf_size); > + if (rc !=3D ACCTEST_STATUS_OK) > + return rc; > + > + tsk_node =3D tsk_node->next; > + } > + > + switch (opcode) { > + case IAX_OPCODE_CRC64: > + rc =3D iax_crc64_multi_task_nodes(ctx); > + if (rc !=3D ACCTEST_STATUS_OK) > + return rc; > + > + /* Verification of all the nodes*/ > + rc =3D iax_task_result_verify_task_nodes(ctx, 0); > + if (rc !=3D ACCTEST_STATUS_OK) > + return rc; > + break; > + default: > + err("Unsupported op %#x\n", opcode); > + return -EINVAL; > + } > + > + acctest_free_task(ctx); > + itr =3D itr - range; > + } > + > + return rc; > +} > + > int main(int argc, char *argv[]) > { > struct acctest_context *iax; > @@ -81,6 +141,7 @@ int main(int argc, char *argv[]) > int wq_type =3D SHARED; > unsigned long buf_size =3D IAX_TEST_SIZE; > int tflags =3D TEST_FLAGS_BOF; > + int extra_flags =3D 0; > int opcode =3D IAX_OPCODE_NOOP; > int opt; > char dev_type[MAX_DEV_LEN]; > @@ -100,6 +161,9 @@ int main(int argc, char *argv[]) > case 'f': > tflags =3D strtoul(optarg, NULL, 0); > break; > + case 'e': > + extra_flags =3D strtoul(optarg, NULL, 0); > + break; > case 'o': > opcode =3D strtoul(optarg, NULL, 0); > break; > @@ -149,6 +213,12 @@ int main(int argc, char *argv[]) > goto error; > break; > = > + case IAX_OPCODE_CRC64: > + rc =3D test_crc64(iax, buf_size, tflags, extra_flags, opcode, num_desc= ); > + if (rc !=3D ACCTEST_STATUS_OK) > + goto error; > + break; > + > default: > rc =3D -EINVAL; > break; --===============1073713940477915397==--